Validate declared annotations before deciding between reflection and ASM
Issue: SPR-16564
This commit is contained in:
@@ -18,6 +18,7 @@ package org.springframework.context.annotation;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
@@ -55,6 +56,7 @@ import org.springframework.core.OrderComparator;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.env.CompositePropertySource;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
@@ -659,8 +661,11 @@ class ConfigurationClassParser {
|
||||
return new SourceClass(Object.class);
|
||||
}
|
||||
try {
|
||||
// Sanity test that we can read annotations, if not fall back to ASM
|
||||
classType.getAnnotations();
|
||||
// Sanity test that we can reflectively read annotations,
|
||||
// including Class attributes; if not -> fall back to ASM
|
||||
for (Annotation ann : classType.getAnnotations()) {
|
||||
AnnotationUtils.validateAnnotation(ann);
|
||||
}
|
||||
return new SourceClass(classType);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
|
||||
Reference in New Issue
Block a user