Hi,
we have (or had) jacoco within our our CI process, realized (more or less) in the following way as with an ant target:
<target name="jacocoalltests" xmlns:jacoco="antlib:org.jacoco.ant">
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath>
<fileset dir="${bootstrap.lib.dir}/" includes="*jacoco*.jar" />
</classpath>
</taskdef>
<jacoco:agent property="agentvmparam"
append="true"
output="file"
destfile="${report.dir}/jacoco.exec" />
<ant dir="${hybris.platform.dir}" target="alltests">
<property name="standalone.javaoptions" value="${agentvmparam} ${standalone.javaoptions}" />
</ant>
<ant dir="${hybris.platform.dir}" target="allwebtests">
<property name="standalone.javaoptions" value="${agentvmparam} ${standalone.javaoptions}" />
</ant>
</target>
But after upgrading to the current SAP Commerce Version 2205 (which comes with Java 17) this is not working anymore, resulting in the following error:
[2022-08-19T10:17:14.829Z] [yunitint] FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed [2022-08-19T10:17:14.829Z] [yunitint] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [2022-08-19T10:17:14.829Z] [yunitint] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) [2022-08-19T10:17:14.829Z] [yunitint] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [2022-08-19T10:17:14.829Z] [yunitint] at java.base/java.lang.reflect.Method.invoke(Method.java:568) [2022-08-19T10:17:14.829Z] [yunitint] at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:491) [2022-08-19T10:17:14.829Z] [yunitint] at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:503) [2022-08-19T10:17:14.829Z] [yunitint] Caused by: java.lang.reflect.InvocationTargetException [2022-08-19T10:17:14.829Z] [yunitint] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [2022-08-19T10:17:14.829Z] [yunitint] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) [2022-08-19T10:17:14.829Z] [yunitint] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [2022-08-19T10:17:14.829Z] [yunitint] at java.base/java.lang.reflect.Method.invoke(Method.java:568) [2022-08-19T10:17:14.829Z] [yunitint] at org.jacoco.agent.rt.internal_43f5073.core.runtime.InjectedClassRuntime$Lookup.defineClass(InjectedClassRuntime.java:134) [2022-08-19T10:17:14.830Z] [yunitint] at org.jacoco.agent.rt.internal_43f5073.core.runtime.InjectedClassRuntime.startup(InjectedClassRuntime.java:54) [2022-08-19T10:17:14.830Z] [yunitint] at org.jacoco.agent.rt.internal_43f5073.PreMain.premain(PreMain.java:53) [2022-08-19T10:17:14.830Z] [yunitint] ... 6 more [2022-08-19T10:17:14.830Z] [yunitint] Caused by: java.lang.LinkageError: loader 'bootstrap' attempted duplicate class definition for java.lang.$JaCoCo. (java.lang.$JaCoCo is in module java.base of loader 'bootstrap') [2022-08-19T10:17:14.830Z] [yunitint] at java.base/java.lang.ClassLoader.defineClass0(Native Method) [2022-08-19T10:17:14.830Z] [yunitint] at java.base/java.lang.System$2.defineClass(System.java:2307) [2022-08-19T10:17:14.830Z] [yunitint] at java.base/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2439) [2022-08-19T10:17:14.830Z] [yunitint] at java.base/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2416) [2022-08-19T10:17:14.830Z] [yunitint] at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:1843) [2022-08-19T10:17:14.830Z] [yunitint] ... 13 more<br>
Is there any advice how to use jacoco with sap commerce 2205/java 17?
FYI: We are using jacoco 0.8.8, Ant 1.10.11 and SAP Commerce 2205.2 with Java 17 (sapmachine 17.0.4, but same behavior with oracle jdk).
best regards,
Raphael