class C { static int a = 1; static int b = 2; static { System.out.println(a); } static { a++; b = 7; System.out.println(a); System.out.println(b); } static { System.out.println(b); } public static void main(String args[]) { C c = new C(); } }
When the resulting class C is passed to javap using no options, output like the following results:
Compiled from C:\users\lindholm\C.java private class C extends java/lang/Object { static int a; static int b; public static void main(java/lang/String []); public C(); static void(); }
Compiled from C:\users\lindholm/C.java private class C extends java/lang/Object { static int a; static int b; public static void main(java/lang/String []); public C(); static void(); Method void main(java/lang/String []) 0 new #4 3 invokenonvirtual #9 ()V> 6 return Method C() 0 aload_0 0 1 invokenonvirtual #10 ()V> 4 return Method void () 0 iconst_1 1 putstatic #7 4 getstatic #6 7 getstatic #7 10 invokevirtual #8 13 getstatic #7 16 iconst_1 17 iadd 18 putstatic #7 21 bipush 7 23 putstatic #5 26 getstatic #6 29 getstatic #7 32 invokevirtual #8 35 getstatic #6 38 getstatic #5 41 invokevirtual #8 44 iconst_2 45 putstatic #5 48 getstatic #6 51 getstatic #5 54 invokevirtual #8 57 return }
.;<your_path>
For example:
.;C:\users\lindholm\classes;D:\java\classes
.;C:\users\lindholm\classes;D:\java\classes