SlideShare a Scribd company logo
Having fun with Javassist
Me
Anton Arhipov
@antonarhipov
We Javassist a lot!
You?
Are you interested in Javassist?
Want to become a better programmer?
Bytecode instrumentation, anyone?
JavaOne 2015 - Having fun with Javassist
@Entity

@Table(name  =  "owners")

public  class  Owner  extends  Person  {

        @Column(name  =  "address")

        @NotEmpty

        private  String  address;



        @Column(name  =  "city")

        @NotEmpty

        private  String  city;



        @Column(name  =  "telephone")

        @NotEmpty

        @Digits(fraction  =  0,  integer  =  10)

        private  String  telephone;



        @OneToMany(cascade  =  CascadeType.ALL,    
                              mappedBy  =  "owner")

        private  Set<Pet>  pets;  
public  class  JavassistLazyInitializer    
              extends  BasicLazyInitializer    
              implements  MethodHandler  {  
final  JavassistLazyInitializer  instance    
          =  new  JavassistLazyInitializer(…);  


ProxyFactory  factory  =  new  ProxyFactory();

factory.setSuperclass(interfaces.length  ==  1?persistentClass:null);

factory.setInterfaces(interfaces);

factory.setFilter(FINALIZE_FILTER);  


Class  cl  =  factory.createClass();

final  HibernateProxy  proxy  =  (HibernateProxy)  cl.newInstance();

((ProxyObject)proxy).setHandler(instance);

instance.constructed  =  true;

return  proxy;  
public  class  JavassistLazyInitializer    
              extends  BasicLazyInitializer    
              implements  MethodHandler  {  
final  JavassistLazyInitializer  instance    
          =  new  JavassistLazyInitializer(…);  


ProxyFactory  factory  =  new  ProxyFactory();

factory.setSuperclass(interfaces.length  ==  1?persistentClass:null);

factory.setInterfaces(interfaces);

factory.setFilter(FINALIZE_FILTER);  


Class  cl  =  factory.createClass();

final  HibernateProxy  proxy  =  (HibernateProxy)  cl.newInstance();

((ProxyObject)proxy).setHandler(instance);

instance.constructed  =  true;

return  proxy;  
Generates  proxy!
The main use case for
bytecode generation
in Java framewoks
is to generate proxies
JavaOne 2015 - Having fun with Javassist
Agenda
Javassist basics
-javaagent
HacksApplications
… and a little bit on the use of Javassist in JRebel
Javassist 101
www.javassist.org
ClassPool
CtClass
CtClass
CtClass
CtClass
CtField
CtMethod
CtConst
CtMethod
insertBefore
insertAfter
instrument
It feels almost like Java Reflection API :)
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ct  =  cp.makeClass("com.zt.A",    
                cp.get("com.zt.Clazz"));  
        CtMethod[]  methods  =  ct.getMethods();

        for  (CtMethod  method  :  methods)  {

              //…  
        }  
        ct.writeFile("/output");  
  }
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ct  =  cp.makeClass("com.zt.A",    
                cp.get("com.zt.Clazz"));  
        CtMethod[]  methods  =  ct.getMethods();

        for  (CtMethod  method  :  methods)  {

              //…  
        }  
        ct.writeFile("/output");  
  }
    ClassPool  cp  =  new  ClassPool(null);  
    cp.appendSystemPath();  
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ct  =  cp.makeClass("com.zt.A",    
                cp.get("com.zt.Clazz"));  
        CtMethod[]  methods  =  ct.getMethods();

        for  (CtMethod  method  :  methods)  {

              //…  
        }  
        ct.writeFile("/output");  
  }
    public  class  A  extends  Clazz  {  

        public  A()  {

        }

    }  
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ct  =  cp.makeClass("com.zt.A",    
                cp.get("com.zt.Clazz"));  
        CtMethod[]  methods  =  ct.getMethods();

        for  (CtMethod  method  :  methods)  {

              //…  
        }  
        ct.writeFile("/output");  
  }
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ct  =  cp.makeClass("com.zt.A",    
                cp.get("com.zt.Clazz"));  
        CtMethod[]  methods  =  ct.getMethods();

        for  (CtMethod  method  :  methods)  {

              //…  
        }  
        ct.writeFile("/output");  
  }
  mars:output  anton$  javap  -­‐c  com/zt/A.class  Compiled  from  "A.java"  
  public  class  com.zt.A  extends  com.zt.Clazz  {  
      public  com.zt.A();  
          Code:  
              0:  aload_0  
              1:  invokespecial  #10    
              4:  return  
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ct  =  cp.makeClass("com.zt.A",    
                cp.get("com.zt.Clazz"));  
        CtMethod[]  methods  =  ct.getMethods();

        for  (CtMethod  method  :  methods)  {

              //…  
        }  
        ct.writeFile("/output");  
  }
Can generate classes from
metadata at build time
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        cp.appendClassPath(new  ClassPath(){  …  });  
        CtClass  ct  =  cp.get("com.zt.A");  
        CtMethod[]  methods  =  ct.getMethods();

        for  (CtMethod  method  :  methods)  {

              //…  
        }  
        ct.writeFile("/output");  
  }
… or you can post process the
compiled classes
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ctClass  =  cp.get("com.zt.A");  
        CtMethod  foo  =  ctClass.getMethod("foo",    
            "()V");  
        foo.insertBefore("System.out.println();");  
        Class  c  =  ctClass.toClass();

        A  a  =  (A)  c.newInstance();

        a.foo("Hello");

  }
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ctClass  =  cp.get("com.zt.A");  
        CtMethod  foo  =  ctClass.getMethod("foo",    
            "()V");  
        foo.insertBefore("System.out.println();");  
        Class  c  =  ctClass.toClass();

        A  a  =  (A)  c.newInstance();

        a.foo("Hello");

  }
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ctClass  =  cp.get("com.zt.A");  
        CtMethod  foo  =  ctClass.getMethod("foo",    
            "()V");  
        foo.insertBefore("System.out.println();");  
        Class  c  =  ctClass.toClass();

        A  a  =  (A)  c.newInstance();

        a.foo("Hello");

  }
    public  void  foo()  {  

    }  
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ctClass  =  cp.get("com.zt.A");  
        CtMethod  foo  =  ctClass.getMethod("foo",    
            "(Ljava/lang/String;)V");  
        foo.insertBefore("System.out.println();");  
        Class  c  =  ctClass.toClass();

        A  a  =  (A)  c.newInstance();

        a.foo("Hello");

  }
    public  void  foo(String  s)  {  

    }  
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ctClass  =  cp.get("com.zt.A");  
        CtMethod  foo  =  ctClass.getMethod("foo",    
            "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lja
        foo.insertBefore("System.out.println();");  
        Class  c  =  ctClass.toClass();

        A  a  =  (A)  c.newInstance();

        a.foo("Hello");

  }
  Descriptors  might  get  quite  long  ;)  
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ctClass  =  cp.get("com.zt.A");  
        CtMethod  foo  =  ctClass.getMethod("foo",    
            "(Ljava/lang/String;)V");  
        foo.insertBefore("System.out.println($1)");  
        Class  c  =  ctClass.toClass();

        A  a  =  (A)  c.newInstance();

        a.foo("Hello");

  }
  $1,  $2,  $3  —  local  variables  
  $0  —  this  for  non-­‐static  methods  
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ctClass  =  cp.get("com.zt.A");  
        CtMethod  foo  =  ctClass.getMethod("foo",    
            "(Ljava/lang/String;)V");  
        foo.insertBefore("System.out.println($1)");  
        Class  c  =  ctClass.toClass();

        A  a  =  (A)  c.newInstance();

        a.foo("Hello");

  }
    
    Exception  in  thread  "main"  javassist.CannotCompileException:  [source  error]  ;  is  missing  
           at  javassist.CtBehavior.insertBefore(CtBehavior.java:774)  
           at  javassist.CtBehavior.insertBefore(CtBehavior.java:734)  
           at  com.zt.basics.Ex.main(Ex.java:35)  
   public  static  void  main(String[]  args)  throws  Exception  {  
        ClassPool  cp  =  ClassPool.getDefault();  
        CtClass  ctClass  =  cp.get("com.zt.A");  
        CtMethod  foo  =  ctClass.getMethod("foo",    
            "(Ljava/lang/String;)V");  
        foo.insertBefore("System.out.println($1);");  
        Class  c  =  ctClass.toClass();

        A  a  =  (A)  c.newInstance();

        a.foo("Hello");

  }
       CtMethod  foo  =  …  
        foo.insertBefore(…);  
        foo.insertAfter(…);  
Can implement tracing
       CtMethod  foo  =  …  
        foo.insertBefore(…);  
        foo.insertAfter(…);  
… or add logging
       CtMethod  foo  =  …  
        foo.insertBefore(…);  
        foo.insertAfter(…);  
… or implement AOP
       CtMethod  foo  =  …  
        foo.instrument(new  ExprEditor()  {  
            @Override

            public  void  edit(NewExpr  e)    
                    throws  CannotCompileException  {

                e.replace("{"  +

                        "$_  =  $proceed($$);"  +

                        "System.out.println($_);"  +

                        "}");

            }  
        });
       CtMethod  foo  =  …  
        foo.instrument(new  ExprEditor()  {  
            @Override

            public  void  edit(NewExpr  e)    
                    throws  CannotCompileException  {

                e.replace("{"  +

                        "$_  =  $proceed($$);"  +

                        "System.out.println($_);"  +

                        "}");

            }  
        });
       CtMethod  foo  =  …  
        foo.instrument(new  ExprEditor()  {  
            @Override

            public  void  edit(NewExpr  e)    
                    throws  CannotCompileException  {

                e.replace("{"  +

                        "$_  =  $proceed($$);"  +

                        "System.out.println($_);"  +

                        "}");

            }  
        }); Intercept new instances
       CtMethod  foo  =  …  
        foo.instrument(new  ExprEditor()  {  
            @Override

            public  void  edit(NewExpr  e)    
                    throws  CannotCompileException  {

                e.replace("{"  +

                        "$_  =  $proceed($$);"  +

                        "System.out.println($_);"  +

                        "}");

            }  
        }); Intercept new instances
       CtMethod  foo  =  …  
        foo.instrument(new  ExprEditor()  {  
            @Override

            public  void  edit(MethodCall  m)    
                    throws  CannotCompileException  {

                if(m.getMethodName().contains("println"))  {

                    m.replace("{}");

                }                
            }  
        }); Remove unwanted
invocations
       CtMethod  foo  =  …  
        foo.instrument(new  ExprEditor()  {  
            @Override

            public  void  edit(FieldAccess  m)    
                    throws  CannotCompileException  {

                if  (f.isWriter())  {

                    CtField  field  =  f.getField();

                    String  setterName  =  findSetter(field);

                    f.replace("{"  +  "$0."  +  setterName  +  "($$);"  +  "}");

                }                
            }  
        });
Replace direct field access
with setter calls
This slide is intentionally left blank
Java Agent
Java Agent
import java.lang.instrument.ClassFileTransformer;  
import java.lang.instrument.Instrumentation;  
public class Agent {  
public static void premain(String args, Instrumentation inst)   
throws Exception {  
inst.addTransformer(new ClassFileTransformer {   
// here be code
});  
}  
}
META-­‐INF/MANIFEST.MF  
Premain-­‐Class:  Agent
$>  java  –javaagent:agent.jar  application.Main
ClassFileTransformer
new ClassFileTransformer() {
public byte[] transform(ClassLoader loader,   
String className,  
Class<?> classBeingRedefined,  
ProtectionDomain protectionDomain,   
byte[] classfileBuffer){
ClassPool cp = ClassPool.getDefault();  
CtClass ct = cp.makeClass(new   
ByteArrayInputStream(classfileBuffer));
// here we can do all the things to ‘ct’
return ct.toBytecode();
}  
}
new ClassFileTransformer() {
public byte[] transform(ClassLoader loader,   
String className,  
Class<?> classBeingRedefined,  
ProtectionDomain protectionDomain,   
byte[] classfileBuffer){
ClassPool cp = ClassPool.getDefault();  
CtClass ct = cp.makeClass(new   
ByteArrayInputStream(classfileBuffer));
// here we can do all the things to ‘ct’
return ct.toBytecode();
}  
}
ClassFileTransformer
new ClassFileTransformer() {
public byte[] transform(ClassLoader loader,   
String className,  
Class<?> classBeingRedefined,  
ProtectionDomain protectionDomain,   
byte[] classfileBuffer){
ClassPool cp = ClassPool.getDefault();  
CtClass ct = cp.makeClass(new   
ByteArrayInputStream(classfileBuffer));
// here we can do all the things to ‘ct’
return ct.toBytecode();
}  
}
ClassFileTransformer
new ClassFileTransformer() {
public byte[] transform(ClassLoader loader,   
String className,  
Class<?> classBeingRedefined,  
ProtectionDomain protectionDomain,   
byte[] classfileBuffer){
ClassPool cp = ClassPool.getDefault();  
CtClass ct = cp.makeClass(new   
ByteArrayInputStream(classfileBuffer));
// here we can do all the things to ‘ct’
return ct.toBytecode();
}  
}
ClassFileTransformer
JavaOne 2015 - Having fun with Javassist
JavaOne 2015 - Having fun with Javassist
JavaOne 2015 - Having fun with Javassist
JavaOne 2015 - Having fun with Javassist
JavaOne 2015 - Having fun with Javassist
https://github.com/zeroturnaround/callspy
Javassist in
http://0t.ee/javaone-jr
JRebel
core
Spring
plugin
Hibernate
plugin
EJB
plugin
JRebel
core
Spring
plugin
Hibernate
plugin
EJB
pluginjrebel.jar
Spring
plugin
Hibernate
plugin
EJB
pluginReloads
classes
JRebel
core
JRebel
core
Spring
plugin
Hibernate
plugin
EJB
pluginNotifies
plugins
JRebel
core
Spring
plugin
Hibernate
plugin
EJB
plugin
Refresh
configurations
JRebel
core
Javassist lives here
Spring
plugin
Hibernate
plugin
EJB
plugin
Spring
Hibernate
OpenEJB
JRebel
core
Spring
plugin
Hibernate
plugin
EJB
plugin
class  Framework  {  
    public  void  configure(){

    }    
}
CtClass  framework    
    =  cp.get("com.zt.Framework");
framework.addInterface(  
  cp.get("com.zt.jrebel.Listener"));
class  Framework    
  implements  Listener  {  
    public  void  configure(){

    }    
} framework.addMethod(  
    CtNewMethod.make(  
        "public  void  onEvent(){"  +  
        "    configure();"  +  
        "}",  
        framework  
));
https://github.com/antonarhipov/jpoint
HowItWorks
JavaOne 2015 - Having fun with Javassist
Your task
Javassist
https://speakerdeck.com/antonarhipov
http://www.slideshare.net/arhan
@antonarhipov
anton@zeroturnaround.com
http://0t.ee/javaone-jr
Ad

More Related Content

What's hot (20)

Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011
Anton Arhipov
 
asyncio internals
asyncio internalsasyncio internals
asyncio internals
Saúl Ibarra Corretgé
 
Use of Apache Commons and Utilities
Use of Apache Commons and UtilitiesUse of Apache Commons and Utilities
Use of Apache Commons and Utilities
Pramod Kumar
 
A deep dive into PEP-3156 and the new asyncio module
A deep dive into PEP-3156 and the new asyncio moduleA deep dive into PEP-3156 and the new asyncio module
A deep dive into PEP-3156 and the new asyncio module
Saúl Ibarra Corretgé
 
Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++
Sergey Platonov
 
DjangoCon US 2011 - Monkeying around at New Relic
DjangoCon US 2011 - Monkeying around at New RelicDjangoCon US 2011 - Monkeying around at New Relic
DjangoCon US 2011 - Monkeying around at New Relic
Graham Dumpleton
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
Anton Arhipov
 
Server1
Server1Server1
Server1
FahriIrawan3
 
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
Anton Arhipov
 
Ggug spock
Ggug spockGgug spock
Ggug spock
Skills Matter
 
Sailing with Java 8 Streams
Sailing with Java 8 StreamsSailing with Java 8 Streams
Sailing with Java 8 Streams
Ganesh Samarthyam
 
Java Class Design
Java Class DesignJava Class Design
Java Class Design
Ganesh Samarthyam
 
Java Class Design
Java Class DesignJava Class Design
Java Class Design
Ganesh Samarthyam
 
Python Coroutines, Present and Future
Python Coroutines, Present and FuturePython Coroutines, Present and Future
Python Coroutines, Present and Future
emptysquare
 
Google Guava & EMF @ GTUG Nantes
Google Guava & EMF @ GTUG NantesGoogle Guava & EMF @ GTUG Nantes
Google Guava & EMF @ GTUG Nantes
mikaelbarbero
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
Ganesh Samarthyam
 
Python Async IO Horizon
Python Async IO HorizonPython Async IO Horizon
Python Async IO Horizon
Lukasz Dobrzanski
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습
DoHyun Jung
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
Ganesh Samarthyam
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
julien.ponge
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011
Anton Arhipov
 
Use of Apache Commons and Utilities
Use of Apache Commons and UtilitiesUse of Apache Commons and Utilities
Use of Apache Commons and Utilities
Pramod Kumar
 
A deep dive into PEP-3156 and the new asyncio module
A deep dive into PEP-3156 and the new asyncio moduleA deep dive into PEP-3156 and the new asyncio module
A deep dive into PEP-3156 and the new asyncio module
Saúl Ibarra Corretgé
 
Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++Антон Нонко, Классические строки в C++
Антон Нонко, Классические строки в C++
Sergey Platonov
 
DjangoCon US 2011 - Monkeying around at New Relic
DjangoCon US 2011 - Monkeying around at New RelicDjangoCon US 2011 - Monkeying around at New Relic
DjangoCon US 2011 - Monkeying around at New Relic
Graham Dumpleton
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
Anton 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 reloading
Anton Arhipov
 
Python Coroutines, Present and Future
Python Coroutines, Present and FuturePython Coroutines, Present and Future
Python Coroutines, Present and Future
emptysquare
 
Google Guava & EMF @ GTUG Nantes
Google Guava & EMF @ GTUG NantesGoogle Guava & EMF @ GTUG Nantes
Google Guava & EMF @ GTUG Nantes
mikaelbarbero
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
Ganesh Samarthyam
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습
DoHyun Jung
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
julien.ponge
 

Viewers also liked (20)

Joker 2016 - Bytecode 101
Joker 2016 - Bytecode 101Joker 2016 - Bytecode 101
Joker 2016 - Bytecode 101
Anton Arhipov
 
JPoint 2016 - Bytecode
JPoint 2016 - BytecodeJPoint 2016 - Bytecode
JPoint 2016 - Bytecode
Anton Arhipov
 
Devclub 01/2017 - (Не)адекватное Java-интервью
Devclub 01/2017 - (Не)адекватное Java-интервьюDevclub 01/2017 - (Не)адекватное Java-интервью
Devclub 01/2017 - (Не)адекватное Java-интервью
Anton Arhipov
 
JPoint 2016 - Etudes of DIY Java profiler
JPoint 2016 - Etudes of DIY Java profilerJPoint 2016 - Etudes of DIY Java profiler
JPoint 2016 - Etudes of DIY Java profiler
Anton Arhipov
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
Anton Arhipov
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
Anton Arhipov
 
import continuous.delivery.*
import continuous.delivery.*import continuous.delivery.*
import continuous.delivery.*
Anton Arhipov
 
Taming Java Agents
Taming Java AgentsTaming Java Agents
Taming Java Agents
Anton Arhipov
 
Con-FESS 2015 - Is your profiler speaking to you?
Con-FESS 2015 - Is your profiler speaking to you?Con-FESS 2015 - Is your profiler speaking to you?
Con-FESS 2015 - Is your profiler speaking to you?
Anton Arhipov
 
JPoint 2015 - Javassist на службе Java-разработчика
JPoint 2015 - Javassist на службе Java-разработчикаJPoint 2015 - Javassist на службе Java-разработчика
JPoint 2015 - Javassist на службе Java-разработчика
Anton Arhipov
 
Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Improve your Developer Experiece using the WAS Liberty Profile with JRebel Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Anton Arhipov
 
NetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience ReportNetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience Report
Anton Arhipov
 
Загрузчики классов в Java - коллекция граблей
Загрузчики классов в Java - коллекция граблейЗагрузчики классов в Java - коллекция граблей
Загрузчики классов в Java - коллекция граблей
Anton Arhipov
 
Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012
Anton Arhipov
 
Scala для всех (РИФ 2015)
Scala для всех (РИФ 2015)Scala для всех (РИФ 2015)
Scala для всех (РИФ 2015)
Арсений Жижелев
 
Under the hood of scala implicits (Scala eXchange 2014)
Under the hood of scala implicits (Scala eXchange 2014)Under the hood of scala implicits (Scala eXchange 2014)
Under the hood of scala implicits (Scala eXchange 2014)
Alexander Podkhalyuzin
 
Scala #3
Scala #3Scala #3
Scala #3
Alexander Podkhalyuzin
 
Lec 2
Lec 2Lec 2
Lec 2
Alexander Rusin
 
Joker 2016 - Bytecode 101
Joker 2016 - Bytecode 101Joker 2016 - Bytecode 101
Joker 2016 - Bytecode 101
Anton Arhipov
 
JPoint 2016 - Bytecode
JPoint 2016 - BytecodeJPoint 2016 - Bytecode
JPoint 2016 - Bytecode
Anton Arhipov
 
Devclub 01/2017 - (Не)адекватное Java-интервью
Devclub 01/2017 - (Не)адекватное Java-интервьюDevclub 01/2017 - (Не)адекватное Java-интервью
Devclub 01/2017 - (Не)адекватное Java-интервью
Anton Arhipov
 
JPoint 2016 - Etudes of DIY Java profiler
JPoint 2016 - Etudes of DIY Java profilerJPoint 2016 - Etudes of DIY Java profiler
JPoint 2016 - Etudes of DIY Java profiler
Anton Arhipov
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
Anton Arhipov
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
Anton Arhipov
 
import continuous.delivery.*
import continuous.delivery.*import continuous.delivery.*
import continuous.delivery.*
Anton Arhipov
 
Con-FESS 2015 - Is your profiler speaking to you?
Con-FESS 2015 - Is your profiler speaking to you?Con-FESS 2015 - Is your profiler speaking to you?
Con-FESS 2015 - Is your profiler speaking to you?
Anton Arhipov
 
JPoint 2015 - Javassist на службе Java-разработчика
JPoint 2015 - Javassist на службе Java-разработчикаJPoint 2015 - Javassist на службе Java-разработчика
JPoint 2015 - Javassist на службе Java-разработчика
Anton Arhipov
 
Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Improve your Developer Experiece using the WAS Liberty Profile with JRebel Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Anton Arhipov
 
NetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience ReportNetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience Report
Anton Arhipov
 
Загрузчики классов в Java - коллекция граблей
Загрузчики классов в Java - коллекция граблейЗагрузчики классов в Java - коллекция граблей
Загрузчики классов в Java - коллекция граблей
Anton Arhipov
 
Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012
Anton Arhipov
 
Under the hood of scala implicits (Scala eXchange 2014)
Under the hood of scala implicits (Scala eXchange 2014)Under the hood of scala implicits (Scala eXchange 2014)
Under the hood of scala implicits (Scala eXchange 2014)
Alexander Podkhalyuzin
 
Ad

Similar to JavaOne 2015 - Having fun with Javassist (20)

Binary patching for fun and profit @ JUG.ru, 25.02.2012
Binary patching for fun and profit @ JUG.ru, 25.02.2012Binary patching for fun and profit @ JUG.ru, 25.02.2012
Binary patching for fun and profit @ JUG.ru, 25.02.2012
Anton Arhipov
 
Java agents are watching your ByteCode
Java agents are watching your ByteCodeJava agents are watching your ByteCode
Java agents are watching your ByteCode
Roman Tsypuk
 
Java Generics
Java GenericsJava Generics
Java Generics
jeslie
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
Tomek Kaczanowski
 
New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancement
Rakesh Madugula
 
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
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
Alex Tumanoff
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
Abed Bukhari
 
My java file
My java fileMy java file
My java file
Anamika Chauhan
 
Summary of C++17 features
Summary of C++17 featuresSummary of C++17 features
Summary of C++17 features
Bartlomiej Filipek
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
tcurdt
 
Java 8 Puzzlers [as presented at OSCON 2016]
Java 8 Puzzlers [as presented at  OSCON 2016]Java 8 Puzzlers [as presented at  OSCON 2016]
Java 8 Puzzlers [as presented at OSCON 2016]
Baruch Sadogursky
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
Tomek Kaczanowski
 
05 pig user defined functions (udfs)
05 pig user defined functions (udfs)05 pig user defined functions (udfs)
05 pig user defined functions (udfs)
Subhas Kumar Ghosh
 
[NHN NEXT] Java 강의 - Week1
[NHN NEXT] Java 강의 - Week1[NHN NEXT] Java 강의 - Week1
[NHN NEXT] Java 강의 - Week1
Young-Ho Cho
 
Nice to meet Kotlin
Nice to meet KotlinNice to meet Kotlin
Nice to meet Kotlin
Jieyi Wu
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
HamletDRC
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
Soumya Behera
 
Java programs
Java programsJava programs
Java programs
Dr.M.Karthika parthasarathy
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
Sandeep Kr. Singh
 
Binary patching for fun and profit @ JUG.ru, 25.02.2012
Binary patching for fun and profit @ JUG.ru, 25.02.2012Binary patching for fun and profit @ JUG.ru, 25.02.2012
Binary patching for fun and profit @ JUG.ru, 25.02.2012
Anton Arhipov
 
Java agents are watching your ByteCode
Java agents are watching your ByteCodeJava agents are watching your ByteCode
Java agents are watching your ByteCode
Roman Tsypuk
 
Java Generics
Java GenericsJava Generics
Java Generics
jeslie
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
Tomek Kaczanowski
 
New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancement
Rakesh Madugula
 
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
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
Abed Bukhari
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
tcurdt
 
Java 8 Puzzlers [as presented at OSCON 2016]
Java 8 Puzzlers [as presented at  OSCON 2016]Java 8 Puzzlers [as presented at  OSCON 2016]
Java 8 Puzzlers [as presented at OSCON 2016]
Baruch Sadogursky
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
Tomek Kaczanowski
 
05 pig user defined functions (udfs)
05 pig user defined functions (udfs)05 pig user defined functions (udfs)
05 pig user defined functions (udfs)
Subhas Kumar Ghosh
 
[NHN NEXT] Java 강의 - Week1
[NHN NEXT] Java 강의 - Week1[NHN NEXT] Java 강의 - Week1
[NHN NEXT] Java 강의 - Week1
Young-Ho Cho
 
Nice to meet Kotlin
Nice to meet KotlinNice to meet Kotlin
Nice to meet Kotlin
Jieyi Wu
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
HamletDRC
 
Ad

More from Anton Arhipov (16)

JavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdfJavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdf
Anton Arhipov
 
Idiomatic kotlin
Idiomatic kotlinIdiomatic kotlin
Idiomatic kotlin
Anton 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 TeamCity
Anton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCityBuild pipelines with TeamCity
Build pipelines with TeamCity
Anton 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 hour
Anton 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 hour
Anton 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 DSL
Anton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCityBuild pipelines with TeamCity
Build pipelines with TeamCity
Anton 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 TestContainers
Anton Arhipov
 
GeeCON Prague 2017 - TestContainers
GeeCON Prague 2017 - TestContainersGeeCON Prague 2017 - TestContainers
GeeCON Prague 2017 - TestContainers
Anton 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 reloading
Anton 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 hassle
Anton 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 reloading
Anton 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 reloading
Anton Arhipov
 
JUG.ua 20170225 - Java bytecode instrumentation
JUG.ua 20170225 - Java bytecode instrumentationJUG.ua 20170225 - Java bytecode instrumentation
JUG.ua 20170225 - Java bytecode instrumentation
Anton Arhipov
 
JavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdfJavaZone 2022 - Building Kotlin DSL.pdf
JavaZone 2022 - Building Kotlin DSL.pdf
Anton Arhipov
 
TechTrain 2019 - (Не)адекватное техническое интервью
TechTrain 2019 - (Не)адекватное техническое интервьюTechTrain 2019 - (Не)адекватное техническое интервью
TechTrain 2019 - (Не)адекватное техническое интервью
Anton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCityBuild pipelines with TeamCity
Build pipelines with TeamCity
Anton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCityBuild pipelines with TeamCity
Build pipelines with TeamCity
Anton 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 hour
Anton 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 hour
Anton 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 DSL
Anton Arhipov
 
Build pipelines with TeamCity
Build pipelines with TeamCityBuild pipelines with TeamCity
Build pipelines with TeamCity
Anton 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 TestContainers
Anton Arhipov
 
GeeCON Prague 2017 - TestContainers
GeeCON Prague 2017 - TestContainersGeeCON Prague 2017 - TestContainers
GeeCON Prague 2017 - TestContainers
Anton 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 reloading
Anton 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 hassle
Anton 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 reloading
Anton 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 reloading
Anton Arhipov
 
JUG.ua 20170225 - Java bytecode instrumentation
JUG.ua 20170225 - Java bytecode instrumentationJUG.ua 20170225 - Java bytecode instrumentation
JUG.ua 20170225 - Java bytecode instrumentation
Anton Arhipov
 

Recently uploaded (20)

Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 

JavaOne 2015 - Having fun with Javassist

  • 1. Having fun with Javassist
  • 3. You? Are you interested in Javassist? Want to become a better programmer? Bytecode instrumentation, anyone?
  • 5. @Entity
 @Table(name  =  "owners")
 public  class  Owner  extends  Person  {
        @Column(name  =  "address")
        @NotEmpty
        private  String  address;
 
        @Column(name  =  "city")
        @NotEmpty
        private  String  city;
 
        @Column(name  =  "telephone")
        @NotEmpty
        @Digits(fraction  =  0,  integer  =  10)
        private  String  telephone;
 
        @OneToMany(cascade  =  CascadeType.ALL,                                  mappedBy  =  "owner")
        private  Set<Pet>  pets;  
  • 6. public  class  JavassistLazyInitializer                  extends  BasicLazyInitializer                  implements  MethodHandler  {   final  JavassistLazyInitializer  instance              =  new  JavassistLazyInitializer(…);   
 ProxyFactory  factory  =  new  ProxyFactory();
 factory.setSuperclass(interfaces.length  ==  1?persistentClass:null);
 factory.setInterfaces(interfaces);
 factory.setFilter(FINALIZE_FILTER);   
 Class  cl  =  factory.createClass();
 final  HibernateProxy  proxy  =  (HibernateProxy)  cl.newInstance();
 ((ProxyObject)proxy).setHandler(instance);
 instance.constructed  =  true;
 return  proxy;  
  • 7. public  class  JavassistLazyInitializer                  extends  BasicLazyInitializer                  implements  MethodHandler  {   final  JavassistLazyInitializer  instance              =  new  JavassistLazyInitializer(…);   
 ProxyFactory  factory  =  new  ProxyFactory();
 factory.setSuperclass(interfaces.length  ==  1?persistentClass:null);
 factory.setInterfaces(interfaces);
 factory.setFilter(FINALIZE_FILTER);   
 Class  cl  =  factory.createClass();
 final  HibernateProxy  proxy  =  (HibernateProxy)  cl.newInstance();
 ((ProxyObject)proxy).setHandler(instance);
 instance.constructed  =  true;
 return  proxy;   Generates  proxy!
  • 8. The main use case for bytecode generation in Java framewoks is to generate proxies
  • 10. Agenda Javassist basics -javaagent HacksApplications … and a little bit on the use of Javassist in JRebel
  • 13.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ct  =  cp.makeClass("com.zt.A",                    cp.get("com.zt.Clazz"));          CtMethod[]  methods  =  ct.getMethods();
        for  (CtMethod  method  :  methods)  {
              //…          }          ct.writeFile("/output");    }
  • 14.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ct  =  cp.makeClass("com.zt.A",                    cp.get("com.zt.Clazz"));          CtMethod[]  methods  =  ct.getMethods();
        for  (CtMethod  method  :  methods)  {
              //…          }          ct.writeFile("/output");    }    ClassPool  cp  =  new  ClassPool(null);      cp.appendSystemPath();  
  • 15.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ct  =  cp.makeClass("com.zt.A",                    cp.get("com.zt.Clazz"));          CtMethod[]  methods  =  ct.getMethods();
        for  (CtMethod  method  :  methods)  {
              //…          }          ct.writeFile("/output");    }    public  class  A  extends  Clazz  {  
        public  A()  {
        }
    }  
  • 16.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ct  =  cp.makeClass("com.zt.A",                    cp.get("com.zt.Clazz"));          CtMethod[]  methods  =  ct.getMethods();
        for  (CtMethod  method  :  methods)  {
              //…          }          ct.writeFile("/output");    }
  • 17.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ct  =  cp.makeClass("com.zt.A",                    cp.get("com.zt.Clazz"));          CtMethod[]  methods  =  ct.getMethods();
        for  (CtMethod  method  :  methods)  {
              //…          }          ct.writeFile("/output");    }  mars:output  anton$  javap  -­‐c  com/zt/A.class  Compiled  from  "A.java"    public  class  com.zt.A  extends  com.zt.Clazz  {        public  com.zt.A();            Code:                0:  aload_0                1:  invokespecial  #10                  4:  return  
  • 18.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ct  =  cp.makeClass("com.zt.A",                    cp.get("com.zt.Clazz"));          CtMethod[]  methods  =  ct.getMethods();
        for  (CtMethod  method  :  methods)  {
              //…          }          ct.writeFile("/output");    } Can generate classes from metadata at build time
  • 19.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          cp.appendClassPath(new  ClassPath(){  …  });          CtClass  ct  =  cp.get("com.zt.A");          CtMethod[]  methods  =  ct.getMethods();
        for  (CtMethod  method  :  methods)  {
              //…          }          ct.writeFile("/output");    } … or you can post process the compiled classes
  • 20.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ctClass  =  cp.get("com.zt.A");          CtMethod  foo  =  ctClass.getMethod("foo",                "()V");          foo.insertBefore("System.out.println();");          Class  c  =  ctClass.toClass();
        A  a  =  (A)  c.newInstance();
        a.foo("Hello");
  }
  • 21.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ctClass  =  cp.get("com.zt.A");          CtMethod  foo  =  ctClass.getMethod("foo",                "()V");          foo.insertBefore("System.out.println();");          Class  c  =  ctClass.toClass();
        A  a  =  (A)  c.newInstance();
        a.foo("Hello");
  }
  • 22.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ctClass  =  cp.get("com.zt.A");          CtMethod  foo  =  ctClass.getMethod("foo",                "()V");          foo.insertBefore("System.out.println();");          Class  c  =  ctClass.toClass();
        A  a  =  (A)  c.newInstance();
        a.foo("Hello");
  }    public  void  foo()  {  
    }  
  • 23.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ctClass  =  cp.get("com.zt.A");          CtMethod  foo  =  ctClass.getMethod("foo",                "(Ljava/lang/String;)V");          foo.insertBefore("System.out.println();");          Class  c  =  ctClass.toClass();
        A  a  =  (A)  c.newInstance();
        a.foo("Hello");
  }    public  void  foo(String  s)  {  
    }  
  • 24.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ctClass  =  cp.get("com.zt.A");          CtMethod  foo  =  ctClass.getMethod("foo",                "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lja        foo.insertBefore("System.out.println();");          Class  c  =  ctClass.toClass();
        A  a  =  (A)  c.newInstance();
        a.foo("Hello");
  }  Descriptors  might  get  quite  long  ;)  
  • 25.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ctClass  =  cp.get("com.zt.A");          CtMethod  foo  =  ctClass.getMethod("foo",                "(Ljava/lang/String;)V");          foo.insertBefore("System.out.println($1)");          Class  c  =  ctClass.toClass();
        A  a  =  (A)  c.newInstance();
        a.foo("Hello");
  }  $1,  $2,  $3  —  local  variables    $0  —  this  for  non-­‐static  methods  
  • 26.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ctClass  =  cp.get("com.zt.A");          CtMethod  foo  =  ctClass.getMethod("foo",                "(Ljava/lang/String;)V");          foo.insertBefore("System.out.println($1)");          Class  c  =  ctClass.toClass();
        A  a  =  (A)  c.newInstance();
        a.foo("Hello");
  }        Exception  in  thread  "main"  javassist.CannotCompileException:  [source  error]  ;  is  missing            at  javassist.CtBehavior.insertBefore(CtBehavior.java:774)            at  javassist.CtBehavior.insertBefore(CtBehavior.java:734)            at  com.zt.basics.Ex.main(Ex.java:35)  
  • 27.    public  static  void  main(String[]  args)  throws  Exception  {          ClassPool  cp  =  ClassPool.getDefault();          CtClass  ctClass  =  cp.get("com.zt.A");          CtMethod  foo  =  ctClass.getMethod("foo",                "(Ljava/lang/String;)V");          foo.insertBefore("System.out.println($1);");          Class  c  =  ctClass.toClass();
        A  a  =  (A)  c.newInstance();
        a.foo("Hello");
  }
  • 28.        CtMethod  foo  =  …          foo.insertBefore(…);          foo.insertAfter(…);   Can implement tracing
  • 29.        CtMethod  foo  =  …          foo.insertBefore(…);          foo.insertAfter(…);   … or add logging
  • 30.        CtMethod  foo  =  …          foo.insertBefore(…);          foo.insertAfter(…);   … or implement AOP
  • 31.        CtMethod  foo  =  …          foo.instrument(new  ExprEditor()  {              @Override
            public  void  edit(NewExpr  e)                        throws  CannotCompileException  {
                e.replace("{"  +
                        "$_  =  $proceed($$);"  +
                        "System.out.println($_);"  +
                        "}");
            }          });
  • 32.        CtMethod  foo  =  …          foo.instrument(new  ExprEditor()  {              @Override
            public  void  edit(NewExpr  e)                        throws  CannotCompileException  {
                e.replace("{"  +
                        "$_  =  $proceed($$);"  +
                        "System.out.println($_);"  +
                        "}");
            }          });
  • 33.        CtMethod  foo  =  …          foo.instrument(new  ExprEditor()  {              @Override
            public  void  edit(NewExpr  e)                        throws  CannotCompileException  {
                e.replace("{"  +
                        "$_  =  $proceed($$);"  +
                        "System.out.println($_);"  +
                        "}");
            }          }); Intercept new instances
  • 34.        CtMethod  foo  =  …          foo.instrument(new  ExprEditor()  {              @Override
            public  void  edit(NewExpr  e)                        throws  CannotCompileException  {
                e.replace("{"  +
                        "$_  =  $proceed($$);"  +
                        "System.out.println($_);"  +
                        "}");
            }          }); Intercept new instances
  • 35.        CtMethod  foo  =  …          foo.instrument(new  ExprEditor()  {              @Override
            public  void  edit(MethodCall  m)                        throws  CannotCompileException  {
                if(m.getMethodName().contains("println"))  {
                    m.replace("{}");
                }                            }          }); Remove unwanted invocations
  • 36.        CtMethod  foo  =  …          foo.instrument(new  ExprEditor()  {              @Override
            public  void  edit(FieldAccess  m)                        throws  CannotCompileException  {
                if  (f.isWriter())  {
                    CtField  field  =  f.getField();
                    String  setterName  =  findSetter(field);
                    f.replace("{"  +  "$0."  +  setterName  +  "($$);"  +  "}");
                }                            }          }); Replace direct field access with setter calls
  • 37. This slide is intentionally left blank
  • 39. Java Agent import java.lang.instrument.ClassFileTransformer;   import java.lang.instrument.Instrumentation;   public class Agent {   public static void premain(String args, Instrumentation inst)   throws Exception {   inst.addTransformer(new ClassFileTransformer {   // here be code });   }   } META-­‐INF/MANIFEST.MF   Premain-­‐Class:  Agent $>  java  –javaagent:agent.jar  application.Main
  • 40. ClassFileTransformer new ClassFileTransformer() { public byte[] transform(ClassLoader loader,   String className,   Class<?> classBeingRedefined,   ProtectionDomain protectionDomain,   byte[] classfileBuffer){ ClassPool cp = ClassPool.getDefault();   CtClass ct = cp.makeClass(new   ByteArrayInputStream(classfileBuffer)); // here we can do all the things to ‘ct’ return ct.toBytecode(); }   }
  • 41. new ClassFileTransformer() { public byte[] transform(ClassLoader loader,   String className,   Class<?> classBeingRedefined,   ProtectionDomain protectionDomain,   byte[] classfileBuffer){ ClassPool cp = ClassPool.getDefault();   CtClass ct = cp.makeClass(new   ByteArrayInputStream(classfileBuffer)); // here we can do all the things to ‘ct’ return ct.toBytecode(); }   } ClassFileTransformer
  • 42. new ClassFileTransformer() { public byte[] transform(ClassLoader loader,   String className,   Class<?> classBeingRedefined,   ProtectionDomain protectionDomain,   byte[] classfileBuffer){ ClassPool cp = ClassPool.getDefault();   CtClass ct = cp.makeClass(new   ByteArrayInputStream(classfileBuffer)); // here we can do all the things to ‘ct’ return ct.toBytecode(); }   } ClassFileTransformer
  • 43. new ClassFileTransformer() { public byte[] transform(ClassLoader loader,   String className,   Class<?> classBeingRedefined,   ProtectionDomain protectionDomain,   byte[] classfileBuffer){ ClassPool cp = ClassPool.getDefault();   CtClass ct = cp.makeClass(new   ByteArrayInputStream(classfileBuffer)); // here we can do all the things to ‘ct’ return ct.toBytecode(); }   } ClassFileTransformer
  • 58. class  Framework  {      public  void  configure(){
    }     } CtClass  framework        =  cp.get("com.zt.Framework"); framework.addInterface(    cp.get("com.zt.jrebel.Listener")); class  Framework      implements  Listener  {      public  void  configure(){
    }     } framework.addMethod(      CtNewMethod.make(          "public  void  onEvent(){"  +          "    configure();"  +          "}",          framework   ));