Invalid method return type metadata for ClassFile variant on JDK 24+#36577
Merged
bclozel merged 2 commits intospring-projects:7.0.xfrom Apr 2, 2026
Merged
Invalid method return type metadata for ClassFile variant on JDK 24+#36577bclozel merged 2 commits intospring-projects:7.0.xfrom
bclozel merged 2 commits intospring-projects:7.0.xfrom
Conversation
Member
|
Please hold off further changes here, I'll take care of fixing the failing build and additional cases. |
f8325f8 to
6f4f0ed
Compare
Contributor
Author
|
I realized that I mistakenly used spaces instead of a tab on one line (ClassFileMethodMetadata.java:165 only). Sorry about that. |
Return correct names for primitive and array types Introduce resolveTypeName helper for ClassDesc handling Add ClassFileMethodMetadataTests (java24Test) Extend AbstractMethodMetadataTests with void return case See spring-projectsgh-36577 Signed-off-by: Junseo Bae <ferrater1013@gmail.com>
bclozel
added a commit
to bebeis/spring-framework
that referenced
this pull request
Apr 2, 2026
Prior to this commit, the ClassFile variant for annotation and method metadata would report incorrect metadata for: * the method return type names in case of primitives and array types * `toString` values for methods * `equals` and `hashcode` information for methods This commit expands the test suite and ensures that the ASM and ClassFile variants are aligned. Fixes spring-projectsgh-36577
6f4f0ed to
36c9f42
Compare
Prior to this commit, the ClassFile variant for annotation and method metadata would report incorrect metadata for: * the method return type names in case of primitives and array types * `toString` values for methods * `equals` and `hashcode` information for methods This commit expands the test suite and ensures that the ASM and ClassFile variants are aligned. Fixes spring-projectsgh-36577 Signed-off-by: Brian Clozel <brian.clozel@broadcom.com>
36c9f42 to
40ef6f6
Compare
Member
|
Thanks for your contribution @bebeis ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On JDK 24+,
@Beanmethods declared with avoidreturn type are not rejected during configuration parsing, and noBeanDefinitionParsingExceptionis raised.Reproduction
JDK 21 (expected behavior)
JDK 24+ (actual behavior)
No exception is thrown and the context starts normally.
Test Failed
Root cause
On JDK 24+, Spring uses
ClassFileMethodMetadata(backed by the JDK 24 ClassFile API) to read method metadata. ThegetReturnTypeName()method was implemented as:ClassDesc.packageName()is only defined for class and interface types. Using it unconditionally when building return type names causes malformed results for primitive and array types.void".void""void"int".int""int"String"java.lang.String""java.lang.String"String[]".String[]""java.lang.String[]"The most visible symptom is that
BeanMethod.validate()inspring-contextchecks:Because
getReturnTypeName()returns".void"instead of"void"on JDK 24+, this check silently passes — allowingvoid @Beanmethods without any error.Fix
Replaced the inline string concatenation with a
resolveTypeName()helper that handles each case correctly:This ensures:
void,int, etc.).MyClassThis change aligns ClassFile-based metadata with existing ASM and reflection-based implementations.
Tests
ClassFileMethodMetadataTests(java24Test)AbstractMethodMetadataTestsNotes
Similar issues exist in other ClassFile-based implementations (e.g. ClassFileAnnotationDelegate and Source#toString()), where primitive, array, and default package types may also be rendered incorrectly. These are not addressed in this PR.