Instrumentation was introduced in JDK 1.5. You can start the JVM specifying a Java agent, or you can attach agents later. An agent's agentmain and/or premain methods will be called by the JVM, and this is where it can register a ClassFileTransformer to modify classes at runtime. (You can find a nice tutorial about instrumentation here.)
The hard way do instrument a class is to implement your own ClassFileTransformer and work with byte arrays representing class files directly, e.g. using a DataInputStream. Of course this is not recommended if you don't want to go into details of the class file structure, but as mentioned during the presentation, this way you can learn a lot about it. ;)
- Use the javap and javac tools together to decompile a class, do your modifications and compile it again. Sounds a bit cumbersome though.
- Use some framework to do the hard work for you, e.g. ASM, Apache Commons BCEL (Byte Code Engineering Library), or Javassist.
- To make it even more comfortable, on top of a framework you can use some IDE plugins like the Bytecode Outline plugin for Eclipse.
Update: Here is the link for the presentation's site.