RFR: 8254275: Development to revise "value-based class" & apply to wrappers [v2]
Dan Smith
dlsmith at openjdk.java.net
Fri Oct 16 17:56:20 UTC 2020
On Fri, 16 Oct 2020 17:15:58 GMT, Dan Smith <dlsmith at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/doc-files/ValueBased.html line 43:
>>
>>> 41: <code>hashCode</code>, and <code>toString</code> which are computed
>>> 42: solely from the instance's state and not from its identity or the state
>>> 43: of any other object or variable;</li>
>>
>> Quibble on pre-existing text:
>>
>> If the instance state is a reference to another object, can its hashCode be included in the hashCode?
>> The " not... from the state of any object" would seem to prohibit that.
>
> Perhaps "not from its identity or the state of any other object or variable that is not part of the instance's state"?
Eh, the "any other object or variable" clause is too strong. What about a `toString` based on `System.lineSeparator()`
or something like that? Seems like it's trying too hard to prohibit some kind of workaround to mutable state. But I
think "computed solely" already communicates that pretty clearly.
How about just: "which are computed solely from the values of the class's instance fields (and properties of the
objects they reference), not from the instance's identity"
-------------
PR: https://git.openjdk.java.net/valhalla/pull/222
More information about the valhalla-dev
mailing list