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

Print this page




  71         try {
  72             return parseAnnotations2(rawAnnotations, constPool, container, null);
  73         } catch(BufferUnderflowException e) {
  74             throw new AnnotationFormatError("Unexpected end of annotations.");
  75         } catch(IllegalArgumentException e) {
  76             // Type mismatch in constant pool
  77             throw new AnnotationFormatError(e);
  78         }
  79     }
  80 
  81     /**
  82      * Like {@link #parseAnnotations(byte[], sun.reflect.ConstantPool, Class)}
  83      * with an additional parameter {@code selectAnnotationClasses} which selects the
  84      * annotation types to parse (other than selected are quickly skipped).<p>
  85      * This method is only used to parse select meta annotations in the construction
  86      * phase of {@link AnnotationType} instances to prevent infinite recursion.
  87      *
  88      * @param selectAnnotationClasses an array of annotation types to select when parsing
  89      */
  90     @SafeVarargs

  91     static Map<Class<? extends Annotation>, Annotation> parseSelectAnnotations(
  92                 byte[] rawAnnotations,
  93                 ConstantPool constPool,
  94                 Class<?> container,
  95                 Class<? extends Annotation> ... selectAnnotationClasses) {
  96         if (rawAnnotations == null)
  97             return Collections.emptyMap();
  98 
  99         try {
 100             return parseAnnotations2(rawAnnotations, constPool, container, selectAnnotationClasses);
 101         } catch(BufferUnderflowException e) {
 102             throw new AnnotationFormatError("Unexpected end of annotations.");
 103         } catch(IllegalArgumentException e) {
 104             // Type mismatch in constant pool
 105             throw new AnnotationFormatError(e);
 106         }
 107     }
 108 
 109     private static Map<Class<? extends Annotation>, Annotation> parseAnnotations2(
 110                 byte[] rawAnnotations,




  71         try {
  72             return parseAnnotations2(rawAnnotations, constPool, container, null);
  73         } catch(BufferUnderflowException e) {
  74             throw new AnnotationFormatError("Unexpected end of annotations.");
  75         } catch(IllegalArgumentException e) {
  76             // Type mismatch in constant pool
  77             throw new AnnotationFormatError(e);
  78         }
  79     }
  80 
  81     /**
  82      * Like {@link #parseAnnotations(byte[], sun.reflect.ConstantPool, Class)}
  83      * with an additional parameter {@code selectAnnotationClasses} which selects the
  84      * annotation types to parse (other than selected are quickly skipped).<p>
  85      * This method is only used to parse select meta annotations in the construction
  86      * phase of {@link AnnotationType} instances to prevent infinite recursion.
  87      *
  88      * @param selectAnnotationClasses an array of annotation types to select when parsing
  89      */
  90     @SafeVarargs
  91     @SuppressWarnings("varargs") // selectAnnotationClasses is used safely
  92     static Map<Class<? extends Annotation>, Annotation> parseSelectAnnotations(
  93                 byte[] rawAnnotations,
  94                 ConstantPool constPool,
  95                 Class<?> container,
  96                 Class<? extends Annotation> ... selectAnnotationClasses) {
  97         if (rawAnnotations == null)
  98             return Collections.emptyMap();
  99 
 100         try {
 101             return parseAnnotations2(rawAnnotations, constPool, container, selectAnnotationClasses);
 102         } catch(BufferUnderflowException e) {
 103             throw new AnnotationFormatError("Unexpected end of annotations.");
 104         } catch(IllegalArgumentException e) {
 105             // Type mismatch in constant pool
 106             throw new AnnotationFormatError(e);
 107         }
 108     }
 109 
 110     private static Map<Class<? extends Annotation>, Annotation> parseAnnotations2(
 111                 byte[] rawAnnotations,