Render parameter type names in ClassFileMethodMetadata#36919
Open
junhyeong9812 wants to merge 1 commit into
Open
Render parameter type names in ClassFileMethodMetadata#36919junhyeong9812 wants to merge 1 commit into
junhyeong9812 wants to merge 1 commit into
Conversation
ClassFileMethodMetadata's toString() formatted method parameter types as packageName() + "." + displayName(). Since ClassDesc.packageName() is empty for primitive, array and default-package types, these rendered with a leading dot (for example ".int" and ".String[]") and reference arrays lost their package. The return type already uses ClassFileAnnotationMetadata.resolveTypeName(); apply it to the parameters as well. Signed-off-by: junhyeong9812 <pickjog@gmail.com>
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.
Overview
On JDK 24+, method metadata is read through the
java.lang.classfilebasedClassFileMethodMetadata(insrc/main/java24).Problem
ClassFileMethodMetadata'stoString()formatted each parameter type aspackageName() + "." + displayName().ClassDesc.packageName()returns an empty string forprimitive, array, and default-package types, so parameters were rendered with a leading dot —
".int",".String[]"— and reference arrays lost their package. For examplevoid sample(int, String[])rendered as...sample(.int,.String[]).The return type of the same method already uses
ClassFileAnnotationMetadata.resolveTypeName(), and the ASM-based reader(
SimpleMethodMetadataReadingVisitor) usesType.getClassName(), both producing canonical names(
int,java.lang.String[]).Fix
Map the parameter
ClassDescs throughClassFileAnnotationMetadata.resolveTypeName()— the samehelper already used for the return type. This affects only the diagnostic
toString()output; nometadata logic consumes it. A regression test is added under
src/test/java24.Relation to gh-36577
gh-36577 fixed the same
packageName() + "." + displayName()problem for the return type(
getReturnTypeName()and the return-type slot intoString()), but the parameter rendering intoString()was left unchanged (ClassFileMethodMetadata, parameter mapping). This PR completesthat fix for the parameter types.