java - 为什么 Gradle 使用 Java 8 构建失败?

标签 java gradle

我们有 Gradle 脚本,它正在构建具有不同 sourceCompatibility 和 targetCompatibility 的多个项目。如果我的环境变量 JAVA_HOME 设置为 jdk7,所有项目都将成功构建。然后我把JAVA_HOME改成了jdk8。现在构建失败并出现以下错误:

 FATAL ERROR in native method: processing of -javaagent failed
FATAL ERROR in native method: processing of -javaagent failed

ava.lang.VerifyError: Expecting a stackmap frame at branch target 51
    Exception Details:
      Location:
        com/test/Tray.<clinit>()V @42: ifnull
      Reason:
        Expected stackmap frame at this location.
      Bytecode:
        0x0000000: 08bd 0063 5903 1264 5359 0412 6553 5905
        0x0000010: 1266 5359 0612 6753 5907 1268 53b3 006a
        0x0000020: 08bd 006c 5903 00b2 0080 c600 09b2 0080
        0x0000030: a700 0c12 82b8 0084 59b3 0080 0053 5904





java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.RuntimeException: Class java/util/UUID could not be instrumented.
        at org.jacoco.agent.rt_6l8m50.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
        at org.jacoco.agent.rt_6l8m50.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:99)
        at org.jacoco.agent.rt_6l8m50.JacocoAgent.createRuntime(JacocoAgent.java:128)
        at org.jacoco.agent.rt_6l8m50.JacocoAgent.init(JacocoAgent.java:74)
        at org.jacoco.agent.rt_6l8m50.JacocoAgent.premain(JacocoAgent.java:165)
        ... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
        at java.lang.Class.getField(Class.java:1703)
        at org.jacoco.agent.rt_6l8m50.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:136)
        ... 10 more
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option UseSplitVerifier; support was removed in 8.0
Exception in thread "main" Could not write standard input into: Gradle Test Executor 2.
java.io.IOException: The pipe is being closed
        at java.io.FileOutputStream.writeBytes(Native Method)
        at java.io.FileOutputStream.write(FileOutputStream.java:326)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
        at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:50)
        at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.RuntimeException: Class java/util/UUID could not be instrumented.
        at org.jacoco.agent.rt_6l8m50.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
        at org.jacoco.agent.rt_6l8m50.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:99)
        at org.jacoco.agent.rt_6l8m50.JacocoAgent.createRuntime(JacocoAgent.java:128)
        at org.jacoco.agent.rt_6l8m50.JacocoAgent.init(JacocoAgent.java:74)
        at org.jacoco.agent.rt_6l8m50.JacocoAgent.premain(JacocoAgent.java:165)
        ... 6 more

你能告诉我如何用 java8 解决这个问题吗?

最佳答案

根据 this,您可能需要尝试使用您的 JaCoCo 和/或 ASM 版本.这是一个可追溯到 2013 年左右的已知问题。转到 Maven 搜索站点,找到最新版本并将您的测试依赖项推送到最新的可用版本,看看是否可以解决问题。

关于java - 为什么 Gradle 使用 Java 8 构建失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30510053/

相关文章:

gradle - 使用Gradle构建可运行的jar Google数据流项目

android - 生成失败原因:java.lang.OutOfMemoryError:超出了GC开销限制

android - Gradle - Android 资源位置丢失

android - 错误 : Failed to find: com. android.support :support-v4:20. 0.+

java - 服务器无法识别 HTTP header SOAPAction : 的值

java - 在 Eclipse 中,当所有三个项目都需要 servlet-api.jar 时,如何让 tomcat 运行两个连接的项目?

gradle - 使用ring和gradle的html页面的路径

java - 打印对象内的值

java - 将 BufferedImage 转换/写入为 postscript

java - 在 Websphere 上使用 Jasper-Reports 时出现 "Bad major version"错误