[英]java.lang.VerifyError: Expecting a stackmap frame at branch target JDK 1.7
After upgrading to JDK 1.7 I am getting below exception:升级到 JDK 1.7 后,出现以下异常:
java.lang.VerifyError: Expecting a stackmap frame at branch target 71 in method com.abc.domain.myPackage.MyClass$JaxbAccessorM_getDescription_setDescription_java_lang_String.get(Ljava/lang/Object;)Ljava/lang/Object; at offset 20
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2413)
at java.lang.Class.getConstructor0(Class.java:2723)
at java.lang.Class.newInstance0(Class.java:345)
at java.lang.Class.newInstance(Class.java:327)
at com.sun.xml.internal.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.instanciate(OptimizedAccessorFactory.java:184)
at com.sun.xml.internal.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:129)
at com.sun.xml.internal.bind.v2.runtime.reflect.Accessor$GetterSetterReflection.optimize(Accessor.java:384)
at com.sun.xml.internal.bind.v2.runtime.property.SingleElementLeafProperty.<init>(SingleElementLeafProperty.java:72)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.sun.xml.internal.bind.v2.runtime.property.PropertyFactory.create(PropertyFactory.java:113)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.<init>(ClassBeanInfoImpl.java:166)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:494)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:311)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:126)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1148)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:248)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:235)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:445)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at com.abc.domain.myPackage.MyClass.marshalFacetsTest(MyClass.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:128)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1203)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1128)
at org.testng.TestNG.run(TestNG.java:1036)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Java 7 introduced stricter verification and changed the class format a bit—to contain a stack map used to verify that code is correct. Java 7 引入了更严格的验证并稍微更改了类格式——包含用于验证代码正确性的堆栈映射。 The exception you see means that some method doesn't have a valid stack map.
您看到的异常意味着某些方法没有有效的堆栈映射。
Java version or bytecode instrumentation could both be to blame. Java 版本或字节码检测都可能是罪魁祸首。 Usually this means that a library used by the application generates invalid bytecode that doesn't pass the stricter verification.
通常这意味着应用程序使用的库会生成未通过更严格验证的无效字节码。 So nothing else than reporting it as a bug to the library can be done by the developer.
因此,开发人员只能将其作为错误报告给库。
As a workaround you can add -noverify
to the JVM arguments in order to disable verification.作为解决方法,您可以将
-noverify
添加到 JVM 参数以禁用验证。 In Java 7 it was also possible to use -XX:-UseSplitVerifier
to use the less strict verification method, but that option was removed in Java 8.在 Java 7 中,也可以使用
-XX:-UseSplitVerifier
来使用不太严格的验证方法,但该选项在 Java 8 中被删除了。
如果您使用的是 java 1.8,请删除XX:-UseSplitVerifier
并在您的 JVM 属性中使用-noverify
。
I ran into this problem and try using the flag -noverify
which really works.我遇到了这个问题并尝试使用真正有效的标志
-noverify
。 It is because of the new bytecode verifier.这是因为新的字节码验证器。 So the flag should really work.
所以这个标志应该真的有用。 I am using JDK 1.7.
我正在使用 JDK 1.7。
Note: This would not work if you are using JDK 1.8注意:如果您使用的是 JDK 1.8,这将不起作用
Pass -noverify
JVM argument to your test task.将
-noverify
JVM 参数传递给您的测试任务。 If you are using gradle, in the build.gradle
you can have something like:如果您使用的是 gradle,则在
build.gradle
可以包含以下内容:
test {
jvmArgs "-noverify"
}
The only difference between files that causing the issue is the 8th byte of file导致问题的文件之间的唯一区别是文件的第 8 个字节
CA FE BA BE 00 00 00 33 - Java 7 CA FE BA BE 00 00 00 33 - Java 7
vs.对比
CA FE BA BE 00 00 00 32 - Java 6 CA FE BA BE 00 00 00 32 - Java 6
Setting -XX:-UseSplitVerifier
resolves the issue.设置
-XX:-UseSplitVerifier
可解决此问题。 However, the cause of this issue is https://bugs.eclipse.org/bugs/show_bug.cgi?id=339388但是,这个问题的原因是https://bugs.eclipse.org/bugs/show_bug.cgi?id=339388
This ERROR can happen when you use Mockito to mock final classes .当您使用 Mockito模拟最终类时可能会发生此错误。
Consider using Mockito inline or Powermock instead.考虑使用 Mockito inline 或 Powermock 代替。
Sorry for digging, but I met the same problem and found the simplier solution.抱歉挖掘,但我遇到了同样的问题并找到了更简单的解决方案。
In Java compiler options you need to uncheck "Preserve unused (never read) local variables" so there is no need to change back target JVM version.在 Java 编译器选项中,您需要取消选中“保留未使用的(从不读取)局部变量”,因此无需更改回目标 JVM 版本。
It seems to be a bug in an older Eclipe versions.这似乎是较旧的 Eclipe 版本中的错误。
如果您自己构建代码,则可以通过向 java 编译器提供“-target 1.5”(或通过在您的 IDE 或构建配置中设置相应选项)来解决此问题。
this link is helpful.这个链接很有帮助。 java.lang.VerifyError: Expecting a stackmap frame
java.lang.VerifyError:需要一个堆栈图帧
the simplest way is changing JRE to 6.最简单的方法是将 JRE 更改为 6。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.