问题描述
所以我收到这些错误
[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
我想知道如何修复它...
我读过的:
我别无选择,请帮忙!:(
解决方案听起来很奇怪.
首先,检查您的代码,看看您是否使用了 JDK 1.7 中引入的新语法特性,例如
try-with-resource
或diamond operator
.我之前在使用 cobertura 时遇到过这个 VerifyError.但是,当我将
-XX:-UseSplitVerifier
设置为junit
任务时,它就解决了.我通过指定一个来设置它
junit
任务的嵌套元素.此外,大多数覆盖库似乎对 JDK1.7 的支持很差.但是,Jacoco 在 JDK1.7 上运行良好,所以我现在使用它.
So I'm getting these errors
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
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
For some really crazy reason the JUnit Passes on
target="test"
but fails ontarget="emmatest"
.This is the output on command prompt from
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 hereI've also tried to make it complaint with
JDK 1.6
on theProject Properties
.JUnit direct testing results (no errors on the trace)
I'm out of options, please help! :(
解决方案Sounds strange.
First, check your code to see if you have used new grammar features introduced in JDK 1.7, like
try-with-resource
ordiamond operator
.I met this VerifyError before, when using cobertura. However, when I set
-XX:-UseSplitVerifier
to thejunit
task, it is resolved. I set it by specifying a<jvmarg>
nested element tojunit
task.Also, most of the coverage libs seem to support JDK1.7 very poorly. However, Jacoco works fine with JDK1.7 so I am using it for now.
这篇关于带有 emma 和 junit 的 Java 7 导致 java.lang.VerifyError 和非法局部变量错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!