RFR: 8373186: Improve readability of core reflection toString specifications

Joe Darcy darcy at openjdk.org
Tue Dec 9 00:27:54 UTC 2025


On Mon, 8 Dec 2025 23:44:02 GMT, Chen Liang <liach at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/reflect/Field.java line 349:
>> 
>>> 347: 
>>> 348:     /**
>>> 349:      * {@return a string describing this {@code Field}}
>> 
>> I don't see a compelling reason to backtrack on the format of toString. 
>> Its likely to break some application or description of the field to a user.
>
> I think the reason to change the format is some future modifiers, like ACC_STRICT_INIT, won't get printed.

Also, it helps avoid "attractive nuisance" questions like "how does the toString() of a bridge method indicate it is a bridge method"? (There is no such indication in the toString output, other than indirectly via the return type, but there is a Method.isBridge() predicate.)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28688#discussion_r2600613169


More information about the core-libs-dev mailing list