Skip to content

Render parameter type names in ClassFileMethodMetadata#36919

Open
junhyeong9812 wants to merge 1 commit into
spring-projects:mainfrom
junhyeong9812:fix/classfilemethodmetadata-tostring
Open

Render parameter type names in ClassFileMethodMetadata#36919
junhyeong9812 wants to merge 1 commit into
spring-projects:mainfrom
junhyeong9812:fix/classfilemethodmetadata-tostring

Conversation

@junhyeong9812

@junhyeong9812 junhyeong9812 commented Jun 14, 2026

Copy link
Copy Markdown

Overview

On JDK 24+, method metadata is read through the java.lang.classfile based
ClassFileMethodMetadata (in src/main/java24).

Problem

ClassFileMethodMetadata's toString() formatted each parameter type as
packageName() + "." + displayName(). ClassDesc.packageName() returns an empty string for
primitive, array, and default-package types, so parameters were rendered with a leading dot —
".int", ".String[]" — and reference arrays lost their package. For example
void 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) uses Type.getClassName(), both producing canonical names
(int, java.lang.String[]).

Fix

Map the parameter ClassDescs through ClassFileAnnotationMetadata.resolveTypeName() — the same
helper already used for the return type. This affects only the diagnostic toString() output; no
metadata 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 in toString()), but the parameter rendering in
toString() was left unchanged (ClassFileMethodMetadata, parameter mapping). This PR completes
that fix for the parameter types.

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>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 14, 2026
@bclozel bclozel self-assigned this Jun 14, 2026
@bclozel bclozel added the in: core Issues in core modules (aop, beans, core, context, expression) label Jun 14, 2026
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) 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