-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure toString() for synthesized annotations is source code compatible
Since the introduction of synthesized annotation support in Spring Framework 4.2 (a.k.a., merged annotations), the toString() implementation attempted to align with the formatting used by the JDK itself. However, Class annotation attributes were formatted using Class#getName in Spring; whereas, the JDK used Class#toString up until JDK 9. In addition, JDK 9 introduced new formatting for toString() for annotations, apparently intended to align with the syntax used in the source code declaration of the annotation. However, JDK 9+ formats enum annotation attributes using Enum#toString instead of Enum#name, which can lead to issues if toString() is overridden in an enum. This commit updates the formatting used for synthesized annotations by ensuring that toString() generates a string that is compatible with the syntax of the originating source code, going beyond the changes made in JDK 9 by using Enum#name instead of Enum#toString. Closes gh-28015
- Loading branch information
Showing
2 changed files
with
50 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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