RFR: JDK-8281462: Annotation toString output for enum not reusable for source input [v2]

Jaikiran Pai jpai at openjdk.java.net
Fri Feb 11 07:38:09 UTC 2022


On Thu, 10 Feb 2022 22:08:27 GMT, Joe Darcy <darcy at openjdk.org> wrote:

>> 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);
>
>> 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);
>> ```
> 
> Fair point; updated in subsequent push. Thanks.

Thank you for this change, Joe. Looks fine to me.

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

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


More information about the core-libs-dev mailing list