81 {
82 JavaLangAccess jla = sun.misc.SharedSecrets.getJavaLangAccess();
83 AnnotationType result = jla.getAnnotationType(annotationClass); // volatile read
84 if (result == null) {
85 result = new AnnotationType(annotationClass);
86 // try to CAS the AnnotationType: null -> result
87 if (!jla.casAnnotationType(annotationClass, null, result)) {
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<>() {
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)
|
81 {
82 JavaLangAccess jla = sun.misc.SharedSecrets.getJavaLangAccess();
83 AnnotationType result = jla.getAnnotationType(annotationClass); // volatile read
84 if (result == null) {
85 result = new AnnotationType(annotationClass);
86 // try to CAS the AnnotationType: null -> result
87 if (!jla.casAnnotationType(annotationClass, null, result)) {
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 * @throws 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)
|