JDK 1.5 added a new feature for instrumenting byte code in Java (See java.lang.Instrument for more information). The attached patch adds support for configuration of java agents and agent dependencies on the surefire command line, when forking is enabled. The code used to configure the jvm argLine does not use any JDK 1.5 features. Test cases are included.
The java.lang.Instrument approach has a few advantages:
1) no stale instrumented classes
2) no need for forked lifecycles and hacks to get the instrumented classes on the classpath
3) any class that is loaded into the jvm can be instrumented