【问题标题】:mockito - java.lang.VerifyError: Inconsistent stackmap frames at branch targetmockito - java.lang.VerifyError:分支目标处的堆栈图帧不一致
【发布时间】:2015-05-04 10:19:17
【问题描述】:
java.lang.VerifyError: Inconsistent stackmap frames at branch target 775
Exception Details:
Location:
    com/../..../class.method()
Reason:
    Type 'java/sql/Connection' (current frame, locals[6]) is not assignable to 'java/lang/Class' (stack map, locals[6])

这是我尝试执行 junit 时得到的结果。

junit 4.8.1 org.mockito 1.8.5 org.powermock 1.3.9 javassist 3.12.0-GA

【问题讨论】:

    标签: java junit mockito


    【解决方案1】:

    您使用的是哪个 JDK 版本?

    我遇到了类似的问题,并通过在 JVM 参数中添加 -noverify 解决了它。

    【讨论】:

    • JDK版本:1.7.0_60
    • 我使用的是 jdk 8,这解决了我的问题 :)
    【解决方案2】:

    如果你使用jdk8+,你可能需要更新javassist,javassist 3.20-不支持jdk8+。

    <dependency>
        <groupId>org.javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.20.0-GA</version>
        <scope>test</scope>
    </dependency>
    

    【讨论】:

      【解决方案3】:
      I was facing the same issue.As i was using Proguard at my end.So i added
      
      **-dontpreverify**
      
      in proguard.txt file. Beause this issue is related to Java 7
      
      You can check here:- [enter link description here][1] 
      
        [1]: http://proguard.sourceforge.net/manual/usage.html
      

      以上情况是如果你使用了proguard。

      【讨论】:

        【解决方案4】:

        我在使用 JDK 1.7.0_79 时遇到了类似的问题,我可以通过在 VM 参数中添加以下参数来解决它。 -更新

        【讨论】:

        • 虽然这可能会提供问题的答案,但需要一些解释。请更新答案,解释此解决方案的工作原理和原因。
        【解决方案5】:

        以下选项对我有用。我的java版本是1.8.0_181

            <dependency>
                <groupId>org.powermock</groupId>
                <artifactId>powermock-api-easymock</artifactId>
                <version>${powermock.version}</version>
                <scope>test</scope>
                <exclusions>
                        <exclusion>
                            <groupId>org.javassist</groupId>
                                <artifactId>javassist</artifactId>
                        </exclusion>
                    </exclusions>
            </dependency>
        
            <dependency>
                <groupId>org.javassist</groupId>
                <artifactId>javassist</artifactId>
                <version>3.21.0-GA</version>
                <scope>test</scope>
            </dependency>
        

        【讨论】:

          【解决方案6】:

          通过将 mockito 版本从 2.5.0 提升到 2.24.5 FWIW 来修复创建模拟时的类似问题“java.lang.VerifyError”(未提及堆栈图)...

          【讨论】:

            猜你喜欢
            • 2016-05-11
            • 2014-12-31
            • 2014-10-22
            • 2014-09-19
            • 2021-03-26
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多