Topic
3 replies Latest Post - ‏2012-03-07T05:48:37Z by SystemAdmin
ErikOstermuellerLR
ErikOstermuellerLR
3 Posts
ACCEPTED ANSWER

Pinned topic adding retransformable transformers is not supported in this environment

‏2012-01-04T05:47:36Z |
Hello all,

I'm having easy-to-reproduce problems loading a JVMTI agent -- see stack trace, below.
To reproduce,
a) download intrace-agent.jar from here: http://intracesite.appspot.com/files/intrace-agent.jar
b) compile the attached TraceExample.java
c) java -javaagent:../lib/intrace-agent.jar example.TraceExample
d) you should see the stack trace I got below.

The following two IBM docs seem to show that my version of the JVM supports the JVMTI RetransformClasses functionality:

http://www-03.ibm.com/systems/resources/systems_i_advantages_perfmgmt_diag60.pdf (page 376)
http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/topic/com.ibm.java.doc.diagnostics.60/diag/tools/shcpd_rbm_jvmti.html

Specifically, I think this is the required functionality:
http://docs.oracle.com/javase/6/docs/platform/jvmti/jvmti.html#RetransformClasses

The IBM doc states some caveats with class caching. I've tried, unsuccessfully, to use these options to address those caveats:

-Xshareclasses:none
-Xshareclasses:cacheRetransformed

The actual agent (with source) is part of this interesting open source project: http://mchr3k.github.com/org.intrace/

Any help would be much appreciated. Thanks,

--Erik

java version "1.6.0"
Java(TM) SE Runtime Environment (build pxa6460sr7ifix-20100220_02(SR7+IZ69890+IZ70326))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Linux amd64-64 jvmxa6460sr7-20100219_54097 (JIT enabled, AOT enabled)
J9VM - 20100219_054097
JIT - r9_20091123_13891
GC - 20100216_AA)
JCL - 20091202_01

  1. Loaded InTrace Agent.
Exception in thread "main" java.lang.UnsupportedOperationException: cannot get the capability, performing dispose of the retransforming environment
at sun.instrument.InstrumentationImpl.isRetransformClassesSupported0(Native Method)
at sun.instrument.InstrumentationImpl.isRetransformClassesSupported(InstrumentationImpl.java:124)
at sun.instrument.InstrumentationImpl.addTransformer(InstrumentationImpl.java:79)
at org.intrace.agent.AgentInit.initialize(AgentInit.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.intrace.agent.Agent.initialize(Agent.java:66)
at org.intrace.agent.Agent.premain(Agent.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:335)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:350)
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:335)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:350)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.intrace.agent.Agent.initialize(Agent.java:70)
at org.intrace.agent.Agent.premain(Agent.java:26)
... 6 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.intrace.agent.Agent.initialize(Agent.java:66)
... 7 more
Caused by: java.lang.UnsupportedOperationException: adding retransformable transformers is not supported in this environment
at sun.instrument.InstrumentationImpl.addTransformer(InstrumentationImpl.java:80)
at org.intrace.agent.AgentInit.initialize(AgentInit.java:41)
... 12 more

Fatal error: processing of -javaagent failed
Java Result: 87
Updated on 2012-03-07T05:48:37Z at 2012-03-07T05:48:37Z by SystemAdmin
  • ErikOstermuellerLR
    ErikOstermuellerLR
    3 Posts
    ACCEPTED ANSWER

    Re: adding retransformable transformers is not supported in this environment

    ‏2012-01-05T20:46:21Z  in response to ErikOstermuellerLR
    ok, replying to self.

    I wrote:
    >>I'm having easy-to-reproduce problems loading a JVMTI agent

    I've been having a sidebar conversation with the maintainer of the InTrace project.
    He set me straight on something -- InTrace uses the Java "Instrumentation API", not JVMTI like I suggested in the above comment.

    So, I need to rephrase my question:
    Does the IBM JDK support the "Instrumentation API"? (http://docs.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html)

    Anyone got IBM JDK doc on that? Can't find it.

    Thanks,
    --Erik
    • ErikOstermuellerLR
      ErikOstermuellerLR
      3 Posts
      ACCEPTED ANSWER

      Re: adding retransformable transformers is not supported in this environment

      ‏2012-01-09T16:58:52Z  in response to ErikOstermuellerLR
      Replying to self, here.

      I fixed this problem. See this link/issue on the InTrace site for details:

      https://github.com/mchr3k/org.intrace/issues/15#issuecomment-3384718

      So, IBM JDK support is working fine for a java.lang.instrument agent....just had to add this attribute to the MANIFEST.MF file of the agent's jar: "Can-Retransform-Classes: true"

      But, I could still use a link to IBM javadoc for java.lang.instrument. Anyone got that?

      Thanks,

      --Erik
      • SystemAdmin
        SystemAdmin
        2736 Posts
        ACCEPTED ANSWER

        Re: adding retransformable transformers is not supported in this environment

        ‏2012-03-07T05:48:37Z  in response to ErikOstermuellerLR
        java.lang.Instrument comes from Oracle.
        This link holds relevance in IBM JDK too.
        http://docs.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html