如何让单元测试在 java 7 中运行:java.lang.VerifyError:在分支目标处期望堆栈图帧
您好,我正在使用 maven 3.0.3 和 hibernate 4.0.0 Final 版本以及 jdk7 update 2 上的 spring 3.1 运行 Maven 测试。
出现以下错误。
Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 63 in method ${myDomainClass}.equals(Ljava/lang/Object;)Z at offset 24
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getDeclaredMethods(Class.java:1808)
at org.hibernate.property.BasicPropertyAccessor.getterMethod(BasicPropertyAccessor.java:352)
at org.hibernate.property.BasicPropertyAccessor.getGetterOrNull(BasicPropertyAccessor.java:331)
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:314)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:310)
at org.hibernate.internal.util.ReflectHelper.getter(ReflectHelper.java:250)
at org.hibernate.internal.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:229)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:314)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:447)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:380)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:320)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:171)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3377)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3369)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3357)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1334)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1724)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:184)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:314)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
我的 Equals 方法使用 commons-lang 2.6 中的 EqualsBuilder。 设置了以下maven选项
SET MAVEN_OPTS=%MAVEN_OPTS% -XX:-UseSplitVerifier
我在阅读此Java 7 JVM verifyError后
注意:我的测试在 jdk 1.6 update 29 下有效。
我该如何解决这个问题?看来设置 -XX:-UseSplitVerifier 仍然会导致错误。
Hi I am running a maven test using maven 3.0.3 with hibernate 4.0.0 Final release and spring 3.1 on jdk7 update 2.
I get the following error.
Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 63 in method ${myDomainClass}.equals(Ljava/lang/Object;)Z at offset 24
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getDeclaredMethods(Class.java:1808)
at org.hibernate.property.BasicPropertyAccessor.getterMethod(BasicPropertyAccessor.java:352)
at org.hibernate.property.BasicPropertyAccessor.getGetterOrNull(BasicPropertyAccessor.java:331)
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:314)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:310)
at org.hibernate.internal.util.ReflectHelper.getter(ReflectHelper.java:250)
at org.hibernate.internal.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:229)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:314)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:447)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:380)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:320)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:171)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3377)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3369)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3357)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1334)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1724)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:184)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:314)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
My Equals method is using EqualsBuilder from commons-lang 2.6.
I set the following maven opts
SET MAVEN_OPTS=%MAVEN_OPTS% -XX:-UseSplitVerifier
after reading this Java 7 JVM verifyError
Note: My test works under jdk 1.6 update 29.
How do I fix this? It seems setting -XX:-UseSplitVerifier still causes the error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 surefire 插件文档 MAVEN_OPTS 不会继承由生成的 JVM 执行,因此您需要指定 argLine 配置参数与 maven-surefire-plugin 配置元素中的 -XX:-UseSplitVerifier 。
According to surefire plugin documentation MAVEN_OPTS are not inherited by a spawned JVM, so you need to specify argLine config parameter with -XX:-UseSplitVerifier in maven-surefire-plugin configuration element.
您似乎与“改进的”字节码验证器发生冲突(实际上它是简单化的,因此它需要编译器提供更多的验证器信息)。您需要通过生成“改进的”字节码格式的编译器字符串处理代码,或者将类文件的版本设置为“旧”版本(我认为该版本将小于 50.0)。
You appear to be running afoul of the "improved" bytecode verifier (which is actually dumbed-down such that it demands a lot more verifier info be supplied by the compiler). You need to either get your code processed by a compiler string that produces the "improved" bytecode format or else have the version of the class file set to the "old" version (which I'm thinking would be something less than 50.0).