SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
Torsten Curdt


   Java
 Byte Code
Engineering
  No black magic
Virtual CPU

Physical Machine

         Java
   Virtual Machine
.cstring
                          .align 2

     Native Assembler
                   LC0:
                          .ascii quot;Hello, world
                          .text
                          .align 2
                          .globl _main
#include <stdio.h>
               _main:
                        mflr r0
                        stmw r30,-8(r1)
int main(char** args) { r0,8(r1)
                        stw
                        stwu r1,-80(r1)
  printf(quot;Hello, worldquot;);
                        mr r30,r1
                        bcl 20,31,quot;L000000000
  return 0;    quot;L00000000001$pbquot;:
}                       mflr r31
                        stw r3,104(r30)
                 gcc -S addis r2,r31,ha16(LC0
                         HelloWorld.c
                        la r3,lo16(LC0-quot;L0000
                        bl L_printf$LDBLStub$
Native Assembler
                        #include <stdio.h>

                        int main(char** args)
mflr r0                   printf(quot;Hello, worl
                          return 0;
stmw r30,-8(r1)         }
stw r0,8(r1)
stwu r1,-80(r1)
mr r30,r1
bcl 20,31,quot;L00000000001$pbquot;
...             gcc -S HelloWorld.c
Compiled from quot;HelloW
         Java Assembler       public class HelloWor
                              public HelloWorld();
                                Code:
                                 0:   aload_0
                                 1:   invokespecial
public class HelloWorld {     Object.quot;<init>quot;:()V
                                 4:   return
    public static void main(String[] args) {
                            public static void ma
      System.out.println(quot;Hello, world!quot;);
                              Code:
    }                          0:   getstatic
                              System.out:Ljava/io/P
                                 3:   ldc     #3; /
}
                                 5:   invokevirtual
                                      //Method java
                         javap -c HelloWorld
                              lang/String;)V
                                 8:   return
Java Assembler
                             public class HelloWo

public static void main(java.lang.String[])
                              public static void
                                System.out.print
  Code:
                              }
   0: getstatic #2; //Field java/lang/
   3: ldc #3; //String Hello, world!
                            }
   5: invokevirtual #4; //Method java/io/
   8:
      return
}
                       javap -c HelloWorld
Jasmin Syntax
                           public class HelloWo

                            public static void
.method public static main([Ljava/lang
                              System.out.print
  .limit stack 2            }
  .limit locals 1
                            }
  .line 4
  getstatic java/lang/System/out Ljava/
  ldc quot;Hello, world!quot;
  invokevirtual java/io/PrintStream/println
  .line 5
  return
.end method
Tools

• Disassembler: Jasper
    java -jar jasper.jar HelloWorld.class

• Assembler: Jasmin
    java -jar jasmin.jar HelloWorld.j
Roundtrip
               jasmin




HelloWorld.j            HelloWorld.class




               jasper
Libraries

• ASM (BSD-style)
• BCEL (ASL)
• CGLIB (ASL)
• Javassist (MPL/LGPL)
Libraries

AOP    Javassist    ASM



           CGLIB   BCEL
BCEL

• Object model based
• JDK 1.4 support
• Verifier
• “DOM”
ASM

• Event driven
• DOM available
• JDK 1.6 support
• “SAX”
BCEL vs ASM

• Community
• JDK support
• “DOM” vs “SAX”
• API
• Tool support
BCEL vs ASM

• BCEL: xalan, findbugs,
 aspectj, javaflow, clirr,
 beanshell, just4log, ...
• ASM: jardiff, javaflow, groovy,
 cobertura, aspectwerkz,
 beanshell, retroweaver, ...
demo
Generation
XSLTC


• XSLT to java compiler
• Creates a translet from xslt
• Translet as JAXP transformer
XSLTC
*.xsl                                  SAX Parser      XPath Parser



                                              XSLT Parser
        JAXP / TrAX API



                          native API

*.xml

                                             XSLT Compiler



                                                    BCEL              class
XSLTC Speed




gregor   msxml   jd.xslt   xsltc   saxon   xalan-j
Groovy
groovy
          Groovy Parser
source




         ASM ClassVisitor   class
Analysis
Findbugs


• Static analysis for bug
 patterns
• False positives
Findbugs
Findbugs
Clirr / Jardiff


• Diff for jars or class files
• Detecting API changes
Jardiff
Jardiff
Dependency


• Analyses class dependencies
• Finding unused classes
• Renaming classes
      http://vafer.org/projects/dependency
Dependency

Set dependencies = DependencyUtils
  .getDependenciesOfClass(
      Class1.class
   );
Dependency
new ResourceRenamer() {
  String getNewNameFor(String oldName) {
   if (oldName.startsWith(
       quot;java.util.HashMapquot;)) {
           return quot;my.quot; + oldName;
   }
   return oldName;
}
Modification
Cobertura / Clover


• Testcase coverage
• Recording the execution path
• Maven plugin
Cobertura
Cobertura
Throttling

• Wrap Socket to deliver
 throughput according to
 settings
• Cannot rewrite java.* classes
Retroweaver

• Compile with jdk 1.5 features,
 run on 1.4
• Static conversion
• Runtime conversion
Just4log

for(int i=0; i<500000; i++) {
for(int i=0; i<500000; i++) {
   if(log.isDebugEnabled()) {
  if(log.isDebugEnabled()) {
     log.debug(quot;messagequot;
    log.debug(quot;messagequot;
       + someLongTaskToExecute());
   } + someLongTaskToExecute());
  }normalCodeToExecute();
} normalCodeToExecute();
}
AspectJ

public aspect LogAspect
{
  declare precedence : LogAspect, *;

 pointcut voidCalls() :
   !within(LogAspect)
   && execution(void *.*(..))
 );
AspectJ
Object around() : voidCalls() {

Signature sig = thisJoinPoint.getSignature();

log.debug('<' + getFullSig(thisJoinPoint));
Object result = proceed();
log.debug('>' + sig.getName());

return result;
Javaflow
class MyRunnable implements Runnable {
  public void run() {
    for(int i=0; i<10; i++ )
      Continuation.suspend();
  }}
Continuation c = Continuation.startWith(
                      new MyRunnable());
Continuation d = Continuation.continueWith(c);
...
Javaflow
What you can do


• reflection without j.l.reflection
• generate classes on the fly
• implement interface on the fly
What you can do

• change visibility
• extend classes that are final
• modify vs forking
• ...
Thanks!

Contenu connexe

Tendances

Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseSages
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJSKyung Yeol Kim
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8XSolve
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Susan Potter
 
Deep Dumpster Diving
Deep Dumpster DivingDeep Dumpster Diving
Deep Dumpster DivingRonnBlack
 
Introduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineIntroduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineMovel
 
Joker 2015 - Валеев Тагир - Что же мы измеряем?
Joker 2015 - Валеев Тагир - Что же мы измеряем?Joker 2015 - Валеев Тагир - Что же мы измеряем?
Joker 2015 - Валеев Тагир - Что же мы измеряем?tvaleev
 
Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsAndrei Pangin
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in RustIngvar Stepanyan
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016Manoj Kumar
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6Dmitry Soshnikov
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueGleicon Moraes
 
Cascadia.js: Don't Cross the Streams
Cascadia.js: Don't Cross the StreamsCascadia.js: Don't Cross the Streams
Cascadia.js: Don't Cross the Streamsmattpodwysocki
 
Reactive Access to MongoDB from Scala
Reactive Access to MongoDB from ScalaReactive Access to MongoDB from Scala
Reactive Access to MongoDB from ScalaHermann Hueck
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6Dmitry Soshnikov
 
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
 

Tendances (20)

Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
 
Deep Dumpster Diving
Deep Dumpster DivingDeep Dumpster Diving
Deep Dumpster Diving
 
Jvm a brief introduction
Jvm  a brief introductionJvm  a brief introduction
Jvm a brief introduction
 
Introduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineIntroduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy Cresine
 
Joker 2015 - Валеев Тагир - Что же мы измеряем?
Joker 2015 - Валеев Тагир - Что же мы измеряем?Joker 2015 - Валеев Тагир - Что же мы измеряем?
Joker 2015 - Валеев Тагир - Что же мы измеряем?
 
Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap Dumps
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in Rust
 
Rust ⇋ JavaScript
Rust ⇋ JavaScriptRust ⇋ JavaScript
Rust ⇋ JavaScript
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message Queue
 
Full Stack Clojure
Full Stack ClojureFull Stack Clojure
Full Stack Clojure
 
Cascadia.js: Don't Cross the Streams
Cascadia.js: Don't Cross the StreamsCascadia.js: Don't Cross the Streams
Cascadia.js: Don't Cross the Streams
 
Reactive Access to MongoDB from Scala
Reactive Access to MongoDB from ScalaReactive Access to MongoDB from Scala
Reactive Access to MongoDB from Scala
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
Google Guava
Google GuavaGoogle Guava
Google Guava
 
05 pig user defined functions (udfs)
05 pig user defined functions (udfs)05 pig user defined functions (udfs)
05 pig user defined functions (udfs)
 

Similaire à Java Byte Code Engineering Tools and Libraries

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 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesCharles Nutter
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Anton Arhipov
 
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
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
Shiksharth com java_topics
Shiksharth com java_topicsShiksharth com java_topics
Shiksharth com java_topicsRajesh Verma
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevMattias Karlsson
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGSylvain Wallez
 
How Scala code is expressed in the JVM
How Scala code is expressed in the JVMHow Scala code is expressed in the JVM
How Scala code is expressed in the JVMKoichi Sakata
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agentsRafael Winterhalter
 
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw  est prêt à tuer le classpathSoft-Shake 2016 : Jigsaw  est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpathAlexis Hassler
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaCharles Nutter
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Sylvain Wallez
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015Charles Nutter
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemGuardSquare
 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javacAnna Brzezińska
 

Similaire à Java Byte Code Engineering Tools and Libraries (20)

Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
 
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
 
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
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Shiksharth com java_topics
Shiksharth com java_topicsShiksharth com java_topics
Shiksharth com java_topics
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUG
 
Java
JavaJava
Java
 
How Scala code is expressed in the JVM
How Scala code is expressed in the JVMHow Scala code is expressed in the JVM
How Scala code is expressed in the JVM
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agents
 
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw  est prêt à tuer le classpathSoft-Shake 2016 : Jigsaw  est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible Java
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
 

Dernier

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
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
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Dernier (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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 ...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
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
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Java Byte Code Engineering Tools and Libraries

  • 1. Torsten Curdt Java Byte Code Engineering No black magic
  • 2. Virtual CPU Physical Machine Java Virtual Machine
  • 3. .cstring .align 2 Native Assembler LC0: .ascii quot;Hello, world .text .align 2 .globl _main #include <stdio.h> _main: mflr r0 stmw r30,-8(r1) int main(char** args) { r0,8(r1) stw stwu r1,-80(r1) printf(quot;Hello, worldquot;); mr r30,r1 bcl 20,31,quot;L000000000 return 0; quot;L00000000001$pbquot;: } mflr r31 stw r3,104(r30) gcc -S addis r2,r31,ha16(LC0 HelloWorld.c la r3,lo16(LC0-quot;L0000 bl L_printf$LDBLStub$
  • 4. Native Assembler #include <stdio.h> int main(char** args) mflr r0 printf(quot;Hello, worl return 0; stmw r30,-8(r1) } stw r0,8(r1) stwu r1,-80(r1) mr r30,r1 bcl 20,31,quot;L00000000001$pbquot; ... gcc -S HelloWorld.c
  • 5. Compiled from quot;HelloW Java Assembler public class HelloWor public HelloWorld(); Code: 0: aload_0 1: invokespecial public class HelloWorld { Object.quot;<init>quot;:()V 4: return public static void main(String[] args) { public static void ma System.out.println(quot;Hello, world!quot;); Code: } 0: getstatic System.out:Ljava/io/P 3: ldc #3; / } 5: invokevirtual //Method java javap -c HelloWorld lang/String;)V 8: return
  • 6. Java Assembler public class HelloWo public static void main(java.lang.String[]) public static void System.out.print Code: } 0: getstatic #2; //Field java/lang/ 3: ldc #3; //String Hello, world! } 5: invokevirtual #4; //Method java/io/ 8: return } javap -c HelloWorld
  • 7. Jasmin Syntax public class HelloWo public static void .method public static main([Ljava/lang System.out.print .limit stack 2 } .limit locals 1 } .line 4 getstatic java/lang/System/out Ljava/ ldc quot;Hello, world!quot; invokevirtual java/io/PrintStream/println .line 5 return .end method
  • 8. Tools • Disassembler: Jasper java -jar jasper.jar HelloWorld.class • Assembler: Jasmin java -jar jasmin.jar HelloWorld.j
  • 9. Roundtrip jasmin HelloWorld.j HelloWorld.class jasper
  • 10. Libraries • ASM (BSD-style) • BCEL (ASL) • CGLIB (ASL) • Javassist (MPL/LGPL)
  • 11. Libraries AOP Javassist ASM CGLIB BCEL
  • 12. BCEL • Object model based • JDK 1.4 support • Verifier • “DOM”
  • 13. ASM • Event driven • DOM available • JDK 1.6 support • “SAX”
  • 14. BCEL vs ASM • Community • JDK support • “DOM” vs “SAX” • API • Tool support
  • 15. BCEL vs ASM • BCEL: xalan, findbugs, aspectj, javaflow, clirr, beanshell, just4log, ... • ASM: jardiff, javaflow, groovy, cobertura, aspectwerkz, beanshell, retroweaver, ...
  • 16. demo
  • 18. XSLTC • XSLT to java compiler • Creates a translet from xslt • Translet as JAXP transformer
  • 19. XSLTC *.xsl SAX Parser XPath Parser XSLT Parser JAXP / TrAX API native API *.xml XSLT Compiler BCEL class
  • 20. XSLTC Speed gregor msxml jd.xslt xsltc saxon xalan-j
  • 21. Groovy groovy Groovy Parser source ASM ClassVisitor class
  • 23. Findbugs • Static analysis for bug patterns • False positives
  • 26. Clirr / Jardiff • Diff for jars or class files • Detecting API changes
  • 29. Dependency • Analyses class dependencies • Finding unused classes • Renaming classes http://vafer.org/projects/dependency
  • 30. Dependency Set dependencies = DependencyUtils .getDependenciesOfClass( Class1.class );
  • 31. Dependency new ResourceRenamer() { String getNewNameFor(String oldName) { if (oldName.startsWith( quot;java.util.HashMapquot;)) { return quot;my.quot; + oldName; } return oldName; }
  • 33. Cobertura / Clover • Testcase coverage • Recording the execution path • Maven plugin
  • 36. Throttling • Wrap Socket to deliver throughput according to settings • Cannot rewrite java.* classes
  • 37. Retroweaver • Compile with jdk 1.5 features, run on 1.4 • Static conversion • Runtime conversion
  • 38. Just4log for(int i=0; i<500000; i++) { for(int i=0; i<500000; i++) { if(log.isDebugEnabled()) { if(log.isDebugEnabled()) { log.debug(quot;messagequot; log.debug(quot;messagequot; + someLongTaskToExecute()); } + someLongTaskToExecute()); }normalCodeToExecute(); } normalCodeToExecute(); }
  • 39. AspectJ public aspect LogAspect { declare precedence : LogAspect, *; pointcut voidCalls() : !within(LogAspect) && execution(void *.*(..)) );
  • 40. AspectJ Object around() : voidCalls() { Signature sig = thisJoinPoint.getSignature(); log.debug('<' + getFullSig(thisJoinPoint)); Object result = proceed(); log.debug('>' + sig.getName()); return result;
  • 41. Javaflow class MyRunnable implements Runnable { public void run() { for(int i=0; i<10; i++ ) Continuation.suspend(); }} Continuation c = Continuation.startWith( new MyRunnable()); Continuation d = Continuation.continueWith(c); ...
  • 43. What you can do • reflection without j.l.reflection • generate classes on the fly • implement interface on the fly
  • 44. What you can do • change visibility • extend classes that are final • modify vs forking • ...