mchr3k / org.intrace

Java tracing agent and live trace client
http://mchr3k.github.com/org.intrace/
73 stars 18 forks source link

IBM JDK Support #15

Closed eostermueller closed 12 years ago

eostermueller commented 12 years ago

The InTrace javaagent throws an exception and fails to start with an IBM JDK. Some of this is documented here:

https://github.com/mchr3k/org.intrace/issues/12#issuecomment-3341518

Here is the JVM that was used:

java -version 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

Here is the full exception, which is also at the above link:

Buildfile: build.xml

init:

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

 [java] Fatal error: processing of -javaagent failed

BUILD SUCCESSFUL Total time: 0 seconds

mchr3k commented 12 years ago

Try the following file: http://intracesite.appspot.com/files/intrace-agent-beta.jar

This should disable the use of retransformation.

eostermueller commented 12 years ago

You're quick and that worked, thanks. But still need to hide this one exception:

 [java] ## Loaded InTrace Agent.****

 [java] Exception in thread "main"

java.lang.UnsupportedOperationException: cannot get the capability, performing dispose of the retransforming environment****

 [java]     at

sun.instrument.InstrumentationImpl.isRetransformClassesSupported0(Native Method)****

 [java]     at

sun.instrument.InstrumentationImpl.isRetransformClassesSupported(InstrumentationImpl.java:124)


 [java]     at org.intrace.agent.AgentInit.initialize(AgentInit.java:41)

 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native

Method)****

 [java]     at

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)


 [java]     at

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)


[java]     at java.lang.reflect.Method.invoke(Method.java:600)****

 [java]     at org.intrace.agent.Agent.initialize(Agent.java:66)****

 [java]     at org.intrace.agent.Agent.premain(Agent.java:26)****

 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native

Method)****

 [java]     at

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)


 [java]     at

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)


 [java]     at java.lang.reflect.Method.invoke(Method.java:600)****

 [java]     at

sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:335)


 [java]     at

sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:350)


 [java] ## Retransform classes is not supported...****

 [java] ## InTrace Agent listening on port 9123****

[tp@spedl36018 build]$****

**

On Tue, Jan 3, 2012 at 3:40 PM, mchr3k < reply@reply.github.com

wrote:

Try the following file: http://intracesite.appspot.com/files/intrace-agent-beta.jar

This should disable the use of retransformation.


Reply to this email directly or view it on GitHub: https://github.com/mchr3k/org.intrace/issues/15#issuecomment-3346670

eostermueller commented 12 years ago

After looking at this closer, IBM doc advertises support for the features being flagged as "unsupported" in the stacktrace.

I've posted the following question to IBM with the details, including how to reproduce the problem: https://www.ibm.com/developerworks/forums/thread.jspa?threadID=413792

mchr3k commented 12 years ago

I've just read your post and spotted a mistake. InTrace is not a JVMTI agent. InTrace is a Java Agent.

eostermueller commented 12 years ago

thx checking that.

I knew I was taking a leap when I wrote that, but help me understand. So is a "java agent" something that abides by this: http://docs.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html ?

Does that mean that both "Java agents" and JVMTI programs have "RetransformClasses" functionality? like this:

http://docs.oracle.com/javase/6/docs/platform/jvmti/jvmti.html#RetransformClasses

--Erik

On Thu, Jan 5, 2012 at 12:12 PM, mchr3k < reply@reply.github.com

wrote:

I've just read your post and spotted a mistake. InTrace is not a JVMTI agent. InTrace is a Java Agent.


Reply to this email directly or view it on GitHub: https://github.com/mchr3k/org.intrace/issues/15#issuecomment-3373732

mchr3k commented 12 years ago

Yes a Java Agent is based on the java.lang.instrument package.

This page from another one of my projects gives an overview of the various developer APIs in the JVM: http://mchr3k.github.com/org.inmemprofiler/implementationdetails.html

JVMTI is a native API for doing bytecode instrumentation (amongst many other things). Java Agents are a way of doing a subset of what JVMTI does but in pure Java.

eostermueller commented 12 years ago

thanks for that education, very helpful. I just replied to my IBM forum question, correcting this point.

On Thu, Jan 5, 2012 at 1:19 PM, mchr3k < reply@reply.github.com

wrote:

Yes a Java Agent is based on the java.lang.instrument package.

This page from another one of my projects gives an overview of the various developer APIs in the JVM: http://mchr3k.github.com/org.inmemprofiler/implementationdetails.html

JVMTI is a native API for doing bytecode instrumentation (amongst many other things). Java Agents are a way of doing a subset of what JVMTI does but in pure Java.


Reply to this email directly or view it on GitHub: https://github.com/mchr3k/org.intrace/issues/15#issuecomment-3374769

eostermueller commented 12 years ago

Ok, I fixed it.

I downloaded the regular intrace-agent.jar and added the following to the MANIFEST.MF: Can-Retransform-Classes: true

...and now it all works great on the IBM JDK. Agent starts w/o error and can dynamically add/remove instrumented classes.

So it looks like the Oracle JDK doesn't pay attention to this attribute and IBM does. Could you add this attribute?

Thanks, --Erik

mchr3k commented 12 years ago

Well spotted. The problem file is line 89 of https://github.com/mchr3k/org.intrace/blob/master/org.intrace/build.xml. I will get this fixed in the next couple of days.

mchr3k commented 12 years ago

This fix is now checked in.

https://github.com/mchr3k/org.intrace/tree/master/binaries/jars/latest_development