< prev index next >

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

Print this page




 244                 annotationClass = (Class<? extends Annotation>)constPool.getClassAt(typeIndex);
 245             }
 246         } catch (NoClassDefFoundError e) {
 247             if (exceptionOnMissingAnnotationClass)
 248                 // note: at this point sig is "[unknown]" or VM-style
 249                 // name instead of a binary name
 250                 throw new TypeNotPresentException(sig, e);
 251             skipAnnotation(buf, false);
 252             return null;
 253         }
 254         catch (TypeNotPresentException e) {
 255             if (exceptionOnMissingAnnotationClass)
 256                 throw e;
 257             skipAnnotation(buf, false);
 258             return null;
 259         }
 260         if (selectAnnotationClasses != null && !contains(selectAnnotationClasses, annotationClass)) {
 261             skipAnnotation(buf, false);
 262             return null;
 263         }
 264         AnnotationType type = null;
 265         try {
 266             type = AnnotationType.getInstance(annotationClass);
 267         } catch (IllegalArgumentException e) {
 268             skipAnnotation(buf, false);
 269             return null;
 270         }
 271 
 272         Map<String, Class<?>> memberTypes = type.memberTypes();
 273         Map<String, Object> memberValues =
 274             new LinkedHashMap<String, Object>(type.memberDefaults());
 275 
 276         int numMembers = buf.getShort() & 0xFFFF;
 277         for (int i = 0; i < numMembers; i++) {
 278             int memberNameIndex = buf.getShort() & 0xFFFF;
 279             String memberName = constPool.getUTF8At(memberNameIndex);
 280             Class<?> memberType = memberTypes.get(memberName);
 281 
 282             if (memberType == null) {
 283                 // Member is no longer present in annotation type; ignore it
 284                 skipMemberValue(buf);
 285             } else {
 286                 Object value = parseMemberValue(memberType, buf, constPool, container);
 287                 if (value instanceof AnnotationTypeMismatchExceptionProxy)
 288                     ((AnnotationTypeMismatchExceptionProxy) value).
 289                         setMember(type.members().get(memberName));
 290                 memberValues.put(memberName, value);




 244                 annotationClass = (Class<? extends Annotation>)constPool.getClassAt(typeIndex);
 245             }
 246         } catch (NoClassDefFoundError e) {
 247             if (exceptionOnMissingAnnotationClass)
 248                 // note: at this point sig is "[unknown]" or VM-style
 249                 // name instead of a binary name
 250                 throw new TypeNotPresentException(sig, e);
 251             skipAnnotation(buf, false);
 252             return null;
 253         }
 254         catch (TypeNotPresentException e) {
 255             if (exceptionOnMissingAnnotationClass)
 256                 throw e;
 257             skipAnnotation(buf, false);
 258             return null;
 259         }
 260         if (selectAnnotationClasses != null && !contains(selectAnnotationClasses, annotationClass)) {
 261             skipAnnotation(buf, false);
 262             return null;
 263         }
 264         AnnotationType type = AnnotationType.getInstance(annotationClass);






 265 
 266         Map<String, Class<?>> memberTypes = type.memberTypes();
 267         Map<String, Object> memberValues =
 268             new LinkedHashMap<String, Object>(type.memberDefaults());
 269 
 270         int numMembers = buf.getShort() & 0xFFFF;
 271         for (int i = 0; i < numMembers; i++) {
 272             int memberNameIndex = buf.getShort() & 0xFFFF;
 273             String memberName = constPool.getUTF8At(memberNameIndex);
 274             Class<?> memberType = memberTypes.get(memberName);
 275 
 276             if (memberType == null) {
 277                 // Member is no longer present in annotation type; ignore it
 278                 skipMemberValue(buf);
 279             } else {
 280                 Object value = parseMemberValue(memberType, buf, constPool, container);
 281                 if (value instanceof AnnotationTypeMismatchExceptionProxy)
 282                     ((AnnotationTypeMismatchExceptionProxy) value).
 283                         setMember(type.members().get(memberName));
 284                 memberValues.put(memberName, value);


< prev index next >