Skip to content

Return null for getSuperClassName() with package-info classes #34869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

philwebb
Copy link
Member

@philwebb philwebb commented May 8, 2025

Upgrading Spring Boot to use Framework 7 hit an issue with spring-hateoas and AOT hints.

at org.springframework.aot.hint.SimpleTypeReference.of(SimpleTypeReference.java:47)	
	at org.springframework.aot.hint.TypeReference.of(TypeReference.java:85)	
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:215)	
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:215)	
	at java.util.Iterator.forEachRemaining(Iterator.java:133)	
	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)	
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:570)	
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)	
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:153)	
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:176)	
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)	
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:636)	
	at org.springframework.hateoas.aot.AotUtils.registerTypesForReflection(AotUtils.java:109)

This is ultimately caused by a change in behavior when running on Java 24. With earlier versions, the registerTypesForReflection uses a scanner that uses a SimpleAnnotationMetadataReader. This scanner always returns null for getSuperClassName() results from package-info classes. It appears that ClassFileClassMetadata returns Object.class.

This seems like a possible bug in the new class file Java API, but I think we should add a workaround in our code as well.

Update `ClassFileClassMetadata` to align the behavior of
`getSuperClassName()` with other readers in that it returns
`null` for `package-info` classes.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 8, 2025
@bclozel bclozel self-assigned this May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants