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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:52:53  来源:igfitidea点击:

Java 7 with emma and junit causing java.lang.VerifyError and Illegal local variable Errors

eclipseantjava-7emma

提问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:

我读过的:

What I've Done:

我所做的:

Resources:

资源:

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 JREto -XX:-UseSplitVerifierfrom here

我试过设置的默认参数为我java7 JRE-XX:-UseSplitVerifier这里

arguments
(source: iforce.co.nz)

争论
(来源:iforce.co.nz

I've also tried to make it complaint with JDK 1.6on the Project Properties.

我也尝试JDK 1.6Project Properties.

complaint
(source: iforce.co.nz)

抱怨
(来源:iforce.co.nz

JUnit direct testing results (no errors on the trace)

JUnit 直接测试结果(跟踪无错误)

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-resourceor diamond operator.

首先,检查您的代码,看看您是否使用了 JDK 1.7 中引入的新语法特性,例如try-with-resourcediamond operator

I met this VerifyError before, when using cobertura. However, when I set -XX:-UseSplitVerifierto the junittask, it is resolved. I set it by specifying a <jvmarg>nested element to junittask.

我之前在使用 cobertura 时遇到过这个 VerifyError。但是,当我设置-XX:-UseSplitVerifierjunit任务,它解决了。我通过<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

对我有用,我不必将JRE1.7降级到1.6