Created
June 19, 2012 00:01
-
-
Save nahi/2951537 to your computer and use it in GitHub Desktop.
This file contains 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
% cat Switch.java | |
public class Switch { | |
public static void main(String[] args) { | |
switch(args[0]) { | |
case "abc": | |
break; | |
default: | |
break; | |
} | |
} | |
} | |
% javac Switch.java | |
% javap -c Switch | |
Compiled from "Switch.java" | |
public class Switch { | |
public Switch(); | |
Code: | |
0: aload_0 | |
1: invokespecial #1 // Method java/lang/Object."<init>":()V | |
4: return | |
public static void main(java.lang.String[]); | |
Code: | |
0: aload_0 | |
1: iconst_0 | |
2: aaload | |
3: astore_1 | |
4: iconst_m1 | |
5: istore_2 | |
6: aload_1 | |
7: invokevirtual #2 // Method java/lang/String.hashCode:()I <<<<<<<< calc args[0].hashCode() | |
10: lookupswitch { // 1 | |
96354: 28 <<<<<<<< 96354 == "abc".hashCode() >>>>>>>> | |
default: 39 | |
} | |
28: aload_1 | |
29: ldc #3 // String abc | |
31: invokevirtual #4 // Method java/lang/String.equals:(Ljava/lang/Object;)Z | |
34: ifeq 39 | |
37: iconst_0 | |
38: istore_2 | |
39: iload_2 | |
40: lookupswitch { // 1 | |
0: 60 | |
default: 63 | |
} | |
60: goto 63 | |
63: return | |
} | |
% ruby -e 'p((?a.ord * 31 + ?b.ord) * 31 + ?c.ord)' | |
96354 | |
% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment