-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Synthesized annotation toString() doesn't match non-synthesized annotation on Java 9+ #28015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is actually by design. The result of invoking See: In any case, it does not appear that the JDK format has changed since Java 9, so I'll go ahead and update to the newer format. |
Ah ok, I wasn't aware of the change between JDK 8 and 9 there. If 5.3.x is currently aligned with the JDK 8 toString format there, we could also simply upgrade to the JDK 9+ format for 6.0. |
Interestingly enough, it turns out there are actually 2 bugs (🐛) lurking behind the scenes here.
I'll see if the OpenJDK team is willing to update the |
|
Reopening to address additional shortcomings in the |
My proposal for the same change in the JDK is currently targeted for JDK 19. - https://bugs.openjdk.java.net/browse/JDK-8281462 - https://bugs.openjdk.java.net/browse/JDK-8281568 - openjdk/jdk#7418 See spring-projectsgh-28015
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 thetoString()
, 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:
Non-Synthesized Annotation
toString()
:Synthesized Annotation
toString()
:spring-framework/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java
Line 202 in a0c97e4
The text was updated successfully, but these errors were encountered: