SlideShare a Scribd company logo
Mastering byte code
The master plan

•   JVM
•   javap
•   opcode
•   ClassLoader
•   Toolkits
•   Puzzles
Stack

1+2

      PUSH 1     1
12+   PUSH 2     2
Stack

1+2

      PUSH 1     3
12+   PUSH 2
      ADD
Stack

1+2

      ICONST_1     3
12+   ICONST_2
      IADD
Frame
Local Variables & Stack
Java Stack Machine

•   JVM is a stack-based machine
•   Each thread has a stack
•   Stack stores frames
•   Frame is created on method invocation
•   Frame:
     o
       Operand stack
     o
       Array of local variables
     o
       Reference to the runtime constant pool
Compiling to binary

C/C++ (*.h, *.cpp)   Java (*.java)



Assembler                     Bytecode


Intel opcode                 Sun opcode
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
•   -verbose – prints stack size, number of
    locals and args for methods
javap -c -verbose Clazz
public class SimpleProgram
{
  public static void main(String[] args)
  {
       System.out.println("Hello Java Fusion!");
  }
}
public class SimpleProgram
{
  public static void main(String[] args)
  {
       System.out.println("Hello Java Fusion!");
  }
}

javap SimpleProgram -c
public class SimpleProgram
{
  public static void main(String[] args)
  {
       System.out.println("Hello Java Fusion!");
  }
}

javap SimpleProgram -c
Compiled from "SimpleProgram.java"
public class SimpleProgram extends java.lang.Object{
public SimpleProgram();
    Code:
    0:   aload_0
    1:   invokespecial    #1; //Method java/lang/Object."":()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 Java Fusion!
    5:   invokevirtual   #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
    8:   return

}
public class SimpleProgram
{
  public static void main(String[] args)
  {
       System.out.println("Hello Java Fusion!");
  }
}

javap SimpleProgram -c
Compiled from "SimpleProgram.java"
public class SimpleProgram extends java.lang.Object{
public SimpleProgram();// The default constructor
 Code:
    0:   aload_0 //Push this sto stack
    1:   invokespecial #1; //Method java/lang/Object."":()V //Invoke <init> on this
    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 Java Fusion!
    5:   invokevirtual   #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
    8:   return


}
public class SimpleProgram
{
  public static void main(String[] args)
  {
       System.out.println("Hello Java Fusion!");
  }
}

javap SimpleProgram -c
Compiled from "SimpleProgram.java"
public class SimpleProgram extends java.lang.Object{
public SimpleProgram();
    Code:
    0:   aload_0
    1:   invokespecial   #1; //Method java/lang/Object."":()V
    4:   return
public static void main(java.lang.String[]);
    Code:
    0:   getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream; //get static field
    3:   ldc #3; //String Hello Java Fusion! //Load String to the stack
    5:   invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V //invoke method with parameter
    8:   return


}
public class SimpleProgram
{
  public static void main(String[] args)
  {
       System.out.println("Hello Java Fusion!");
  }
}

javap SimpleProgram -c
Compiled from "SimpleProgram.java"
public class SimpleProgram extends java.lang.Object{
public SimpleProgram();
    Code:
    0:   aload_0
    1:   invokespecial    #1; //Method java/lang/Object."":()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 Java Fusion!
    5:   invokevirtual   #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
    8:   return

}
public class SimpleProgram
{
  public static void main(String[] args)
  {
       System.out.println("Hello Java Fusion!");
  }
}

javap SimpleProgram -c -verbose
Compiled from "SimpleProgram.java“
public class SimpleProgram extends java.lang.Object
SourceFile: "SimpleProgram.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 Java Fusion!
const #4 = Method #24.#25; // java/io/PrintStream.println:(Ljava/lang/String;)V
const #5 = class #26; // SimpleProgram
const #6 = class #27; // java/lang/Object
сonst #7 = Asciz <init>;
...
Bytecode

One-byte instructions
256 possible opcodes
207 in use
49 currently unassigned for opcodes and are reserved
for future use
TYPE OPERATION
Instructions fall into a number of broad groups:
•Local variables and stack interaction (e.g. aload_0,istore)
•Array operations (aload, astore)
•Arithmetic and logic (e.g. ladd,fcmpl)
•Type conversion (e.g. i2b,d2i)
•Object creation and manipulation (new, putfield)
•Operand stack management (e.g. swap,dup2)
•Control transfer (e.g. ifeq, goto)
•Method invocation and return (e.g. invokespecial,areturn)
•Operations with constant values (ldc, iconst_1)
•Math (add, sub, mul, div)
•Boolean/bitwise operations (iand, ixor)
•Comparisons (cmpg, cmpl, ifne)
•...
Opcode type
Prefix/Suffix   Operand Type
i               integer
l               long
s               short
b               byte
c               char
f               float
d               double
a               reference
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;
ClassLoader

- Works with bytecode
- Has native methods
- Bytecode Verification via SecurityManager.class
Toolkits

JVM:
•ASM
•Javassist
•BCEL (Byte Code Engineering Library)

Jrebel
Terracotta
Common sample
public class SimpleProgram
{
  public static void main(String[] args)
  {
       System.out.println("Hello Java Fusion!");
  }
}
ASM sample
public class ASMSample extends ClassLoader implements Opcodes {
{
  public static void main(String[] args)
  {
     ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
      cw.visit(V1_1, ACC_PUBLIC, "SimpleProgram", null, "java/lang/Object", null);
    }
}
ASM sample
public class ASMSample extends ClassLoader implements Opcodes {
{
  public static void main(String[] args)
  {
     ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
      cw.visit(V1_1, ACC_PUBLIC, "SimpleProgram", null, "java/lang/Object", null); // creates a GeneratorAdapter
for the (implicit) constructor
      Method m = Method.getMethod("void <init> ()");
      GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, m, null, null, cw);
      mg.loadThis();
      mg.invokeConstructor(Type.getType(Object.class), m);
      mg.returnValue();
      mg.endMethod();
    }
}
ASM sample
public class ASMSample extends ClassLoader implements Opcodes {
{
  public static void main(String[] args)
  {
     ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
      cw.visit(V1_1, ACC_PUBLIC, "SimpleProgram", null, "java/lang/Object", null);
      // creates a GeneratorAdapter for the (implicit) constructor
      Method m = Method.getMethod("void <init> ()");
      GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, m, null, null, cw);
      mg.loadThis();
      mg.invokeConstructor(Type.getType(Object.class), m);
      mg.returnValue();
      mg.endMethod();       // creates a GeneratorAdapter for the 'main' method
      m = Method.getMethod("void main (String[])");
      mg = new GeneratorAdapter(ACC_PUBLIC + ACC_STATIC, m, null, null, cw);
      mg.getStatic(Type.getType(System.class), "out",Type.getType(PrintStream.class));
      mg.push("Hello Java Fusion!");
      mg.invokeVirtual(Type.getType(PrintStream.class),
            Method.getMethod("void println (String)"));
      mg.returnValue();
      mg.endMethod();
      cw.visitEnd();
    }
}
ASM sample
public class ASMSample extends ClassLoader implements Opcodes {
{
  public static void main(String[] args)
  {
     ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
      cw.visit(V1_1, ACC_PUBLIC, "SimpleProgram", null, "java/lang/Object", null);
      // creates a GeneratorAdapter for the (implicit) constructor
      Method m = Method.getMethod("void <init> ()");
      GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, m, null, null, cw);
      mg.loadThis();
      mg.invokeConstructor(Type.getType(Object.class), m);
      mg.returnValue();
      mg.endMethod();
      // creates a GeneratorAdapter for the 'main' method
      m = Method.getMethod("void main (String[])");
      mg = new GeneratorAdapter(ACC_PUBLIC + ACC_STATIC, m, null, null, cw);
      mg.getStatic(Type.getType(System.class), "out",Type.getType(PrintStream.class));
      mg.push("Hello Java Fusion!");
      mg.invokeVirtual(Type.getType(PrintStream.class),
            Method.getMethod("void println (String)"));
      mg.returnValue();
      mg.endMethod();
      cw.visitEnd();    byte[] code = cw.toByteArray();
      ASMSample loader = new ASMSample ();
      Class<?> exampleClass = loader.defineClass("SimpleProgram", code, 0, code.length);
      // uses the dynamically generated class to print 'Hello Java Fusion'
      exampleClass.getMethods()[0].invoke(null, new Object[] { null } );
    }
}
ASM vs. Javassist
•        Javassist source level API is much easier to use than the
actual bytecode manipulation in ASM
•       Javassist provides a higher level abstraction layer over complex
bytecode level operations. Javassist source level API requires very less or
no knowledge of actual bytecodes, so much easier & faster to
implement.
•      Javassist uses reflection mechanism which makes it slower
compared to ASM which uses Classworking techniques at runtime.
•          Overall ASM is much faster & gives better performance than
Javassist. Javassist uses a simplified version of Java source code, which
it then compiles into bytecode. That makes Javassist very easy to use, but
it also limits the use of bytecode to what can be expressed within the limits
of the Javassist source code.
•       In conclusion, if someone needs easier way of dynamically
manipulating or creating Java classes Javassist API should be used &
where the performance is the key issue ASM library should be used.
JRebel
Redeploying sucks, so JRebel
eliminates it. How?


    JRebel maps your project workspace directly to the
  application under development. When you change any
 class or resource in your IDE, the change is immediately
     reflected in the application, skipping the build and
                       redeploy phases.
How JRebel works
1) Classes


• JRebel integrates with the JVM and rewrites each class to be
updateable
• JRebel versions each class individually, instead of an application or
  module at a time
• It does not use classloaders!
• Changes to classes are always visible in the Reflection API
How JRebel works
2) Workspace mapping




                                                petclinic.war

                            • JRebel integrates with application
                              servers, frameworks and your IDE
                            • When a class or resource is being
                              looked up, JRebel redirects straight
                              to the workspace
                            • When an HTTP resource needs to
                              be served, JRebel serves it from the
                              workspace
Size and speed issues
Size and speed issues




top1 and top2 are functionally identical
Size and speed issues
Method int top1()
 0 aload_0          //Push the object reference(this) at index
              //0 of the local variable table.
 1 getfield #6 <Field int intArr[]>
              //Pop the object reference(this) and push
              //the object reference for intArr accessed
              //from the constant pool.
 4 iconst_0         //Push 0.
 5 iaload         //Pop the top two values and push the
              //value at index 0 of intArr.
 6 ireturn        //Pop top value and push it on the operand
              //stack of the invoking method. Exit.
Size and speed issues
Method int top2()
 0 aload_0
 1 astore_2
 2 aload_2
 3 monitorenter
    4 aload_0
    5 getfield #6 <Field int intArr[]>
    8 iconst_0       //Push 0.
    9 iaload
    10 istore_1
    11 jsr 19
    14 iload_1       .
    15 ireturn
    16 aload_2
    17 monitorexit   .                   Exception table:    //If any exception occurs between
    18 athrow      .                     from to target type //location 4 (inclusive) and location
    19 astore_3                           4 16 16 any //16 (exclusive) jump to location 16
    20 aload_2
    21 monitorexit
    22 ret 3
.
Size and speed issues




top1 and top2 are functionally identical
top1 is 13% faster than top2 as well as much smaller.
Puzzle Cutting Class
                                                          public class Strange2 {
public class Strange1 {
                                                               public static void main(String[] args) {
     public static void main(String[] args) {
                                                                  Missing m;         try {
        try {
                                                                     m = new Missing();           } catch
           Missing m = new Missing();           } catch
                                                          (java.lang.NoClassDefFoundError ex) {
(java.lang.NoClassDefFoundError ex) {
                                                                     System.out.println("Got it!");
           System.out.println("Got it!");
                                                                  }
        }
                                                               }
     }
                                                             }
   }




  class Missing {
       Missing() { }
   }
Puzzle Cutting Class
                                                          public class Strange2 {
public class Strange1 {
                                                               public static void main(String[] args) {
     public static void main(String[] args) {
                                                                  Missing m;         try {
        try {
                                                                     m = new Missing();           } catch
           Missing m = new Missing();           } catch
                                                          (java.lang.NoClassDefFoundError ex) {
(java.lang.NoClassDefFoundError ex) {
                                                                     System.out.println("Got it!");
           System.out.println("Got it!");
                                                                  }
        }
                                                               }
     }
                                                             }
   }




  class Missing {
       Missing() { }
   }
Puzzle Cutting Class
                                                              public class Strange2 {
public class Strange1 {
                                                                   public static void main(String[] args) {
     public static void main(String[] args) {
                                                                      Missing m;         try {
        try {
                                                                         m = new Missing();           } catch
           Missing m = new Missing();            } catch
                                                              (java.lang.NoClassDefFoundError ex) {
(java.lang.NoClassDefFoundError ex) {
                                                                         System.out.println("Got it!");
           System.out.println("Got it!");
                                                                      }
        }
                                                                   }
     }
                                                                 }
   }
                                          class Missing {
                                              Missing() { }
                                           }




                                                     ???
           System.out.println("Got it!");                       throws an uncaught
                                                                NoClassDefFoundError
Puzzle Cutting Class
                                                            public class Strange2 {
public class Strange1 {
                                                                 public static void main(String[] args) {
     public static void main(String[] args) {
                                                                    Missing m;         try {
        try {
                                                                       m = new Missing();           } catch
           Missing m = new Missing();           } catch
                                                            (java.lang.NoClassDefFoundError ex) {
(java.lang.NoClassDefFoundError ex) {
                                                                       System.out.println("Got it!");
           System.out.println("Got it!");
                                                                    }
        }
                                                                 }
     }

                                        class Missing {
                                            Missing() { }
                                         }




           System.out.println("Got it!");        Expected     throws an uncaught
                                                              NoClassDefFoundError


           throws an uncaught                    Result       System.out.println("Got it!");
           NoClassDefFoundError
Puzzle Cutting Class
0: new             #2; // class Missing

3: dup

4: invokespecial #3; // Method Missing."<init>":()V

7: astore_1

8: goto 20

11: astore_1

12: getstatic      #5; // Field System.out:Ljava/io/PrintStream;

15: ldc            #6; // String "Got it!"

17: invokevirtual #7; // Method PrintStream.println:(String;)V

20: return

Exception table:

from to target type

  0 8 11 Class java/lang/NoClassDefFoundError

The corresponding code for Strange2.main differs in only one instruction:
11: astore_2 //Store ex catch parameter




javap -c Strange1
Using reflection
public class Strange {

    public static void main(String[] args) throws Exception {

        try {

            Object m = Class.forName("Missing").newInstance();

        } catch (ClassNotFoundException ex) {

            System.err.println("Got it!");

        }

    }

}
Benefits

• Improve speed and size of your applications
• Critical when debugging and doing performance and
  memory usage tuning
• Realtime injection
• Build ORM project
• Clustering with AOP
• Know your platform!
• Create your own compile/decompiler?
Mastering Java ByteCode

More Related Content

What's hot

Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013
Charles Nutter
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015
Charles Nutter
 
Monitoring distributed (micro-)services
Monitoring distributed (micro-)servicesMonitoring distributed (micro-)services
Monitoring distributed (micro-)services
Rafael Winterhalter
 
Live Updating Swift Code
Live Updating Swift CodeLive Updating Swift Code
Live Updating Swift Code
Bartosz Polaczyk
 
Object Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypassObject Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypass
Sam Thomas
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Susan Potter
 
Invokedynamic / JSR-292
Invokedynamic / JSR-292Invokedynamic / JSR-292
Invokedynamic / JSR-292ytoshima
 
Java and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemJava and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystem
Rafael Winterhalter
 
Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap Dumps
Andrei Pangin
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Raimonds Simanovskis
 
Down the Rabbit Hole
Down the Rabbit HoleDown the Rabbit Hole
Down the Rabbit Hole
Charles Nutter
 
Rails on Oracle 2011
Rails on Oracle 2011Rails on Oracle 2011
Rails on Oracle 2011
Raimonds Simanovskis
 
sizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may mattersizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may matter
Dawid Weiss
 
An introduction to JVM performance
An introduction to JVM performanceAn introduction to JVM performance
An introduction to JVM performance
Rafael Winterhalter
 
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
Anton Arhipov
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?
Mario Camou Riveroll
 
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!
Sylvain Wallez
 
Why Every Tester Should Learn Ruby
Why Every Tester Should Learn RubyWhy Every Tester Should Learn Ruby
Why Every Tester Should Learn Ruby
Raimonds Simanovskis
 
Java byte code in practice
Java byte code in practiceJava byte code in practice
Java byte code in practice
Rafael Winterhalter
 
Sailing with Java 8 Streams
Sailing with Java 8 StreamsSailing with Java 8 Streams
Sailing with Java 8 Streams
Ganesh Samarthyam
 

What's hot (20)

Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015
 
Monitoring distributed (micro-)services
Monitoring distributed (micro-)servicesMonitoring distributed (micro-)services
Monitoring distributed (micro-)services
 
Live Updating Swift Code
Live Updating Swift CodeLive Updating Swift Code
Live Updating Swift Code
 
Object Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypassObject Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypass
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
 
Invokedynamic / JSR-292
Invokedynamic / JSR-292Invokedynamic / JSR-292
Invokedynamic / JSR-292
 
Java and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemJava and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystem
 
Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap Dumps
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
 
Down the Rabbit Hole
Down the Rabbit HoleDown the Rabbit Hole
Down the Rabbit Hole
 
Rails on Oracle 2011
Rails on Oracle 2011Rails on Oracle 2011
Rails on Oracle 2011
 
sizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may mattersizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may matter
 
An introduction to JVM performance
An introduction to JVM performanceAn introduction to JVM performance
An introduction to JVM performance
 
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
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?
 
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!
 
Why Every Tester Should Learn Ruby
Why Every Tester Should Learn RubyWhy Every Tester Should Learn Ruby
Why Every Tester Should Learn Ruby
 
Java byte code in practice
Java byte code in practiceJava byte code in practice
Java byte code in practice
 
Sailing with Java 8 Streams
Sailing with Java 8 StreamsSailing with Java 8 Streams
Sailing with Java 8 Streams
 

Viewers also liked

Эффективный JavaScript - IQLab Frontend Fusion 2012
Эффективный  JavaScript - IQLab Frontend Fusion 2012Эффективный  JavaScript - IQLab Frontend Fusion 2012
Эффективный JavaScript - IQLab Frontend Fusion 2012
Ecommerce Solution Provider SysIQ
 
Гибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSSГибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSS
Ecommerce Solution Provider SysIQ
 
Доступность веб-сайтов: WWW для всех?
Доступность веб-сайтов: WWW для всех?Доступность веб-сайтов: WWW для всех?
Доступность веб-сайтов: WWW для всех?
Ecommerce Solution Provider SysIQ
 
Правила хорошего SEO тона в Frontend разработке
Правила хорошего SEO тона в Frontend разработкеПравила хорошего SEO тона в Frontend разработке
Правила хорошего SEO тона в Frontend разработкеEcommerce Solution Provider SysIQ
 

Viewers also liked (20)

Unexpected achievements 2013
Unexpected achievements 2013Unexpected achievements 2013
Unexpected achievements 2013
 
Testing schools overview
Testing schools overviewTesting schools overview
Testing schools overview
 
QA evolution, in pictures
QA evolution, in picturesQA evolution, in pictures
QA evolution, in pictures
 
User focused design
User focused designUser focused design
User focused design
 
Speed Up Your Website
Speed Up Your WebsiteSpeed Up Your Website
Speed Up Your Website
 
Going global
Going globalGoing global
Going global
 
User Behavior: Interacting With Important Website Elements
User Behavior: Interacting With Important Website ElementsUser Behavior: Interacting With Important Website Elements
User Behavior: Interacting With Important Website Elements
 
Manifest of modern engineers
Manifest of modern engineersManifest of modern engineers
Manifest of modern engineers
 
Quick Intro to Clean Coding
Quick Intro to Clean CodingQuick Intro to Clean Coding
Quick Intro to Clean Coding
 
Эффективный JavaScript - IQLab Frontend Fusion 2012
Эффективный  JavaScript - IQLab Frontend Fusion 2012Эффективный  JavaScript - IQLab Frontend Fusion 2012
Эффективный JavaScript - IQLab Frontend Fusion 2012
 
Гибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSSГибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSS
 
IGears: Template Architecture and Principles
IGears: Template Architecture and PrinciplesIGears: Template Architecture and Principles
IGears: Template Architecture and Principles
 
Доступность веб-сайтов: WWW для всех?
Доступность веб-сайтов: WWW для всех?Доступность веб-сайтов: WWW для всех?
Доступность веб-сайтов: WWW для всех?
 
Java serialization
Java serializationJava serialization
Java serialization
 
Developing for e commerce is important
Developing for e commerce is importantDeveloping for e commerce is important
Developing for e commerce is important
 
QA evolution to the present day
QA evolution to the present dayQA evolution to the present day
QA evolution to the present day
 
All things php
All things phpAll things php
All things php
 
External Widgets Performance
External Widgets PerformanceExternal Widgets Performance
External Widgets Performance
 
Getting to know magento
Getting to know magentoGetting to know magento
Getting to know magento
 
Правила хорошего SEO тона в Frontend разработке
Правила хорошего SEO тона в Frontend разработкеПравила хорошего SEO тона в Frontend разработке
Правила хорошего SEO тона в Frontend разработке
 

Similar to Mastering Java ByteCode

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
tcurdt
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Anton Arhipov
 
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
Sylvain Wallez
 
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
 
Exploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systemsExploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systems
InfinIT - Innovationsnetværket for it
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agents
Rafael Winterhalter
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
Sylvain Wallez
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Partnered Health
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
Luiz Fernando Teston
 
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw  est prêt à tuer le classpathSoft-Shake 2016 : Jigsaw  est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Alexis Hassler
 
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHave Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHoward Lewis Ship
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
Andres Almiray
 
Shiksharth com java_topics
Shiksharth com java_topicsShiksharth com java_topics
Shiksharth com java_topics
Rajesh Verma
 
4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdf4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdf
amitbhachne
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
Supercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamicSupercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamic
Ian Robertson
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Nayden Gochev
 
CogLab Information.htmlCogLab InformationCogLabs for this
CogLab Information.htmlCogLab InformationCogLabs for this CogLab Information.htmlCogLab InformationCogLabs for this
CogLab Information.htmlCogLab InformationCogLabs for this
WilheminaRossi174
 
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Soumen Santra
 

Similar to Mastering Java ByteCode (20)

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
 
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
 
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
 
Exploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systemsExploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systems
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agents
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
 
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw  est prêt à tuer le classpathSoft-Shake 2016 : Jigsaw  est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
 
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHave Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
 
Shiksharth com java_topics
Shiksharth com java_topicsShiksharth com java_topics
Shiksharth com java_topics
 
4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdf4CS4-25-Java-Lab-Manual.pdf
4CS4-25-Java-Lab-Manual.pdf
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Supercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamicSupercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamic
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
CogLab Information.htmlCogLab InformationCogLabs for this
CogLab Information.htmlCogLab InformationCogLabs for this CogLab Information.htmlCogLab InformationCogLabs for this
CogLab Information.htmlCogLab InformationCogLabs for this
 
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
 

More from Ecommerce Solution Provider SysIQ

Frontend Servers and NGINX: What, Where and How
Frontend Servers and NGINX: What, Where and HowFrontend Servers and NGINX: What, Where and How
Frontend Servers and NGINX: What, Where and How
Ecommerce Solution Provider SysIQ
 

More from Ecommerce Solution Provider SysIQ (13)

Developing for e commerce is important
Developing for e commerce is importantDeveloping for e commerce is important
Developing for e commerce is important
 
Magento code audit
Magento code auditMagento code audit
Magento code audit
 
Scalability and performance for e commerce
Scalability and performance for e commerceScalability and performance for e commerce
Scalability and performance for e commerce
 
Lupan big enterprise ecommerce fusion 2013
Lupan   big enterprise ecommerce fusion 2013Lupan   big enterprise ecommerce fusion 2013
Lupan big enterprise ecommerce fusion 2013
 
non-blocking java script
non-blocking java scriptnon-blocking java script
non-blocking java script
 
Going Global
Going GlobalGoing Global
Going Global
 
Seo and Marketing Requirements in Web Architecture
Seo and Marketing Requirements in Web ArchitectureSeo and Marketing Requirements in Web Architecture
Seo and Marketing Requirements in Web Architecture
 
Management and Communications (IPAA)
Management and Communications (IPAA)Management and Communications (IPAA)
Management and Communications (IPAA)
 
Databases on Client Side
Databases on Client SideDatabases on Client Side
Databases on Client Side
 
Interactive web prototyping
Interactive web prototypingInteractive web prototyping
Interactive web prototyping
 
Модульные сетки в реальном мире
Модульные сетки в реальном миреМодульные сетки в реальном мире
Модульные сетки в реальном мире
 
Understanding Annotations in Java
Understanding Annotations in JavaUnderstanding Annotations in Java
Understanding Annotations in Java
 
Frontend Servers and NGINX: What, Where and How
Frontend Servers and NGINX: What, Where and HowFrontend Servers and NGINX: What, Where and How
Frontend Servers and NGINX: What, Where and How
 

Recently uploaded

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 

Recently uploaded (20)

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 

Mastering Java ByteCode

  • 2. The master plan • JVM • javap • opcode • ClassLoader • Toolkits • Puzzles
  • 3. Stack 1+2 PUSH 1 1 12+ PUSH 2 2
  • 4. Stack 1+2 PUSH 1 3 12+ PUSH 2 ADD
  • 5. Stack 1+2 ICONST_1 3 12+ ICONST_2 IADD
  • 7.
  • 9. Java Stack Machine • JVM is a stack-based machine • Each thread has a stack • Stack stores frames • Frame is created on method invocation • Frame: o Operand stack o Array of local variables o Reference to the runtime constant pool
  • 10. Compiling to binary C/C++ (*.h, *.cpp) Java (*.java) Assembler Bytecode Intel opcode Sun opcode
  • 11. 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 • -verbose – prints stack size, number of locals and args for methods
  • 13. public class SimpleProgram { public static void main(String[] args) { System.out.println("Hello Java Fusion!"); } }
  • 14. public class SimpleProgram { public static void main(String[] args) { System.out.println("Hello Java Fusion!"); } } javap SimpleProgram -c
  • 15. public class SimpleProgram { public static void main(String[] args) { System.out.println("Hello Java Fusion!"); } } javap SimpleProgram -c Compiled from "SimpleProgram.java" public class SimpleProgram extends java.lang.Object{ public SimpleProgram(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object."":()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 Java Fusion! 5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V 8: return }
  • 16. public class SimpleProgram { public static void main(String[] args) { System.out.println("Hello Java Fusion!"); } } javap SimpleProgram -c Compiled from "SimpleProgram.java" public class SimpleProgram extends java.lang.Object{ public SimpleProgram();// The default constructor Code: 0: aload_0 //Push this sto stack 1: invokespecial #1; //Method java/lang/Object."":()V //Invoke <init> on this 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 Java Fusion! 5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V 8: return }
  • 17. public class SimpleProgram { public static void main(String[] args) { System.out.println("Hello Java Fusion!"); } } javap SimpleProgram -c Compiled from "SimpleProgram.java" public class SimpleProgram extends java.lang.Object{ public SimpleProgram(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object."":()V 4: return public static void main(java.lang.String[]); Code: 0: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream; //get static field 3: ldc #3; //String Hello Java Fusion! //Load String to the stack 5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V //invoke method with parameter 8: return }
  • 18. public class SimpleProgram { public static void main(String[] args) { System.out.println("Hello Java Fusion!"); } } javap SimpleProgram -c Compiled from "SimpleProgram.java" public class SimpleProgram extends java.lang.Object{ public SimpleProgram(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object."":()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 Java Fusion! 5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V 8: return }
  • 19. public class SimpleProgram { public static void main(String[] args) { System.out.println("Hello Java Fusion!"); } } javap SimpleProgram -c -verbose Compiled from "SimpleProgram.java“ public class SimpleProgram extends java.lang.Object SourceFile: "SimpleProgram.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 Java Fusion! const #4 = Method #24.#25; // java/io/PrintStream.println:(Ljava/lang/String;)V const #5 = class #26; // SimpleProgram const #6 = class #27; // java/lang/Object сonst #7 = Asciz <init>; ...
  • 20. Bytecode One-byte instructions 256 possible opcodes 207 in use 49 currently unassigned for opcodes and are reserved for future use
  • 21. TYPE OPERATION Instructions fall into a number of broad groups: •Local variables and stack interaction (e.g. aload_0,istore) •Array operations (aload, astore) •Arithmetic and logic (e.g. ladd,fcmpl) •Type conversion (e.g. i2b,d2i) •Object creation and manipulation (new, putfield) •Operand stack management (e.g. swap,dup2) •Control transfer (e.g. ifeq, goto) •Method invocation and return (e.g. invokespecial,areturn) •Operations with constant values (ldc, iconst_1) •Math (add, sub, mul, div) •Boolean/bitwise operations (iand, ixor) •Comparisons (cmpg, cmpl, ifne) •...
  • 22. Opcode type Prefix/Suffix Operand Type i integer l long s short b byte c char f float d double a reference
  • 23. 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;
  • 24. 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;
  • 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. 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. ClassLoader - Works with bytecode - Has native methods - Bytecode Verification via SecurityManager.class
  • 28. Toolkits JVM: •ASM •Javassist •BCEL (Byte Code Engineering Library) Jrebel Terracotta
  • 29. Common sample public class SimpleProgram { public static void main(String[] args) { System.out.println("Hello Java Fusion!"); } }
  • 30. ASM sample public class ASMSample extends ClassLoader implements Opcodes { { public static void main(String[] args) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); cw.visit(V1_1, ACC_PUBLIC, "SimpleProgram", null, "java/lang/Object", null); } }
  • 31. ASM sample public class ASMSample extends ClassLoader implements Opcodes { { public static void main(String[] args) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); cw.visit(V1_1, ACC_PUBLIC, "SimpleProgram", null, "java/lang/Object", null); // creates a GeneratorAdapter for the (implicit) constructor Method m = Method.getMethod("void <init> ()"); GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, m, null, null, cw); mg.loadThis(); mg.invokeConstructor(Type.getType(Object.class), m); mg.returnValue(); mg.endMethod(); } }
  • 32. ASM sample public class ASMSample extends ClassLoader implements Opcodes { { public static void main(String[] args) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); cw.visit(V1_1, ACC_PUBLIC, "SimpleProgram", null, "java/lang/Object", null); // creates a GeneratorAdapter for the (implicit) constructor Method m = Method.getMethod("void <init> ()"); GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, m, null, null, cw); mg.loadThis(); mg.invokeConstructor(Type.getType(Object.class), m); mg.returnValue(); mg.endMethod(); // creates a GeneratorAdapter for the 'main' method m = Method.getMethod("void main (String[])"); mg = new GeneratorAdapter(ACC_PUBLIC + ACC_STATIC, m, null, null, cw); mg.getStatic(Type.getType(System.class), "out",Type.getType(PrintStream.class)); mg.push("Hello Java Fusion!"); mg.invokeVirtual(Type.getType(PrintStream.class), Method.getMethod("void println (String)")); mg.returnValue(); mg.endMethod(); cw.visitEnd(); } }
  • 33. ASM sample public class ASMSample extends ClassLoader implements Opcodes { { public static void main(String[] args) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); cw.visit(V1_1, ACC_PUBLIC, "SimpleProgram", null, "java/lang/Object", null); // creates a GeneratorAdapter for the (implicit) constructor Method m = Method.getMethod("void <init> ()"); GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, m, null, null, cw); mg.loadThis(); mg.invokeConstructor(Type.getType(Object.class), m); mg.returnValue(); mg.endMethod(); // creates a GeneratorAdapter for the 'main' method m = Method.getMethod("void main (String[])"); mg = new GeneratorAdapter(ACC_PUBLIC + ACC_STATIC, m, null, null, cw); mg.getStatic(Type.getType(System.class), "out",Type.getType(PrintStream.class)); mg.push("Hello Java Fusion!"); mg.invokeVirtual(Type.getType(PrintStream.class), Method.getMethod("void println (String)")); mg.returnValue(); mg.endMethod(); cw.visitEnd(); byte[] code = cw.toByteArray(); ASMSample loader = new ASMSample (); Class<?> exampleClass = loader.defineClass("SimpleProgram", code, 0, code.length); // uses the dynamically generated class to print 'Hello Java Fusion' exampleClass.getMethods()[0].invoke(null, new Object[] { null } ); } }
  • 34. ASM vs. Javassist • Javassist source level API is much easier to use than the actual bytecode manipulation in ASM • Javassist provides a higher level abstraction layer over complex bytecode level operations. Javassist source level API requires very less or no knowledge of actual bytecodes, so much easier & faster to implement. • Javassist uses reflection mechanism which makes it slower compared to ASM which uses Classworking techniques at runtime. • Overall ASM is much faster & gives better performance than Javassist. Javassist uses a simplified version of Java source code, which it then compiles into bytecode. That makes Javassist very easy to use, but it also limits the use of bytecode to what can be expressed within the limits of the Javassist source code. • In conclusion, if someone needs easier way of dynamically manipulating or creating Java classes Javassist API should be used & where the performance is the key issue ASM library should be used.
  • 35. JRebel Redeploying sucks, so JRebel eliminates it. How? JRebel maps your project workspace directly to the application under development. When you change any class or resource in your IDE, the change is immediately reflected in the application, skipping the build and redeploy phases.
  • 36. How JRebel works 1) Classes • JRebel integrates with the JVM and rewrites each class to be updateable • JRebel versions each class individually, instead of an application or module at a time • It does not use classloaders! • Changes to classes are always visible in the Reflection API
  • 37. How JRebel works 2) Workspace mapping petclinic.war • JRebel integrates with application servers, frameworks and your IDE • When a class or resource is being looked up, JRebel redirects straight to the workspace • When an HTTP resource needs to be served, JRebel serves it from the workspace
  • 38. Size and speed issues
  • 39. Size and speed issues top1 and top2 are functionally identical
  • 40. Size and speed issues Method int top1() 0 aload_0 //Push the object reference(this) at index //0 of the local variable table. 1 getfield #6 <Field int intArr[]> //Pop the object reference(this) and push //the object reference for intArr accessed //from the constant pool. 4 iconst_0 //Push 0. 5 iaload //Pop the top two values and push the //value at index 0 of intArr. 6 ireturn //Pop top value and push it on the operand //stack of the invoking method. Exit.
  • 41. Size and speed issues Method int top2() 0 aload_0 1 astore_2 2 aload_2 3 monitorenter 4 aload_0 5 getfield #6 <Field int intArr[]> 8 iconst_0 //Push 0. 9 iaload 10 istore_1 11 jsr 19 14 iload_1 . 15 ireturn 16 aload_2 17 monitorexit . Exception table: //If any exception occurs between 18 athrow . from to target type //location 4 (inclusive) and location 19 astore_3 4 16 16 any //16 (exclusive) jump to location 16 20 aload_2 21 monitorexit 22 ret 3 .
  • 42. Size and speed issues top1 and top2 are functionally identical top1 is 13% faster than top2 as well as much smaller.
  • 43. Puzzle Cutting Class public class Strange2 { public class Strange1 { public static void main(String[] args) { public static void main(String[] args) { Missing m; try { try { m = new Missing(); } catch Missing m = new Missing(); } catch (java.lang.NoClassDefFoundError ex) { (java.lang.NoClassDefFoundError ex) { System.out.println("Got it!"); System.out.println("Got it!"); } } } } } } class Missing { Missing() { } }
  • 44. Puzzle Cutting Class public class Strange2 { public class Strange1 { public static void main(String[] args) { public static void main(String[] args) { Missing m; try { try { m = new Missing(); } catch Missing m = new Missing(); } catch (java.lang.NoClassDefFoundError ex) { (java.lang.NoClassDefFoundError ex) { System.out.println("Got it!"); System.out.println("Got it!"); } } } } } } class Missing { Missing() { } }
  • 45. Puzzle Cutting Class public class Strange2 { public class Strange1 { public static void main(String[] args) { public static void main(String[] args) { Missing m; try { try { m = new Missing(); } catch Missing m = new Missing(); } catch (java.lang.NoClassDefFoundError ex) { (java.lang.NoClassDefFoundError ex) { System.out.println("Got it!"); System.out.println("Got it!"); } } } } } } class Missing { Missing() { } } ??? System.out.println("Got it!"); throws an uncaught NoClassDefFoundError
  • 46. Puzzle Cutting Class public class Strange2 { public class Strange1 { public static void main(String[] args) { public static void main(String[] args) { Missing m; try { try { m = new Missing(); } catch Missing m = new Missing(); } catch (java.lang.NoClassDefFoundError ex) { (java.lang.NoClassDefFoundError ex) { System.out.println("Got it!"); System.out.println("Got it!"); } } } } class Missing { Missing() { } } System.out.println("Got it!"); Expected throws an uncaught NoClassDefFoundError throws an uncaught Result System.out.println("Got it!"); NoClassDefFoundError
  • 47. Puzzle Cutting Class 0: new #2; // class Missing 3: dup 4: invokespecial #3; // Method Missing."<init>":()V 7: astore_1 8: goto 20 11: astore_1 12: getstatic #5; // Field System.out:Ljava/io/PrintStream; 15: ldc #6; // String "Got it!" 17: invokevirtual #7; // Method PrintStream.println:(String;)V 20: return Exception table: from to target type 0 8 11 Class java/lang/NoClassDefFoundError The corresponding code for Strange2.main differs in only one instruction: 11: astore_2 //Store ex catch parameter javap -c Strange1
  • 48. Using reflection public class Strange { public static void main(String[] args) throws Exception { try { Object m = Class.forName("Missing").newInstance(); } catch (ClassNotFoundException ex) { System.err.println("Got it!"); } } }
  • 49. Benefits • Improve speed and size of your applications • Critical when debugging and doing performance and memory usage tuning • Realtime injection • Build ORM project • Clustering with AOP • Know your platform! • Create your own compile/decompiler?

Editor's Notes

  1. Добавить много Realtime примеров в Far и Inteliji Idea или Eclipse!!!!
  2. #1, #2 и т.д. храняться в пуле констант. Подробней в -verbose
  3. #1, #2 и т.д. храняться в пуле констант. Подробней в -verbose
  4. #1, #2 и т.д. храняться в пуле констант. Подробней в -verbose
  5. #1, #2 и т.д. храняться в пуле констант. Подробней в -verbose The array of local variables, also called the local variable table, contains the parameters of the method and is also used to hold the values of the local variables.
  6. Байт-кода стеко-ориентированный язык, похожий по своей структуре на ассемблер. Что бы произвести операции с данными их сначала нужно положит на стек. Мы хотим взять поле у объект. Что бы это сделять нужно его положить в стек. В байт-коде нет имен переменных, у них есть номера. Нулевой номер у ссылки на текущий объект или у переменой this. Потом идут параметры исполняемого метода. Затем остальные переменные.
  7. Each thread has a JVM stack which stores frames . A frame is created each time a method is invoked, and consists of an operand stack, an array of local variables, and a reference to the runtime constant pool of the class of the current method.
  8. Intel opcode выполняються в среде ОС, Sun opcode в среде JVM Платформы java имеется две особенности. Для обеспечения кроссплатформенности программа сначала компилируется в промежуточный язык низкого уровня - байт-код. Вторая особенность загрузка исполняемых классов происходит с помощью расширяемых classloader. Это механизм обеспечивает большую гибкость и позволяет модифицировать исполняемый код при загрузки, создавать и подгружать новые классы во время выполнения программы. Такая техника широко применяется для реализации AOP, создания тестовых фреймворков, ORM.
  9. Каждому классу в java соответствует один откомпилированный файл. Это справедливо даже для подклассов или анонимным классов. Такой файл содержит информацию об имени класса, его родители, список интерфейсов которые он реализует, перечисление его полей и методов. Важно отметить, что после компиляции информации которая содержит директива import теряется и все классы именуются теперь через полный путь. Например в место String будет записано java/lang/String.
  10. #1, #2 и т.д. храняться в пуле констант
  11. Добавить диограму с Constant pool
  12. prefix определяет тип, для которого предназначен opcode
  13. Each method has a corresponding bytecode array. These values correspond to the index into the array where each opcode and its arguments are stored. You might wonder why the values are not sequential. Since bytecode got its name because each instruction occupies one byte, why are the indexes not 0, 1, and 2? The reason is some of the opcodes have parameters that take up space in the bytecode array. For example, the aload_0 instruction has no parameters and naturally occupies one byte in the bytecode array. Therefore, the next opcode, getfield, is in location 1. However, areturn is in location 4. This is because the getfield opcode and its parameters occupy location 1, 2, and 3
  14. Class Loader при загрузке байткода проверяет его на безопастность и исправность. Больше информации про Class loader
  15. Добавить утелиты для реалных примеров (Jrebel), изменение байт кода без деплоя и тд?
  16. Создадим класс SimpleProgram с помощью библиотеки ASM
  17. Добавить диаграму разницы
  18. Добавить Realtime примеры в Far и Inteliji Idea или Eclipse!!!!
  19. Добавить Realtime примеры в Far и Inteliji Idea или Eclipse!!!!
  20. Добавить Realtime примеры в Far и Inteliji Idea или Eclipse!!!!
  21. В чем разница межжу top1 and top2 ?
  22. Они одинаковые. Методы работают с одной скоростю, если нет, то какой быстрее?
  23. Они одинаковые. Методы работают с одной скоростю, если нет, то какой быстрее?
  24. Они одинаковые. Методы работают с одной скоростю, если нет, то какой быстрее?
  25. показать байт коды классов?
  26. Strange2 хранит в astore_1 ex, а в astore_2 Missing. Strange1 хранить в a_store_1 Missing. Как же правильно сделать прверку? Обяснить подробней
  27. Правильный способ проверки наличия класса. Обяснить его подробней?