所以我收到这些错误
[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
我想知道如何解决它......
我读过的内容:
- Eclipse 中的 Java 7 JVM 验证错误 https://stackoverflow.com/questions/7970622/java-7-jvm-verifyerror-in-eclipse
- Testng、Emma、Cobertura、覆盖率和 JDK 7 导致 ClassFormatError 和VerifyError https://stackoverflow.com/questions/7010665/testng-emma-cobertura-coverage-and-jdk-7-result-in-classformaterror-and-verif
- EMMA 代码覆盖率 https://sourceforge.net/p/emma/discussion/373867/thread/963f0d6f/
- 将 EMMA 与 ANT 结合使用进行 JUnit 测试覆盖率报告 http://wiki.metawerx.net/wiki/UsingEMMAWithANTForJUnitTestCoverageReporting
- Bug 141252 - 1.6 编译器 ClassFormatError:类文件中存在非法类名“”(已修复) https://bugs.eclipse.org/bugs/show_bug.cgi?id=141252
- 3.2. :即时检测 Java 类 http://emma.sourceforge.net/userguide_single/userguide.html#N101C4
我所做的:
资源:
-
构建.xml http://pastebin.com/arxhiFey(将在24小时后过期)
-
构建.xml 输出 http://pastebin.com/raw.php?i=3ZfAFXpN(将在24小时后过期)
-
蚂蚁诊断报告 http://pastebin.com/ytj6sa9f(将在24小时后过期)
- 上一个问题 https://stackoverflow.com/questions/12171438/emma-with-junit-should-i-be-testing-with-the-instrumented-classes-or-java-class/12171942#comment16292650_12171942
- maven-emma-plugin-0.6.jar http://hivelocity.dl.sourceforge.net/project/emma/plugins-testing/maven-1.0-plugin-0.6/maven-emma-plugin-0.6.jar
- emma.jar 和 emma_ant.jar https://sourceforge.net/projects/emma/files/emma-release/2.0.5312/emma-2.0.5312.zip/download
由于一些非常疯狂的原因,JUnit 继续存在target="test"
但失败了target="emmatest"
.
这是命令提示符下的输出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)
我尝试过为我的设置设置默认参数java7 JRE
to -XX:-UseSplitVerifier
from here https://vikashazrati.wordpress.com/2011/10/09/quicktip-verifyerror-with-jdk-7/
(source: iforce.co.nz http://iforce.co.nz/i/dvsh1eoc.n0m.png)
我也试图让它投诉JDK 1.6
on the Project Properties
.
(source: iforce.co.nz http://iforce.co.nz/i/4jxuj4eb.rae.png)
JUnit直接测试结果(trace上没有错误)
(source: iforce.co.nz http://iforce.co.nz/i/wicrvpsi.5gw.png)
我没有选择,请帮忙! :(
听起来很奇怪。
首先,检查您的代码,看看您是否使用了 JDK 1.7 中引入的新语法功能,例如try-with-resource
or diamond operator
.
我之前在使用 cobertura 时遇到过这个VerifyError。然而,当我设置-XX:-UseSplitVerifier
to the junit
任务,已解决。我通过指定一个来设置它<jvmarg>
嵌套元素到junit
task.
另外,大多数覆盖库似乎对 JDK1.7 的支持很差。然而,Jacoco与 JDK1.7 配合良好,所以我现在使用它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)