Skip to content
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

Closed
wants to merge 11 commits into from
@@ -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>,
Copy link
Collaborator

@RogerRiggs RogerRiggs Nov 23, 2020

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...".

Copy link
Collaborator Author

@dansmithcode dansmithcode Nov 24, 2020

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.

<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&mdash;in particular, any factory
Copy link
Collaborator

@RogerRiggs RogerRiggs Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mdash came out as "â" in the javadoc.

Copy link
Collaborator Author

@dansmithcode dansmithcode Oct 16, 2020

Choose a reason for hiding this comment

The 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 make docs...

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