Hello,

The initial implementation of java.lang.Record uses a default constructor; an explicit constructor should be added instead. Please review the code change and CSR for this:

    JDK-8236695: java.lang.Record should be declared with an explicit constructor
    CSR: https://bugs.openjdk.java.net/browse/JDK-8236699
    http://cr.openjdk.java.net/~darcy/8236695.0/

Patch below. It is sufficient for the constructor to be declared as protected rather than public; the serialization tests and other records test pass with this change.

Thanks,

-Joe

--- old/src/java.base/share/classes/java/lang/Record.java 2020-01-06 13:47:31.740871560 -0800 +++ new/src/java.base/share/classes/java/lang/Record.java 2020-01-06 13:47:31.552777567 -0800
@@ -91,6 +91,11 @@
                              essentialAPI=true)
 public abstract class Record {
     /**
+     * Constructor for record classes to call.
+     */
+    protected Record() {}
+
+    /**
      * Indicates whether some other object is "equal to" this one.  In addition
      * to the general contract of {@link Object#equals(Object)},
      * record classes must further participate in the invariant that when

Reply via email to