title: How to save instrumented java bytecode by Java Agent?
body: <p><a href="http://docs.oracle.com/javase/8/docs/api/java/lang/instrument/package-summary.html" rel="nofollow noreferrer">Java Agent</a> provides services needed to instrument Java programming language code. <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/instrument/ClassFileTransformer.html#transform-java.lang.ClassLoader-java.lang.String-java.lang.Class-java.security.ProtectionDomain-byte:A-" rel="nofollow noreferrer">ClassFileTransformer</a> is an implementation for Java Agent, and the transformation occurs before the class is defined by the JVM. The only method <code>transform</code> is required to implement, and it is called for every new class definition. An illustration of how <code>Java Agent</code> works:</p>
  
  <p><img src="https://blog.newrelic.com/wp-content/uploads/BM3.png" alt="Java Agent"></p>
  
  <p><strong>I want to save the instrumented code</strong>, so that I can run the instrumented class file without instrumenting every time. As I checked <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html" rel="nofollow noreferrer">Interface Instrumentation</a>, I didn't see any direct api to save the transformed bytecode. I wonder whether it is possible to use <code>Java Agent</code> to achieve my goal, or some other tools?</p>