2015-05-28 164 views
3

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

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这个问题?

+1

您是否正在使用与Java 8兼容的JaCoCo版本(或与JaCoCo兼容的Gradle版本)? – Makoto

+0

添加了新的jacoco版本(org.jacoco.agent-0.7.4.201502262128和org.jacoco.ant-0.7.4.201502262128)。现在它工作正常。 – user3496599

回答

1

根据this,您可能需要使用JaCoCo和/或ASM的版本。这是一个已知的问题,回到2013年左右。转到Maven搜索站点,找到最新版本,并将测试依赖关系推向最新的可用测试依赖关系,并查看是否可以修复它。

+0

是的。这似乎是一个已知的问题。你可以用它来搜索。 https://discuss.gradle.org/t/jacoco-java-8-support/4978 – gujralam