Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit aa37b19

Browse files
committed
Avoid java.lang.Object declared method reflection entries
Regression between 0.11.0-RC1 and 0.11.0. Closes gh-1391
1 parent 82e16f1 commit aa37b19

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

spring-aot/src/main/java/org/springframework/core/IndexedBeanHierarchyNativeConfigurationProcessor.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.BeanFactoryNativeConfigurationProcessor;
2727
import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.NativeConfigurationRegistry;
2828
import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.NativeConfigurationUtils;
29+
import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.NativeReflectionEntry;
30+
import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.NativeReflectionEntry.Builder;
2931
import org.springframework.aot.support.BeanFactoryProcessor;
3032
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
3133
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -40,6 +42,7 @@
4042
* Register as much of the hierarchy of {@link Indexed} marked beans as is required.
4143
*
4244
* @author Andy Clement
45+
* @author Sebastien Deleuze
4346
*/
4447
public class IndexedBeanHierarchyNativeConfigurationProcessor implements BeanFactoryNativeConfigurationProcessor {
4548

@@ -66,7 +69,10 @@ public void walkTypeAndRegisterReflection(Class<?> type, NativeConfigurationRegi
6669
if (!visited.add(type)) {
6770
return;
6871
}
69-
registry.reflection().forType(type).withAccess(TypeAccess.DECLARED_METHODS);
72+
Builder builder = registry.reflection().forType(type);
73+
if (!type.getPackageName().startsWith("java.")) {
74+
builder.withAccess(TypeAccess.DECLARED_METHODS);
75+
}
7076
Set<Class<?>> collector = new TreeSet<>((c1,c2) -> c1.getName().compareTo(c2.getName()));
7177
Type genericSuperclass = type.getGenericSuperclass();
7278
NativeConfigurationUtils.collectReferenceTypesUsed(genericSuperclass, collector);

spring-aot/src/test/java/org/springframework/core/IndexedBeanHierarchyNativeConfigurationProcessorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* Tests for {@link IndexedBeanHierarchyNativeConfigurationProcessor}.
3535
*
3636
* @author Andy Clement
37+
* @author Sebastien Deleuze
3738
*/
3839
class IndexedBeanHierarchyNativeConfigurationProcessorTests {
3940

@@ -48,8 +49,7 @@ void basicComponent() {
4849
assertThat(classDescriptors).contains(getClassDescriptor(Foo.class,TypeAccess.DECLARED_METHODS));
4950
assertThat(classDescriptors).contains(getClassDescriptor(Boo.class,TypeAccess.DECLARED_METHODS));
5051
assertThat(classDescriptors).contains(getClassDescriptor(Bar.class,TypeAccess.DECLARED_METHODS));
51-
// TODO maybe filter out the java.* types in the configuration processor
52-
assertThat(classDescriptors).contains(getClassDescriptor(Object.class,TypeAccess.DECLARED_METHODS));
52+
assertThat(classDescriptors).contains(getClassDescriptor(Object.class));
5353
}
5454

5555
@Test

0 commit comments

Comments
 (0)