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

Print this page




  88                 // somebody was quicker -> read it's result
  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 




  88                 // somebody was quicker -> read it's result
  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         // Initialize memberTypes and defaultValues
 109         Method[] methods =
 110             AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
 111                 public Method[] run() {
 112                     Method[] methods = annotationClass.getDeclaredMethods();
 113                     AccessibleObject.setAccessible(methods, true);
 114                     return methods;
 115                 }
 116             });
 117 
 118         memberTypes = new HashMap<String,Class<?>>(methods.length+1, 1.0f);
 119         memberDefaults = new HashMap<String, Object>(0);
 120         members = new HashMap<String, Method>(methods.length+1, 1.0f);
 121 
 122         for (Method method :  methods) {
 123             if (method.getParameterTypes().length != 0)
 124                 throw new IllegalArgumentException(method + " has params");
 125             String name = method.getName();
 126             Class<?> type = method.getReturnType();
 127             memberTypes.put(name, invocationHandlerReturnType(type));
 128             members.put(name, method);
 129 
 130             Object defaultValue = method.getDefaultValue();
 131             if (defaultValue != null)
 132                 memberDefaults.put(name, defaultValue);
 133         }
 134