title: Javaagent. What for?
body: <p>When I try to find examples of using Javaagent, in most cases they are examples with working with byte-code. These examples use third-party libraries, such as Javaassist.</p>
  
  <p>As far as I know there are no standard means in Java to work with byte-code and in any case you'll have to resort to the libraries. </p>
  
  <p>So, I tried to use these libraries in my own custom classloader before calling <code>defineClass()</code>. And, off course, it worked perfectly well. I could change byte-code the same way, as if I would do it with <code>ClassFileTransformer</code>'s <code>transform()</code> method.</p>
  
  <p>Do I understand correctly that there is another useful feature of javaagents, that in turn is their main feature? Because, first of all, javaagent gives you an <code>Instrumentation</code> object and the Java spec says that the <code>instrument</code> package is mainly used to work with byte-code. But why do I need to do that if I just can implement my own classloader (the thing I could do long before the <code>instrument</code> package was introduced)?</p>