Skip to content

Conversation

philwebb
Copy link
Member

@philwebb philwebb commented May 8, 2025

Return null for getSuperClassName() with package-info classes:

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
Update `ClassFileClassMetadata` so that member classes only include
immediate children. This aligns with the other `ClassMetadata`
implementations.
@philwebb philwebb changed the title Return null for getSuperClassName() with package-info classes Align ClassFileClassMetadata with other implementations May 8, 2025
@philwebb
Copy link
Member Author

philwebb commented May 8, 2025

I found another quirk with member classes so I've added a second commit to this PR.

@bclozel bclozel added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 9, 2025
@bclozel bclozel added this to the 7.0.0-M5 milestone May 9, 2025
bclozel pushed a commit that referenced this pull request May 9, 2025
Update `ClassFileClassMetadata` to align the behavior of
`getSuperClassName()` with other readers in that it returns
`null` for `package-info` classes.

See gh-34869
@bclozel bclozel closed this in 13b09e6 May 9, 2025
@bclozel
Copy link
Member

bclozel commented May 9, 2025

Thanks @philwebb !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants