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

Joe Darcy darcy at openjdk.java.net
Thu Feb 10 22:12:58 UTC 2022


On Thu, 10 Feb 2022 14:56:46 GMT, Sam Brannen <duke at openjdk.java.net> wrote:

>> Joe Darcy has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Respond to review feedback.
>
> src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java line 256:
> 
>> 254:         return Objects.toString(finalComponent.getCanonicalName(),
>> 255:                                 "<no canonical name>") +
>> 256:             arrayBrackets.toString() + ".class";
> 
> Since we're using the canonical name now (which takes the array brackets into account), can't the whole method be simplified down to the following?
> 
> Suggestion:
> 
>         return Objects.toString(clazz.getCanonicalName(), "<no canonical name>") + ".class";

The getCanonicalName is not specified to behave that way, should be a RFE I suppose, but appears to in practice; changed as suggested in subsequent push. Thanks.

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

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


More information about the core-libs-dev mailing list