SlideShare uma empresa Scribd logo
1 de 87
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 1 2 +
+ 1 + 2 1 2 1 2 +
+ 1 + 2 1 2 1 2 +  1 PUSH 1
+ 1 + 2 1 2 1 2 +  2 PUSH 1 PUSH 2 1
+ 1 + 2 1 2 1 2 +  3 PUSH 1 PUSH 2 ADD
+ 1 + 2 1 2 1 2 +  3 ICONST_1 ICONST_2 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:orkuglasses>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:orkuglasses>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:orkuglasses>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:orkuglasses>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 areturn aload_0 00 02 getfield 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 B0 2A 00 02 B4 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 A dup pop swap dup_x1 dup_x2 B
Stack Operations A dup pop swap dup_x1 dup_x2 A B
Stack Operations A dup pop swap dup_x1 dup_x2 B
Stack Operations B dup pop swap dup_x1 dup_x2 A
Stack Operations B dup pop swap dup_x1 dup_x2 A B
Stack Operations B dup pop swap dup_x1 dup_x2 A B B 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 numbered from 0
Local Variables instance methods have this at 0 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 maps numbers to names 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 Sized explicitly 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 Stack Local Variables value var value depth ldc"Hello" astore_0 iconst_1 astore_1 aload_0 0 0 1 1 2 2 3 3 4 4
Local Variables Stack Local Variables value var value depth ldc"Hello" astore_0 iconst_1 astore_1 aload_0 0 0 "Hello" 1 1 2 2 3 3 4 4
Local Variables Stack Local Variables value var value depth ldc"Hello" astore_0 iconst_1 astore_1 aload_0 "Hello" 0 0 1 1 2 2 3 3 4 4
Local Variables Stack Local Variables value var value depth ldc"Hello" astore_0 iconst_1 astore_1 aload_0 "Hello" 0 0 1 1 1 2 2 3 3 4 4
Local Variables Stack Local Variables value var value depth ldc"Hello" astore_0 iconst_1 astore_1 aload_0 "Hello" 0 0 1 1 1 2 2 3 3 4 4
Local Variables Stack Local Variables value var value depth ldc"Hello" astore_0 iconst_1 astore_1 aload_0 "Hello" 0 0 "Hello" 1 1 1 2 2 3 3 4 4
Local Variables & Stack load Stack Local Variables Table store
Object Initialization new  <init> <clinit> Instance initialization method 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();   0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0    6: aload_1    7: invokespecial #3; 10: areturn var value Stack 1 value depth 2 1 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7;  9: areturn 5 1 6 2 3
Local Variables public java.lang.Object execute(); 0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0    6: aload_1    7: invokespecial #3;  10: areturn var value Stack 1 value depth 2 1 this 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7;  9: areturn 5 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0  1: invokespecial #2; //createRandomValue()   4: astore_1    5: aload_0    6: aload_1    7: invokespecial #3;  10: areturn var value Stack 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7;  9: areturn 5 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2; 4: astore_1    5: aload_0    6: aload_1    7: invokespecial #3;  10: areturn var value Stack objectref 1 value depth 2 1 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7;  9: areturn 5 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2;   4: astore_1  5: aload_0    6: aload_1    7: invokespecial #3;  10: areturn var value Stack objectref 1 value depth 2 1 this 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7;  9: areturn 5 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0  6: aload_1    7: invokespecial #3;  10: areturn var value Stack objectref 1 value depth 2 1 objectref 3 2 this 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7;  9: areturn 5 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0    6: aload_1  7: invokespecial #3;//incValue 10: areturn var value Stack objectref 1 value depth 2 1 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7;  9: areturn 5 objectref 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0    6: aload_1  7: invokespecial #3; //incValue 10: areturn var value Stack objectref 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8; 4: iconst_1  5: iadd  6: invokestatic #7;  9: areturn 5 objectref 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0    6: aload_1  7: invokespecial #3; //incValue 10: areturn var value Stack objectref 1 value depth 2 1 X 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;// Integer.intValue:() 4: iconst_1  5: iadd  6: invokestatic #7;  9: areturn 5 objectref 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0    6: aload_1  7: invokespecial #3; //incValue 10: areturn var value Stack objectref 1 value depth 2 1 1 3 2 X 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7;  9: areturn 5 objectref 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0    6: aload_1  7: invokespecial #3; //incValue 10: areturn var value Stack objectref 1 value depth 2 1 X + 1 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd 6: invokestatic #7;  9: areturn 5 objectref 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0    6: aload_1  7: invokespecial #3; //incValue 10: areturn var value Stack objectref 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7;//Integer.valueOf 9: areturn 5 objectref 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0    6: aload_1  7: invokespecial #3; //incValue 10: areturn var value Stack objectref 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7; 9: areturn 5 objectref 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0    6: aload_1    7: invokespecial #3;  10: areturn var value Stack objectref 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7; 9: areturn 5 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0    6: aload_1    7: invokespecial #3;  10: areturn var value Stack 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7; 9: areturn 5 1 6 2 3
Local Variables public java.lang.Object execute();   0: aload_0    1: invokespecial #2;   4: astore_1    5: aload_0    6: aload_1    7: invokespecial #3;  10: areturn var value Stack 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1  1: invokevirtual #8;  4: iconst_1  5: iadd  6: invokestatic #7; 9: areturn 5 1 6 2 3
Flow Control
Flow Control GOTO
Stack value depth public int decide(int);   Code:    0:   iload_1    1:   bipush     10    3:   if_icmpge    8    6:   iconst_0    7:   ireturn    8:   bipush   100 10:   ireturn 1 2 3
Stack value depth public int decide(int);   Code:    0:   iload_1    1:   bipush     10    3:   if_icmpge    8    6:   iconst_0    7:   ireturn    8:   bipush   100 10:   ireturn a 1 2 3
Stack value depth public int decide(int);   Code:    0:   iload_1    1:   bipush     10    3:   if_icmpge    8    6:   iconst_0    7:   ireturn    8:   bipush   100 10:   ireturn 10 1 a 2 3
Stack value depth public int decide(int);   Code:    0:   iload_1    1:   bipush     10    3:   if_icmpge    8    6:   iconst_0    7:   ireturn    8:   bipush   100 10:   ireturn 10 1 a 2 3
Stack value depth public int decide(int);   Code:    0:   iload_1    1:   bipush     10    3:   if_icmpge    8    6:   iconst_0    7:   ireturn    8:   bipush   100 10:   ireturn 1 2 3
Stack value depth public int decide(int);   Code:    0:   iload_1    1:   bipush     10    3:   if_icmpge    8    6:   iconst_0    7:   ireturn    8:   bipush   100 10:   ireturn 100 1 2 3
Stack value depth public int decide(int);   Code:    0:   iload_1    1:   bipush     10    3:   if_icmpge    8    6:   iconst_0    7:   ireturn    8:   bipush   100 10:   ireturn 100 1 2 3
Stack value depth public int decide(int);   Code:    0:   iload_1    1:   bipush     10    3:   if_icmpge    8    6:   iconst_0    7:   ireturn    8:   bipush   100 10:   ireturn 1 2 3
ant.arhipov@gmail.com http://arhipov.blogspot.com @antonarhipov @javarebel

Mais conteúdo relacionado

Mais procurados

Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012
Anton Arhipov
 
C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)
Olve Maudal
 

Mais procurados (20)

Specialized Compiler for Hash Cracking
Specialized Compiler for Hash CrackingSpecialized Compiler for Hash Cracking
Specialized Compiler for Hash Cracking
 
掀起 Swift 的面紗
掀起 Swift 的面紗掀起 Swift 的面紗
掀起 Swift 的面紗
 
Runtime Symbol Resolution
Runtime Symbol ResolutionRuntime Symbol Resolution
Runtime Symbol Resolution
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012
 
Listen afup 2010
Listen afup 2010Listen afup 2010
Listen afup 2010
 
C
CC
C
 
Writing Parsers and Compilers with PLY
Writing Parsers and Compilers with PLYWriting Parsers and Compilers with PLY
Writing Parsers and Compilers with PLY
 
Idiomatic C++
Idiomatic C++Idiomatic C++
Idiomatic C++
 
Understanding Java byte code and the class file format
Understanding Java byte code and the class file formatUnderstanding Java byte code and the class file format
Understanding Java byte code and the class file format
 
Free your lambdas
Free your lambdasFree your lambdas
Free your lambdas
 
C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)
 
C tutorial
C tutorialC tutorial
C tutorial
 
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
An Embedded Error Recovery and Debugging Mechanism for Scripting Language Ext...
 
Lambda and Stream Master class - part 1
Lambda and Stream Master class - part 1Lambda and Stream Master class - part 1
Lambda and Stream Master class - part 1
 
Secure Programming Practices in C++ (NDC Security 2018)
Secure Programming Practices in C++ (NDC Security 2018)Secure Programming Practices in C++ (NDC Security 2018)
Secure Programming Practices in C++ (NDC Security 2018)
 
STL ALGORITHMS
STL ALGORITHMSSTL ALGORITHMS
STL ALGORITHMS
 
IOS debugging
IOS debuggingIOS debugging
IOS debugging
 
Kotlin as a Better Java
Kotlin as a Better JavaKotlin as a Better Java
Kotlin as a Better Java
 
The Sincerest Form of Flattery
The Sincerest Form of FlatteryThe Sincerest Form of Flattery
The Sincerest Form of Flattery
 

Destaque

Business Services Cluster Slideshow
Business Services Cluster SlideshowBusiness Services Cluster Slideshow
Business Services Cluster Slideshow
sherisseliburd
 
Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Improve your Developer Experiece using the WAS Liberty Profile with JRebel Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Anton Arhipov
 
JPoint 2015 - Javassist на службе Java-разработчика
JPoint 2015 - Javassist на службе Java-разработчикаJPoint 2015 - Javassist на службе Java-разработчика
JPoint 2015 - Javassist на службе Java-разработчика
Anton Arhipov
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
Anton Arhipov
 

Destaque (17)

Business Services Cluster Slideshow
Business Services Cluster SlideshowBusiness Services Cluster Slideshow
Business Services Cluster Slideshow
 
Con-FESS 2015 - Is your profiler speaking to you?
Con-FESS 2015 - Is your profiler speaking to you?Con-FESS 2015 - Is your profiler speaking to you?
Con-FESS 2015 - Is your profiler speaking to you?
 
Det sociale internet
Det sociale internetDet sociale internet
Det sociale internet
 
Oredev 2015 - Taming Java Agents
Oredev 2015 - Taming Java AgentsOredev 2015 - Taming Java Agents
Oredev 2015 - Taming Java Agents
 
Counting people
Counting peopleCounting people
Counting people
 
Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Improve your Developer Experiece using the WAS Liberty Profile with JRebel Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Improve your Developer Experiece using the WAS Liberty Profile with JRebel
 
JPoint 2016 - Bytecode
JPoint 2016 - BytecodeJPoint 2016 - Bytecode
JPoint 2016 - Bytecode
 
Pain and distress during CO2 euthanasia
Pain and distress during CO2 euthanasiaPain and distress during CO2 euthanasia
Pain and distress during CO2 euthanasia
 
JPoint 2015 - Javassist на службе Java-разработчика
JPoint 2015 - Javassist на службе Java-разработчикаJPoint 2015 - Javassist на службе Java-разработчика
JPoint 2015 - Javassist на службе Java-разработчика
 
Con-FESS 2015 - Having Fun With Javassist
Con-FESS 2015 - Having Fun With JavassistCon-FESS 2015 - Having Fun With Javassist
Con-FESS 2015 - Having Fun With Javassist
 
Pain and distress during CO2 euthanasia
Pain and distress during CO2 euthanasiaPain and distress during CO2 euthanasia
Pain and distress during CO2 euthanasia
 
Riga Dev Day 2016 - Having fun with Javassist
Riga Dev Day 2016 - Having fun with JavassistRiga Dev Day 2016 - Having fun with Javassist
Riga Dev Day 2016 - Having fun with Javassist
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
 
Pain and distress during CO2 euthanasia
Pain and distress during CO2 euthanasiaPain and distress during CO2 euthanasia
Pain and distress during CO2 euthanasia
 
Love Story
Love StoryLove Story
Love Story
 

Semelhante a Java Bytecode Fundamentals - JUG.lv

Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011
Anton Arhipov
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
Anton 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 2011
Anton Arhipov
 

Semelhante a Java Bytecode Fundamentals - JUG.lv (20)

Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
 
LatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode FundamentalsLatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode Fundamentals
 
In Vogue Dynamic
In Vogue DynamicIn Vogue Dynamic
In Vogue Dynamic
 
The bytecode hocus pocus - JavaOne 2016
The bytecode hocus pocus - JavaOne 2016The bytecode hocus pocus - JavaOne 2016
The bytecode hocus pocus - JavaOne 2016
 
Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3
 
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
 
The bytecode mumbo-jumbo
The bytecode mumbo-jumboThe bytecode mumbo-jumbo
The bytecode mumbo-jumbo
 
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
 
Beyond java8
Beyond java8Beyond java8
Beyond java8
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
 
Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014Improving Android Performance at Droidcon UK 2014
Improving Android Performance at Droidcon UK 2014
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUG
 
What I Love About Ruby
What I Love About RubyWhat I Love About Ruby
What I Love About Ruby
 
Aprendendo solid com exemplos
Aprendendo solid com exemplosAprendendo solid com exemplos
Aprendendo solid com exemplos
 
Java For Automation
Java   For AutomationJava   For Automation
Java For Automation
 
Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8
 
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
 
A Life of breakpoint
A Life of breakpointA Life of breakpoint
A Life of breakpoint
 

Mais de Anton Arhipov

JavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdfJavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdf
Anton Arhipov
 
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloadingRiga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Anton Arhipov
 

Mais de Anton Arhipov (20)

JavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdfJavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdf
 
Idiomatic kotlin
Idiomatic kotlinIdiomatic kotlin
Idiomatic kotlin
 
TechTrain 2019 - (Не)адекватное техническое интервью
TechTrain 2019 - (Не)адекватное техническое интервьюTechTrain 2019 - (Не)адекватное техническое интервью
TechTrain 2019 - (Не)адекватное техническое интервью
 
Build pipelines with TeamCity
Build pipelines with TeamCityBuild pipelines with TeamCity
Build pipelines with TeamCity
 
Build pipelines with TeamCity
Build pipelines with TeamCityBuild pipelines with TeamCity
Build pipelines with TeamCity
 
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hourDevoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
 
GeeCON Prague 2018 - Kotlin DSL in under an hour
GeeCON Prague 2018 - Kotlin DSL in under an hourGeeCON Prague 2018 - Kotlin DSL in under an hour
GeeCON Prague 2018 - Kotlin DSL in under an hour
 
Build pipelines with TeamCity and Kotlin DSL
Build pipelines with TeamCity and Kotlin DSLBuild pipelines with TeamCity and Kotlin DSL
Build pipelines with TeamCity and Kotlin DSL
 
Build pipelines with TeamCity
Build pipelines with TeamCityBuild pipelines with TeamCity
Build pipelines with TeamCity
 
JavaDay Kiev 2017 - Integration testing with TestContainers
JavaDay Kiev 2017 - Integration testing with TestContainersJavaDay Kiev 2017 - Integration testing with TestContainers
JavaDay Kiev 2017 - Integration testing with TestContainers
 
GeeCON Prague 2017 - TestContainers
GeeCON Prague 2017 - TestContainersGeeCON Prague 2017 - TestContainers
GeeCON Prague 2017 - TestContainers
 
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
JavaOne 2017 - The hitchhiker’s guide to Java class reloadingJavaOne 2017 - The hitchhiker’s guide to Java class reloading
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
 
JavaOne 2017 - TestContainers: integration testing without the hassle
JavaOne 2017 - TestContainers: integration testing without the hassleJavaOne 2017 - TestContainers: integration testing without the hassle
JavaOne 2017 - TestContainers: integration testing without the hassle
 
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
JavaOne 2017 - The hitchhiker’s guide to Java class reloadingJavaOne 2017 - The hitchhiker’s guide to Java class reloading
JavaOne 2017 - The hitchhiker’s guide to Java class reloading
 
JavaZone 2017 - The Hitchhiker’s guide to Java class reloading
JavaZone 2017 - The Hitchhiker’s guide to Java class reloadingJavaZone 2017 - The Hitchhiker’s guide to Java class reloading
JavaZone 2017 - The Hitchhiker’s guide to Java class reloading
 
JUG.ua 20170225 - Java bytecode instrumentation
JUG.ua 20170225 - Java bytecode instrumentationJUG.ua 20170225 - Java bytecode instrumentation
JUG.ua 20170225 - Java bytecode instrumentation
 
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloadingRiga DevDays 2017 - The hitchhiker’s guide to Java class reloading
Riga DevDays 2017 - The hitchhiker’s guide to Java class reloading
 
GeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassleGeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassle
 
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
JEEConf 2017 - The hitchhiker’s guide to Java class reloadingJEEConf 2017 - The hitchhiker’s guide to Java class reloading
JEEConf 2017 - The hitchhiker’s guide to Java class reloading
 
JEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with JavassistJEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with Javassist
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Java Bytecode Fundamentals - JUG.lv

  • 1.
  • 2. Java Bytecode Fundamentals JUG.LV 2011, Riga
  • 3. whoami Anton Arhipov ZeroTurnaround JRebel http://arhipov.blogspot.com @antonarhipov @javarebel
  • 6. + 1 + 2 1 2
  • 7. + 1 + 2 1 2 1 2 +
  • 8. + 1 + 2 1 2 1 2 +
  • 9. + 1 + 2 1 2 1 2 + 1 PUSH 1
  • 10. + 1 + 2 1 2 1 2 + 2 PUSH 1 PUSH 2 1
  • 11. + 1 + 2 1 2 1 2 + 3 PUSH 1 PUSH 2 ADD
  • 12. + 1 + 2 1 2 1 2 + 3 ICONST_1 ICONST_2 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:orkuglasses>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:orkuglasses>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:orkuglasses>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:orkuglasses>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 areturn aload_0 00 02 getfield 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 B0 2A 00 02 B4 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 A dup pop swap dup_x1 dup_x2 B
  • 32. Stack Operations A dup pop swap dup_x1 dup_x2 A B
  • 33. Stack Operations A dup pop swap dup_x1 dup_x2 B
  • 34. Stack Operations B dup pop swap dup_x1 dup_x2 A
  • 35. Stack Operations B dup pop swap dup_x1 dup_x2 A B
  • 36. Stack Operations B dup pop swap dup_x1 dup_x2 A B B 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 numbered from 0
  • 40. Local Variables instance methods have this at 0 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 maps numbers to names 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
  • 42. Local Variables Sized explicitly 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
  • 43. Local Variables Stack Local Variables value var value depth ldc"Hello" astore_0 iconst_1 astore_1 aload_0 0 0 1 1 2 2 3 3 4 4
  • 44. Local Variables Stack Local Variables value var value depth ldc"Hello" astore_0 iconst_1 astore_1 aload_0 0 0 "Hello" 1 1 2 2 3 3 4 4
  • 45. Local Variables Stack Local Variables value var value depth ldc"Hello" astore_0 iconst_1 astore_1 aload_0 "Hello" 0 0 1 1 2 2 3 3 4 4
  • 46. Local Variables Stack Local Variables value var value depth ldc"Hello" astore_0 iconst_1 astore_1 aload_0 "Hello" 0 0 1 1 1 2 2 3 3 4 4
  • 47. Local Variables Stack Local Variables value var value depth ldc"Hello" astore_0 iconst_1 astore_1 aload_0 "Hello" 0 0 1 1 1 2 2 3 3 4 4
  • 48. Local Variables Stack Local Variables value var value depth ldc"Hello" astore_0 iconst_1 astore_1 aload_0 "Hello" 0 0 "Hello" 1 1 1 2 2 3 3 4 4
  • 49. Local Variables & Stack load Stack Local Variables Table store
  • 50. Object Initialization new <init> <clinit> Instance initialization method 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
  • 61. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; 10: areturn var value Stack 1 value depth 2 1 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 1 6 2 3
  • 62. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; 10: areturn var value Stack 1 value depth 2 1 this 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 1 6 2 3
  • 63. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; //createRandomValue() 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; 10: areturn var value Stack 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 1 6 2 3
  • 64. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; 10: areturn var value Stack objectref 1 value depth 2 1 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 1 6 2 3
  • 65. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; 10: areturn var value Stack objectref 1 value depth 2 1 this 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 1 6 2 3
  • 66. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; 10: areturn var value Stack objectref 1 value depth 2 1 objectref 3 2 this 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 1 6 2 3
  • 67. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3;//incValue 10: areturn var value Stack objectref 1 value depth 2 1 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 objectref 1 6 2 3
  • 68. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; //incValue 10: areturn var value Stack objectref 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 objectref 1 6 2 3
  • 69. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; //incValue 10: areturn var value Stack objectref 1 value depth 2 1 X 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8;// Integer.intValue:() 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 objectref 1 6 2 3
  • 70. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; //incValue 10: areturn var value Stack objectref 1 value depth 2 1 1 3 2 X 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 objectref 1 6 2 3
  • 71. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; //incValue 10: areturn var value Stack objectref 1 value depth 2 1 X + 1 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 objectref 1 6 2 3
  • 72. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; //incValue 10: areturn var value Stack objectref 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7;//Integer.valueOf 9: areturn 5 objectref 1 6 2 3
  • 73. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; //incValue 10: areturn var value Stack objectref 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 objectref 1 6 2 3
  • 74. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; 10: areturn var value Stack objectref 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 1 6 2 3
  • 75. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; 10: areturn var value Stack 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 1 6 2 3
  • 76. Local Variables public java.lang.Object execute(); 0: aload_0 1: invokespecial #2; 4: astore_1 5: aload_0 6: aload_1 7: invokespecial #3; 10: areturn var value Stack 1 value depth 2 1 objectref 3 2 3 private java.lang.Integer incValue(java.lang.Integer); 4 var value 0: aload_1 1: invokevirtual #8; 4: iconst_1 5: iadd 6: invokestatic #7; 9: areturn 5 1 6 2 3
  • 79. Stack value depth public int decide(int); Code: 0: iload_1 1: bipush 10 3: if_icmpge 8 6: iconst_0 7: ireturn 8: bipush 100 10: ireturn 1 2 3
  • 80. Stack value depth public int decide(int); Code: 0: iload_1 1: bipush 10 3: if_icmpge 8 6: iconst_0 7: ireturn 8: bipush 100 10: ireturn a 1 2 3
  • 81. Stack value depth public int decide(int); Code: 0: iload_1 1: bipush 10 3: if_icmpge 8 6: iconst_0 7: ireturn 8: bipush 100 10: ireturn 10 1 a 2 3
  • 82. Stack value depth public int decide(int); Code: 0: iload_1 1: bipush 10 3: if_icmpge 8 6: iconst_0 7: ireturn 8: bipush 100 10: ireturn 10 1 a 2 3
  • 83. Stack value depth public int decide(int); Code: 0: iload_1 1: bipush 10 3: if_icmpge 8 6: iconst_0 7: ireturn 8: bipush 100 10: ireturn 1 2 3
  • 84. Stack value depth public int decide(int); Code: 0: iload_1 1: bipush 10 3: if_icmpge 8 6: iconst_0 7: ireturn 8: bipush 100 10: ireturn 100 1 2 3
  • 85. Stack value depth public int decide(int); Code: 0: iload_1 1: bipush 10 3: if_icmpge 8 6: iconst_0 7: ireturn 8: bipush 100 10: ireturn 100 1 2 3
  • 86. Stack value depth public int decide(int); Code: 0: iload_1 1: bipush 10 3: if_icmpge 8 6: iconst_0 7: ireturn 8: bipush 100 10: ireturn 1 2 3