Skip to content

Synthesized annotation toString() doesn't match non-synthesized annotation on Java 9+ #28015

Closed
@jeff-miller-cfa

Description

@jeff-miller-cfa

Synthesized annotations that contain arrays and/or strings do not generate the same toString() value as the non-synthesized version.

The non-synthesized annotation's toString() method returns a string which is a code equivalent version of that annotation meaning that you can take the result of the toString(), copy and paste it into code, and have it compile. This is very convenient when writing a code generation library since it allows you to copy annotations.

This does not work with synthesized annotations though as the way the array gets serialized in toString() doesn't match.

Actual Annotation:

@Bean("testValue")

Non-Synthesized Annotation toString():

@org.springframework.context.annotation.Bean(value = {"testValue"})

Synthesized Annotation toString():

@org.springframework.context.annotation.Bean(value = [testValue])

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions