本文介绍了带有 emma 和 junit 的 Java 7 导致 java.lang.VerifyError 和非法局部变量错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我收到这些错误

[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-resourcediamond 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:

    What I've Done:

    Resources:

    For some really crazy reason the JUnit Passes on target="test" but fails on target="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 here


    I've also tried to make it complaint with JDK 1.6 on the Project 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 or 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.

    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 和非法局部变量错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 14:18
查看更多