Michael Musgrove commented on JBTM-2440:
I asked [~adinn] to provide an opinion about whether it could be the annotation rather
than the agent loading functionality that is the root cause of the problem and he suspects
that it is most likely a bug in the dynamic agent loading behaviour in the J9 compiler.
He also gave a good analysis of the issue which I am including here:
I downloaded IBM's Java 7 SDK and tried to use it to build Byteman.
That's enough to thoroughly test the use of the agent.
The tests on the Byteman agent maven module are configured to install
the agent from the command line using the -javaagent option (I do that
rather than use the BMUnitRunner to auto-load because I don't want
failures in BMUnit to stop the agent jar being built). These tests all
worked ok. So, the IBM JDK does support all the functionality of the
Byteman agent when you load it from the command line.
The maven tests in the BMUnit maven module rely the BMUnitRunner
annotation to auto-install the agent into an already running test JVM
and this is what failed. The error output is attached. As you can see
from the first exception trace the IBM JVM does implement dynamic
loading -- the Attach operation is fielded and J9 tries to install the
agent by executing
If you look at the cause of the exception you can see that this
eventually calls into
which is the Byteman entry point. This tries to register its
ClassFileTransformer (InstrumentationImpl.addTransformer) and at this
point J9 blows up. It is objecting to the agent's request for the
ClassFileTransformer to be installed as a 'retransformable' transformer.
That means it wants to be able to handle retransformations of existing
classes as well as being given a chance to modify newly loaded classes.
This seems a tad odd because when the Byteman agent is loaded on the
command line it also asks its ClassFileTransformer to be installed as a
retransformable transformer. So, the refusal by J9 must be some sort of
policy decision on its part. I suspect that this may be a performance
hack -- J9 may be willing to not perform certain optimizations in order
to allow for retransformers if you install them from the get go but
otherwise may decide to switch on optimizations that mean subsequent use
of retransformers won't work. Whatever the reason IBM have done this you
are snookered until you can get them to remove this restriction. n.b. it
is a legitimate (i.e. JVMTI agent spec-compliant) behaviour but it's not
exactly very useful. I will make eqnuiries to see if I can talk to
someone in IBM and get this removed or, at least, find a way to relax it
but I am not sure I will have any traction.
I think there is only one workaround which will fix this if you want to
use BMUnit on both OpenJDK/Oracle and IBM. You will need to switch to
loading the agent from the command line (whatever JVM you are using). To
do this you need to:
i) install the agent on the command line of the test JVM by
configuring java command line argument
ii) stop BMUnit from loading the agent by adding adding the property
n.b. you will need to build the path to the byteman jar by referencing
the relevant dependency in your maven repo dir. you should be able to do
that using by substituting maven property values (repo dir + byteman
dependency version) into the path
n.b. if you don't do the load yourself then you may want to set some
other -javaagent options and/or Byteman system properties. The auto load
will do the equivalent of adding boot:/path/to/byteman.jar to the
-javaagent line and adding -Dorg.jboss.byteman.allow.config.update as a
system property setting. The former allows you to inject into JDK
runtime classes. The latter allows BMUnit to pay heed to your any
options specified using a BMUnitConfig annotation on your test class.
Byteman tests fail when running with the IBM JVM
Project: JBoss Transaction Manager
Issue Type: Task
Affects Versions: 5.1.1
Reporter: Michael Musgrove
Assignee: Michael Musgrove
Fix For: 5.later
Byteman instrumentation does not work with the IBM J9 JVM:- it fails with errors like the
*** java.lang.instrument ASSERTION FAILED ***: "jvmtierror ==
JVMTI_ERROR_NOT_AVAILABLE" at JPLISAgent.c line: 1009
Exception in thread "Attachment 59984" Agent failed to start!
JVMJ9TI064E Agent initialization function Agent_OnAttach failed for library instrument,
return code 102
I will implement a workaround by disabling byteman when testing with this JVM.
This message was sent by Atlassian JIRA