Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to measure code coverage after migrating to 3.10 #1783

Closed
inad9300 opened this issue Dec 21, 2023 · 5 comments
Closed

Unable to measure code coverage after migrating to 3.10 #1783

inad9300 opened this issue Dec 21, 2023 · 5 comments
Assignees

Comments

@inad9300
Copy link

inad9300 commented Dec 21, 2023

Up until version 3.9, I was able to do code coverage verifications through JaCoCo in the following way:

$ JACOCO_AGENT=$(docker compose exec my_app ./mvnw jacoco:prepare-agent | grep -o -E "\-javaagent:.*\.jar")
$ docker compose exec my_app ./mvnw -Dliberty.jvm.coverage="$JACOCO_AGENT=output=tcpserver" liberty:run

Since 3.10, when running these commands, I see the following error:

CWWKM2001I: Invoke command is [/my_app/target/liberty/wlp/bin/server, run, defaultServer].

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:77)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:568)
 at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:491)
 at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:503)
Caused by: java.lang.reflect.InvocationTargetException
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:568)
 at org.jacoco.agent.rt.internal_4742761.core.runtime.InjectedClassRuntime$Lookup.defineClass(InjectedClassRuntime.java:134)
 at org.jacoco.agent.rt.internal_4742761.core.runtime.InjectedClassRuntime.startup(InjectedClassRuntime.java:54)
 at org.jacoco.agent.rt.internal_4742761.PreMain.premain(PreMain.java:50)
 ... 6 more
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')
 at java.base/java.lang.ClassLoader.defineClass0(Native Method)
 at java.base/java.lang.System$2.defineClass(System.java:2307)
 at java.base/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2439)
 at java.base/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2416)
 at java.base/java.lang.invoke.MethodHandles$Lookup.defineClass(MethodHandles.java:1843)
 ... 13 more
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message Outstanding error when calling method in invokeJavaAgentMainMethod at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 619
*** java.lang.instrument ASSERTION FAILED ***: "success" with message invokeJavaAgentMainMethod failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 459
*** 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
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x8ad82e]  jni_FatalError+0xbe
V  [libjvm.so+0xa28e62]  JvmtiExport::post_vm_initialized()+0x132
V  [libjvm.so+0xe6afb0]  Threads::create_vm(JavaVMInitArgs*, bool*)+0x960
V  [libjvm.so+0x8bbe82]  JNI_CreateJavaVM+0x52
C  [libjli.so+0x4a0f]  JavaMain+0x8f
C  [libjli.so+0x8d09]  ThreadJavaMain+0x9

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
@cherylking
Copy link
Member

@inad9300 I think you may have run into this issue, which I have merged a PR for last week. I just created a 3.11-SNAPSHOT that includes that fix if you would like to try it. Another workaround would be to specify that jvm option in a jvm.options file in the src/main/liberty/config folder instead of from the command line.

@inad9300
Copy link
Author

Thanks, that seems plausible. I'll keep an eye out for 3.11, since I'm not familiar with the process I'd have to go through to try 3.11-SNAPSHOT.

@cherylking
Copy link
Member

@inad9300 The info on using a snapshot can be found here if you are interested.

@inad9300
Copy link
Author

inad9300 commented Jan 2, 2024

I have given 3.11-SNAPSHOT a try and can confirm it fixes the bug. Thanks, @cherylking.

@cherylking cherylking self-assigned this Jan 9, 2024
@cherylking
Copy link
Member

This fix was included in the latest published release. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants