You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
JDK-8164819 changed the toString() implementation of some AnnotationValue implementations to match core reflection.
For AnnotationValues representing an enum constant, the toString() is now the simple name instead of a fully qualified name. I encountered some code that using CodeBlock.of("$L", annotationValue), which ends up just calling toString(), which now results in an unqualified simple name of the enum constant.
Is there already a better way to convert an AnnotationValue to a CodeBlock? I couldn't find one. There's some logic in AnnotationSpec that's close to what I want, but the only entry point takes an entire AnnotationMirror:
JDK-8164819 changed the
toString()
implementation of someAnnotationValue
implementations to match core reflection.For
AnnotationValue
s representing an enum constant, thetoString()
is now the simple name instead of a fully qualified name. I encountered some code that usingCodeBlock.of("$L", annotationValue)
, which ends up just callingtoString()
, which now results in an unqualified simple name of the enum constant.Is there already a better way to convert an
AnnotationValue
to aCodeBlock
? I couldn't find one. There's some logic inAnnotationSpec
that's close to what I want, but the only entry point takes an entireAnnotationMirror
:javapoet/src/main/java/com/squareup/javapoet/AnnotationSpec.java
Lines 267 to 269 in 8851788
Demo:
With JDK 11,
CodeBlock.of("$L", av)
is the qualified nameP.E.ONE
:With JDK 17, it's just
ONE
:The text was updated successfully, but these errors were encountered: