Hi,

Something wrong in your configuration, because
you're trying to use JaCoCo version 0.8.6,
however exception indicates use of JaCoCo agent version *0.7.9*
which does not support Java 11.


Regards,
Evgeny

On Tuesday, December 22, 2020 at 2:44:32 PM UTC+1 j.bal...@dotsource.de 
wrote:

>
> Hi,
>
> We're working on an SAP-Commerce (ex Hybris) project and want to measure 
> test-coverage in our build-pipeline. SAP-Commerce uses ant for builds and 
> Tests. Earlier versions of it had a pre-defined ant task called 
> jacocoalltests which executed all tests with coverage. In newer versions of 
> SAP-Commerce this task is gone and I'm trying to rebuild it. Reading the 
> former task definition and the jacoco documentation I wrote the following 
> ant task, which is supposed to set the appropriate jvm-parameter when the 
> actual test-execution is performed:
>
> ```{xml}
> <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
>     <classpath path="REDACTED/lib/"/>
> </taskdef>
>
> <target name="jacocoalltests" description="runs allstests with jacoco 
> attached">
>     <jacoco:agent property="agentvmparam"
>                   append="true"
>                   output="file"
>                   destfile="${HYBRIS_LOG_DIR}/junit/jacoco.exec"
>                   excludes="jdk.internal.*"
>                   inclnolocationclasses="true"
>     />
>     <property name="testclasses.extensions" value="${extname}"/>
>     <ant dir="${platformhome}" target="alltests" inheritrefs="false">
>         <property name="standalone.javaoptions" value="${agentvmparam} 
> ${standalone.javaoptions}"/>
>     </ant>
> </target>
> ```
>
> The referenced classpath includes jacoco-core-0.8.6.jar, 
> jacoco-ant-0.8.6.jar, jacoco-report-0.8.6.jar and jacoco-agent-0.8.6.jar. 
> The excludes and inclnolocationclasses were included after reading 
> https://github.com/jangrewe/gitlab-ci-android/issues/59 - without them 
> there is no different outcome.
>
> I've tried to execute this task with two different JDKs, one being the 
> debian build of openjdk-11 and the other being the current version of 
> sapmachine (see also below).
> The latter is the JDK we actually ant to use.
>
> When I execute it I get teh following error for both tested JDKs:
>
> ```
> ---snip---
> alltests:
>      [echo] preparing...
> ---snip---
>      [echo] jvmargs: 
> -javaagent:/tmp/jacocoagent11926682159682554528.jar=destfile=/home/developer/hybris-logs/junit/jacoco.exec,append=true,excludes=jdk.internal.*,inclnolocationclasses=true,output=file
>  
> -Xmx2g -Djava.locale.providers=COMPAT,CLDR 
> --add-exports="java.base/jdk.internal.ref=ALL-UNNAMED" 
> --add-exports="java.naming/com.sun.jndi.ldap=ALL-UNNAMED" 
> --add-exports="jdk.management.agent/jdk.internal.agent=ALL-UNNAMED" 
> -Ddeployed.server.type="tomcat"
> ---snip---
>  [yunitint] --> found 1731 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:62)
>  [yunitint]     at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  [yunitint]     at 
> java.base/java.lang.reflect.Method.invoke(Method.java:566)
>  [yunitint]     at 
> java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
>  [yunitint]     at 
> java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
>  [yunitint] Caused by: java.lang.RuntimeException: Class java/util/UUID 
> could not be instrumented.
>  [yunitint]     at 
> org.jacoco.agent.rt.internal_8ff85ea.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:140)
>  [yunitint]     at 
> org.jacoco.agent.rt.internal_8ff85ea.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:101)
>  [yunitint]     at 
> org.jacoco.agent.rt.internal_8ff85ea.PreMain.createRuntime(PreMain.java:55)
>  [yunitint]     at 
> org.jacoco.agent.rt.internal_8ff85ea.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:1999)
>  [yunitint]     at 
> org.jacoco.agent.rt.internal_8ff85ea.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
> ---snip---
> ```
>
> As you can see the jacoco javaagent seems to be the first jvm-argument, as 
> was recommended in the documentation.
>
> Am I missing something? What further checks could I perform to see, 
> whether this is a Problem with my task-definition, with the SAP-Commerce 
> Build-Framework or with jacoco itself?
>
> Thanks a lot!
>
> Johannes Ballmann
>
>
>
> Environment
> * OS: Debian stable
> * JDK
> ** OpenJDK:
> $ java -version
> openjdk version "11.0.9.1" 2020-11-04
> OpenJDK Runtime Environment (build 11.0.9.1+1-post-Debian-1deb10u2)
> OpenJDK 64-Bit Server VM (build 11.0.9.1+1-post-Debian-1deb10u2, mixed 
> mode, sharing)
> ** Sap-Machine:
> $ java -version
> openjdk version "11.0.9.1" 2020-11-05 LTS
> OpenJDK Runtime Environment SapMachine (build 11.0.9.1+1-LTS-sapmachine)
> OpenJDK 64-Bit Server VM SapMachine (build 11.0.9.1+1-LTS-sapmachine, 
> mixed mode)
> * ant: Apache Ant(TM) version 1.10.6 compiled on May 2 2019
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/90890b84-2095-4840-8b8b-f5a119cfee41n%40googlegroups.com.

Reply via email to