SlideShare a Scribd company logo
1 of 70
Main sponsor




Mastering Java Bytecode
       With ASM
       Anton Arhipov
Me
Anton Arhipov
JRebel @
Product manager by
day, coding monkey by
night
anton@zeroturnaround.com
@antonarhipov
Bytecode
• One-byte instructions
• 256 possible opcodes (200+ in use)
• Stack based (pop, push)
ASM
• Low-level API for bytecode crunching
  • Core API – visitors
  • Tree API – nodes
    • Analysis package
• http://asm.ow2.org
Why?
• Compilers for JVM
• Programming model (AOP, ORM)
• Awesome tools for JVM
public class Items implements Serializable {
  private List<Integer> ids
       = new ArrayList<Integer>();
  {
    ids.add(1);
    ids.add(100);
    ids.add(100000);
  }

    public int getId(int i) {
      return ids.get(i);
    }
}
public class Items implements Serializable {
  private List<Integer> ids
       = new ArrayList<Integer>();
  {
    ids.add(1);
    ids.add(100);
    ids.add(100000);
  }

    public int getId(int i) {
      return ids.get(i);
    }
}
public class Items implements Serializable {
  private List<Integer> ids
       = new ArrayList<Integer>();
  {
    ids.add(1);
    ids.add(100);
    ids.add(100000);
  }

    public int getId(int i) {
      return ids.get(i);
    }
}
public class Items implements Serializable {
  private List<Integer> ids
       = new ArrayList<Integer>();
  {
    ids.add(1);
    ids.add(100);
    ids.add(100000);
  }

    public int getId(int i) {
      return ids.get(i);
    }
}
public class Items implements Serializable {
  private List<Integer> ids
       = new ArrayList<Integer>();
  {
    ids.add(1);
    ids.add(100);
    ids.add(100000);
  }

    public int getId(int i) {
      return ids.get(i);
    }
}
Basic Process
• Construct ClassWriter
• Stack up the visitors for:
  • annotations, methods, fields, etc
• Write out bytes
javap
ClassWriter

ClassWriter cw = new ClassWriter(
     ClassWriter.COMPUTE_MAXS |
     ClassWriter.COMPUTE_FRAMES);
Visit Class
cw.visit(
   Opcodes.V1_6,
   Opcodes.ACC_PUBLIC,
   "zt/asm/Items",
   null,
   "java/lang/Object",
   new String[]
    {"java/io/Serializable"});
Visit Class
cw.visit(
   Opcodes.V1_6,
   Opcodes.ACC_PUBLIC,
   "zt/asm/Items",
   null,
   "java/lang/Object",
   new String[]
    {"java/io/Serializable"});
Visit Class
cw.visit(
   Opcodes.V1_6,
   Opcodes.ACC_PUBLIC,
   "zt/asm/Items",
   null,
   "java/lang/Object",
   new String[]
    {"java/io/Serializable"});
Visit Class
cw.visit(
   Opcodes.V1_6,
   Opcodes.ACC_PUBLIC,
   "zt/asm/Items",
   null,
   "java/lang/Object",
   new String[]
    {"java/io/Serializable"});
Visit Class
cw.visit(
   Opcodes.V1_6,
   Opcodes.ACC_PUBLIC,
   "zt/asm/Items",
   null,
   "java/lang/Object",
   new String[]
    {"java/io/Serializable"});
Field
private List<Integer> ids
       = new ArrayList<Integer>();




private List<Integer> ids;
public Items() {
  ids = new ArrayList<Integer>();
}
Visit Field
FieldVisitor fv = cw.visitField(
Opcodes.ACC_PRIVATE,
"ids",
"Ljava/util/List;",
"Ljava/util/List<Lj/l/Integer;>;",
 null);
Visit Field
FieldVisitor fv = cw.visitField(
Opcodes.ACC_PRIVATE,
"ids",
"Ljava/util/List;",
"Ljava/util/List<Lj/l/Integer;>;",
 null);
Descriptor

• Primitives
  • B, C, S, I, J, F, D, Z, V
• References
  • Ljava/lang/Object;
• Arrays
  • Prefixed with [, i.e. [Ljava/lang/Object;
Descriptor

  Ljava/util/List;

([Ljava/lang/String;)V
org.objectweb.asm.Type


Type.getObjectType("java/lang/String")

         Ljava/lang/String;
Visit Method

MethodVisitor constructor =
   cw.visitMethod(
      Opcodes.ACC_PUBLIC,
      "<init>",
      "()V",
      null,
      null);
Visit Method

MethodVisitor get =
   cw.visitMethod(
      Opcodes.ACC_PUBLIC,
      "get",
      "(I)I",
      null,
      null);
public class Items implements Serializable {
  private List<Integer> ids
       = new ArrayList<Integer>();
  {
    ids.add(1);
    ids.add(100);
    ids.add(100000);
  }

    public int getId(int i) {
      return ids.get(i);
    }
}
public class Items implements Serializable {
  private List<Integer> ids
       = new ArrayList<Integer>();
  {
    ids.add(1);
    ids.add(100);
    ids.add(100000);
  }

    public int getId(int i) {
      return ids.get(i);
    }
}
public Items() {
    super();

    ids = new ArrayList<Integer>();

    ids.add(1);
    ids.add(100);
    ids.add(100000);
}
public Items() {
    super();

    ids = new ArrayList<Integer>();

    ids.add(1);
    ids.add(100);
    ids.add(100000);
}
super()
   0: aload_0
   1: invokespecial #1 // Object.<init>


MethodVisitor mv = …
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL,
 "java/lang/Object", "<init>", "()V");
public Items() {
    super();

    ids = new ArrayList<Integer>();

    ids.add(1);
    ids.add(100);
    ids.add(100000);
}
public Items() {
    super();

    ids = new ArrayList<Integer>();

    ids.add(1);
    ids.add(100);
    ids.add(100000);
}
Assignment
 4:   aload_0
 5:   new           #2 // ArrayList
 8:   dup
 9:   invokespecial #3 // <init>
12:   putfield      #4 // ids
Assignment
                       Create instance
 4:   aload_0
 5:   new           #2 // ArrayList
 8:   dup
 9:   invokespecial #3 // <init>
12:   putfield      #4 // ids
Assignment
 4:   aload_0
 5:   new           #2 // ArrayList
 8:   dup
 9:   invokespecial #3 // <init>
12:   putfield      #4 // ids

              Assign to a field
Assignment

 5:   new           #2 // ArrayList
 8:   dup
 9:   invokespecial #3 // <init>
12:   astore_1      #4 // ids

              Assign to local variable
Assignment
mv.visitVarInsn(ALOAD, 0);
mv.visitTypeInsn(NEW, "java/util/ArrayList");
mv.visitInsn(DUP);
mv.visitMethodInsn(INVOKESPECIAL,
"java/util/ArrayList", "<init>", "()V");
mv.visitFieldInsn(PUTFIELD,
"zt/asm/Items", "ids", "Ljava/util/List;");
Assignment
mv.visitVarInsn(ALOAD, 0);
mv.visitTypeInsn(NEW, "java/util/ArrayList");
mv.visitInsn(DUP);
mv.visitMethodInsn(INVOKESPECIAL,
"java/util/ArrayList", "<init>", "()V");
mv.visitFieldInsn(PUTFIELD,
"zt/asm/Items", "ids", "Ljava/util/List;");
public Items() {
    super();

    ids = new ArrayList<Integer>();

    ids.add(1);
    ids.add(100);
    ids.add(100000);
}
public Items() {
    super();

    ids = new ArrayList<Integer>();

    ids.add(1);
    ids.add(100);
    ids.add(100000);
}
ids.add(1)

15:   aload_0
16:   getfield   #4 // ids
19:   iconst_1
20:   invokestatic #5 // Integer.valueOf
23:   invokeinterface #6, 2 // List.add
28:   pop
ids.add(1)

15:   aload_0
16:   getfield   #4 // ids
19:   iconst_1
20:   invokestatic #5 // Integer.valueOf
23:   invokeinterface #6, 2 // List.add
28:   pop
ids.add(1)

15:   aload_0
16:   getfield   #4 // ids
19:   iconst_1
20:   invokestatic #5 // Integer.valueOf
23:   invokeinterface #6, 2 // List.add
28:   pop
ids.add(1)

15:   aload_0
16:   getfield   #4 // ids
19:   iconst_1
20:   invokestatic #5 // Integer.valueOf
23:   invokeinterface #6, 2 // List.add
28:   pop
ids.add(1)

15:   aload_0
16:   getfield   #4 // ids
19:   iconst_1
20:   invokestatic #5 // Integer.valueOf
23:   invokeinterface #6, 2 // List.add
28:   pop
ids.add(1)

15:   aload_0
16:   getfield   #4 // ids
19:   iconst_1
20:   invokestatic #5 // Integer.valueOf
23:   invokeinterface #6, 2 // List.add
28:   pop
ids.add(100)

15:   aload_0
16:   getfield   #4 // ids
19:   bipush 100
20:   invokestatic #5 // Integer.valueOf
23:   invokeinterface #6, 2 // List.add
28:   pop
ids.add(100_000)

15:   aload_0
16:   getfield   #4 // ids
19:   ldc #7 // int 100000
20:   invokestatic #5 // Integer.valueOf
23:   invokeinterface #6, 2 // List.add
28:   pop
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD,
"zt/asm/Items", "ids",
"Ljava/util/List;");
mv.visitInsn(ICONST_1);
mv.visitMethodInsn(INVOKESTATIC, "java/lang
/Integer", "valueOf", "(I)Ljava/lang/Intege
r;");
mv.visitMethodInsn(INVOKEINTERFACE, "java/u
til/List", "add", "(Ljava/lang/Object;)Z");
mv.visitInsn(POP);
public class Items implements Serializable {
  private List<Integer> ids
       = new ArrayList<Integer>();
  {
    ids.add(1);
    ids.add(100);
    ids.add(100000);
  }

    public int getId(int i) {
      return ids.get(i);
    }
}
ASMified
mv = cw.visitMethod(ACC_PUBLIC, "getId", "(I)I", null, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitLineNumber(16, l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, "zt/asm/Items", "ids", "Ljava/util/List;");
mv.visitVarInsn(ILOAD, 1);
mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List",
                                    "get", "(I)Ljava/lang/Object;");
mv.visitTypeInsn(CHECKCAST, "java/lang/Integer");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer",
                                  "intValue", "()I");
mv.visitInsn(IRETURN);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLocalVariable("this", "Lzt/asm/Items;", null, l0, l1, 0);
mv.visitLocalVariable("i", "I", null, l0, l1, 1);
mv.visitMaxs(2, 2);
mv.visitEnd();
ASMified
mv = cw.visitMethod(ACC_PUBLIC, "getId", "(I)I", null, null);
mv.visitCode();
Label l0 = new Label();
  java -cp asm-all-3.3.1.jar:asm-util-3.3.1.jar 
mv.visitLabel(l0);
mv.visitLineNumber(16, l0);
  org.objectweb.asm.util.ASMifierClassVisitor 
mv.visitVarInsn(ALOAD, 0);
  Items.class
mv.visitFieldInsn(GETFIELD, "zt/asm/Items", "ids", "Ljava/util/List;");
mv.visitVarInsn(ILOAD, 1);
mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List",
                                    "get", "(I)Ljava/lang/Object;");
mv.visitTypeInsn(CHECKCAST, "java/lang/Integer");
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer",
                                  "intValue", "()I");
mv.visitInsn(IRETURN);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLocalVariable("this", "Lzt/asm/Items;", null, l0, l1, 0);
mv.visitLocalVariable("i", "I", null, l0, l1, 1);
mv.visitMaxs(2, 2);
mv.visitEnd();
javap
public class zt.asm.deg.Items {
  public java.util.List<java.lang.Integer> ids;

    public int getId(int);
       Code:
         0: aload_0
         1: getfield          #4
         4: iload_1
         5: invokeinterface   #8,   2
        10: checkcast         #9
        13: invokevirtual     #10
        16: ireturn
}
Groovyfied
public class zt/asm/Items {
   public Ljava/util/List; ids

    @groovyx.ast.bytecode.Bytecode
    public int getId(int a) {
       aload 0
       getfield zt.asm.Items.ids >> List
       iload 1
       invokeinterface List.get(int) >> Object
       checkcast Integer
       invokevirtual Integer.intValue() >> int
       ireturn
    }
}
                 https://github.com/melix/groovy-bytecode-ast
Generating bytecode
            from scratch
                     is too simple …

Transforming the bytecode is
               much more fun! 
Instrument
  some bytecode
Ninja.class   Ninja.class’
10101010101   10101010101
11000101010   11100001010
10101010001   10101010001
00010001110   00010001110
11011101011   11011101110
How?
• Add –javaagent to hook into class loading
  process
• Implement ClassFileTransformer
• Use bytecode manipulation libraries
  (Javassist, cglib, asm) to add any custom logic

            java.lang.instrument
How ? (2)
• Use custom ClassLoader
  – Override ClassLoader#findClass
  – Use ClassReader(String) to read the class
    in and transform it via visitor chain
  – Call ClassLoader#defineClass explicitly
    with the result from the transformation
    step
java.lang.instrument

import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;

public class Agent {
public static void premain(String args, Instrumentation inst)
  { inst.addTransformer(new ClassFileTransformer(), true); }

public static void agentmain(String args, Instrumentation inst)
  { premain(args,inst); }
}
java.lang.instrument

import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;

public class Agent {
public static void premain(String args, Instrumentation inst)
  { inst.addTransformer(new ClassFileTransformer(), true); }

public static void agentmain(String args, Instrumentation inst)
  { premain(args,inst); }
}
java.lang.instrument

import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;

public class Agent {
public static void premain(String args, Instrumentation inst)
  { inst.addTransformer(new ClassFileTransformer(), true); }

public static void agentmain(String args, Instrumentation inst)
  { premain(args,inst); }
}
   META-INF/MANIFEST.MF
   Premain-Class: Agent
                               java –javaagent:agent.jar …
   Agent-Class: Agent
j.l.instrument.ClassFileTransformer
new ClassFileTransformer() {
  public byte[] transform(ClassLoader loader, String className,
                          Class<?>classBeingRedefined,
                          ProtectionDomain protectionDomain,
                          byte[] classfileBuffer){

    ClassReader cr = new ClassReader(classfileBuffer);
    ClassWriter cw = new ClassWriter(cr,
                     ClassWriter.COMPUTE_MAXS |
                     ClassWriter.COMPUTE_FRAMES);
    MyAdapter ca = new MyAdapter(cw);
    cr.accept(ca, ClassReader.EXPAND_FRAMES);
    return cw.toByteArray();
}
j.l.instrument.ClassFileTransformer
new ClassFileTransformer() {
  public byte[] transform(ClassLoader loader, String className,
                          Class<?>classBeingRedefined,
                          ProtectionDomain protectionDomain,
                          byte[] classfileBuffer){

    ClassReader cr = new ClassReader(classfileBuffer);
    ClassWriter cw = new ClassWriter(cr,
                     ClassWriter.COMPUTE_MAXS |
                     ClassWriter.COMPUTE_FRAMES);
    MyAdapter ca = new MyAdapter(cw);
    cr.accept(ca, ClassReader.EXPAND_FRAMES);
    return cw.toByteArray();
}
j.l.instrument.ClassFileTransformer
new ClassFileTransformer() {
  public byte[] transform(ClassLoader loader, String className,
                          Class<?>classBeingRedefined,
                          ProtectionDomain protectionDomain,
                          byte[] classfileBuffer){

    ClassReader cr = new ClassReader(classfileBuffer);
    ClassWriter cw = new ClassWriter(cr,
                     ClassWriter.COMPUTE_MAXS |
                     ClassWriter.COMPUTE_FRAMES);

    MyAdapter ca = new MyAdapter(cw);
    cr.accept(ca, ClassReader.EXPAND_FRAMES);
    return cw.toByteArray();
}
public class MyClassLoader extends ClassLoader {

 protected Class findClass(String name)
                          throws ClassNotFoundException {

     ClassReader cr = new ClassReader(name);
     ClassWriter cw = new ClassWriter(cr,
                          ClassWriter.COMPUTE_MAXS |
                          ClassWriter.COMPUTE_FRAMES);

     MyClassAdapter ca =
             new MyClassAdapter(cw);
     cr.accept(ca, ClassReader.EXPAND_FRAMES);

     byte b[] = cw.toByteArray();
     return defineClass(name, b, 0, b.length);
 }
SLIDES
GOTO IDE
SLIDES
IDE: DEMO
@antonarhipov

anton@zeroturnaround.com

More Related Content

What's hot

Scalaで型クラス入門
Scalaで型クラス入門Scalaで型クラス入門
Scalaで型クラス入門Makoto Fukuhara
 
F#によるFunctional Programming入門
F#によるFunctional Programming入門F#によるFunctional Programming入門
F#によるFunctional Programming入門bleis tift
 
『例えば、PHPを避ける』以降PHPはどれだけ安全になったか
『例えば、PHPを避ける』以降PHPはどれだけ安全になったか『例えば、PHPを避ける』以降PHPはどれだけ安全になったか
『例えば、PHPを避ける』以降PHPはどれだけ安全になったかHiroshi Tokumaru
 
30分で分かる!OSの作り方
30分で分かる!OSの作り方30分で分かる!OSの作り方
30分で分かる!OSの作り方uchan_nos
 
MicrometerとPrometheusによる LINEファミリーアプリのモニタリング
MicrometerとPrometheusによる LINEファミリーアプリのモニタリングMicrometerとPrometheusによる LINEファミリーアプリのモニタリング
MicrometerとPrometheusによる LINEファミリーアプリのモニタリングLINE Corporation
 
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門tamtam180
 
設計書自動生成への取り組み~手書き設計書から脱却するには?~
設計書自動生成への取り組み~手書き設計書から脱却するには?~設計書自動生成への取り組み~手書き設計書から脱却するには?~
設計書自動生成への取り組み~手書き設計書から脱却するには?~SystemIntegrator2
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeAngel Boy
 
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Christian Schneider
 
ROP 輕鬆談
ROP 輕鬆談ROP 輕鬆談
ROP 輕鬆談hackstuff
 
君はyarn.lockをコミットしているか?
君はyarn.lockをコミットしているか?君はyarn.lockをコミットしているか?
君はyarn.lockをコミットしているか?Teppei Sato
 
プログラムの処方箋~健康なコードと病んだコード
プログラムの処方箋~健康なコードと病んだコードプログラムの処方箋~健康なコードと病んだコード
プログラムの処方箋~健康なコードと病んだコードShigenori Sagawa
 
Spring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutesSpring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutesVMware Tanzu
 
Dalvik仮想マシンのアーキテクチャ 改訂版
Dalvik仮想マシンのアーキテクチャ 改訂版Dalvik仮想マシンのアーキテクチャ 改訂版
Dalvik仮想マシンのアーキテクチャ 改訂版Takuya Matsunaga
 
PlaySQLAlchemy: SQLAlchemy入門
PlaySQLAlchemy: SQLAlchemy入門PlaySQLAlchemy: SQLAlchemy入門
PlaySQLAlchemy: SQLAlchemy入門泰 増田
 
Introduction to Java 11
Introduction to Java 11 Introduction to Java 11
Introduction to Java 11 Knoldus Inc.
 

What's hot (20)

Scalaで型クラス入門
Scalaで型クラス入門Scalaで型クラス入門
Scalaで型クラス入門
 
F#によるFunctional Programming入門
F#によるFunctional Programming入門F#によるFunctional Programming入門
F#によるFunctional Programming入門
 
『例えば、PHPを避ける』以降PHPはどれだけ安全になったか
『例えば、PHPを避ける』以降PHPはどれだけ安全になったか『例えば、PHPを避ける』以降PHPはどれだけ安全になったか
『例えば、PHPを避ける』以降PHPはどれだけ安全になったか
 
30分で分かる!OSの作り方
30分で分かる!OSの作り方30分で分かる!OSの作り方
30分で分かる!OSの作り方
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 
MicrometerとPrometheusによる LINEファミリーアプリのモニタリング
MicrometerとPrometheusによる LINEファミリーアプリのモニタリングMicrometerとPrometheusによる LINEファミリーアプリのモニタリング
MicrometerとPrometheusによる LINEファミリーアプリのモニタリング
 
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
Introduction httpClient on Java11 / Java11時代のHTTPアクセス再入門
 
設計書自動生成への取り組み~手書き設計書から脱却するには?~
設計書自動生成への取り組み~手書き設計書から脱却するには?~設計書自動生成への取り組み~手書き設計書から脱却するには?~
設計書自動生成への取り組み~手書き設計書から脱却するには?~
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledge
 
C++ Interview Questions
C++ Interview QuestionsC++ Interview Questions
C++ Interview Questions
 
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
 
ROP 輕鬆談
ROP 輕鬆談ROP 輕鬆談
ROP 輕鬆談
 
君はyarn.lockをコミットしているか?
君はyarn.lockをコミットしているか?君はyarn.lockをコミットしているか?
君はyarn.lockをコミットしているか?
 
プログラムの処方箋~健康なコードと病んだコード
プログラムの処方箋~健康なコードと病んだコードプログラムの処方箋~健康なコードと病んだコード
プログラムの処方箋~健康なコードと病んだコード
 
Spring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutesSpring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutes
 
Dalvik仮想マシンのアーキテクチャ 改訂版
Dalvik仮想マシンのアーキテクチャ 改訂版Dalvik仮想マシンのアーキテクチャ 改訂版
Dalvik仮想マシンのアーキテクチャ 改訂版
 
PlaySQLAlchemy: SQLAlchemy入門
PlaySQLAlchemy: SQLAlchemy入門PlaySQLAlchemy: SQLAlchemy入門
PlaySQLAlchemy: SQLAlchemy入門
 
Introduction to Java 11
Introduction to Java 11 Introduction to Java 11
Introduction to Java 11
 
Metaspace
MetaspaceMetaspace
Metaspace
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 

Viewers also liked

Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Anton Arhipov
 
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...srisatish ambati
 
JVM, byte codes & jvm languages
JVM, byte codes & jvm languagesJVM, byte codes & jvm languages
JVM, byte codes & jvm languagesEdgar Espina
 
JavaOne 2012 CON 3961 Innovative Testing Techniques Using Bytecode Instrument...
JavaOne 2012 CON 3961 Innovative Testing Techniques Using Bytecode Instrument...JavaOne 2012 CON 3961 Innovative Testing Techniques Using Bytecode Instrument...
JavaOne 2012 CON 3961 Innovative Testing Techniques Using Bytecode Instrument...PaulThwaite
 
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 2011Anton Arhipov
 
Java bytecode and classes
Java bytecode and classesJava bytecode and classes
Java bytecode and classesyoavwix
 
Make Java Profilers Lie Less
Make Java Profilers Lie LessMake Java Profilers Lie Less
Make Java Profilers Lie LessJaroslav Bachorik
 
GeeCon2016- High Performance Instrumentation (handout)
GeeCon2016- High Performance Instrumentation (handout)GeeCon2016- High Performance Instrumentation (handout)
GeeCon2016- High Performance Instrumentation (handout)Jaroslav Bachorik
 

Viewers also liked (8)

Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
 
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
 
JVM, byte codes & jvm languages
JVM, byte codes & jvm languagesJVM, byte codes & jvm languages
JVM, byte codes & jvm languages
 
JavaOne 2012 CON 3961 Innovative Testing Techniques Using Bytecode Instrument...
JavaOne 2012 CON 3961 Innovative Testing Techniques Using Bytecode Instrument...JavaOne 2012 CON 3961 Innovative Testing Techniques Using Bytecode Instrument...
JavaOne 2012 CON 3961 Innovative Testing Techniques Using Bytecode Instrument...
 
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
 
Java bytecode and classes
Java bytecode and classesJava bytecode and classes
Java bytecode and classes
 
Make Java Profilers Lie Less
Make Java Profilers Lie LessMake Java Profilers Lie Less
Make Java Profilers Lie Less
 
GeeCon2016- High Performance Instrumentation (handout)
GeeCon2016- High Performance Instrumentation (handout)GeeCon2016- High Performance Instrumentation (handout)
GeeCon2016- High Performance Instrumentation (handout)
 

Similar to Mastering Java Bytecode With ASM - 33rd degree, 2012

Open Source Search: An Analysis
Open Source Search: An AnalysisOpen Source Search: An Analysis
Open Source Search: An AnalysisJustin Finkelstein
 
Real World Generics In Swift
Real World Generics In SwiftReal World Generics In Swift
Real World Generics In SwiftVadym Markov
 
jQuery - Introdução
jQuery - IntroduçãojQuery - Introdução
jQuery - IntroduçãoGustavo Dutra
 
JQuery do dia-a-dia Gustavo Dutra
JQuery do dia-a-dia Gustavo DutraJQuery do dia-a-dia Gustavo Dutra
JQuery do dia-a-dia Gustavo DutraTchelinux
 
Persisting Data on SQLite using Room
Persisting Data on SQLite using RoomPersisting Data on SQLite using Room
Persisting Data on SQLite using RoomNelson Glauber Leal
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvmIsaias Barroso
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationJoni
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
Devoxx 2012 hibernate envers
Devoxx 2012   hibernate enversDevoxx 2012   hibernate envers
Devoxx 2012 hibernate enversRomain Linsolas
 
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developersSoftshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developersMatthew Farwell
 
JavaScript and the AST
JavaScript and the ASTJavaScript and the AST
JavaScript and the ASTJarrod Overson
 
Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsJarod Ferguson
 
Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CAlexis Gallagher
 

Similar to Mastering Java Bytecode With ASM - 33rd degree, 2012 (20)

Open Source Search: An Analysis
Open Source Search: An AnalysisOpen Source Search: An Analysis
Open Source Search: An Analysis
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Real World Generics In Swift
Real World Generics In SwiftReal World Generics In Swift
Real World Generics In Swift
 
jQuery - Introdução
jQuery - IntroduçãojQuery - Introdução
jQuery - Introdução
 
JQuery do dia-a-dia Gustavo Dutra
JQuery do dia-a-dia Gustavo DutraJQuery do dia-a-dia Gustavo Dutra
JQuery do dia-a-dia Gustavo Dutra
 
Persisting Data on SQLite using Room
Persisting Data on SQLite using RoomPersisting Data on SQLite using Room
Persisting Data on SQLite using Room
 
Spine JS
Spine JSSpine JS
Spine JS
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvm
 
Miracle of std lib
Miracle of std libMiracle of std lib
Miracle of std lib
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introduction
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET Application
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Devoxx 2012 hibernate envers
Devoxx 2012   hibernate enversDevoxx 2012   hibernate envers
Devoxx 2012 hibernate envers
 
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developersSoftshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
 
JavaScript and the AST
JavaScript and the ASTJavaScript and the AST
JavaScript and the AST
 
Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.js
 
Jason parsing
Jason parsingJason parsing
Jason parsing
 
Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-C
 
Test
TestTest
Test
 

More from Anton Arhipov

JavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdfJavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdfAnton Arhipov
 
TechTrain 2019 - (Не)адекватное техническое интервью
TechTrain 2019 - (Не)адекватное техническое интервьюTechTrain 2019 - (Не)адекватное техническое интервью
TechTrain 2019 - (Не)адекватное техническое интервьюAnton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCityBuild pipelines with TeamCity
Build pipelines with TeamCityAnton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCityBuild pipelines with TeamCity
Build pipelines with TeamCityAnton Arhipov
 
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 hourAnton Arhipov
 
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 hourAnton Arhipov
 
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 DSLAnton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCityBuild pipelines with TeamCity
Build pipelines with TeamCityAnton Arhipov
 
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 TestContainersAnton Arhipov
 
GeeCON Prague 2017 - TestContainers
GeeCON Prague 2017 - TestContainersGeeCON Prague 2017 - TestContainers
GeeCON Prague 2017 - TestContainersAnton Arhipov
 
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 reloadingAnton Arhipov
 
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 hassleAnton Arhipov
 
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 reloadingAnton Arhipov
 
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 reloadingAnton Arhipov
 
JUG.ua 20170225 - Java bytecode instrumentation
JUG.ua 20170225 - Java bytecode instrumentationJUG.ua 20170225 - Java bytecode instrumentation
JUG.ua 20170225 - Java bytecode instrumentationAnton 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 reloadingAnton Arhipov
 
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 hassleAnton Arhipov
 
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 reloadingAnton Arhipov
 
JEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with JavassistJEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with JavassistAnton Arhipov
 

More from 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
 

Recently uploaded

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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.pptxHampshireHUG
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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 textsMaria Levchenko
 
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 slidevu2urc
 
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 WorkerThousandEyes
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Recently uploaded (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 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
 
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
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Mastering Java Bytecode With ASM - 33rd degree, 2012

  • 1. Main sponsor Mastering Java Bytecode With ASM Anton Arhipov
  • 2. Me Anton Arhipov JRebel @ Product manager by day, coding monkey by night anton@zeroturnaround.com @antonarhipov
  • 3. Bytecode • One-byte instructions • 256 possible opcodes (200+ in use) • Stack based (pop, push)
  • 4. ASM • Low-level API for bytecode crunching • Core API – visitors • Tree API – nodes • Analysis package • http://asm.ow2.org
  • 5. Why? • Compilers for JVM • Programming model (AOP, ORM) • Awesome tools for JVM
  • 6.
  • 7. public class Items implements Serializable { private List<Integer> ids = new ArrayList<Integer>(); { ids.add(1); ids.add(100); ids.add(100000); } public int getId(int i) { return ids.get(i); } }
  • 8. public class Items implements Serializable { private List<Integer> ids = new ArrayList<Integer>(); { ids.add(1); ids.add(100); ids.add(100000); } public int getId(int i) { return ids.get(i); } }
  • 9. public class Items implements Serializable { private List<Integer> ids = new ArrayList<Integer>(); { ids.add(1); ids.add(100); ids.add(100000); } public int getId(int i) { return ids.get(i); } }
  • 10. public class Items implements Serializable { private List<Integer> ids = new ArrayList<Integer>(); { ids.add(1); ids.add(100); ids.add(100000); } public int getId(int i) { return ids.get(i); } }
  • 11. public class Items implements Serializable { private List<Integer> ids = new ArrayList<Integer>(); { ids.add(1); ids.add(100); ids.add(100000); } public int getId(int i) { return ids.get(i); } }
  • 12. Basic Process • Construct ClassWriter • Stack up the visitors for: • annotations, methods, fields, etc • Write out bytes
  • 13. javap
  • 14. ClassWriter ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
  • 15. Visit Class cw.visit( Opcodes.V1_6, Opcodes.ACC_PUBLIC, "zt/asm/Items", null, "java/lang/Object", new String[] {"java/io/Serializable"});
  • 16. Visit Class cw.visit( Opcodes.V1_6, Opcodes.ACC_PUBLIC, "zt/asm/Items", null, "java/lang/Object", new String[] {"java/io/Serializable"});
  • 17. Visit Class cw.visit( Opcodes.V1_6, Opcodes.ACC_PUBLIC, "zt/asm/Items", null, "java/lang/Object", new String[] {"java/io/Serializable"});
  • 18. Visit Class cw.visit( Opcodes.V1_6, Opcodes.ACC_PUBLIC, "zt/asm/Items", null, "java/lang/Object", new String[] {"java/io/Serializable"});
  • 19. Visit Class cw.visit( Opcodes.V1_6, Opcodes.ACC_PUBLIC, "zt/asm/Items", null, "java/lang/Object", new String[] {"java/io/Serializable"});
  • 20. Field private List<Integer> ids = new ArrayList<Integer>(); private List<Integer> ids; public Items() { ids = new ArrayList<Integer>(); }
  • 21. Visit Field FieldVisitor fv = cw.visitField( Opcodes.ACC_PRIVATE, "ids", "Ljava/util/List;", "Ljava/util/List<Lj/l/Integer;>;", null);
  • 22. Visit Field FieldVisitor fv = cw.visitField( Opcodes.ACC_PRIVATE, "ids", "Ljava/util/List;", "Ljava/util/List<Lj/l/Integer;>;", null);
  • 23. Descriptor • Primitives • B, C, S, I, J, F, D, Z, V • References • Ljava/lang/Object; • Arrays • Prefixed with [, i.e. [Ljava/lang/Object;
  • 26. Visit Method MethodVisitor constructor = cw.visitMethod( Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
  • 27. Visit Method MethodVisitor get = cw.visitMethod( Opcodes.ACC_PUBLIC, "get", "(I)I", null, null);
  • 28. public class Items implements Serializable { private List<Integer> ids = new ArrayList<Integer>(); { ids.add(1); ids.add(100); ids.add(100000); } public int getId(int i) { return ids.get(i); } }
  • 29. public class Items implements Serializable { private List<Integer> ids = new ArrayList<Integer>(); { ids.add(1); ids.add(100); ids.add(100000); } public int getId(int i) { return ids.get(i); } }
  • 30. public Items() { super(); ids = new ArrayList<Integer>(); ids.add(1); ids.add(100); ids.add(100000); }
  • 31. public Items() { super(); ids = new ArrayList<Integer>(); ids.add(1); ids.add(100); ids.add(100000); }
  • 32. super() 0: aload_0 1: invokespecial #1 // Object.<init> MethodVisitor mv = … mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
  • 33. public Items() { super(); ids = new ArrayList<Integer>(); ids.add(1); ids.add(100); ids.add(100000); }
  • 34. public Items() { super(); ids = new ArrayList<Integer>(); ids.add(1); ids.add(100); ids.add(100000); }
  • 35. Assignment 4: aload_0 5: new #2 // ArrayList 8: dup 9: invokespecial #3 // <init> 12: putfield #4 // ids
  • 36. Assignment Create instance 4: aload_0 5: new #2 // ArrayList 8: dup 9: invokespecial #3 // <init> 12: putfield #4 // ids
  • 37. Assignment 4: aload_0 5: new #2 // ArrayList 8: dup 9: invokespecial #3 // <init> 12: putfield #4 // ids Assign to a field
  • 38. Assignment 5: new #2 // ArrayList 8: dup 9: invokespecial #3 // <init> 12: astore_1 #4 // ids Assign to local variable
  • 41. public Items() { super(); ids = new ArrayList<Integer>(); ids.add(1); ids.add(100); ids.add(100000); }
  • 42. public Items() { super(); ids = new ArrayList<Integer>(); ids.add(1); ids.add(100); ids.add(100000); }
  • 43. ids.add(1) 15: aload_0 16: getfield #4 // ids 19: iconst_1 20: invokestatic #5 // Integer.valueOf 23: invokeinterface #6, 2 // List.add 28: pop
  • 44. ids.add(1) 15: aload_0 16: getfield #4 // ids 19: iconst_1 20: invokestatic #5 // Integer.valueOf 23: invokeinterface #6, 2 // List.add 28: pop
  • 45. ids.add(1) 15: aload_0 16: getfield #4 // ids 19: iconst_1 20: invokestatic #5 // Integer.valueOf 23: invokeinterface #6, 2 // List.add 28: pop
  • 46. ids.add(1) 15: aload_0 16: getfield #4 // ids 19: iconst_1 20: invokestatic #5 // Integer.valueOf 23: invokeinterface #6, 2 // List.add 28: pop
  • 47. ids.add(1) 15: aload_0 16: getfield #4 // ids 19: iconst_1 20: invokestatic #5 // Integer.valueOf 23: invokeinterface #6, 2 // List.add 28: pop
  • 48. ids.add(1) 15: aload_0 16: getfield #4 // ids 19: iconst_1 20: invokestatic #5 // Integer.valueOf 23: invokeinterface #6, 2 // List.add 28: pop
  • 49. ids.add(100) 15: aload_0 16: getfield #4 // ids 19: bipush 100 20: invokestatic #5 // Integer.valueOf 23: invokeinterface #6, 2 // List.add 28: pop
  • 50. ids.add(100_000) 15: aload_0 16: getfield #4 // ids 19: ldc #7 // int 100000 20: invokestatic #5 // Integer.valueOf 23: invokeinterface #6, 2 // List.add 28: pop
  • 51. mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, "zt/asm/Items", "ids", "Ljava/util/List;"); mv.visitInsn(ICONST_1); mv.visitMethodInsn(INVOKESTATIC, "java/lang /Integer", "valueOf", "(I)Ljava/lang/Intege r;"); mv.visitMethodInsn(INVOKEINTERFACE, "java/u til/List", "add", "(Ljava/lang/Object;)Z"); mv.visitInsn(POP);
  • 52. public class Items implements Serializable { private List<Integer> ids = new ArrayList<Integer>(); { ids.add(1); ids.add(100); ids.add(100000); } public int getId(int i) { return ids.get(i); } }
  • 53. ASMified mv = cw.visitMethod(ACC_PUBLIC, "getId", "(I)I", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitLineNumber(16, l0); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, "zt/asm/Items", "ids", "Ljava/util/List;"); mv.visitVarInsn(ILOAD, 1); mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;"); mv.visitTypeInsn(CHECKCAST, "java/lang/Integer"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I"); mv.visitInsn(IRETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", "Lzt/asm/Items;", null, l0, l1, 0); mv.visitLocalVariable("i", "I", null, l0, l1, 1); mv.visitMaxs(2, 2); mv.visitEnd();
  • 54. ASMified mv = cw.visitMethod(ACC_PUBLIC, "getId", "(I)I", null, null); mv.visitCode(); Label l0 = new Label(); java -cp asm-all-3.3.1.jar:asm-util-3.3.1.jar mv.visitLabel(l0); mv.visitLineNumber(16, l0); org.objectweb.asm.util.ASMifierClassVisitor mv.visitVarInsn(ALOAD, 0); Items.class mv.visitFieldInsn(GETFIELD, "zt/asm/Items", "ids", "Ljava/util/List;"); mv.visitVarInsn(ILOAD, 1); mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;"); mv.visitTypeInsn(CHECKCAST, "java/lang/Integer"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I"); mv.visitInsn(IRETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", "Lzt/asm/Items;", null, l0, l1, 0); mv.visitLocalVariable("i", "I", null, l0, l1, 1); mv.visitMaxs(2, 2); mv.visitEnd();
  • 55. javap public class zt.asm.deg.Items { public java.util.List<java.lang.Integer> ids; public int getId(int); Code: 0: aload_0 1: getfield #4 4: iload_1 5: invokeinterface #8, 2 10: checkcast #9 13: invokevirtual #10 16: ireturn }
  • 56. Groovyfied public class zt/asm/Items { public Ljava/util/List; ids @groovyx.ast.bytecode.Bytecode public int getId(int a) { aload 0 getfield zt.asm.Items.ids >> List iload 1 invokeinterface List.get(int) >> Object checkcast Integer invokevirtual Integer.intValue() >> int ireturn } } https://github.com/melix/groovy-bytecode-ast
  • 57. Generating bytecode from scratch is too simple … Transforming the bytecode is much more fun! 
  • 58. Instrument some bytecode
  • 59. Ninja.class Ninja.class’ 10101010101 10101010101 11000101010 11100001010 10101010001 10101010001 00010001110 00010001110 11011101011 11011101110
  • 60. How? • Add –javaagent to hook into class loading process • Implement ClassFileTransformer • Use bytecode manipulation libraries (Javassist, cglib, asm) to add any custom logic java.lang.instrument
  • 61. How ? (2) • Use custom ClassLoader – Override ClassLoader#findClass – Use ClassReader(String) to read the class in and transform it via visitor chain – Call ClassLoader#defineClass explicitly with the result from the transformation step
  • 62. java.lang.instrument import java.lang.instrument.ClassFileTransformer; import java.lang.instrument.Instrumentation; public class Agent { public static void premain(String args, Instrumentation inst) { inst.addTransformer(new ClassFileTransformer(), true); } public static void agentmain(String args, Instrumentation inst) { premain(args,inst); } }
  • 63. java.lang.instrument import java.lang.instrument.ClassFileTransformer; import java.lang.instrument.Instrumentation; public class Agent { public static void premain(String args, Instrumentation inst) { inst.addTransformer(new ClassFileTransformer(), true); } public static void agentmain(String args, Instrumentation inst) { premain(args,inst); } }
  • 64. java.lang.instrument import java.lang.instrument.ClassFileTransformer; import java.lang.instrument.Instrumentation; public class Agent { public static void premain(String args, Instrumentation inst) { inst.addTransformer(new ClassFileTransformer(), true); } public static void agentmain(String args, Instrumentation inst) { premain(args,inst); } } META-INF/MANIFEST.MF Premain-Class: Agent java –javaagent:agent.jar … Agent-Class: Agent
  • 65. j.l.instrument.ClassFileTransformer new ClassFileTransformer() { public byte[] transform(ClassLoader loader, String className, Class<?>classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer){ ClassReader cr = new ClassReader(classfileBuffer); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); MyAdapter ca = new MyAdapter(cw); cr.accept(ca, ClassReader.EXPAND_FRAMES); return cw.toByteArray(); }
  • 66. j.l.instrument.ClassFileTransformer new ClassFileTransformer() { public byte[] transform(ClassLoader loader, String className, Class<?>classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer){ ClassReader cr = new ClassReader(classfileBuffer); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); MyAdapter ca = new MyAdapter(cw); cr.accept(ca, ClassReader.EXPAND_FRAMES); return cw.toByteArray(); }
  • 67. j.l.instrument.ClassFileTransformer new ClassFileTransformer() { public byte[] transform(ClassLoader loader, String className, Class<?>classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer){ ClassReader cr = new ClassReader(classfileBuffer); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); MyAdapter ca = new MyAdapter(cw); cr.accept(ca, ClassReader.EXPAND_FRAMES); return cw.toByteArray(); }
  • 68. public class MyClassLoader extends ClassLoader { protected Class findClass(String name) throws ClassNotFoundException { ClassReader cr = new ClassReader(name); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); MyClassAdapter ca = new MyClassAdapter(cw); cr.accept(ca, ClassReader.EXPAND_FRAMES); byte b[] = cw.toByteArray(); return defineClass(name, b, 0, b.length); }

Editor's Notes

  1. Programs are composed of classes, classes are thebytecode, blah blahblahJava bytecode is stack based: most of the operations push to the stack of consume values from the stack
  2. ObjectWeb ASM is the de-facto standard decomposing, modifying, and recomposing Javabytecode. ASM provides a simple library that exposes the internal aggregate components of a given Java class through its visitor oriented API. On top of visitor API ASM provides tree API that represents classes as object constructs.ASM is very popular and is used widely in various Java open-source projects. In fact, this could be the primary motivation for someone the learn this library.
  3. Why would learn Java bytecode and ASM at all?Well, creating a brand new JVM language might be a good idea  This is what all the cool kids are doing, right?Secondly – programming model that is exposed by many frameworks is backed with bytecode generation or instrumentation. AspectJ, for instance uses bytecode instrumentation extensively.Also, there are some many awesome tools that do awesome stuff, like …. JRebel for instance 
  4. This presentation gives some pointe
  5. Let’s start with an example: the class “Items” implements an interface,…
  6. Includes a field declaration &amp; assignment,..
  7. Initializer block, ..
  8. and a virtual method.
  9. The most common scenario to generate bytecode that corresponds to the example source, is to create ClassWriter, visit the structure – fields, methods, etc, and after the job is done, write out the final bytes.
  10. Actually, before going further, let’s mention javap– the Java class disassembler. The output of javap command isn’t particularly useful as there’s no way to modify it and compile back to the executable code. However, it is much more easier to read the bytecodes produced by javap, rather than the code that is written using ASM API. So, javap is good for reference when studying the bytecode.
  11. Let’s go on and construct a ClassWriter.. The constructor takes anint which is composed of different flags.COMPUTE_MAXS says that the sizes of local variables and operand stack parts will be computed automatically. Still have to call visitMaxs with any argumentsCOMPUTE_FRAMES – everything is computed automatically. ASM will compute the stack map, still have to call visitMaxs
  12. To create class signature, we’ll call ClassWriter#visit methodThe interface is full of constants, as one may notice.
  13. Java version. V1_1 – V1_7 are available.
  14. Accessor modifiers:ACC_PUBLIC, ACC_PRIVATEACC_SYNTHETIC, ACC_BRIDGE
  15. Types declared as strings 
  16. Even this API call, not that complex, but looks ugly
  17. Field declaration with assignment is actually split between the field declaration for the class, and assignment is performed in constructor. So this is something we need to keep in mind when generating the code.
  18. fisitField method creates the field declaration
  19. The ugliest part of ASM API is the descriptiors. Sorry, I’d like to rant the library a bit on this one 
  20. Blah blah descriptors, blah blah descriptors, blah blah…
  21. some descriptor examples…
  22. Fortunately, Type can help a bit with all this descriptor mess
  23. Let’s generate some methods nowFirst of all, the constructor. There isn’t a special API to generate a constructor, only the special name, &lt;init&gt;, tells that the method is actually a constructor.
  24. The real method isn’t any different from the constructor from the API point of view
  25. Now it is time to generate the constructor body
  26. The constructor consists of super() callField assignmentSome method calls
  27. The super() call for the regular class is the call to Obect.&lt;init&gt;
  28. Assigning a value to a field takes a series of opcodes to complete
  29. At first the value has to be created and placed on the stack
  30. Next,putfield, putstatic or xstoreopcode can be used to assign the value to the required location
  31. The ASM code doesn’t look very different to the javap-like code, besides all the noise it brings
  32. After the field is initialized, let’s add some values to the list: a byte, a short and an integer
  33. Adding the values to the list results in method calls with a parameter. The parameter has to be loaded to the stack in order to be passed to a method.As the autoboxing takes place, Integer.valueOf is called in order to add an Integer to the List
  34. The ASM code is getting uglier… and the captain doesn’t like it.
  35. Let’s take a step back and select a shortcut for the taks
  36. ASM code can be easily generated
  37. ... using ASMifierClassVisitor (ASMifier in ASM4). The output is rather noisy, with all the labels,but the noise is easy to remove.
  38. However,javap output is still the cleanest and easiest to read and there are some alternatives to ASM visitor API
  39. For instance, Groovy AST transformations make it possible to write code which is very close to javap output.