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

javap output for <vnew> is inconsistent

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4
    • repo-valhalla
    • repo-valhalla
    • tools

    Description

      Source:

      public value class Val {
          int x;
          public Val(int x) { this.x = x; }
      }

      javap output:

      Compiled from "Val.java"
      public final value class Val {
        final int x;
        public static Val Val(int);
      }

      Or, with -verbose:

        public static Val Val(int);
          descriptor: (I)LVal;
          flags: (0x0009) ACC_PUBLIC, ACC_STATIC
          Code:
            stack=2, locals=2, args_size=1
               0: aconst_init #1 // class Val
               3: astore_1
               4: iload_0
               5: aload_1
               6: swap
               7: withfield #3 // Field x:I
              10: astore_1
              11: aload_1
              12: areturn
            LineNumberTable:
              line 3: 0

      I don't love the precedent that javap turns "<init>" into a source-like constructor declaration, but as long as we're doing so, we should do the same with "<vnew>", and make the signature look like the source:

      Compiled from "Val.java"
      public final value class Val {
        final int x;
        public Val(int);
      }

      (No 'static', since source-level constructors can't be 'static', and no return type.)

      Attachments

        Activity

          People

            Unassigned Unassigned
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: