On Thu, 10 Feb 2022 05:49:47 GMT, Joe Darcy <da...@openjdk.org> wrote:

> Two changes to the toString output for annotations to give better source 
> fidelity:
> 
> 1) For enum constants, call their name method rather than their toString 
> method. An enum class can override the toString method to print something 
> other than the name.
> 
> 2) Switch from using binary names (names with "$" for nested types) to 
> canonical names (names with "." with nested types)
> 
> Various existing regression tests are updated to accommodate the changes.
> 
> Please also review the CSR:
> https://bugs.openjdk.java.net/browse/JDK-8281568

src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
 line 197:

> 195:                 // Predicate above covers enum constants, including
> 196:                 // those with specialized class bodies.
> 197:                 return toSourceString((Enum<?>) value);

Hello Joe, would it be better to use the new syntax for `instanceof` here to 
avoid the subsequent cast?


else if (value instanceof Enum<?> v) 
  ....
  return toSourceString(v);

-------------

PR: https://git.openjdk.java.net/jdk/pull/7418

Reply via email to