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

Commit

Permalink
Avoid java.lang.Object declared method reflection entries
Browse files Browse the repository at this point in the history
Regression between 0.11.0-RC1 and 0.11.0.

Closes gh-1391
  • Loading branch information
sdeleuze committed Dec 21, 2021
1 parent 82e16f1 commit aa37b19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.BeanFactoryNativeConfigurationProcessor;
import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.NativeConfigurationRegistry;
import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.NativeConfigurationUtils;
import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.NativeReflectionEntry;
import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.NativeReflectionEntry.Builder;
import org.springframework.aot.support.BeanFactoryProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
Expand All @@ -40,6 +42,7 @@
* Register as much of the hierarchy of {@link Indexed} marked beans as is required.
*
* @author Andy Clement
* @author Sebastien Deleuze
*/
public class IndexedBeanHierarchyNativeConfigurationProcessor implements BeanFactoryNativeConfigurationProcessor {

Expand All @@ -66,7 +69,10 @@ public void walkTypeAndRegisterReflection(Class<?> type, NativeConfigurationRegi
if (!visited.add(type)) {
return;
}
registry.reflection().forType(type).withAccess(TypeAccess.DECLARED_METHODS);
Builder builder = registry.reflection().forType(type);
if (!type.getPackageName().startsWith("java.")) {
builder.withAccess(TypeAccess.DECLARED_METHODS);
}
Set<Class<?>> collector = new TreeSet<>((c1,c2) -> c1.getName().compareTo(c2.getName()));
Type genericSuperclass = type.getGenericSuperclass();
NativeConfigurationUtils.collectReferenceTypesUsed(genericSuperclass, collector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* Tests for {@link IndexedBeanHierarchyNativeConfigurationProcessor}.
*
* @author Andy Clement
* @author Sebastien Deleuze
*/
class IndexedBeanHierarchyNativeConfigurationProcessorTests {

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

@Test
Expand Down

0 comments on commit aa37b19

Please sign in to comment.