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

Print this page




 111         TypeAnnotation[] tas = parseTypeAnnotations(rawAnnotations,
 112                                                     cp,
 113                                                     decl,
 114                                                     container);
 115         for (TypeAnnotation t : tas) {
 116             TypeAnnotationTargetInfo ti = t.getTargetInfo();
 117             if (ti.getTarget() == filter) {
 118                 int pos = ti.getCount();
 119                 if (l[pos] == null) {
 120                     ArrayList<TypeAnnotation> tmp = new ArrayList<>(tas.length);
 121                     l[pos] = tmp;
 122                 }
 123                 @SuppressWarnings("unchecked")
 124                 ArrayList<TypeAnnotation> tmp = l[pos];
 125                 tmp.add(t);
 126             }
 127         }
 128         for (int i = 0; i < size; i++) {
 129             @SuppressWarnings("unchecked")
 130             ArrayList<TypeAnnotation> list = l[i];

 131             if (list != null) {
 132                 TypeAnnotation[] typeAnnotations = list.toArray(new TypeAnnotation[0]);



 133                 result[i] = AnnotatedTypeFactory.buildAnnotatedType(types[i],
 134                                                                     LocationInfo.BASE_LOCATION,
 135                                                                     typeAnnotations,
 136                                                                     typeAnnotations,
 137                                                                     decl);
 138             }
 139         }
 140         return result;
 141     }
 142 
 143     // Class helpers
 144 
 145     /**
 146      * Build an AnnotatedType for the class decl's supertype.
 147      *
 148      * @param rawAnnotations the byte[] encoding of all type annotations on this declaration
 149      * @param cp the ConstantPool needed to parse the embedded Annotation
 150      * @param decl the Class which annotated supertype is being built
 151      */
 152     public static AnnotatedType buildAnnotatedSuperclass(byte[] rawAnnotations,
 153             ConstantPool cp,
 154             Class<?> decl) {
 155         Type supertype = decl.getGenericSuperclass();
 156         if (supertype == null)
 157             return AnnotatedTypeFactory.EMPTY_ANNOTATED_TYPE;
 158         return buildAnnotatedType(rawAnnotations,




 111         TypeAnnotation[] tas = parseTypeAnnotations(rawAnnotations,
 112                                                     cp,
 113                                                     decl,
 114                                                     container);
 115         for (TypeAnnotation t : tas) {
 116             TypeAnnotationTargetInfo ti = t.getTargetInfo();
 117             if (ti.getTarget() == filter) {
 118                 int pos = ti.getCount();
 119                 if (l[pos] == null) {
 120                     ArrayList<TypeAnnotation> tmp = new ArrayList<>(tas.length);
 121                     l[pos] = tmp;
 122                 }
 123                 @SuppressWarnings("unchecked")
 124                 ArrayList<TypeAnnotation> tmp = l[pos];
 125                 tmp.add(t);
 126             }
 127         }
 128         for (int i = 0; i < size; i++) {
 129             @SuppressWarnings("unchecked")
 130             ArrayList<TypeAnnotation> list = l[i];
 131             TypeAnnotation[] typeAnnotations;
 132             if (list != null) {
 133                 typeAnnotations = list.toArray(new TypeAnnotation[0]);
 134             } else {
 135                 typeAnnotations = new TypeAnnotation[0];
 136             }
 137             result[i] = AnnotatedTypeFactory.buildAnnotatedType(types[i],
 138                                                                 LocationInfo.BASE_LOCATION,
 139                                                                 typeAnnotations,
 140                                                                 typeAnnotations,
 141                                                                 decl);
 142 
 143         }
 144         return result;
 145     }
 146 
 147     // Class helpers
 148 
 149     /**
 150      * Build an AnnotatedType for the class decl's supertype.
 151      *
 152      * @param rawAnnotations the byte[] encoding of all type annotations on this declaration
 153      * @param cp the ConstantPool needed to parse the embedded Annotation
 154      * @param decl the Class which annotated supertype is being built
 155      */
 156     public static AnnotatedType buildAnnotatedSuperclass(byte[] rawAnnotations,
 157             ConstantPool cp,
 158             Class<?> decl) {
 159         Type supertype = decl.getGenericSuperclass();
 160         if (supertype == null)
 161             return AnnotatedTypeFactory.EMPTY_ANNOTATED_TYPE;
 162         return buildAnnotatedType(rawAnnotations,