< prev index next >

src/java.base/share/classes/sun/reflect/annotation/AnnotationType.java

Print this page




  89                 result = jla.getAnnotationType(annotationClass);
  90                 assert result != null;
  91             }
  92         }
  93 
  94         return result;
  95     }
  96 
  97     /**
  98      * Sole constructor.
  99      *
 100      * @param annotationClass the class object for the annotation type
 101      * @throw IllegalArgumentException if the specified class object for
 102      *     does not represent a valid annotation type
 103      */
 104     private AnnotationType(final Class<? extends Annotation> annotationClass) {
 105         if (!annotationClass.isAnnotation())
 106             throw new IllegalArgumentException("Not an annotation type");
 107 
 108         Method[] methods =
 109             AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
 110                 public Method[] run() {
 111                     // Initialize memberTypes and defaultValues
 112                     return annotationClass.getDeclaredMethods();
 113                 }
 114             });
 115 
 116         memberTypes = new HashMap<String,Class<?>>(methods.length+1, 1.0f);
 117         memberDefaults = new HashMap<String, Object>(0);
 118         members = new HashMap<String, Method>(methods.length+1, 1.0f);
 119 
 120         for (Method method : methods) {
 121             if (method.getParameterTypes().length != 0)
 122                 throw new IllegalArgumentException(method + " has params");
 123             String name = method.getName();
 124             Class<?> type = method.getReturnType();
 125             memberTypes.put(name, invocationHandlerReturnType(type));
 126             members.put(name, method);
 127 
 128             Object defaultValue = method.getDefaultValue();
 129             if (defaultValue != null)
 130                 memberDefaults.put(name, defaultValue);
 131         }
 132 
 133         // Initialize retention, & inherited fields.  Special treatment
 134         // of the corresponding annotation types breaks infinite recursion.
 135         if (annotationClass != Retention.class &&
 136             annotationClass != Inherited.class) {
 137             JavaLangAccess jla = sun.misc.SharedSecrets.getJavaLangAccess();
 138             Map<Class<? extends Annotation>, Annotation> metaAnnotations =




  89                 result = jla.getAnnotationType(annotationClass);
  90                 assert result != null;
  91             }
  92         }
  93 
  94         return result;
  95     }
  96 
  97     /**
  98      * Sole constructor.
  99      *
 100      * @param annotationClass the class object for the annotation type
 101      * @throw IllegalArgumentException if the specified class object for
 102      *     does not represent a valid annotation type
 103      */
 104     private AnnotationType(final Class<? extends Annotation> annotationClass) {
 105         if (!annotationClass.isAnnotation())
 106             throw new IllegalArgumentException("Not an annotation type");
 107 
 108         Method[] methods =
 109             AccessController.doPrivileged(new PrivilegedAction<>() {
 110                 public Method[] run() {
 111                     // Initialize memberTypes and defaultValues
 112                     return annotationClass.getDeclaredMethods();
 113                 }
 114             });
 115 
 116         memberTypes = new HashMap<>(methods.length+1, 1.0f);
 117         memberDefaults = new HashMap<>(0);
 118         members = new HashMap<>(methods.length+1, 1.0f);
 119 
 120         for (Method method : methods) {
 121             if (method.getParameterTypes().length != 0)
 122                 throw new IllegalArgumentException(method + " has params");
 123             String name = method.getName();
 124             Class<?> type = method.getReturnType();
 125             memberTypes.put(name, invocationHandlerReturnType(type));
 126             members.put(name, method);
 127 
 128             Object defaultValue = method.getDefaultValue();
 129             if (defaultValue != null)
 130                 memberDefaults.put(name, defaultValue);
 131         }
 132 
 133         // Initialize retention, & inherited fields.  Special treatment
 134         // of the corresponding annotation types breaks infinite recursion.
 135         if (annotationClass != Retention.class &&
 136             annotationClass != Inherited.class) {
 137             JavaLangAccess jla = sun.misc.SharedSecrets.getJavaLangAccess();
 138             Map<Class<? extends Annotation>, Annotation> metaAnnotations =


< prev index next >