Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8236699

java.lang.Record should be declared with an explicit constructor

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P2
    • Resolution: Approved
    • Fix Version/s: 14
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      source
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Pre-GA change to a preview feature.
    • Interface Kind:
      Java API
    • Scope:
      SE

      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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              darcy Joe Darcy
              Reporter:
              darcy Joe Darcy
              Reviewed By:
              Chris Hegarty
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: