SimpleMetadataReader(Resource resource, @Nullable ClassLoader classLoader) throws IOException { InputStream is = new BufferedInputStream(resource.getInputStream()); ClassReader classReader; try { classReader = new ClassReader(is); } catch (IllegalArgumentException ex) { throw new NestedIOException("ASM ClassReader failed to parse class file - " + "probably due to a new Java class file version that isn't supported yet: " + resource, ex); } finally { is.close(); } AnnotationMetadataReadingVisitor visitor = new AnnotationMetadataReadingVisitor(classLoader); classReader.accept(visitor, ClassReader.SKIP_DEBUG); this.annotationMetadata = visitor; // (since AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor) this.classMetadata = visitor; this.resource = resource; }
@Override @Nullable public AnnotationAttributes getAnnotationAttributes(String annotationName, boolean classValuesAsString) { AnnotationAttributes raw = AnnotationReadingVisitorUtils.getMergedAnnotationAttributes( this.attributesMap, this.metaAnnotationMap, annotationName); if (raw == null) { return null; } return AnnotationReadingVisitorUtils.convertClassValues( "class '" + getClassName() + "'", this.classLoader, raw, classValuesAsString); }
@Override @Nullable public AnnotationAttributes getAnnotationAttributes(String annotationName) { return getAnnotationAttributes(annotationName, false); }
@Override @Nullable public AnnotationAttributes getAnnotationAttributes(String annotationName, boolean classValuesAsString) { AnnotationAttributes raw = AnnotationReadingVisitorUtils.getMergedAnnotationAttributes( this.attributesMap, this.metaAnnotationMap, annotationName); if (raw == null) { return null; } return AnnotationReadingVisitorUtils.convertClassValues( "class '" + getClassName() + "'", this.classLoader, raw, classValuesAsString); }
@Override @Nullable public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName) { return getAllAnnotationAttributes(annotationName, false); }
public AnnotationAttributes getAnnotationAttributes( String annotationType, boolean classValuesAsString, boolean nestedAttributesAsMap) { AnnotationAttributes raw = this.attributeMap.get(annotationType); return convertClassValues(raw, classValuesAsString, nestedAttributesAsMap); }
@Override @SuppressWarnings("null") public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { // Skip bridge methods - we're only interested in original user methods. // On JDK 8, we'd otherwise run into double detection of the same method... if ((access & Opcodes.ACC_BRIDGE) != 0) { return super.visitMethod(access, name, desc, signature, exceptions); } // Skip constructors if (name.equals("<init>")) { return super.visitMethod(access, name, desc, signature, exceptions); } MethodMetadataReadingVisitor visitor = new MethodMetadataReadingVisitor(name, access, getClassName(), Type.getReturnType(desc).getClassName(), this.classLoader, this.methodMetadataSet); this.methodMetadataSet.add(visitor); return visitor; }
@Override @Nullable public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName) { return getAllAnnotationAttributes(annotationName, false); }
Object value = entry.getValue(); if (value instanceof AnnotationAttributes) { value = convertClassValues((AnnotationAttributes)value, classValuesAsString, nestedAttributesAsMap); values[i] = convertClassValues(values[i], classValuesAsString, nestedAttributesAsMap);
@Override @Nullable public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) { MultiValueMap<String, Object> allAttributes = new LinkedMultiValueMap<>(); List<AnnotationAttributes> attributes = this.attributesMap.get(annotationName); if (attributes == null) { return null; } for (AnnotationAttributes raw : attributes) { for (Map.Entry<String, Object> entry : AnnotationReadingVisitorUtils.convertClassValues( "class '" + getClassName() + "'", this.classLoader, raw, classValuesAsString).entrySet()) { allAttributes.add(entry.getKey(), entry.getValue()); } } return allAttributes; }
SimpleMetadataReader(Resource resource, @Nullable ClassLoader classLoader) throws IOException { InputStream is = new BufferedInputStream(resource.getInputStream()); ClassReader classReader; try { classReader = new ClassReader(is); } catch (IllegalArgumentException ex) { throw new NestedIOException("ASM ClassReader failed to parse class file - " + "probably due to a new Java class file version that isn't supported yet: " + resource, ex); } finally { is.close(); } AnnotationMetadataReadingVisitor visitor = new AnnotationMetadataReadingVisitor(classLoader); classReader.accept(visitor, ClassReader.SKIP_DEBUG); this.annotationMetadata = visitor; // (since AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor) this.classMetadata = visitor; this.resource = resource; }
@Override @Nullable public AnnotationAttributes getAnnotationAttributes(String annotationName) { return getAnnotationAttributes(annotationName, false); }
@Override @Nullable public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName) { return getAllAnnotationAttributes(annotationName, false); }
@Override @Nullable public AnnotationAttributes getAnnotationAttributes(String annotationName, boolean classValuesAsString) { AnnotationAttributes raw = AnnotationReadingVisitorUtils.getMergedAnnotationAttributes( this.attributesMap, this.metaAnnotationMap, annotationName); if (raw == null) { return null; } return AnnotationReadingVisitorUtils.convertClassValues( "class '" + getClassName() + "'", this.classLoader, raw, classValuesAsString); }
SimpleMetadataReader(Resource resource, ClassLoader classLoader) throws IOException { InputStream is = new BufferedInputStream(resource.getInputStream()); ClassReader classReader = null; try { classReader = new ClassReader(is); } finally { is.close(); } AnnotationMetadataReadingVisitor visitor = new AnnotationMetadataReadingVisitor(classLoader); classReader.accept(visitor, true); this.annotationMetadata = visitor; // (since AnnotationMetadataReader extends ClassMetadataReadingVisitor) this.classMetadata = visitor; this.resource = resource; }
public AnnotationAttributes getAnnotationAttributes(String annotationType, boolean classValuesAsString) { return getAnnotationAttributes(annotationType, classValuesAsString, false); }
@Override @Nullable public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName) { return getAllAnnotationAttributes(annotationName, false); }
@Override @Nullable public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) { MultiValueMap<String, Object> allAttributes = new LinkedMultiValueMap<>(); List<AnnotationAttributes> attributes = this.attributesMap.get(annotationName); if (attributes == null) { return null; } for (AnnotationAttributes raw : attributes) { for (Map.Entry<String, Object> entry : AnnotationReadingVisitorUtils.convertClassValues( "class '" + getClassName() + "'", this.classLoader, raw, classValuesAsString).entrySet()) { allAttributes.add(entry.getKey(), entry.getValue()); } } return allAttributes; }
public AnnotationMetadata getAnnotationMetadata() { AnnotationMetadataReadingVisitor visitor = new AnnotationMetadataReadingVisitor(this.classLoader); this.classReader.accept(visitor, ClassReader.SKIP_DEBUG); return visitor; }
public AnnotationAttributes getAnnotationAttributes(String annotationType) { return getAnnotationAttributes(annotationType, false); }