Skip to content

AOT bean registrations miss reflection hints on public methods #31293

Closed
@bclozel

Description

@bclozel

See #31213 for background.

As seen in #31224, our reflection hints predicates were previously considering that org.springframework.aot.hint.MemberCategory#INTROSPECT_DECLARED_METHODS was somehow including org.springframework.aot.hint.MemberCategory#INTROSPECT_PUBLIC_METHODS. As documented in MemberCategory, this is not true because of inherited methods. This means that if Class#getMethods() is being called at runtime, it is required to register a INTROSPECT_PUBLIC_METHODS reflection hint.

We are missing such a hint in our core bean arrangement as we can see the following warnings when introspecting types and their inherited methods:

org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access org.springframework.aop.framework.autoproxy.InfrastructureAdvisorAutoProxyCreator.getMethods() without it being registered for runtime reflection. Add org.springframework.aop.framework.autoproxy.InfrastructureAdvisorAutoProxyCreator.getMethods() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
  java.base@21/java.lang.Class.getMethods(DynamicHub.java:1004)
  org.springframework.beans.PropertyDescriptorUtils.determineBasicProperties(PropertyDescriptorUtils.java:62)
  org.springframework.beans.SimpleBeanInfoFactory.getBeanInfo(SimpleBeanInfoFactory.java:53)
  org.springframework.beans.CachedIntrospectionResults.getBeanInfo(CachedIntrospectionResults.java:228)

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)theme: aotAn issue related to Ahead-of-time processingtype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions