Summary
Make the output of the toString for annotation objects consistent between core reflection and javac.
Problem
There are a number of consistencies in the output of annotations (and the related AnnotationMirror the the annotation processing API) between core reflection and javac.
Solution
Make the output consistent in both situations. Examining javadoc output for consistency will be done as separate work.
Specification
No specification update as the exact toString output is, by design, not specified. The behavior changes are:
For javac:
- The string for class literals, either stand-alone or in an array now properly end in ".class".
- For an enum constant, just the constant name is emitted rather than the full class name followed by the enum constant name. This shorter form is also used by javadoc.
For core reflection:
- Eliding "value=" when it is not necessary, logic already present for this in the javac implementations.
- Changing the formatting of byte values to follow the existing javac convention, "(byte)0x1a"
- Adopting the same quoting policy for char and string values as javac. This was accomplished by copying a few small methods from the javac internals; I don't think it is worthwhile to go through the contortions that would be needed to share this small bit of rarely changing code across these modules.
- Unconditionally append a trailing "L" to long values, as done by javac.
- csr of
-
JDK-8164819 Make javac's toString() on annotation objects consistent with core reflection
-
- Resolved
-