The Hotspot/OpenJDK Java agent capability and its associated java.lang.instrument API provide support for runtime bytecode transformation, either initially at class load time or, since JDK6, retrospectively after classes have been loaded and instantiated. This API has been adopted as a de facto standard by several other industrial strength JVMs. The uses of this API extend far beyond simple code instrumentation and suggest that more widespread adoption of the OpenJDK Java agent model and use of Java agents is highly desirable. Byteman is a Java agent program and suite of associated tools which supports tracing, monitoring and testing of Java applications via bytecode transformation. This has many advantages over conventional approaches, in particular being much more flexible and far less invasive. This talk will demonstrate Byteman in action showing you how to install and run it both standalone from the java command line and integrated with the JUnit and TestNG test frameworks driven from ant or maven. The examples progress from injecting simple debug trace to displaying a timing bug in a multi-threaded application. Along the way you should learn how Java agent programs work and how much freedom they have to manipulate the JVM runtime. I hope to encourage many of you to use Byteman and to contribute suggestions for new features. Also, maybe a few of you will be inspired to implement your own agent programs or to provide support for agents in other JVMs.
Speakers: Andrew Dinn