Consistent non-exposure of inherited annotations in AnnotationMetadata

Closes gh-22766
This commit is contained in:
Juergen Hoeller
2019-04-08 15:59:06 +02:00
parent 2e7ed915cd
commit fd8fa301a6
3 changed files with 29 additions and 10 deletions

View File

@@ -638,13 +638,13 @@ class ConfigurationClassParser {
* Factory method to obtain a {@link SourceClass} from a {@link Class}.
*/
SourceClass asSourceClass(@Nullable Class<?> classType) throws IOException {
if (classType == null || classType.getName().startsWith("java.lang.annotation")) {
if (classType == null || classType.getName().startsWith("java.lang.annotation.")) {
return this.objectSourceClass;
}
try {
// Sanity test that we can reflectively read annotations,
// including Class attributes; if not -> fall back to ASM
for (Annotation ann : classType.getAnnotations()) {
for (Annotation ann : classType.getDeclaredAnnotations()) {
AnnotationUtils.validateAnnotation(ann);
}
return new SourceClass(classType);
@@ -670,7 +670,7 @@ class ConfigurationClassParser {
* Factory method to obtain a {@link SourceClass} from a class name.
*/
SourceClass asSourceClass(@Nullable String className) throws IOException {
if (className == null || className.startsWith("java.lang.annotation")) {
if (className == null || className.startsWith("java.lang.annotation.")) {
return this.objectSourceClass;
}
if (className.startsWith("java")) {
@@ -1017,7 +1017,7 @@ class ConfigurationClassParser {
Set<SourceClass> result = new LinkedHashSet<>();
if (this.source instanceof Class) {
Class<?> sourceClass = (Class<?>) this.source;
for (Annotation ann : sourceClass.getAnnotations()) {
for (Annotation ann : sourceClass.getDeclaredAnnotations()) {
Class<?> annType = ann.annotationType();
if (!annType.getName().startsWith("java")) {
try {