< prev index next >

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

Print this page




 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 (Modifier.isPublic(method.getModifiers()) &&
 122                 Modifier.isAbstract(method.getModifiers()) &&
 123                 !method.isSynthetic()) {
 124                 if (method.getParameterTypes().length != 0) {
 125                     throw new IllegalArgumentException(method + " has params");
 126                 }
 127                 String name = method.getName();
 128                 Class<?> type = method.getReturnType();
 129                 memberTypes.put(name, invocationHandlerReturnType(type));
 130                 members.put(name, method);
 131 
 132                 Object defaultValue = method.getDefaultValue();
 133                 if (defaultValue != null) {
 134                     memberDefaults.put(name, defaultValue);
 135                 }


 136             }
 137         }
 138 
 139         // Initialize retention, & inherited fields.  Special treatment
 140         // of the corresponding annotation types breaks infinite recursion.
 141         if (annotationClass != Retention.class &&
 142             annotationClass != Inherited.class) {
 143             JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
 144             Map<Class<? extends Annotation>, Annotation> metaAnnotations =
 145                 AnnotationParser.parseSelectAnnotations(
 146                     jla.getRawClassAnnotations(annotationClass),
 147                     jla.getConstantPool(annotationClass),
 148                     annotationClass,
 149                     Retention.class, Inherited.class
 150                 );
 151             Retention ret = (Retention) metaAnnotations.get(Retention.class);
 152             retention = (ret == null ? RetentionPolicy.CLASS : ret.value());
 153             inherited = metaAnnotations.containsKey(Inherited.class);
 154         }
 155         else {




 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 (Modifier.isPublic(method.getModifiers()) &&
 122                 Modifier.isAbstract(method.getModifiers()) &&
 123                 !method.isSynthetic()) {
 124                 if (method.getParameterTypes().length != 0) {
 125                     throw new IllegalArgumentException(method + " has params");
 126                 }
 127                 String name = method.getName();
 128                 Class<?> type = method.getReturnType();
 129                 memberTypes.put(name, invocationHandlerReturnType(type));
 130                 members.put(name, method);
 131 
 132                 Object defaultValue = method.getDefaultValue();
 133                 if (defaultValue != null) {
 134                     memberDefaults.put(name, defaultValue);
 135                 }
 136             } else {
 137                 throw new IllegalArgumentException(method + " has invalid modifier");                
 138             }
 139         }
 140 
 141         // Initialize retention, & inherited fields.  Special treatment
 142         // of the corresponding annotation types breaks infinite recursion.
 143         if (annotationClass != Retention.class &&
 144             annotationClass != Inherited.class) {
 145             JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
 146             Map<Class<? extends Annotation>, Annotation> metaAnnotations =
 147                 AnnotationParser.parseSelectAnnotations(
 148                     jla.getRawClassAnnotations(annotationClass),
 149                     jla.getConstantPool(annotationClass),
 150                     annotationClass,
 151                     Retention.class, Inherited.class
 152                 );
 153             Retention ret = (Retention) metaAnnotations.get(Retention.class);
 154             retention = (ret == null ? RetentionPolicy.CLASS : ret.value());
 155             inherited = metaAnnotations.containsKey(Inherited.class);
 156         }
 157         else {


< prev index next >