XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Not an Issue
    • Icon: P4 P4
    • repo-valhalla
    • repo-valhalla
    • tools
    • None
    • generic
    • generic

      According to JLS 8.10 Record Declarations. The direct superclass type of a record class is java.lang.Record.

      However, for primitive classes the value class inherits from the reference class, not java.lang.Record.

      Example;


      public class RecordTest {
          inline static record R(int x) {}

          public static void main(String... args) {
              R r = new R(10);
              System.out.println(r.x);
          }
      }

      >> javap 'RecordTest$R'
      Compiled from "RecordTest.java"
      final value class RecordTest$R extends RecordTest$R$ref {
        public final java.lang.String toString();
        public final int hashCode();
        public final boolean equals(java.lang.Object);
        public int x();
        static RecordTest$R RecordTest$R(int);
      }

      >> javap 'RecordTest$R.ref'
      Compiled from "RecordTest.java"
      abstract class RecordTest$R$ref extends java.lang.Record {
      }

            sadayapalam Srikanth Adayapalam (Inactive)
            jlaskey Jim Laskey
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: