Last active
August 29, 2015 14:00
Compiling static finals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
☕ javap -c Gate\$StaticFinal2Gate.class | |
Compiled from "Gate.java" | |
public class Gate$StaticFinal2Gate { | |
public Gate$StaticFinal2Gate(); | |
Code: | |
0: aload_0 | |
1: invokespecial #1 // Method java/lang/Object."<init>":()V | |
4: aload_0 | |
5: iconst_0 | |
6: putfield #2 // Field flag:Z | |
9: return | |
public void runit(); | |
Code: | |
0: return | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
☕ javap -c Gate\$StaticFinalGate.class | |
Compiled from "Gate.java" | |
public class Gate$StaticFinalGate { | |
public Gate$StaticFinalGate(boolean); | |
Code: | |
0: aload_0 | |
1: invokespecial #1 // Method java/lang/Object."<init>":()V | |
4: aload_0 | |
5: iload_1 | |
6: putfield #2 // Field flag:Z | |
9: return | |
public void runit(); | |
Code: | |
0: aload_0 | |
1: getfield #2 // Field flag:Z | |
4: ifeq 15 | |
7: getstatic #3 // Field java/lang/System.out:Ljava/io/PrintStream; | |
10: ldc #4 // String OK | |
12: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/String;)V | |
15: return | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
☕ javap -c Gate\$StaticGate.class | |
Compiled from "Gate.java" | |
public class Gate$StaticGate { | |
public Gate$StaticGate(boolean); | |
Code: | |
0: aload_0 | |
1: invokespecial #1 // Method java/lang/Object."<init>":()V | |
4: aload_0 | |
5: iload_1 | |
6: putfield #2 // Field flag:Z | |
9: return | |
public void runit(); | |
Code: | |
0: aload_0 | |
1: getfield #2 // Field flag:Z | |
4: ifeq 15 | |
7: getstatic #3 // Field java/lang/System.out:Ljava/io/PrintStream; | |
10: ldc #4 // String OK | |
12: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/String;)V | |
15: return | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Gate { | |
public static class StaticGate { | |
private boolean flag; | |
public StaticGate(boolean flag) { | |
this.flag = flag; | |
} | |
public void runit() { | |
if (flag) { | |
System.out.println("OK"); | |
} | |
} | |
} | |
public static class StaticFinalGate { | |
private final boolean flag; | |
public StaticFinalGate(boolean flag) { | |
this.flag = flag; | |
} | |
public void runit() { | |
if (flag) { | |
System.out.println("OK"); | |
} | |
} | |
} | |
public static class StaticFinal2Gate { | |
private final boolean flag = false; | |
public void runit() { | |
if (flag) { | |
System.out.println("OK"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment