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

Sam Brannen duke at openjdk.java.net
Fri Feb 11 15:36:13 UTC 2022


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

>> 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.

Thanks, Joe.

Regarding the RFE, do you plan to open an issue to address the documentation for `getCanonicalName`?

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

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


More information about the core-libs-dev mailing list