8006283: Change to Class.cast() in javax.lang.model implementation for repeating annotations
authordarcy
Wed, 16 Jan 2013 13:22:09 -0800
changeset 15365 1f33464bbf46
parent 15364 deefeacccc41
child 15366 545307ec740c
8006283: Change to Class.cast() in javax.lang.model implementation for repeating annotations Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java
--- a/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java	Wed Jan 16 12:14:29 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java	Wed Jan 16 13:22:09 2013 -0800
@@ -266,9 +266,10 @@
 
     private static Class<? extends Annotation> initRepeatable() {
         try {
-            @SuppressWarnings("unchecked") // java.lang.annotation.Repeatable extends Annotation by being an annotation type
-            Class<? extends Annotation> c = (Class)Class.forName("java.lang.annotation.Repeatable");
-            return c;
+            // Repeatable will not be available when bootstrapping on
+            // JDK 7 so use a reflective lookup instead of a class
+            // literal for Repeatable.class.
+            return Class.forName("java.lang.annotation.Repeatable").asSubclass(Annotation.class);
         } catch (ClassNotFoundException e) {
             return null;
         } catch (SecurityException e) {