简体   繁体   中英

How do I get unit test to run in java 7: java.lang.VerifyError: Expecting a stackmap frame at branch target

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.

根据surefire 插件文档, MAVEN_OPTS不会由生成的JVM继承,因此您需要在maven-surefire-plugin配置元素中使用-XX:-UseSplitVerifier指定argLine配置参数。

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM