jacoco agent not getting started with jdk 1.8u66

151 views
Skip to first unread message

er.yogesh...@gmail.com

unread,
Jan 10, 2017, 5:03:22 AM1/10/17
to JaCoCo and EclEmma Users
i am getting below error while trying to start jacoco agent by putting up the below properties

set JACOCO_PROPERTIES=-javaagent:/opt/jacoco-0.7.8/lib/jacocoagent.jar=destfile=/opt/jacoco.exec,output=tcpserver,address=*

error:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source)
Caused by: java.lang.RuntimeException: Class java/util/UUID could not be instrumented.
at org.jacoco.agent.rt.internal_e5875b2.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:140)
at org.jacoco.agent.rt.internal_e5875b2.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:101)
at org.jacoco.agent.rt.internal_e5875b2.PreMain.createRuntime(PreMain.java:55)
at org.jacoco.agent.rt.internal_e5875b2.PreMain.premain(PreMain.java:47)
... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
at java.lang.Class.getField(Unknown Source)
at org.jacoco.agent.rt.internal_e5875b2.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
... 9 more
FATAL ERROR in native method: processing of -javaagent failed

er.yogesh...@gmail.com

unread,
Jan 10, 2017, 5:10:20 AM1/10/17
to JaCoCo and EclEmma Users, er.yogesh...@gmail.com
jacoco version: 0.7.8
java version:jdk 1.8u66

Evgeny Mandrikov

unread,
Jan 10, 2017, 10:37:48 AM1/10/17
to JaCoCo and EclEmma Users, er.yogesh...@gmail.com
Given:

public class Example {
 public static void main(String[] args) {
   System.out.println("Hello, World!");
 }
}

And using:

$ java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

$ javac -version
javac 1.8.0_66

Runs just fine:

$ java -javaagent:jacoco-0.7.8/lib/jacocoagent.jar=destfile=jacoco.exec,output=tcpserver,address=* Example

Based on your stack trace:

The only known to me example of such failure relates to usage of IBM JRE J9 and WebSphere - https://github.com/jacoco/eclemma/issues/94
If this is your case, then as stated in our FAQ ( http://www.eclemma.org/jacoco/trunk/doc/faq.html ): To make the JaCoCo agent work please set the VM option -Xshareclasses:none.

If this is not your case and since failure happens not during instrumentation, but in a sequence of agent startup, then AFAIK there is no known examples of such failure and hence no known solutions. So without additional details will be hard to help you. However as a workaround you can switch on usage of solely offline instrumentation that doesn't require agent ( http://www.eclemma.org/jacoco/trunk/doc/offline.html ).

And here is my wild guesses to give you an ideas of which details to provide and in which directions to dig during investigations on your side:
Maybe class java/util/UUID somehow loaded prior to JaCoCo agent gets a chance to modify it. What could cause this?
Or maybe you have Java Security Manager that forbids JaCoCo agent to modify class java/util/UUID somehow. Again - how?

As always - good reproducer consists of exact steps that others can do to reproduce your problem.

Hope this helps,
Evgeny

er.yogesh...@gmail.com

unread,
Jan 10, 2017, 1:00:10 PM1/10/17
to JaCoCo and EclEmma Users, er.yogesh...@gmail.com
Thanks. It got resolved after changing the sequence of agent startup.

Added jacoco agent in the begining of java_opts.

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages