New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8254275: [valhalla/jep390] Revise "value-based class" & apply to wrappers #222
Changes from 1 commit
5ae32ad
0b97d4a
2f13d53
3288f43
1448724
3c8fa53
7746462
a327a32
4c21b22
6191412
63db13c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -39,17 +39,17 @@ <h1 id="ValueBased">{@index "Value-based Classes"}</h1> | ||
to mutable objects);</li> | ||
<li>the class declares implementations of <code>equals</code>, | ||
<code>hashCode</code>, and <code>toString</code> which are computed | ||
solely from the values of the class's instance fields (and properties of | ||
solely from the values of the class's instance fields (and the members of | ||
the objects they reference), not from the instance's identity;</li> | ||
<li>the class's methods treat instances as <em>freely substitutable</em> | ||
when equal, meaning that interchanging any two instances <code>x</code> and | ||
<code>y</code> that are equal according to <code>equals()</code> produces no | ||
visible change in the behavior of the class's methods;</li> | ||
<li>the class performs no synchronization using an instance's monitor;</li> | ||
<li>the class does not declare (or has deprecated any) accessible constructors;</li> | ||
<li>the class does not provide any other instance creation mechanism that promises | ||
<li>the class does not provide any instance creation mechanism that promises | ||
a unique identity on each method call—in particular, any factory | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The mdash came out as "â" in the javadoc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. That's annoying. In what context? Worked okay when I did a Are character entities supposed to work? Or is the coding convention to stick strictly to ASCII? |
||
method must allow for the possibility that if two independently-produced | ||
method's contract must allow for the possibility that if two independently-produced | ||
instances are equal according to <code>equals()</code>, they may also be | ||
equal according to <code>==</code>;</li> | ||
<li>the class is final, and extends either <code>Object</code> or a hierarchy of | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does saying the class "declares" the methods apply to Records and other classes that have provided or generated methods for equals, hashcode, and toString? Must the class explicitly declare the methods to meet the criteria?
Perhaps "the implementations of equals, hashCode, and tostring use only the instance's state...".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generated fields and methods are "implicitly declared". But I suppose acceptable implementations could be inherited from a superclass, if the superclass isn't Object. I'll fix.