package bar;
import foo.A;
import foo.B;
public class C {
public static void main(String[] arguments) {
B[] array = new B[3];
// B f = A.f;
System.out.println(array);
}
}
The Java code above is compiled into the byte code below:
suztomo-macbookpro44% javap -private -verbose -cp b-public.jar bar.C
Classfile jar:file:/Users/suztomo/wsgenoptions/b-public.jar!/bar/C.class
Last modified Sep 16, 2020; size 550 bytes
MD5 checksum b2c5d4dcb7dc29db85cdca1de5856f4f
Compiled from "C.java"
public class bar.C
minor version: 0
major version: 52
flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
#1 = Methodref #6.#22 // java/lang/Object."<init>":()V
#2 = Class #23 // foo/B
#3 = Fieldref #24.#25 // java/lang/System.out:Ljava/io/PrintStream;
#4 = Methodref #26.#27 // java/io/PrintStream.println:(Ljava/lang/Object;)V
#5 = Class #28 // bar/C
#6 = Class #29 // java/lang/Object
#7 = Utf8 <init>
#8 = Utf8 ()V
#9 = Utf8 Code
#10 = Utf8 LineNumberTable
#11 = Utf8 LocalVariableTable
#12 = Utf8 this
#13 = Utf8 Lbar/C;
#14 = Utf8 main
#15 = Utf8 ([Ljava/lang/String;)V
#16 = Utf8 arguments
#17 = Utf8 [Ljava/lang/String;
#18 = Utf8 array
#19 = Utf8 [Lfoo/B;
#20 = Utf8 SourceFile
#21 = Utf8 C.java
#22 = NameAndType #7:#8 // "<init>":()V
#23 = Utf8 foo/B
#24 = Class #30 // java/lang/System
#25 = NameAndType #31:#32 // out:Ljava/io/PrintStream;
#26 = Class #33 // java/io/PrintStream
#27 = NameAndType #34:#35 // println:(Ljava/lang/Object;)V
#28 = Utf8 bar/C
#29 = Utf8 java/lang/Object
#30 = Utf8 java/lang/System
#31 = Utf8 out
#32 = Utf8 Ljava/io/PrintStream;
#33 = Utf8 java/io/PrintStream
#34 = Utf8 println
#35 = Utf8 (Ljava/lang/Object;)V
{
public bar.C();
descriptor: ()V
flags: ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 26: 0
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this Lbar/C;
public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=2, args_size=1
0: iconst_3
1: anewarray #2 // class foo/B
4: astore_1
5: getstatic #3 // Field java/lang/System.out:Ljava/io/PrintStream;
8: aload_1
9: invokevirtual #4 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
12: return
LineNumberTable:
line 28: 0
line 30: 5
line 31: 12
LocalVariableTable:
Start Length Slot Name Signature
0 13 0 arguments [Ljava/lang/String;
5 8 1 array [Lfoo/B;
}