Only load enclosing class for TYPE_HIERARCHY_AND_ENCLOSING_CLASSES strategy

Prior to this commit, the enclosing class was always eagerly loaded
even if the annotation search strategy was not explicitly
TYPE_HIERARCHY_AND_ENCLOSING_CLASSES.

See gh-24136
This commit is contained in:
Sam Brannen
2019-12-10 22:08:26 +01:00
parent 76bc581528
commit 16ed7e2a19

View File

@@ -230,12 +230,14 @@ abstract class AnnotationsScanner {
return superclassResult;
}
}
Class<?> enclosingClass = source.getEnclosingClass();
if (includeEnclosing && enclosingClass != null) {
R enclosingResult = processClassHierarchy(context, aggregateIndex,
if (includeEnclosing) {
Class<?> enclosingClass = source.getEnclosingClass();
if (enclosingClass != null) {
R enclosingResult = processClassHierarchy(context, aggregateIndex,
enclosingClass, processor, classFilter, includeInterfaces, true);
if (enclosingResult != null) {
return enclosingResult;
if (enclosingResult != null) {
return enclosingResult;
}
}
}
return null;