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

2

12

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.

Lea answered 26/12, 2011 at 18:21 Comment(2)
I would clean and build all project again and try other commons-lang lib. Seems a bit like this issue: https://mcmap.net/q/1010228/-where-to-put-super-or-this-in-my-classesLudhiana
Hibernate uses cglib and dependending upon how you have set up spring, it might also be using similar libraries, maybe they might be to blame. Try using a more recent version of cglib in you classpath and see if that satisfies.Alphonso
S
14

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.

Sundaysundberg answered 6/2, 2012 at 16:26 Comment(2)
Ex: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>-XX:-UseSplitVerifier</argLine> </configuration> </plugin>Slurry
How to do this using Ant? What I tried <jvmarg value="-XX:-UseSplitVerifier"/> ? Not working. I'm using JDK 6 u43Amortization
H
-1

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

Hartmann answered 6/2, 2012 at 16:38 Comment(4)
The problem is actually not in the user code, but in the tools/libraries, such as Hibernate and CGLIB. Those tools are not aware of the new bytecode requirements and obviously don't work well with classes compiled to target Java 7.Sundaysundberg
@EugeneKuleshov -- So what solution do you propose other than one of the two I suggested?Hartmann
Here is the thing. You didn't really offer a solution to the original poster problem, yet made few offensive remarks about bytecode verifier.Sundaysundberg
I offered two solutions -- adjust the compiler string to produce the "new" format, or target an "old" version. Apparently the fix that was adopted uses the first of those two. What I said about the verifier is nothing but the truth.Hartmann

© 2022 - 2024 — McMap. All rights reserved.