eclipse 带有 emma 和 junit 的 Java 7 导致 java.lang.VerifyError 和非法局部变量错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12173420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java 7 with emma and junit causing java.lang.VerifyError and Illegal local variable Errors
提问by Killrawr
So I'm getting these errors
所以我收到这些错误
[junit] Illegal local variable table length 17 in method test.nz.ac.massey.cs.sdc.log4jassignment.s06005586.AppenderLayoutTest.()V
[junit] java.lang.VerifyError: Expecting a stackmap frame at branch target 11 in method test.nz.ac.massey.cs.sdc.log4jassignment.s06005586.StressTest.()V at offset 4
[junit] java.lang.ClassFormatError: Illegal local variable table length 17 in method test.nz.ac.massey.cs.sdc.log4jassignment.s06005586.AppenderLayoutTest.()V
[junit] 方法 test.nz.ac.massey.cs.sdc.log4jassignment.s06005586.AppenderLayoutTest.()V 中的非法局部变量表长度为 17
[junit] java.lang.VerifyError:在方法 test.nz.ac.massey.cs.sdc.log4jassignment.s06005586.StressTest.()V 在偏移量 4 处期望在分支目标 11 处有一个堆栈图帧
[junit] java.lang.ClassFormatError: 方法 test.nz.ac.massey.cs.sdc.log4jassignment.s06005586.AppenderLayoutTest.()V 中的非法局部变量表长度 17
And I would like to know how I can fix it...
我想知道如何解决它...
What I've Read:
我读过的:
- Java 7 JVM VerifyError in Eclipse
- Testng, Emma, Cobertura, coverage and JDK 7 result in ClassFormatError and VerifyError
- EMMA code coverage
- Using EMMA with ANT for JUnit test coverage reporting
- Bug 141252 - 1.6 compiler ClassFormatError: Illegal class name "" in class file (FIXED)
- 3.2. : instrumenting Java classes on-the-fly
- Eclipse 中的 Java 7 JVM 验证错误
- Testng、Emma、Cobertura、coverage 和 JDK 7 导致 ClassFormatError 和 VerifyError
- EMMA 代码覆盖率
- 使用 EMMA 和 ANT 进行 JUnit 测试覆盖率报告
- 错误 141252 - 1.6 编译器 ClassFormatError:类文件中的非法类名“”(已修复)
- 3.2. :即时检测 Java 类
What I've Done:
我所做的:
Resources:
资源:
- build.xml(will expire in 24 hours)
- build.xml output(will expire in 24 hours)
- Ant diagnostics report(will expire in 24 hours)
- previous question
- maven-emma-plugin-0.6.jar
- emma.jar and emma_ant.jar
- build.xml(将在 24 小时后过期)
- build.xml 输出(将在 24 小时后过期)
- 蚂蚁诊断报告(24小时后过期)
- 上一个问题
- maven-emma-plugin-0.6.jar
- emma.jar 和 emma_ant.jar
For some really crazy reason the JUnit Passes on target="test"
but fails on target="emmatest"
.
由于某些非常疯狂的原因,JUnit 通过target="test"
但在target="emmatest"
.
This is the output on command prompt from java -version
这是命令提示符下的输出 java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
I've tried setting the default arguments for my java7 JRE
to -XX:-UseSplitVerifier
from here
我试过设置的默认参数为我java7 JRE
来-XX:-UseSplitVerifier
从这里
(source: iforce.co.nz)
(来源:iforce.co.nz)
I've also tried to make it complaint with JDK 1.6
on the Project Properties
.
我也尝试JDK 1.6
在Project Properties
.
(source: iforce.co.nz)
(来源:iforce.co.nz)
JUnit direct testing results (no errors on the trace)
JUnit 直接测试结果(跟踪无错误)
(source: iforce.co.nz)
(来源:iforce.co.nz)
I'm out of options, please help! :(
我别无选择,请帮忙!:(
采纳答案by coolcfan
Sounds strange.
听起来很奇怪。
First, check your code to see if you have used new grammar features introduced in JDK 1.7, like try-with-resource
or diamond operator
.
首先,检查您的代码,看看您是否使用了 JDK 1.7 中引入的新语法特性,例如try-with-resource
或diamond operator
。
I met this VerifyError before, when using cobertura. However, when I set -XX:-UseSplitVerifier
to the junit
task, it is resolved. I set it by specifying a <jvmarg>
nested element to junit
task.
我之前在使用 cobertura 时遇到过这个 VerifyError。但是,当我设置-XX:-UseSplitVerifier
的junit
任务,它解决了。我通过<jvmarg>
为junit
任务指定一个嵌套元素来设置它。
Also, most of the coverage libs seem to support JDK1.7 very poorly. However, Jacocoworks fine with JDK1.7 so I am using it for now.
此外,大多数覆盖库似乎对 JDK1.7 的支持很差。但是,Jacoco 在 JDK1.7 上运行良好,所以我现在正在使用它。
回答by user2064436
-XX:-UseSplitVerifier
-XX:-UseSplitVerifier
Does work for me and I did not have to downgrade JREfrom 1.7to 1.6
对我有用,我不必将JRE从1.7降级到1.6