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:28:10 UTC 2022
On Thu, 10 Feb 2022 22:12:57 GMT, Joe Darcy <darcy at 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
>
> 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 148:
> 146: StringBuilder result = new StringBuilder(128);
> 147: result.append('@');
> 148: // Guard against shouldn't-happen NPE for a missing canonical name
NIT: A NPE would not be thrown. Rather, `"null"` would be appended to the buffer. Right?
-------------
PR: https://git.openjdk.java.net/jdk/pull/7418
More information about the core-libs-dev
mailing list