Optimize @Configuration class parsing a little
Update `ConfigurationClassParser` to skip `java.lang.annotation` types which were often processed but would never provide useful results. Also use a single shared immutable `SourceClass` instance to represent `Object.class`. Closes gh-22563
This commit is contained in:
parent
37255afca4
commit
aa4e56b251
|
|
@ -140,6 +140,8 @@ class ConfigurationClassParser {
|
||||||
|
|
||||||
private final DeferredImportSelectorHandler deferredImportSelectorHandler = new DeferredImportSelectorHandler();
|
private final DeferredImportSelectorHandler deferredImportSelectorHandler = new DeferredImportSelectorHandler();
|
||||||
|
|
||||||
|
private final SourceClass objectSourceClass = new SourceClass(Object.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link ConfigurationClassParser} instance that will be used
|
* Create a new {@link ConfigurationClassParser} instance that will be used
|
||||||
|
|
@ -639,8 +641,8 @@ class ConfigurationClassParser {
|
||||||
* Factory method to obtain a {@link SourceClass} from a {@link Class}.
|
* Factory method to obtain a {@link SourceClass} from a {@link Class}.
|
||||||
*/
|
*/
|
||||||
SourceClass asSourceClass(@Nullable Class<?> classType) throws IOException {
|
SourceClass asSourceClass(@Nullable Class<?> classType) throws IOException {
|
||||||
if (classType == null) {
|
if (classType == null || classType.getName().startsWith("java.lang.annotation")) {
|
||||||
return new SourceClass(Object.class);
|
return this.objectSourceClass;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Sanity test that we can reflectively read annotations,
|
// Sanity test that we can reflectively read annotations,
|
||||||
|
|
@ -671,8 +673,8 @@ class ConfigurationClassParser {
|
||||||
* Factory method to obtain a {@link SourceClass} from a class name.
|
* Factory method to obtain a {@link SourceClass} from a class name.
|
||||||
*/
|
*/
|
||||||
SourceClass asSourceClass(@Nullable String className) throws IOException {
|
SourceClass asSourceClass(@Nullable String className) throws IOException {
|
||||||
if (className == null) {
|
if (className == null || className.startsWith("java.lang.annotation")) {
|
||||||
return new SourceClass(Object.class);
|
return this.objectSourceClass;
|
||||||
}
|
}
|
||||||
if (className.startsWith("java")) {
|
if (className.startsWith("java")) {
|
||||||
// Never use ASM for core java types
|
// Never use ASM for core java types
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue