JDK-8236699 : java.lang.Record should be declared with an explicit constructor
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P2
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 14
  • Submitted: 2020-01-06
  • Updated: 2020-01-07
  • Resolved: 2020-01-07
Related Reports
CSR :  
Description
Summary
-------

The type `java.lang.Record` should use an explicit constructor rather than a default one.

Problem
-------

Relying on a default constructor is not prudent for platform classes.

Solution
--------

Add an explicit `protected` constructor.

Specification
-------------

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



Comments
Moving to Approved.
07-01-2020