Skip to content

Improve primitive array handling in AnnotationAttributes.toString() - #37395

Merged
sbrannen merged 1 commit into
spring-projects:mainfrom
guanchengang:improve/annotation-attributes-tostring-primitive-arrays
Oct 5, 2026
Merged

sbrannen merged 1 commit into
spring-projects:mainfrom
guanchengang:improve/annotation-attributes-tostring-primitive-arrays

Conversation

@guanchengang

Copy link
Copy Markdown
Contributor

valueToString only formatted Object[]; primitive arrays such as int[], boolean[], and double[] fell through to String.valueOf and were rendered as hash-based strings like [I@1a2b3c.

Use java.lang.reflect.Array to iterate over any array type so that toString() also produces readable output for primitive arrays.

`valueToString` only formatted `Object[]`; primitive arrays such as
`int[]`, `boolean[]`, and `double[]` fell through to `String.valueOf`
and were rendered as hash-based strings like `[I@1a2b3c`.

Use `java.lang.reflect.Array` to iterate over any array type so that
`toString()` also produces readable output for primitive arrays.

Signed-off-by: Chengang Guan <guanchengang@qq.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 5, 2026
@sbrannen sbrannen self-assigned this Oct 5, 2026
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 5, 2026
@sbrannen sbrannen added this to the 7.1.0-RC1 milestone Oct 5, 2026
@sbrannen
sbrannen merged commit afaa8fd into spring-projects:main Oct 5, 2026
5 checks passed
sbrannen added a commit that referenced this pull request Oct 5, 2026
@sbrannen

sbrannen commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

This has been merged into main in afaa8fd, and I introduced tests in cd21915.

Thanks


See also:

sbrannen added a commit that referenced this pull request Oct 5, 2026
To improve diagnostics, AnnotationAttributes.toString() now renders
Class values using their canonical names with a ".class" suffix and
enum constants using Enum.name(), analogous to the toString()
implementation for synthesized annotations.

See gh-37395
Closes gh-37396
@guanchengang
guanchengang deleted the improve/annotation-attributes-tostring-primitive-arrays branch October 6, 2026 00:06
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: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants