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

[lworld] VerifyError invoking a compact constructor in record

XMLWordPrintable

      Code:
      public static void main(String argv[]) {

          R e = new R("one"); //this is the problematic call

      }

      record R(String p, String q) implements Serializable {

          public R(String p, String q) {
              this.p = p;
              this.q = q;
          }

          public R(String p) {
              this(p, "null");
          }
      }

      Error:
        Location:
          Main$R.<init>(Ljava/lang/String;Ljava/lang/String;)V @0: aload_0
        Reason:
          Invalid use of strict instance fields
        Current Frame:
          bci: @0
          flags: { flagThisUninit }
          locals: { uninitializedThis, 'java/lang/String', 'java/lang/String' }
          stack: { }
        Bytecode:
          0000000: 2a2b b500 012a 2c12 07b6 0009 9900 0812
          0000010: 0fa7 0005 1207 b500 112a b700 14b1
        Stackmap Table:

              at Main.main(Main.java:11)

            Unassigned Unassigned
            eananeva Ella Ananeva
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: