本文介绍了jacoco的java.lang.NoSuchFieldException错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试对此处提供的kotlin代码进行测试: https://github.com/ligi/ipfs-api-kotlin 与gradlew
I am trying to run the tests of the kotlin code provided from here : https://github.com/ligi/ipfs-api-kotlin 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
推荐答案
我在build.gradle中缺少以下内容:
I was missing the following from my build.gradle:
jacoco {
toolVersion = "0.8.6"
}
虽然很明显,build.gradle可以从其他gradle文件继承属性,并且由于我不知道的原因, jacoco
传递给一个子项目,但不能传递给另一个子项目.
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.
这篇关于jacoco的java.lang.NoSuchFieldException错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!