SlideShare une entreprise Scribd logo
1  sur  87
Télécharger pour lire hors ligne
Java Bytecode
Fundamentals
  JUG.LV 2011, Riga
whoami

Anton Arhipov
ZeroTurnaround
JRebel


                 http://arhipov.blogspot.com
                              @antonarhipov
                                   @javarebel
who-are-you?
1+2
+
1+2
      1       2
+
1+2
      1       2
12+
+
1+2
      1       2
12+
+
1+2
           1           2
12+   PUSH 1
                   1
+
1+2
           1           2
12+   PUSH 1
      PUSH 2
                   2
                   1
+
1+2
           1           2
12+   PUSH 1
      PUSH 2
                   3
      ADD
+
1+2
           1             2
12+   ICONST_1
      ICONST_2
                     3
      IADD
?=1+2
Byte Code
 One-byte instructions
 256 possible opcodes
 ~200 in use
Byte Code
 One-byte instructions
 256 possible opcodes
 ~200 in use
The Master Plan

  javap
  Stack Machine
  Objects and Methods
  Flow Control
javap
 Java class file disassembler
 Used with no options shows class
 structure only
   Methods, superclass, interfaces, etc
 -c – shows the bytecode
 -private – shows all classes and members
 -s – prints internal types signatures
 -l – prints lines numbers and local variable
 tables
C:workjugclasses>javap Hello -c
Compiled from "Hello.java"
public class Hello extends java.lang.Object{
public Hello();
  Code:
   0: aload_0
   1: invokespecial #1; //Method java/lang/Object."<init>":()V
   4: return

public static void main(java.lang.String[]);
  Code:
  0: getstatic      #2; //Field java/lang/System.out:Ljava/io/PrintStream;
  3: ldc #3; //String Hello, World!
  5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
C:workjugclasses>javap Hello -verbose
Compiled from "Hello.java“
public class Hello extends java.lang.Object
 SourceFile: "Hello.java"
 minor version: 0
 major version: 50
 Constant pool:
const #1 = Method #6.#20; // java/lang/Object."<init>":()V
const #2 = Field     #21.#22;     // java/lang/System.out:Ljava/io/PrintStream;
const #3 = String    #23; // Hello, World!
const #4 = Method #24.#25;        // java/io/PrintStream.println:(Ljava/lang/String;)V
const #5 = class     #26; // Hello
const #6 = class     #27; // java/lang/Object
const #7 = Asciz     <init>;
const #8 = Asciz     ()V;
C:workjugclasses>javap Hello -verbose
…
public Hello();
 Code:
 Stack=1, Locals=1, Args_size=1
 0: aload_0
 1: invokespecial #1; //Method java/lang/Object."<init>":()V
 4: return
 LineNumberTable:
 line 1: 0

 LocalVariableTable:
 Start Length Slot Name Signature
 0    5    0 this    LHello;
C:workjugclasses>javap Hello -verbose
…
public static void main(java.lang.String[]);
 Code:
 Stack=2, Locals=1, Args_size=1
 0: getstatic      #2; //Field java/lang/System.out:Ljava/io/PrintStream;
 3: ldc #3; //String Hello, World!
 5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
 8: return
 LineNumberTable:
 line 4: 0
 line 5: 8
 LocalVariableTable:
 Start Length Slot Name Signature
 0     9    0 args       [Ljava/lang/String;
Stack Machine
 JVM is a stack-based machine
 Each thread has a stack
 Stack stores frames
 Frame is created on method invocation
 Frame:
   Operand stack
   Array of local variables
Frame
public java.lang.String getName();
 Code:
 Stack=1, Locals=1, Args_size=1
 0: aload_0
 1: getfield      #2; //Field name:Ljava/lang/String;
 4: areturn
LocalVariableTable:
 Start Length Slot Name Signature
 0    5    0 this       LGet;
0              1            2         3         4

     aload_0         getfield         00        02      areturn




public java.lang.String getName();
 Code:
 Stack=1, Locals=1, Args_size=1
 0: aload_0
 1: getfield      #2; //Field name:Ljava/lang/String;
 4: areturn
LocalVariableTable:
 Start Length Slot Name Signature
 0    5    0 this       LGet;
0              1            2         3       4

         2A              B4           00        02      B0




public java.lang.String getName();
 Code:
 Stack=1, Locals=1, Args_size=1
 0: aload_0
 1: getfield      #2; //Field name:Ljava/lang/String;
 4: areturn
LocalVariableTable:
 Start Length Slot Name Signature
 0    5    0 this       LGet;
public java.lang.String getName();
 Code:
 Stack=1, Locals=1, Args_size=1
 0: aload_0
 1: getfield      #2; //Field name:Ljava/lang/String;
 4: areturn
LocalVariableTable:
 Start Length Slot Name Signature
 0    5    0 this       LGet;
public java.lang.String getName();
 Code:
 Stack=1, Locals=1, Args_size=1
 0: aload_0
 1: getfield      #2; //Field name:Ljava/lang/String;
 4: areturn
LocalVariableTable:
 Start Length Slot Name Signature
 0    5    0 this       LGet;
public java.lang.String getName();
 Code:
 Stack=1, Locals=1, Args_size=1
 0: aload_0
 1: getfield      #2; //Field name:Ljava/lang/String;
 4: areturn
LocalVariableTable:
 Start Length Slot Name Signature
 0    5    0 this       LGet;
Stack Operations


   dup             A
   pop             B
   swap
   dup_x1
   dup_x2
Stack Operations


   dup             A
   pop             A
   swap            B
   dup_x1
   dup_x2
Stack Operations


   dup             A
   pop             B
   swap
   dup_x1
   dup_x2
Stack Operations


   dup             B
   pop             A
   swap
   dup_x1
   dup_x2
Stack Operations


   dup             B
   pop             A
   swap            B
   dup_x1
   dup_x2
Stack Operations


   dup             B
   pop             A
   swap            B
   dup_x1          B
   dup_x2          A
Local Variables
Local Variables



public int calculate(int);
 Code:
 Stack=2, Locals=2, Args_size=2
  …

 LocalVariableTable:
 Start Length Slot Name Signature
    0        5    0 this  LLocalVariables;
    0        5    1 value I
Local Variables



public int calculate(int);
 Code:
 Stack=2, Locals=2, Args_size=2
  …

 LocalVariableTable:
 Start Length Slot Name Signature
    0        5    0 this  LLocalVariables;
    0        5    1 value I
Local Variables



public int calculate(int);
 Code:
 Stack=2, Locals=2, Args_size=2
  …

 LocalVariableTable:
 Start Length Slot Name Signature
    0        5    0 this  LLocalVariables;
    0        5    1 value I
Local Variables



                                              The table
public int calculate(int);
 Code:
                                               maps
 Stack=2, Locals=2, Args_size=2              numbers to
  …
                                               names
 LocalVariableTable:
 Start Length Slot Name Signature
    0        5    0 this  LLocalVariables;
    0        5    1 value I
Local Variables



public int calculate(int);
 Code:
 Stack=2, Locals=2, Args_size=2              Sized explicitly
  …

 LocalVariableTable:
 Start Length Slot Name Signature
    0        5    0 this  LLocalVariables;
    0        5    1 value I
Local Variables
    Local Variables                         Stack

var         value                   depth     value

                      ldc "Hello"
0                                    0
                      astore_0
1                     iconst_1       1
                      astore_1
2                     aload_0        2

3                                    3

4                                    4
Local Variables
    Local Variables                         Stack

var         value                   depth     value

                      ldc "Hello"
0                                    0      "Hello"
                      astore_0
1                     iconst_1       1
                      astore_1
2                     aload_0        2

3                                    3

4                                    4
Local Variables
    Local Variables                         Stack

var         value                   depth     value

                      ldc "Hello"
0          "Hello"                   0
                      astore_0
1                     iconst_1       1
                      astore_1
2                     aload_0        2

3                                    3

4                                    4
Local Variables
    Local Variables                         Stack

var         value                   depth     value

                      ldc "Hello"
0          "Hello"                   0              1
                      astore_0
1                     iconst_1       1
                      astore_1
2                     aload_0        2

3                                    3

4                                    4
Local Variables
    Local Variables                         Stack

var         value                   depth     value

                      ldc "Hello"
0          "Hello"                   0
                      astore_0
1               1     iconst_1       1
                      astore_1
2                     aload_0        2

3                                    3

4                                    4
Local Variables
    Local Variables                         Stack

var         value                   depth     value

                      ldc "Hello"
0          "Hello"                   0      "Hello"
                      astore_0
1               1     iconst_1       1
                      astore_1
2                     aload_0        2

3                                    3

4                                    4
Local Variables & Stack


                load
      Local
    Variables             Stack
      Table

                store
Object Initialization

new
            <init>
     Instance initialization method

                             <clinit>
                            Class and interface
                           initialization method
Object Initialization: static {}




                    static {};
                     Code:
                      0: iconst_1
                      1: putstatic   #2; //Field a:I
                      4: iconst_2
                      5: putstatic   #3; //Field b:I
                      8: return
Object Initialization: static {}



                                     <clinit>

                    static {};
                     Code:
                      0: iconst_1
                      1: putstatic    #2; //Field a:I
                      4: iconst_2
                      5: putstatic    #3; //Field b:I
                      8: return
Object Initialization: new




public Initializer();
 Code:
 0: aload_0
 1: invokespecial #1; //Method java/lang/Object."<init>":()V
 4: aload_0
 5: new #2; //class java/lang/Object
 8: dup
 9: invokespecial #1; //Method java/lang/Object."<init>":()V
12: putfield        #3; //Field o:Ljava/lang/Object;
15: return
Object Initialization: new




public Initializer();
 Code:
 0: aload_0
 1: invokespecial #1; //Method java/lang/Object."<init>":()V
 4: aload_0
 5: new #2; //class java/lang/Object
 8: dup
 9: invokespecial #1; //Method java/lang/Object."<init>":()V
12: putfield        #3; //Field o:Ljava/lang/Object;
15: return
Object Initialization: {}
Object Initialization: {}
Object Initialization: {}

                     public Initializer(int);
                      Code:
                      0:     aload_0
                      1:     invokespecial #1; // ..<init>
                      4:     aload_0
                      5:     iconst_1
                      6:     putfield       #2; //Field a:I
                      9:     aload_0
                     10:     iconst_2
                     11:     putfield       #3; //Field c:I
                     14:     aload_0
                     15:     iload_1
                     16:     putfield       #4; //Field b:I
                     19:     return
Method Invocation
 invokestatic
 invokeinterface
 invokevirtual
 invokespecial
 invokedynamic
Parameter Passing
Parameter Passing




                    parameter




                     return
                     value
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1
 3                     7: invokespecial #3;
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1                      1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1        this
 3                     7: invokespecial #3;
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1                      1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                Stack
                       1: invokespecial #2; //createRandomValue()
1
                       4: astore_1                       depth                    value
2                      5: aload_0
                       6: aload_1                          1                    objectref
 3                     7: invokespecial #3;
                      10: areturn                           2


                                                                            3

                   private java.lang.Integer incValue(java.lang.Integer);   4
var      value
                       0: aload_1
1                      1: invokevirtual #8;                                 5

                       4: iconst_1                                          6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1      objectref
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1
 3                     7: invokespecial #3;
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1                      1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1      objectref
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1        this
 3                     7: invokespecial #3;
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1                      1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1      objectref
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1     objectref
 3                     7: invokespecial #3;
                      10: areturn                                             2        this


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1                      1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1      objectref
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1
 3                     7: invokespecial #3; //incValue
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1      objectref       1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1      objectref
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1     objectref
 3                     7: invokespecial #3; //incValue
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1      objectref       1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1      objectref
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1         X
 3                     7: invokespecial #3; //incValue
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1      objectref       1: invokevirtual #8; // Integer.intValue:() 5
                       4: iconst_1                                 6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1      objectref
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1         1
 3                     7: invokespecial #3; //incValue
                      10: areturn                                             2         X


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1      objectref       1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1      objectref
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1       X+1
 3                     7: invokespecial #3; //incValue
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1      objectref       1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1      objectref
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1      objectref
 3                     7: invokespecial #3; //incValue
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1      objectref       1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7; //Integer.valueOf
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1      objectref
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1      objectref
 3                     7: invokespecial #3; //incValue
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1      objectref       1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1      objectref
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1      objectref
 3                     7: invokespecial #3;
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1                      1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1      objectref
 3                     7: invokespecial #3;
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1                      1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Local Variables
                   public java.lang.Object execute();

var      value         0: aload_0
                                                                                    Stack
                       1: invokespecial #2;
1
                       4: astore_1                                          depth     value
2                      5: aload_0
                       6: aload_1                                             1      objectref
 3                     7: invokespecial #3;
                      10: areturn                                             2


                                                                              3

                   private java.lang.Integer incValue(java.lang.Integer);     4
var      value
                       0: aload_1
1                      1: invokevirtual #8;                                   5

                       4: iconst_1                                            6
2
                       5: iadd
 3
                       6: invokestatic #7;
                       9: areturn
Flow Control
Flow Control




               GOTO
Stack

                          depth     value
public int decide(int);
 Code:                       1
 0: iload_1
 1: bipush       10          2
 3: if_icmpge 8
 6: iconst_0                 3

 7: ireturn
 8: bipush 100
10: ireturn
Stack

                          depth     value
public int decide(int);
 Code:
 0: iload_1
                             1       a
 1: bipush       10          2
 3: if_icmpge 8
 6: iconst_0                 3

 7: ireturn
 8: bipush 100
10: ireturn
Stack

                          depth     value
public int decide(int);
 Code:
 0: iload_1
                             1     10
 1: bipush
 3: if_icmpge 8
                 10          2      a
 6: iconst_0                 3

 7: ireturn
 8: bipush 100
10: ireturn
Stack

                          depth     value
public int decide(int);
 Code:
 0: iload_1
                             1     10
 1: bipush
 3: if_icmpge 8
                 10          2      a
 6: iconst_0                 3

 7: ireturn
 8: bipush 100
10: ireturn
Stack

                          depth     value
public int decide(int);
 Code:                       1
 0: iload_1
 1: bipush       10          2
 3: if_icmpge 8
 6: iconst_0                 3

 7: ireturn
 8: bipush 100
10: ireturn
Stack

                          depth     value
public int decide(int);
 Code:
 0: iload_1
                             1    100
 1: bipush       10          2
 3: if_icmpge 8
 6: iconst_0                 3

 7: ireturn
 8: bipush 100
10: ireturn
Stack

                          depth     value
public int decide(int);
 Code:
 0: iload_1
                             1    100
 1: bipush       10          2
 3: if_icmpge 8
 6: iconst_0                 3

 7: ireturn
 8: bipush 100
10: ireturn
Stack

                          depth     value
public int decide(int);
 Code:                       1
 0: iload_1
 1: bipush       10          2
 3: if_icmpge 8
 6: iconst_0                 3

 7: ireturn
 8: bipush 100
10: ireturn
ant.arhipov@gmail.com
http://arhipov.blogspot.com
@antonarhipov
@javarebel

Contenu connexe

Tendances

[수정본] 우아한 객체지향
[수정본] 우아한 객체지향[수정본] 우아한 객체지향
[수정본] 우아한 객체지향Young-Ho Cho
 
Utilizing kotlin flows in an android application
Utilizing kotlin flows in an android applicationUtilizing kotlin flows in an android application
Utilizing kotlin flows in an android applicationSeven Peaks Speaks
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlinintelliyole
 
Jpa 잘 (하는 척) 하기
Jpa 잘 (하는 척) 하기Jpa 잘 (하는 척) 하기
Jpa 잘 (하는 척) 하기경원 이
 
Making Java more dynamic: runtime code generation for the JVM
Making Java more dynamic: runtime code generation for the JVMMaking Java more dynamic: runtime code generation for the JVM
Making Java more dynamic: runtime code generation for the JVMRafael Winterhalter
 
Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin Coroutines in Practice @ KotlinConf 2018Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin Coroutines in Practice @ KotlinConf 2018Roman Elizarov
 
Whitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applicationsWhitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applicationsYura Nosenko
 
Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4ICS
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
[2D1]Elasticsearch 성능 최적화
[2D1]Elasticsearch 성능 최적화[2D1]Elasticsearch 성능 최적화
[2D1]Elasticsearch 성능 최적화NAVER D2
 
[AWSKRUG] Lambda로컬테스트부터 배포까지의 여정-박태성
[AWSKRUG] Lambda로컬테스트부터 배포까지의 여정-박태성[AWSKRUG] Lambda로컬테스트부터 배포까지의 여정-박태성
[AWSKRUG] Lambda로컬테스트부터 배포까지의 여정-박태성Tae-Seong Park
 
Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Sunghyouk Bae
 
GraalVM Native and Spring Boot 3.0
GraalVM Native and Spring Boot 3.0GraalVM Native and Spring Boot 3.0
GraalVM Native and Spring Boot 3.0MoritzHalbritter
 
Jenkins 2.0 Pipeline & Blue Ocean
Jenkins 2.0 Pipeline & Blue OceanJenkins 2.0 Pipeline & Blue Ocean
Jenkins 2.0 Pipeline & Blue OceanAkihiko Horiuchi
 
Une introduction à Javascript et ECMAScript 6
Une introduction à Javascript et ECMAScript 6Une introduction à Javascript et ECMAScript 6
Une introduction à Javascript et ECMAScript 6Jean-Baptiste Vigneron
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseChristian Melchior
 
Java仮想マシンの実装技術
Java仮想マシンの実装技術Java仮想マシンの実装技術
Java仮想マシンの実装技術Kiyokuni Kawachiya
 

Tendances (20)

[수정본] 우아한 객체지향
[수정본] 우아한 객체지향[수정본] 우아한 객체지향
[수정본] 우아한 객체지향
 
Utilizing kotlin flows in an android application
Utilizing kotlin flows in an android applicationUtilizing kotlin flows in an android application
Utilizing kotlin flows in an android application
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
 
Jpa 잘 (하는 척) 하기
Jpa 잘 (하는 척) 하기Jpa 잘 (하는 척) 하기
Jpa 잘 (하는 척) 하기
 
Making Java more dynamic: runtime code generation for the JVM
Making Java more dynamic: runtime code generation for the JVMMaking Java more dynamic: runtime code generation for the JVM
Making Java more dynamic: runtime code generation for the JVM
 
GraalVm and Quarkus
GraalVm and QuarkusGraalVm and Quarkus
GraalVm and Quarkus
 
Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin Coroutines in Practice @ KotlinConf 2018Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin Coroutines in Practice @ KotlinConf 2018
 
Whitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applicationsWhitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applications
 
Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
[2D1]Elasticsearch 성능 최적화
[2D1]Elasticsearch 성능 최적화[2D1]Elasticsearch 성능 최적화
[2D1]Elasticsearch 성능 최적화
 
[AWSKRUG] Lambda로컬테스트부터 배포까지의 여정-박태성
[AWSKRUG] Lambda로컬테스트부터 배포까지의 여정-박태성[AWSKRUG] Lambda로컬테스트부터 배포까지의 여정-박태성
[AWSKRUG] Lambda로컬테스트부터 배포까지의 여정-박태성
 
Maven
MavenMaven
Maven
 
Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017
 
Recursive Query Throwdown
Recursive Query ThrowdownRecursive Query Throwdown
Recursive Query Throwdown
 
GraalVM Native and Spring Boot 3.0
GraalVM Native and Spring Boot 3.0GraalVM Native and Spring Boot 3.0
GraalVM Native and Spring Boot 3.0
 
Jenkins 2.0 Pipeline & Blue Ocean
Jenkins 2.0 Pipeline & Blue OceanJenkins 2.0 Pipeline & Blue Ocean
Jenkins 2.0 Pipeline & Blue Ocean
 
Une introduction à Javascript et ECMAScript 6
Une introduction à Javascript et ECMAScript 6Une introduction à Javascript et ECMAScript 6
Une introduction à Javascript et ECMAScript 6
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in Practise
 
Java仮想マシンの実装技術
Java仮想マシンの実装技術Java仮想マシンの実装技術
Java仮想マシンの実装技術
 

Similaire à LatJUG. Java Bytecode Fundamentals

Java Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvJava Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvAnton Arhipov
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performanceDuoyi Wu
 
The LLDB Debugger in FreeBSD by Ed Maste
The LLDB Debugger in FreeBSD by Ed MasteThe LLDB Debugger in FreeBSD by Ed Maste
The LLDB Debugger in FreeBSD by Ed Masteeurobsdcon
 
Java Bytecode: Passing Parameters
Java Bytecode: Passing ParametersJava Bytecode: Passing Parameters
Java Bytecode: Passing ParametersAnton Arhipov
 
Charles nutter star techconf 2011 - jvm languages
Charles nutter   star techconf 2011 - jvm languagesCharles nutter   star techconf 2011 - jvm languages
Charles nutter star techconf 2011 - jvm languagesStarTech Conference
 
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...Lucidworks
 
Lifting The Veil - Reading Java Bytecode
Lifting The Veil - Reading Java BytecodeLifting The Veil - Reading Java Bytecode
Lifting The Veil - Reading Java BytecodeAlexander Shopov
 
Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Davide Cerbo
 
VkRunner: a Vulkan shader test tool (FOSDEM 2019)
VkRunner: a Vulkan shader test tool (FOSDEM 2019)VkRunner: a Vulkan shader test tool (FOSDEM 2019)
VkRunner: a Vulkan shader test tool (FOSDEM 2019)Igalia
 
Virtual machine and javascript engine
Virtual machine and javascript engineVirtual machine and javascript engine
Virtual machine and javascript engineDuoyi Wu
 
No dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real worldNo dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real worldtcurdt
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Anton Arhipov
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Anton Arhipov
 
NoSQL - how it works (@pavlobaron)
NoSQL - how it works (@pavlobaron)NoSQL - how it works (@pavlobaron)
NoSQL - how it works (@pavlobaron)Pavlo Baron
 
iOS Visual F/X Using GLSL
iOS Visual F/X Using GLSLiOS Visual F/X Using GLSL
iOS Visual F/X Using GLSLDouglass Turner
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaCharles Nutter
 

Similaire à LatJUG. Java Bytecode Fundamentals (20)

Java Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvJava Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lv
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
 
The LLDB Debugger in FreeBSD by Ed Maste
The LLDB Debugger in FreeBSD by Ed MasteThe LLDB Debugger in FreeBSD by Ed Maste
The LLDB Debugger in FreeBSD by Ed Maste
 
Java Bytecode: Passing Parameters
Java Bytecode: Passing ParametersJava Bytecode: Passing Parameters
Java Bytecode: Passing Parameters
 
Assembler
AssemblerAssembler
Assembler
 
Charles nutter star techconf 2011 - jvm languages
Charles nutter   star techconf 2011 - jvm languagesCharles nutter   star techconf 2011 - jvm languages
Charles nutter star techconf 2011 - jvm languages
 
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
 
Yokozuna
YokozunaYokozuna
Yokozuna
 
Lifting The Veil - Reading Java Bytecode
Lifting The Veil - Reading Java BytecodeLifting The Veil - Reading Java Bytecode
Lifting The Veil - Reading Java Bytecode
 
Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)
 
VkRunner: a Vulkan shader test tool (FOSDEM 2019)
VkRunner: a Vulkan shader test tool (FOSDEM 2019)VkRunner: a Vulkan shader test tool (FOSDEM 2019)
VkRunner: a Vulkan shader test tool (FOSDEM 2019)
 
Virtual machine and javascript engine
Virtual machine and javascript engineVirtual machine and javascript engine
Virtual machine and javascript engine
 
No dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real worldNo dark magic - Byte code engineering in the real world
No dark magic - Byte code engineering in the real world
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
 
tutorial5
tutorial5tutorial5
tutorial5
 
tutorial5
tutorial5tutorial5
tutorial5
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011
 
NoSQL - how it works (@pavlobaron)
NoSQL - how it works (@pavlobaron)NoSQL - how it works (@pavlobaron)
NoSQL - how it works (@pavlobaron)
 
iOS Visual F/X Using GLSL
iOS Visual F/X Using GLSLiOS Visual F/X Using GLSL
iOS Visual F/X Using GLSL
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible Java
 

Plus de denis Udod

JUG.LV What do you know about Logging?
JUG.LV What do you know about Logging?JUG.LV What do you know about Logging?
JUG.LV What do you know about Logging?denis Udod
 
Java. Exceptions - how to cook, how to eat.
Java. Exceptions - how to cook, how to eat.Java. Exceptions - how to cook, how to eat.
Java. Exceptions - how to cook, how to eat.denis Udod
 
LatJUG. Complete Idiots Guide2Android
LatJUG. Complete Idiots Guide2AndroidLatJUG. Complete Idiots Guide2Android
LatJUG. Complete Idiots Guide2Androiddenis Udod
 
LatJUG. Spring Roo
LatJUG. Spring RooLatJUG. Spring Roo
LatJUG. Spring Roodenis Udod
 
LatJUG.Jun-2011
LatJUG.Jun-2011LatJUG.Jun-2011
LatJUG.Jun-2011denis Udod
 
LatJUG. Mar-2011
LatJUG. Mar-2011LatJUG. Mar-2011
LatJUG. Mar-2011denis Udod
 
LatJUG. JPA2 Done Right
LatJUG. JPA2 Done RightLatJUG. JPA2 Done Right
LatJUG. JPA2 Done Rightdenis Udod
 
LatJUG. Google App Engine
LatJUG. Google App EngineLatJUG. Google App Engine
LatJUG. Google App Enginedenis Udod
 
LatJUG. JSF2.0 - The JavaEE6 Standard
LatJUG. JSF2.0 - The JavaEE6 StandardLatJUG. JSF2.0 - The JavaEE6 Standard
LatJUG. JSF2.0 - The JavaEE6 Standarddenis Udod
 
LatJUG Feb-2011
LatJUG Feb-2011LatJUG Feb-2011
LatJUG Feb-2011denis Udod
 
Agile latvia evening_unit_testing_in_practice
Agile latvia evening_unit_testing_in_practiceAgile latvia evening_unit_testing_in_practice
Agile latvia evening_unit_testing_in_practicedenis Udod
 

Plus de denis Udod (11)

JUG.LV What do you know about Logging?
JUG.LV What do you know about Logging?JUG.LV What do you know about Logging?
JUG.LV What do you know about Logging?
 
Java. Exceptions - how to cook, how to eat.
Java. Exceptions - how to cook, how to eat.Java. Exceptions - how to cook, how to eat.
Java. Exceptions - how to cook, how to eat.
 
LatJUG. Complete Idiots Guide2Android
LatJUG. Complete Idiots Guide2AndroidLatJUG. Complete Idiots Guide2Android
LatJUG. Complete Idiots Guide2Android
 
LatJUG. Spring Roo
LatJUG. Spring RooLatJUG. Spring Roo
LatJUG. Spring Roo
 
LatJUG.Jun-2011
LatJUG.Jun-2011LatJUG.Jun-2011
LatJUG.Jun-2011
 
LatJUG. Mar-2011
LatJUG. Mar-2011LatJUG. Mar-2011
LatJUG. Mar-2011
 
LatJUG. JPA2 Done Right
LatJUG. JPA2 Done RightLatJUG. JPA2 Done Right
LatJUG. JPA2 Done Right
 
LatJUG. Google App Engine
LatJUG. Google App EngineLatJUG. Google App Engine
LatJUG. Google App Engine
 
LatJUG. JSF2.0 - The JavaEE6 Standard
LatJUG. JSF2.0 - The JavaEE6 StandardLatJUG. JSF2.0 - The JavaEE6 Standard
LatJUG. JSF2.0 - The JavaEE6 Standard
 
LatJUG Feb-2011
LatJUG Feb-2011LatJUG Feb-2011
LatJUG Feb-2011
 
Agile latvia evening_unit_testing_in_practice
Agile latvia evening_unit_testing_in_practiceAgile latvia evening_unit_testing_in_practice
Agile latvia evening_unit_testing_in_practice
 

LatJUG. Java Bytecode Fundamentals

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