Java Bytecode Fundamentals<br />JUG.LV 2011, Riga<br />
whoami<br />Anton Arhipov<br />ZeroTurnaround<br />JRebel<br />http://arhipov.blogspot.com<br />@antonarhipov<br />@javare...
who-are-you?<br />
1 + 2<br />
+<br />1 + 2<br />1<br />2<br />
+<br />1 + 2<br />1<br />2<br />1 2 + <br />
+<br />1 + 2<br />1<br />2<br />1 2 + <br />
+<br />1 + 2<br />1<br />2<br />1 2 + <br />1<br />PUSH 1<br />
+<br />1 + 2<br />1<br />2<br />1 2 + <br />2<br />PUSH 1<br />PUSH 2<br />1<br />
+<br />1 + 2<br />1<br />2<br />1 2 + <br />3<br />PUSH 1<br />PUSH 2<br />ADD<br />
+<br />1 + 2<br />1<br />2<br />1 2 + <br />3<br />ICONST_1<br />ICONST_2<br />IADD<br />
? = 1 + 2<br />
Byte Code<br />One-byte instructions<br />256 possible opcodes<br />~200 in use<br />
Byte Code<br />One-byte instructions<br />256 possible opcodes<br />~200 in use<br />
The Master Plan<br />javap<br />Stack Machine<br />Objects and Methods<br />Flow Control<br />
javap<br />Java class file disassembler<br />Used with no options shows class structure only <br />Methods, superclass, in...
C:workjugclasses>javap Hello -c<br />Compiled from "Hello.java"<br />public class Hello extends java.lang.Object{<br />pub...
C:workjugclasses>javap Hello -verbose<br />Compiled from "Hello.java“<br />public class Hello extends java.lang.Object<br ...
C:workjugclasses>javap Hello -verbose<br />…<br />public Hello();<br />Code:<br />   Stack=1, Locals=1, Args_size=1<br /> ...
C:workjugclasses>javap Hello -verbose<br />…<br />public static void main(java.lang.String[]);<br />  Code:<br />   Stack=...
Stack Machine<br />JVM is a stack-based machine<br />Each thread has a stack<br />Stack stores frames<br />Frame is create...
Frame<br />
public java.lang.String getName();<br />  Code:<br />   Stack=1, Locals=1, Args_size=1<br />   0:   aload_0<br />   1:   g...
      0                1             2          3             4<br />areturn<br />aload_0<br />00<br />02<br />getfield<br...
      0                1             2          3             4<br />B0<br />2A<br />00<br />02<br />B4<br />public java.l...
public java.lang.String getName();<br />  Code:<br />   Stack=1, Locals=1, Args_size=1<br />   0:   aload_0<br />   1:   g...
public java.lang.String getName();<br />  Code:<br />   Stack=1, Locals=1, Args_size=1<br />   0:   aload_0<br />   1:   g...
public java.lang.String getName();<br />  Code:<br />   Stack=1, Locals=1, Args_size=1<br />   0:   aload_0<br />   1:   g...
Stack Operations<br />A<br />dup<br />pop<br />swap<br />dup_x1<br />dup_x2<br />B<br />
Stack Operations<br />A<br />dup<br />pop<br />swap<br />dup_x1<br />dup_x2<br />A<br />B<br />
Stack Operations<br />A<br />dup<br />pop<br />swap<br />dup_x1<br />dup_x2<br />B<br />
Stack Operations<br />B<br />dup<br />pop<br />swap<br />dup_x1<br />dup_x2<br />A<br />
Stack Operations<br />B<br />dup<br />pop<br />swap<br />dup_x1<br />dup_x2<br />A<br />B<br />
Stack Operations<br />B<br />dup<br />pop<br />swap<br />dup_x1<br />dup_x2<br />A<br />B<br />B<br />A<br />
Local Variables<br />
Local Variables<br />public int calculate(int);<br />Code:<br />   Stack=2, Locals=2, Args_size=2<br />    …<br />  LocalV...
Local Variables<br />public int calculate(int);<br />Code:<br />   Stack=2, Locals=2, Args_size=2<br />    …<br />  LocalV...
Local Variables<br />instance methods<br />have this at 0<br />public int calculate(int);<br />Code:<br />   Stack=2, Loca...
Local Variables<br />The table maps numbers to names<br />public int calculate(int);<br />Code:<br />   Stack=2, Locals=2,...
Local Variables<br />Sized explicitly<br />public int calculate(int);<br />Code:<br />   Stack=2, Locals=2, Args_size=2<br...
Local Variables<br />Stack<br />Local Variables<br />value<br />var<br />value<br />depth<br />ldc"Hello"<br />astore_0<br...
Local Variables<br />Stack<br />Local Variables<br />value<br />var<br />value<br />depth<br />ldc"Hello"<br />astore_0<br...
Local Variables<br />Stack<br />Local Variables<br />value<br />var<br />value<br />depth<br />ldc"Hello"<br />astore_0<br...
Local Variables<br />Stack<br />Local Variables<br />value<br />var<br />value<br />depth<br />ldc"Hello"<br />astore_0<br...
Local Variables<br />Stack<br />Local Variables<br />value<br />var<br />value<br />depth<br />ldc"Hello"<br />astore_0<br...
Local Variables<br />Stack<br />Local Variables<br />value<br />var<br />value<br />depth<br />ldc"Hello"<br />astore_0<br...
Local Variables & Stack<br />load<br />Stack<br />Local Variables Table<br />store<br />
Object Initialization<br />new <br /><init><br /><clinit><br />Instance initialization method<br />Class and interface ini...
Object Initialization: static {}<br />static {};<br />  Code:<br />0:   iconst_1<br />   1:   putstatic       #2; //Field ...
Object Initialization: static {}<br /><clinit><br />static {};<br />  Code:<br />0:   iconst_1<br />   1:   putstatic     ...
Object Initialization: new<br />public Initializer();<br />Code:<br />   0:   aload_0<br />   1:   invokespecial   #1; //M...
Object Initialization: new<br />public Initializer();<br />Code:<br />   0:   aload_0<br />   1:   invokespecial   #1; //M...
Object Initialization: {}<br />
Object Initialization: {}<br />?<br />
Object Initialization: {}<br />public Initializer(int);<br />  Code:<br />0:aload_0<br />   1:invokespecial   #1; // ..<in...
Method Invocation<br />invokestatic<br />invokeinterface<br />invokevirtual<br />invokespecial<br />invokedynamic<br />
Parameter Passing<br />
Parameter Passing<br />parameter<br />return<br />value<br />
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Local Variables<br />public java.lang.Object execute();<br />0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 <b...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />1: invokespecial #2; //createRandomValue()...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />4: astore_1 <b...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Local Variables<br />public java.lang.Object execute();<br />  0: aload_0 <br />  1: invokespecial #2;<br />  4: astore_1 ...
Flow Control<br />
Flow Control<br />GOTO<br />
Stack<br />value<br />depth<br />public int decide(int);<br />  Code:<br />   0:   iload_1<br />   1:   bipush     10<br /...
Stack<br />value<br />depth<br />public int decide(int);<br />  Code:<br />   0:   iload_1<br />   1:   bipush     10<br /...
Stack<br />value<br />depth<br />public int decide(int);<br />  Code:<br />   0:   iload_1<br />   1:   bipush     10<br /...
Stack<br />value<br />depth<br />public int decide(int);<br />  Code:<br />   0:   iload_1<br />   1:   bipush     10<br /...
Stack<br />value<br />depth<br />public int decide(int);<br />  Code:<br />   0:   iload_1<br />   1:   bipush     10<br /...
Stack<br />value<br />depth<br />public int decide(int);<br />  Code:<br />   0:   iload_1<br />   1:   bipush     10<br /...
Stack<br />value<br />depth<br />public int decide(int);<br />  Code:<br />   0:   iload_1<br />   1:   bipush     10<br /...
Stack<br />value<br />depth<br />public int decide(int);<br />  Code:<br />   0:   iload_1<br />   1:   bipush     10<br /...
ant.arhipov@gmail.com<br />http://arhipov.blogspot.com<br />@antonarhipov<br />@javarebel<br />
Upcoming SlideShare
Loading in...5
×

Java Bytecode Fundamentals - JUG.lv

3,054

Published on

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,054
On Slideshare
0
From Embeds
0
Number of Embeds
17
Actions
Shares
0
Downloads
124
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Java Bytecode Fundamentals - JUG.lv

  1. 1.
  2. 2. Java Bytecode Fundamentals<br />JUG.LV 2011, Riga<br />
  3. 3. whoami<br />Anton Arhipov<br />ZeroTurnaround<br />JRebel<br />http://arhipov.blogspot.com<br />@antonarhipov<br />@javarebel<br />
  4. 4. who-are-you?<br />
  5. 5. 1 + 2<br />
  6. 6. +<br />1 + 2<br />1<br />2<br />
  7. 7. +<br />1 + 2<br />1<br />2<br />1 2 + <br />
  8. 8. +<br />1 + 2<br />1<br />2<br />1 2 + <br />
  9. 9. +<br />1 + 2<br />1<br />2<br />1 2 + <br />1<br />PUSH 1<br />
  10. 10. +<br />1 + 2<br />1<br />2<br />1 2 + <br />2<br />PUSH 1<br />PUSH 2<br />1<br />
  11. 11. +<br />1 + 2<br />1<br />2<br />1 2 + <br />3<br />PUSH 1<br />PUSH 2<br />ADD<br />
  12. 12. +<br />1 + 2<br />1<br />2<br />1 2 + <br />3<br />ICONST_1<br />ICONST_2<br />IADD<br />
  13. 13. ? = 1 + 2<br />
  14. 14. Byte Code<br />One-byte instructions<br />256 possible opcodes<br />~200 in use<br />
  15. 15. Byte Code<br />One-byte instructions<br />256 possible opcodes<br />~200 in use<br />
  16. 16.
  17. 17. The Master Plan<br />javap<br />Stack Machine<br />Objects and Methods<br />Flow Control<br />
  18. 18. javap<br />Java class file disassembler<br />Used with no options shows class structure only <br />Methods, superclass, interfaces, etc<br />-c – shows the bytecode<br />-private – shows all classes and members<br />-s – prints internal types signatures<br />-l – prints lines numbers and local variable tables<br />
  19. 19. C:workjugclasses>javap Hello -c<br />Compiled from "Hello.java"<br />public class Hello extends java.lang.Object{<br />public Hello();<br />Code:<br />0: aload_0<br />1: invokespecial #1; //Method java/lang/Object."<init>":()V<br />4: return<br />public static void main(java.lang.String[]);<br />Code:<br />0: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;<br />3: ldc #3; //String Hello, World!<br />5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V<br />
  20. 20. C:workjugclasses>javap Hello -verbose<br />Compiled from "Hello.java“<br />public class Hello extends java.lang.Object<br /> SourceFile: "Hello.java"<br /> minor version: 0<br /> major version: 50<br /> Constant pool:<br />const #1 = Method#6.#20; // java/lang/Object."<init>":()V<br />const #2 = Field#21.#22; // java/lang/System.out:Ljava/io/PrintStream;<br />const #3 = String#23; // Hello, World!<br />const #4 = Method#24.#25; // java/io/PrintStream.println:(Ljava/lang/String;)V<br />const #5 = class#26; // Hello<br />const #6 = class#27; // java/lang/Object<br />const #7 = Asciz<init>;<br />const #8 = Asciz()V;<br />
  21. 21. C:workjugclasses>javap Hello -verbose<br />…<br />public Hello();<br />Code:<br /> Stack=1, Locals=1, Args_size=1<br /> 0: aload_0<br /> 1: invokespecial #1; //Method java/lang/Object."<init>":()V<br /> 4: return<br />LineNumberTable:<br /> line 1: 0<br /> LocalVariableTable:<br /> Start Length Slot Name Signature<br /> 0 5 0 this LHello;<br />
  22. 22. C:workjugclasses>javap Hello -verbose<br />…<br />public static void main(java.lang.String[]);<br /> Code:<br /> Stack=2, Locals=1, Args_size=1<br /> 0: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;<br /> 3: ldc #3; //String Hello, World!<br /> 5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V<br /> 8: return<br /> LineNumberTable:<br /> line 4: 0<br /> line 5: 8<br /> LocalVariableTable:<br /> Start Length Slot Name Signature<br /> 0 9 0 args [Ljava/lang/String;<br />
  23. 23. Stack Machine<br />JVM is a stack-based machine<br />Each thread has a stack<br />Stack stores frames<br />Frame is created on method invocation<br />Frame:<br />Operand stack<br />Array of local variables<br />
  24. 24. Frame<br />
  25. 25. public java.lang.String getName();<br /> Code:<br /> Stack=1, Locals=1, Args_size=1<br /> 0: aload_0<br /> 1: getfield #2; //Field name:Ljava/lang/String;<br /> 4: areturn<br />LocalVariableTable:<br /> Start Length Slot Name Signature<br /> 0 5 0 this LGet;<br />
  26. 26. 0 1 2 3 4<br />areturn<br />aload_0<br />00<br />02<br />getfield<br />public java.lang.String getName();<br /> Code:<br /> Stack=1, Locals=1, Args_size=1<br /> 0: aload_0<br /> 1: getfield #2; //Field name:Ljava/lang/String;<br /> 4: areturn<br />LocalVariableTable:<br /> Start Length Slot Name Signature<br /> 0 5 0 this LGet;<br />
  27. 27. 0 1 2 3 4<br />B0<br />2A<br />00<br />02<br />B4<br />public java.lang.String getName();<br /> Code:<br /> Stack=1, Locals=1, Args_size=1<br /> 0: aload_0<br /> 1: getfield #2; //Field name:Ljava/lang/String;<br /> 4: areturn<br />LocalVariableTable:<br /> Start Length Slot Name Signature<br /> 0 5 0 this LGet;<br />
  28. 28. public java.lang.String getName();<br /> Code:<br /> Stack=1, Locals=1, Args_size=1<br /> 0: aload_0<br /> 1: getfield #2; //Field name:Ljava/lang/String;<br /> 4: areturn<br />LocalVariableTable:<br /> Start Length Slot Name Signature<br /> 0 5 0 this LGet;<br />
  29. 29. public java.lang.String getName();<br /> Code:<br /> Stack=1, Locals=1, Args_size=1<br /> 0: aload_0<br /> 1: getfield #2; //Field name:Ljava/lang/String;<br /> 4: areturn<br />LocalVariableTable:<br /> Start Length Slot Name Signature<br /> 0 5 0 this LGet;<br />
  30. 30. public java.lang.String getName();<br /> Code:<br /> Stack=1, Locals=1, Args_size=1<br /> 0: aload_0<br /> 1: getfield #2; //Field name:Ljava/lang/String;<br /> 4: areturn<br />LocalVariableTable:<br /> Start Length Slot Name Signature<br /> 0 5 0 this LGet;<br />
  31. 31. Stack Operations<br />A<br />dup<br />pop<br />swap<br />dup_x1<br />dup_x2<br />B<br />
  32. 32. Stack Operations<br />A<br />dup<br />pop<br />swap<br />dup_x1<br />dup_x2<br />A<br />B<br />
  33. 33. Stack Operations<br />A<br />dup<br />pop<br />swap<br />dup_x1<br />dup_x2<br />B<br />
  34. 34. Stack Operations<br />B<br />dup<br />pop<br />swap<br />dup_x1<br />dup_x2<br />A<br />
  35. 35. Stack Operations<br />B<br />dup<br />pop<br />swap<br />dup_x1<br />dup_x2<br />A<br />B<br />
  36. 36. Stack Operations<br />B<br />dup<br />pop<br />swap<br />dup_x1<br />dup_x2<br />A<br />B<br />B<br />A<br />
  37. 37. Local Variables<br />
  38. 38. Local Variables<br />public int calculate(int);<br />Code:<br /> Stack=2, Locals=2, Args_size=2<br /> …<br /> LocalVariableTable:<br /> Start Length Slot Name Signature<br />0 5 0 this LLocalVariables;<br />0 5 1 value I<br />
  39. 39. Local Variables<br />public int calculate(int);<br />Code:<br /> Stack=2, Locals=2, Args_size=2<br /> …<br /> LocalVariableTable:<br /> Start Length Slot Name Signature<br />0 5 0 this LLocalVariables;<br />0 5 1 value I<br />numbered from 0<br />
  40. 40. Local Variables<br />instance methods<br />have this at 0<br />public int calculate(int);<br />Code:<br /> Stack=2, Locals=2, Args_size=2<br /> …<br /> LocalVariableTable:<br /> Start Length Slot Name Signature<br />0 5 0 this LLocalVariables;<br />0 5 1 value I<br />
  41. 41. Local Variables<br />The table maps numbers to names<br />public int calculate(int);<br />Code:<br /> Stack=2, Locals=2, Args_size=2<br /> …<br /> LocalVariableTable:<br /> Start Length Slot Name Signature<br />0 5 0 this LLocalVariables;<br />0 5 1 value I<br />
  42. 42. Local Variables<br />Sized explicitly<br />public int calculate(int);<br />Code:<br /> Stack=2, Locals=2, Args_size=2<br /> …<br /> LocalVariableTable:<br /> Start Length Slot Name Signature<br />0 5 0 this LLocalVariables;<br />0 5 1 value I<br />
  43. 43. Local Variables<br />Stack<br />Local Variables<br />value<br />var<br />value<br />depth<br />ldc"Hello"<br />astore_0<br />iconst_1<br />astore_1<br />aload_0<br />0<br />0<br />1<br />1<br />2<br />2<br />3<br />3<br />4<br />4<br />
  44. 44. Local Variables<br />Stack<br />Local Variables<br />value<br />var<br />value<br />depth<br />ldc"Hello"<br />astore_0<br />iconst_1<br />astore_1<br />aload_0<br />0<br />0<br />"Hello"<br />1<br />1<br />2<br />2<br />3<br />3<br />4<br />4<br />
  45. 45. Local Variables<br />Stack<br />Local Variables<br />value<br />var<br />value<br />depth<br />ldc"Hello"<br />astore_0<br />iconst_1<br />astore_1<br />aload_0<br />"Hello"<br />0<br />0<br />1<br />1<br />2<br />2<br />3<br />3<br />4<br />4<br />
  46. 46. Local Variables<br />Stack<br />Local Variables<br />value<br />var<br />value<br />depth<br />ldc"Hello"<br />astore_0<br />iconst_1<br />astore_1<br />aload_0<br />"Hello"<br />0<br />0<br />1<br />1<br />1<br />2<br />2<br />3<br />3<br />4<br />4<br />
  47. 47. Local Variables<br />Stack<br />Local Variables<br />value<br />var<br />value<br />depth<br />ldc"Hello"<br />astore_0<br />iconst_1<br />astore_1<br />aload_0<br />"Hello"<br />0<br />0<br />1<br />1<br />1<br />2<br />2<br />3<br />3<br />4<br />4<br />
  48. 48. Local Variables<br />Stack<br />Local Variables<br />value<br />var<br />value<br />depth<br />ldc"Hello"<br />astore_0<br />iconst_1<br />astore_1<br />aload_0<br />"Hello"<br />0<br />0<br />"Hello"<br />1<br />1<br />1<br />2<br />2<br />3<br />3<br />4<br />4<br />
  49. 49. Local Variables & Stack<br />load<br />Stack<br />Local Variables Table<br />store<br />
  50. 50. Object Initialization<br />new <br /><init><br /><clinit><br />Instance initialization method<br />Class and interface initialization method<br />
  51. 51. Object Initialization: static {}<br />static {};<br /> Code:<br />0: iconst_1<br /> 1: putstatic #2; //Field a:I<br /> 4: iconst_2<br /> 5: putstatic #3; //Field b:I<br /> 8: return<br />
  52. 52. Object Initialization: static {}<br /><clinit><br />static {};<br /> Code:<br />0: iconst_1<br /> 1: putstatic #2; //Field a:I<br /> 4: iconst_2<br /> 5: putstatic #3; //Field b:I<br /> 8: return<br />
  53. 53. Object Initialization: new<br />public Initializer();<br />Code:<br /> 0: aload_0<br /> 1: invokespecial #1; //Method java/lang/Object."<init>":()V<br /> 4: aload_0<br /> 5: new#2; //class java/lang/Object<br /> 8: dup<br /> 9: invokespecial #1; //Method java/lang/Object."<init>":()V<br />12: putfield #3; //Field o:Ljava/lang/Object;<br />15: return<br />
  54. 54. Object Initialization: new<br />public Initializer();<br />Code:<br /> 0: aload_0<br /> 1: invokespecial #1; //Method java/lang/Object."<init>":()V<br /> 4: aload_0<br /> 5: new#2; //class java/lang/Object<br /> 8: dup<br /> 9: invokespecial #1; //Method java/lang/Object."<init>":()V<br />12: putfield #3; //Field o:Ljava/lang/Object;<br />15: return<br />
  55. 55. Object Initialization: {}<br />
  56. 56. Object Initialization: {}<br />?<br />
  57. 57. Object Initialization: {}<br />public Initializer(int);<br /> Code:<br />0:aload_0<br /> 1:invokespecial #1; // ..<init><br />4:aload_0<br /> 5:iconst_1<br /> 6:putfield #2; //Field a:I<br /> 9:aload_0<br />10:iconst_2<br /> 11:putfield #3; //Field c:I<br /> 14:aload_0<br />15:iload_1<br />16:putfield #4; //Field b:I<br />19:return<br />
  58. 58. Method Invocation<br />invokestatic<br />invokeinterface<br />invokevirtual<br />invokespecial<br />invokedynamic<br />
  59. 59. Parameter Passing<br />
  60. 60. Parameter Passing<br />parameter<br />return<br />value<br />
  61. 61. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br /> 7: invokespecial #3;<br />10: areturn<br />var<br />value<br />Stack<br />1<br />value<br />depth<br />2<br />1<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7; <br />9: areturn<br />5<br />1<br />6<br />2<br />3<br />
  62. 62. Local Variables<br />public java.lang.Object execute();<br />0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br /> 7: invokespecial #3; <br />10: areturn<br />var<br />value<br />Stack<br />1<br />value<br />depth<br />2<br />1<br />this<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7; <br />9: areturn<br />5<br />1<br />6<br />2<br />3<br />
  63. 63. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br />1: invokespecial #2; //createRandomValue()<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br /> 7: invokespecial #3; <br />10: areturn<br />var<br />value<br />Stack<br />1<br />value<br />depth<br />2<br />1<br />objectref<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7; <br />9: areturn<br />5<br />1<br />6<br />2<br />3<br />
  64. 64. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br />4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br /> 7: invokespecial #3; <br />10: areturn<br />var<br />value<br />Stack<br />objectref<br />1<br />value<br />depth<br />2<br />1<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7; <br />9: areturn<br />5<br />1<br />6<br />2<br />3<br />
  65. 65. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br />5: aload_0 <br /> 6: aload_1 <br /> 7: invokespecial #3; <br />10: areturn<br />var<br />value<br />Stack<br />objectref<br />1<br />value<br />depth<br />2<br />1<br />this<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7; <br />9: areturn<br />5<br />1<br />6<br />2<br />3<br />
  66. 66. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br />6: aload_1 <br /> 7: invokespecial #3; <br />10: areturn<br />var<br />value<br />Stack<br />objectref<br />1<br />value<br />depth<br />2<br />1<br />objectref<br />3<br />2<br />this<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7; <br />9: areturn<br />5<br />1<br />6<br />2<br />3<br />
  67. 67. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br />7: invokespecial #3;//incValue<br />10: areturn<br />var<br />value<br />Stack<br />objectref<br />1<br />value<br />depth<br />2<br />1<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7; <br />9: areturn<br />5<br />objectref<br />1<br />6<br />2<br />3<br />
  68. 68. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br />7: invokespecial #3; //incValue<br />10: areturn<br />var<br />value<br />Stack<br />objectref<br />1<br />value<br />depth<br />2<br />1<br />objectref<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8;<br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7; <br />9: areturn<br />5<br />objectref<br />1<br />6<br />2<br />3<br />
  69. 69. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br />7: invokespecial #3; //incValue<br />10: areturn<br />var<br />value<br />Stack<br />objectref<br />1<br />value<br />depth<br />2<br />1<br />X<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8;// Integer.intValue:()<br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7; <br />9: areturn<br />5<br />objectref<br />1<br />6<br />2<br />3<br />
  70. 70. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br />7: invokespecial #3; //incValue<br />10: areturn<br />var<br />value<br />Stack<br />objectref<br />1<br />value<br />depth<br />2<br />1<br />1<br />3<br />2<br />X<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7; <br />9: areturn<br />5<br />objectref<br />1<br />6<br />2<br />3<br />
  71. 71. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br />7: invokespecial #3; //incValue<br />10: areturn<br />var<br />value<br />Stack<br />objectref<br />1<br />value<br />depth<br />2<br />1<br />X + 1<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd<br />6: invokestatic #7; <br />9: areturn<br />5<br />objectref<br />1<br />6<br />2<br />3<br />
  72. 72. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br />7: invokespecial #3; //incValue<br />10: areturn<br />var<br />value<br />Stack<br />objectref<br />1<br />value<br />depth<br />2<br />1<br />objectref<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7;//Integer.valueOf<br />9: areturn<br />5<br />objectref<br />1<br />6<br />2<br />3<br />
  73. 73. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br />7: invokespecial #3; //incValue<br />10: areturn<br />var<br />value<br />Stack<br />objectref<br />1<br />value<br />depth<br />2<br />1<br />objectref<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7;<br />9: areturn<br />5<br />objectref<br />1<br />6<br />2<br />3<br />
  74. 74. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br /> 7: invokespecial #3; <br />10: areturn<br />var<br />value<br />Stack<br />objectref<br />1<br />value<br />depth<br />2<br />1<br />objectref<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7;<br />9: areturn<br />5<br />1<br />6<br />2<br />3<br />
  75. 75. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br /> 7: invokespecial #3; <br />10: areturn<br />var<br />value<br />Stack<br />1<br />value<br />depth<br />2<br />1<br />objectref<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7;<br />9: areturn<br />5<br />1<br />6<br />2<br />3<br />
  76. 76. Local Variables<br />public java.lang.Object execute();<br /> 0: aload_0 <br /> 1: invokespecial #2;<br /> 4: astore_1 <br /> 5: aload_0 <br /> 6: aload_1 <br /> 7: invokespecial #3; <br />10: areturn<br />var<br />value<br />Stack<br />1<br />value<br />depth<br />2<br />1<br />objectref<br />3<br />2<br />3<br />private java.lang.Integer incValue(java.lang.Integer);<br />4<br />var<br />value<br />0: aload_1 <br />1: invokevirtual #8; <br />4: iconst_1 <br />5: iadd <br />6: invokestatic #7;<br />9: areturn<br />5<br />1<br />6<br />2<br />3<br />
  77. 77. Flow Control<br />
  78. 78. Flow Control<br />GOTO<br />
  79. 79. Stack<br />value<br />depth<br />public int decide(int);<br /> Code:<br /> 0: iload_1<br /> 1: bipush 10<br /> 3: if_icmpge 8<br /> 6: iconst_0<br /> 7: ireturn<br /> 8: bipush 100<br />10: ireturn<br />1<br />2<br />3<br />
  80. 80. Stack<br />value<br />depth<br />public int decide(int);<br /> Code:<br /> 0: iload_1<br /> 1: bipush 10<br /> 3: if_icmpge 8<br /> 6: iconst_0<br /> 7: ireturn<br /> 8: bipush 100<br />10: ireturn<br />a<br />1<br />2<br />3<br />
  81. 81. Stack<br />value<br />depth<br />public int decide(int);<br /> Code:<br /> 0: iload_1<br /> 1: bipush 10<br /> 3: if_icmpge 8<br /> 6: iconst_0<br /> 7: ireturn<br /> 8: bipush 100<br />10: ireturn<br />10<br />1<br />a<br />2<br />3<br />
  82. 82. Stack<br />value<br />depth<br />public int decide(int);<br /> Code:<br /> 0: iload_1<br /> 1: bipush 10<br /> 3: if_icmpge 8<br /> 6: iconst_0<br /> 7: ireturn<br /> 8: bipush 100<br />10: ireturn<br />10<br />1<br />a<br />2<br />3<br />
  83. 83. Stack<br />value<br />depth<br />public int decide(int);<br /> Code:<br /> 0: iload_1<br /> 1: bipush 10<br /> 3: if_icmpge 8<br /> 6: iconst_0<br /> 7: ireturn<br /> 8: bipush 100<br />10: ireturn<br />1<br />2<br />3<br />
  84. 84. Stack<br />value<br />depth<br />public int decide(int);<br /> Code:<br /> 0: iload_1<br /> 1: bipush 10<br /> 3: if_icmpge 8<br /> 6: iconst_0<br /> 7: ireturn<br /> 8: bipush 100<br />10: ireturn<br />100<br />1<br />2<br />3<br />
  85. 85. Stack<br />value<br />depth<br />public int decide(int);<br /> Code:<br /> 0: iload_1<br /> 1: bipush 10<br /> 3: if_icmpge 8<br /> 6: iconst_0<br /> 7: ireturn<br /> 8: bipush 100<br />10: ireturn<br />100<br />1<br />2<br />3<br />
  86. 86. Stack<br />value<br />depth<br />public int decide(int);<br /> Code:<br /> 0: iload_1<br /> 1: bipush 10<br /> 3: if_icmpge 8<br /> 6: iconst_0<br /> 7: ireturn<br /> 8: bipush 100<br />10: ireturn<br />1<br />2<br />3<br />
  87. 87. ant.arhipov@gmail.com<br />http://arhipov.blogspot.com<br />@antonarhipov<br />@javarebel<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×