Jacoco Agent (0.8.8) breaks with OpenJDK 17

3,407 views
Skip to first unread message

Xavier León Civera

unread,
Aug 18, 2022, 3:33:04 AM8/18/22
to JaCoCo and EclEmma Users

* JaCoCo version: 0.8.8
* Operating system: Debian 11.2 amd64
* Tool integration: Ant (1.10.11)
* JDK: OpenJDK Runtime Environment, 17.0.4+8-LTS
* Complete executable reproducer: 

Bellow code is working with JDK 11 and Jacoco 0.8.7

<project name="jacocoreport.ant" xmlns:jacoco="antlib:org.jacoco.ant">
  <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
  <classpath>
    <fileset dir="${ext.jacocoreport.path}/lib" includes="*.jar"/>
  </classpath>
  </taskdef>

  <property name="LOG_DIR" value="${basedir}/../../log"/>
  <target name="jacocoalltests" description="runs allstests with jacoco attached">
    <jacoco:agent property="agentvmparam" 
      append="true"
      output="file"
      destfile="${LOG_DIR}/junit/jacoco.exec"
    />
    <property name="testclasses.extensions" value="${extname}"/>
    <ant target="alltests" inheritrefs="false">
      <property name="standalone.javaoptions" value="${agentvmparam} ${standalone.javaoptions}"/>
    </ant>
  </target>
</project>

* Steps:
1st Upgrade JDK from openJDK 11 to OpenJDK 17.
2nd Change Jacoco Libraries from jacoco 0.8.7 to 0.8.8
3th Execute ant jacocoalltests (Target jacoco alltest invoke an other target that execute all unit test)

### Expected behaviour (part output with JDK 11 and Jacoco 0.8.7)
 [yunitrep] Processing /opt/cxcommerce/hybris/log/junit/TESTS-TestSuites.xml to /tmp/null969800646
[yunitrep] Loading stylesheet jar:file:/opt/cxcommerce/hybris/bin/platform/apache-ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[yunitrep] Transform time: 535ms
[yunitrep] Deleting: /tmp/null969800646
[echo] Report generated to /opt/cxcommerce/hybris/log/junit/index.html
[echo] JUNITTESTS FAILED. See /opt/cxcommerce/hybris/log/junit/index.html!
BUILD SUCCESSFUL
Total time: 2 minutes 8 seconds

### Actual behaviour (JDK 17 and jacoco 0.8.8)
[yunitint]
|-- Adding Filter for UnitTests
|-- Adding Filter for IntegrationTests
|-- Adding Filter for DemoTests
|-- Adding Filter for extension adyenpaybylinkintegration
|-- Adding Filter for extension almapayments
|-- Adding Filter for extension bihrassistedservicestorefront
|-- Adding Filter for extension bihrbackoffice
|-- Adding Filter for extension bihrbackofficeaddon
|-- Adding Filter for extension bihrcommercewebservices
|-- Adding Filter for extension bihrcore
|-- Adding Filter for extension bihrcustomerticketingaddon
|-- Adding Filter for extension bihrfacades
|-- Adding Filter for extension bihrfulfilmentprocess
|-- Adding Filter for extension bihrinitialdata
|-- Adding Filter for extension bihrintegrationfacades
|-- Adding Filter for extension bihrpatches
|-- Adding Filter for extension bihrstorefront
|-- Adding Filter for extension newsaddon
|-- Adding Filter for extension newsaddonbackoffice
|-- Adding Filter for extension psdtocache
 [yunitint] Using TestClassesUtil...
 [yunitint] Found 71 filtered classes...
 [yunitint] Scanning finished in : 505ms, found 71 testclasse(s)!
 [yunitint] --> found 71 testclasses!
 [yunitint] FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed
 [yunitint] Exception in thread "main" java.lang.reflect.InvocationTargetException
 [yunitint]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [yunitint]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
 [yunitint]     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 [yunitint]     at java.base/java.lang.reflect.Method.invoke(Method.java:568)
 [yunitint]     at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:491)
 [yunitint]     at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:503)
 [yunitint] Caused by: java.lang.RuntimeException: Class java/lang/UnknownError could not be instrumented.
 [yunitint]     at org.jacoco.agent.rt.internal_28bab1d.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:140)
 [yunitint]     at org.jacoco.agent.rt.internal_28bab1d.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:101)
 [yunitint]     at org.jacoco.agent.rt.internal_28bab1d.PreMain.createRuntime(PreMain.java:55)
 [yunitint]     at org.jacoco.agent.rt.internal_28bab1d.PreMain.premain(PreMain.java:47)
 [yunitint]     ... 6 more
 [yunitint] Caused by: java.lang.NoSuchFieldException: $jacocoAccess
 [yunitint]     at java.base/java.lang.Class.getField(Class.java:2117)
 [yunitint]     at org.jacoco.agent.rt.internal_28bab1d.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
 [yunitint]     ... 9 more
 [yunitint] *** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422
 [yunitint] Running eu.bihr.fulfilmentprocess.test.SendPaymentFailedNotificationTest
 [yunitint] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
 [yunitint] Tests FAILED (crashed)
 [yunitrep] Processing /opt/cxcommerce/hybris/log/junit/TESTS-TestSuites.xml to /tmp/null1271442651
 [yunitrep] Loading stylesheet jar:file:/opt/cxcommerce/hybris/bin/platform/apache-ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
 [yunitrep] Transform time: 496ms
 [yunitrep] Deleting: /tmp/null1271442651
     [echo] Report generated to /opt/cxcommerce/hybris/log/junit/index.html
     [echo] JUNITTESTS FAILED. See /opt/cxcommerce/hybris/log/junit/index.html!
     [echo] Disabling debug output for integration-apis in local.properties
     [move] Moving 1 file to /opt/cxcommerce/hybris/config

Marc Hoffmann

unread,
Aug 18, 2022, 5:27:30 AM8/18/22
to JaCoCo and EclEmma Users
Hi Xavier,

from your stack trace 


[yunitint] Caused by: java.lang.RuntimeException: Class java/lang/UnknownError could not be instrumented.
 [yunitint]     at org.jacoco.agent.rt.internal_28bab1d.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:140)
 [yunitint]     at org.jacoco.agent.rt.internal_28bab1d.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:101)
 [yunitint]     at org.jacoco.agent.rt.internal_28bab1d.PreMain.createRuntime(PreMain.java:55)
 [yunitint]     at org.jacoco.agent.rt.internal_28bab1d.PreMain.premain(PreMain.java:47)

it looks like this is not a official JaCoCo 0.8.7. nor 0.8.8 release. Our version 0.8.8 has the package name

org.jacoco.agent.rt.internal_b6258fc

Please re-test the official artifacts from Maven central.

Best regards,
-marc




--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/20f3a890-947b-4d2d-9429-367bf22c0acan%40googlegroups.com.

Xavier León Civera

unread,
Aug 18, 2022, 6:57:19 AM8/18/22
to JaCoCo and EclEmma Users
Hello Marc.

I've downloaded the package from jacoco.org

My md5sum is the same as https://www.jacoco.org/jacoco/download/jacoco-0.8.8.zip.md5.txt :
 md5sum /tmp/jacoco-0.8.8.zip
10a812712aa9d4bf02ad975e3e1364e4  /tmp/jacoco-0.8.8.zip
Official MD5sum package:
10a812712aa9d4bf02ad975e3e1364e4 jacoco-0.8.8.zip

As you can see my software is the official version.
Maybe the official ZIP is not the correct version?
El dia dijous, 18 d’agost de 2022 a les 11:27:30 UTC+2, Marc R. Hoffmann va escriure:

Marc Hoffmann

unread,
Aug 18, 2022, 11:15:30 AM8/18/22
to JaCoCo and EclEmma Users
Hi Xavier,

your download seems to be correct. But you use a different agent in your build. Please verify yourself

$ curl -Lo jacoco.zip https://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/0.8.8/jacoco-0.8.8.zip
$ md5 jacoco.zip
MD5 (jacoco.zip) = 10a812712aa9d4bf02ad975e3e1364e4
$ unzip jacoco.zip
$ jar tf lib/jacocoagent.jar
....
org/jacoco/agent/rt/internal_b6258fc/core/
...

Cheers,
-marc



Marc Hoffmann

unread,
Aug 18, 2022, 11:35:14 AM8/18/22
to jac...@googlegroups.com
Hi Xavier,

I looked up the agent package names for old versions: https://github.com/jacoco/jacoco/wiki/AgentPackageNames

So your build actually uses quite old version 0.8.2 from 2018 which had no Java 17 support of course.

Cheers,
-marc 

Xavier León Civera

unread,
Aug 19, 2022, 5:12:31 AM8/19/22
to JaCoCo and EclEmma Users
Hi Marc.

You were right the jacoco library was the wrong version. I've found a tricky reference for an old library on app configuration.

Now everything it's OK.

Thank you for being so helpful.


El dia dijous, 18 d’agost de 2022 a les 17:15:30 UTC+2, Marc R. Hoffmann va escriure:

Marc Hoffmann

unread,
Aug 19, 2022, 5:13:25 AM8/19/22
to jac...@googlegroups.com
Glad you figured it out! :)

Suchi Bansal

unread,
Apr 16, 2024, 6:28:13 AMApr 16
to JaCoCo and EclEmma Users
which version to use with java 17?
Reply all
Reply to author
Forward
0 new messages