Implicit record members and ACC_FINAL
Chris Hegarty
chris.hegarty at oracle.com
Fri Mar 26 15:09:48 UTC 2021
( Sorry, I know I’ve asked this before, but cannot remember or find the
answer now )
While it may not matter all that much, since a record class is final,
is there any specific reason why the toString, hashCode, and equals
methods have ACC_FINAL. While the accessors do not have ACC_FINAL.
I do note that the compiler behaving in a way that is consistent with
the JLS.
For example,
$ cat Point.java
public record Point (int x, int y) { }
$ javap Point
Compiled from "Point.java"
public final class Point extends java.lang.Record {
public Point(int, int);
public final java.lang.String toString();
public final int hashCode();
public final boolean equals(java.lang.Object);
public int x();
public int y();
}
-Chris.
P.S. Peter Levart asked this question at a recent ODL talk, where I
didn't have the answer to hand.
More information about the amber-dev
mailing list