Skip to content

Instantly share code, notes, and snippets.

@SirYwell
Last active May 23, 2022 19:31
Show Gist options
  • Save SirYwell/33995f369608634f183419362ef3c828 to your computer and use it in GitHub Desktop.
Save SirYwell/33995f369608634f183419362ef3c828 to your computer and use it in GitHub Desktop.
// The first formal parameter of an anonymous constructor of an anonymous class
// whose superclass is an inner class (not in a static context) (§15.9.5.1).
public class A {
class InnerA {
}
public void m() {
new InnerA() {};
}
}
// The first formal parameter of a constructor of a non-private inner member class (§8.8.1, §8.8.9).
class C {
class InnerC {
InnerC(int a) {
}
}
}
// The formal parameter name of the valueOf method which is implicitly declared in an enum class (§8.9.3).
public enum E {
}

A.java

The attribute is not emitted.

relevant part from javap -v A\$1.class for javac A.java:

{
  A$1(A);
    descriptor: (LA;)V
    flags: (0x0000)
    Code:
      stack=2, locals=2, args_size=2
         0: aload_0
         1: aload_1
         2: invokespecial #1                  // Method A$InnerA."<init>":(LA;)V
         5: return
      LineNumberTable:
        line 9: 0
}

relevant part from javap -v A\$1.class for javac -parameters A.java:

{
  A$1(A);
    descriptor: (LA;)V
    flags: (0x0000)
    Code:
      stack=2, locals=2, args_size=2
         0: aload_0
         1: aload_1
         2: invokespecial #1                  // Method A$InnerA."<init>":(LA;)V
         5: return
      LineNumberTable:
        line 9: 0
    MethodParameters:
      Name                           Flags
      this$0                         final mandated
}

C.java

The attribute is not emitted.

relevant part from javap -v C\$InnerC.class for javac C.java:

{
  C$InnerC(C, int);
    descriptor: (LC;I)V
    flags: (0x0000)
    Code:
      stack=1, locals=3, args_size=3
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 4: 0
        line 5: 4
}

relevant part from javap -v C\$InnerC.class for javac -parameters C.java:

{
  C$InnerC(C, int);
    descriptor: (LC;I)V
    flags: (0x0000)
    Code:
      stack=1, locals=3, args_size=3
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 4: 0
        line 5: 4
    MethodParameters:
      Name                           Flags
      this$0                         final mandated
      a
}

E.java

The attribute is not emitted.

relevant part from javap -v E.class for javac E.java:

  public static E valueOf(java.lang.String);
    descriptor: (Ljava/lang/String;)LE;
    flags: (0x0009) ACC_PUBLIC, ACC_STATIC
    Code:
      stack=2, locals=1, args_size=1
         0: ldc           #1                  // class E
         2: aload_0
         3: invokestatic  #12                 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;
         6: checkcast     #1                  // class E
         9: areturn
      LineNumberTable:
        line 2: 0

relevant part from javap -v E.class for javac -parameters E.java:

  public static E valueOf(java.lang.String);
    descriptor: (Ljava/lang/String;)LE;
    flags: (0x0009) ACC_PUBLIC, ACC_STATIC
    Code:
      stack=2, locals=1, args_size=1
         0: ldc           #1                  // class E
         2: aload_0
         3: invokestatic  #12                 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;
         6: checkcast     #1                  // class E
         9: areturn
      LineNumberTable:
        line 2: 0
    MethodParameters:
      Name                           Flags
      name                           mandated

R.java

The attribute is present but the flags are missing.

relevant part from javap -v R.class for javac R.java:

  public R(int, float);
    descriptor: (IF)V
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=2, locals=3, args_size=3
         0: aload_0
         1: invokespecial #1                  // Method java/lang/Record."<init>":()V
         4: aload_0
         5: iload_1
         6: putfield      #7                  // Field a:I
         9: aload_0
        10: fload_2
        11: putfield      #13                 // Field b:F
        14: return
      LineNumberTable:
        line 3: 0
        line 5: 14
    MethodParameters:
      Name                           Flags
      a
      b
// The formal parameters of a compact constructor of a record class (§8.10.4).
public record R(int a, float b) {
public R {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment