Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 1070 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
java.lang.NoSuchFieldException error from jacoco

#1
I am trying to run the tests of the kotlin code provided from here : [

[To see links please register here]

][1] with gradlew

I got the error listed below.
Could someone tell me what this error means ?

```
> Task :test FAILED
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)
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed
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_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:140)
at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:101)
at org.jacoco.agent.rt.internal_c13123e.PreMain.createRuntime(PreMain.java:55)
at org.jacoco.agent.rt.internal_c13123e.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_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
... 9 more
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at line: 422

```


[1]: https:///github.com/ligi/ipfs-api-kotlin
Reply

#2
The issue comes from the Java version which needs not to be too recent.

sdk install java 19.3.0.2.r8-grl

makes things ok.
Reply

#3
After followed below steps it's working fine for me.

In Eclipse,Go to Window--Preferences--java.Right-click on installed JRE. There add an installed JDK path & remove others.
Reply

#4
Ensure you are using JDK-11,
if using maven, ensure;

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

Ensure you are using latest jacoco.

<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
Reply

#5
I had similar issue when I upgraded my jdk1.8 to openjdk11 but it was solved by updating the toolVersion = "0.8.6" (used toolVersion = "0.8.1" with jdk1.8)
Reply

#6
I was missing the following from my build.gradle:

```
jacoco {
toolVersion = "0.8.6"
}
```

While obvious, build.gradle can inherit properties from other gradle files and for reasons I can't figure out, `jacoco` was passing through in to one subproject but not to another.
Reply

#7
**Fixed this error** changing Java SDK in my project from 14 to 11 and my tests started working fine.

**Solution**:
IntellijIDEA: File > Project Structure > Project Tab > SDK adopt-opendjdk-11 (in my case for Ubuntu).

Oh! Make sure Gradle Settings are also using the same JVM!
[![enter image description here][1]][1]
[![enter image description here][2]][2]

Hope that helps someone out there.


[1]:

[2]:
Reply

#8
Fix in my case was to download and install Java 8 (jdk1.8.0_301) and set it in Project Settings

[![enter image description here][1]][1]


[1]:
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through