JACOCO TCPSERVER INTERGRATION

76 views
Skip to first unread message

Vansh Kumar Madan

unread,
Sep 28, 2020, 9:05:13 AM9/28/20
to JaCoCo and EclEmma Users
Hi,

I am using jacoco javagent  method to record execution coverage.

Command-
java -javaagent:jacocoagent.jar=address=*,port=57026,output=tcpserver,destfile=jacoco-it.exec

After executing above command.

ERROR:

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
    at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
Caused by: java.lang.RuntimeException: Class java/lang/UnknownError could not be instrumented.
    at org.jacoco.agent.rt.internal_290345e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:139)
    at org.jacoco.agent.rt.internal_290345e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:100)
    at org.jacoco.agent.rt.internal_290345e.PreMain.createRuntime(PreMain.java:55)
    at org.jacoco.agent.rt.internal_290345e.PreMain.premain(PreMain.java:47)
    ... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
    at java.base/java.lang.Class.getField(Class.java:1999)
    at org.jacoco.agent.rt.internal_290345e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:137)
    ... 9 more
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at ./src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed
Aborted (core dumped)

Vansh Kumar Madan

unread,
Sep 28, 2020, 9:07:11 AM9/28/20
to JaCoCo and EclEmma Users
OS- LINUX(UBUNTU)
JACOCO Version -0.8.0

Evgeny Mandrikov

unread,
Sep 28, 2020, 9:10:14 AM9/28/20
to JaCoCo and EclEmma Users
JaCoCo version 0.8.0 supports only Java class files up to Java 9 version. 

So instead of the old 0.8.0 version, please always use the latest released JaCoCo version, which is 0.8.6 as of today.

Vansh Kumar Madan

unread,
Sep 28, 2020, 12:07:18 PM9/28/20
to JaCoCo and EclEmma Users
Hi,

JAVA VERSION - openjdk 11.0.8 2020-07-14
JACOCO VERSION NOW 0.8.6

java -javaagent:jacocoagent.jar=address=*,port=57026,output=tcpserver,destfile=jacoco-it.exec

Above command is throwing java help page as output after jacoco version change.

OUTPUT:
Usage: java [options] <mainclass> [args...]
           (to execute a class)
   or  java [options] -jar <jarfile> [args...]
           (to execute a jar file)
   or  java [options] -m <module>[/<mainclass>] [args...]
       java [options] --module <module>[/<mainclass>] [args...]
           (to execute the main class in a module)
   or  java [options] <sourcefile> [args]
           (to execute a single source-file program)

 Arguments following the main class, source file, -jar <jarfile>,
 -m or --module <module>/<mainclass> are passed as the arguments to
 main class.

 where options include:

    -zero      to select the "zero" VM
    -dcevm      to select the "dcevm" VM
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    --class-path <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -p <module path>

Evgeny Mandrikov

unread,
Sep 28, 2020, 12:19:34 PM9/28/20
to JaCoCo and EclEmma Users
Please read this help - as written in it to start Java application you have to specify more than just "-javaagent".
Reply all
Reply to author
Forward
0 new messages