Minimized ASM usage
In particular, avoid accidental usage of ASM for core JDK types - which will fail in case of a new bytecode version in the JDK, even if the application itself has been compiled with an earlier bytecode target. Issue: SPR-10292
This commit is contained in:
@@ -114,8 +114,15 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
|
||||
}
|
||||
catch (IOException ex) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Exception thrown while reading '.class' file for class [" + clazz
|
||||
+ "] - unable to determine constructors/methods parameter names", ex);
|
||||
logger.debug("Exception thrown while reading '.class' file for class [" + clazz +
|
||||
"] - unable to determine constructors/methods parameter names", ex);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("ASM ClassReader failed to parse class file [" + clazz +
|
||||
"], probably due to a new Java class file version that isn't supported yet " +
|
||||
"- unable to determine constructors/methods parameter names", ex);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -145,6 +145,8 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements
|
||||
return AnnotationUtils.getAnnotationAttributes(
|
||||
ann, classValuesAsString, this.nestedAnnotationsAsMap);
|
||||
}
|
||||
}
|
||||
for (Annotation ann : anns) {
|
||||
for (Annotation metaAnn : ann.annotationType().getAnnotations()) {
|
||||
if (metaAnn.annotationType().getName().equals(annotationType)) {
|
||||
return AnnotationUtils.getAnnotationAttributes(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -105,19 +105,11 @@ final class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor
|
||||
}
|
||||
|
||||
public AnnotationAttributes getAnnotationAttributes(String annotationType, boolean classValuesAsString) {
|
||||
return getAnnotationAttributes(annotationType, classValuesAsString, false);
|
||||
}
|
||||
|
||||
public AnnotationAttributes getAnnotationAttributes(
|
||||
String annotationType, boolean classValuesAsString, boolean nestedAttributesAsMap) {
|
||||
|
||||
AnnotationAttributes raw = this.attributeMap.get(annotationType);
|
||||
return convertClassValues(raw, classValuesAsString, nestedAttributesAsMap);
|
||||
return convertClassValues(raw, classValuesAsString);
|
||||
}
|
||||
|
||||
private AnnotationAttributes convertClassValues(
|
||||
AnnotationAttributes original, boolean classValuesAsString, boolean nestedAttributesAsMap) {
|
||||
|
||||
private AnnotationAttributes convertClassValues(AnnotationAttributes original, boolean classValuesAsString) {
|
||||
if (original == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -126,12 +118,12 @@ final class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor
|
||||
try {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof AnnotationAttributes) {
|
||||
value = convertClassValues((AnnotationAttributes)value, classValuesAsString, nestedAttributesAsMap);
|
||||
value = convertClassValues((AnnotationAttributes) value, classValuesAsString);
|
||||
}
|
||||
else if (value instanceof AnnotationAttributes[]) {
|
||||
AnnotationAttributes[] values = (AnnotationAttributes[])value;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
values[i] = convertClassValues(values[i], classValuesAsString, nestedAttributesAsMap);
|
||||
values[i] = convertClassValues(values[i], classValuesAsString);
|
||||
}
|
||||
}
|
||||
else if (value instanceof Type) {
|
||||
@@ -182,4 +174,5 @@ final class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor
|
||||
annotatedMethods.addAll(list);
|
||||
return annotatedMethods;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ final class SimpleMetadataReader implements MetadataReader {
|
||||
classReader.accept(visitor, ClassReader.SKIP_DEBUG);
|
||||
|
||||
this.annotationMetadata = visitor;
|
||||
// (since AnnotationMetadataReader extends ClassMetadataReadingVisitor)
|
||||
// (since AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor)
|
||||
this.classMetadata = visitor;
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user