Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8246771 JEP 395: Records
  3. JDK-8262133

Release Note: JEP 395: Records

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: P3
    • Resolution: Delivered
    • Affects Version/s: 16
    • Fix Version/s: 16
    • Component/s: tools

      Description

      Records have been added to the Java language. Records are a new kind of class in the Java language. They act as transparent carriers for immutable data with less ceremony than normal classes.

      Since nested classes were first introduced to Java, with the exception of static final fields initialized by constant expressions, nested class declarations that are inner have been prohibited from declaring static members. This restriction applies to non-static member classes, local classes, and anonymous classes.

      [JEP 384: Records (Second Preview)](https://openjdk.java.net/jeps/384) added support for local interfaces, enum classes, and record classes, all of which are static definitions. This was a well-received enhancement, permitting coding styles that reduce the scope of certain declarations to local contexts.

      While [JEP 384](https://openjdk.java.net/jeps/384) allowed for static local classes and interfaces, it did not relax the restriction on static member classes and interfaces of inner classes. An inner class could declare a static interface inside one of its method bodies, but not as a class member.

      As a natural next step, [JEP 395](https://openjdk.java.net/jeps/395) further relaxes nesting restrictions, and permits static classes, methods, fields, etc., to be declared within inner classes.
       
      For further details, see [JEP 395](https://openjdk.java.net/jeps/395).

        Attachments

          Activity

            People

            Assignee:
            vromero Vicente Arturo Romero Zaldivar
            Reporter:
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: