RFR: 8373186: Improve readability of core reflection toString specifications
Joe Darcy
darcy at openjdk.org
Mon Dec 8 23:56:56 UTC 2025
On Mon, 8 Dec 2025 09:06:13 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Partial implementation of a spec refactoring to get some feedback before writing similar changes for other core reflection types.
>
> src/java.base/share/classes/java/lang/reflect/Field.java line 349:
>
>> 347:
>> 348: /**
>> 349: * {@return a string describing this {@code Field}}
>
> Field::toString has been specified this way since JDK 1.1 and we have to assume there are frameworks or libraries that would break if we were ever change the format of the String representation. Would it be possible to put more context for the proposal in the JBS or PR? I think I'm mostly trying to understand if this is just about readability or whether an incompatible change to the string representation might follow.
I don't have any implementation changes planned, but if there are new kinds of things added, I prefer to avoid treating the toString() method as a home for a context free grammar to provide all the necessary information about the item.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28688#discussion_r2600550124
More information about the core-libs-dev
mailing list