Bug 421307 - VerifyError with Java7 but not with Java6 (Problem with StackMapTable)
Summary: VerifyError with Java7 but not with Java6 (Problem with StackMapTable)
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.7.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.8.0   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-08 03:50 EST by Thomas Pasch CLA
Modified: 2014-06-21 23:37 EDT (History)
3 users (show)

See Also:


Attachments
java source code of the impacted class (17.68 KB, text/x-java)
2013-11-08 03:52 EST, Thomas Pasch CLA
no flags Details
stacktrace snipplet from (tomcat) server.log (14.62 KB, text/plain)
2013-11-08 03:53 EST, Thomas Pasch CLA
no flags Details
corresponding class file of the impacted class (zip, as there are inner classes) (15.36 KB, application/zip)
2013-11-08 03:58 EST, Thomas Pasch CLA
no flags Details
Disassembled class files (with 'javap -constants -sysinfo -s -p -l -c *.class') (111.04 KB, text/plain)
2013-11-08 04:03 EST, Thomas Pasch CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Pasch CLA 2013-11-08 03:50:20 EST
In our (open source) project we've got a class org.nuclos.server.history.ejb3.HistoryFacadeBean that is annotated with (Spring) @Transactional and (by the way we configured spring and the mvn build) hence instrumented by aspectj.

We encouter no problems when using Java6, but with Java7 starting the (tomcat) server, we see the following problem in the server.log:

2013-11-07 17:27:06,030 ERROR [org.nuclos.server.web.NuclosContextLoaderListener] - startup of heart beat server thread in timer task failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stateCache': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: final void org.nuclos.server.common.StateCache.setStateFacadeLocal(org.nuclos.server.statemodel.ejb3.StateFacadeLocal); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stateFacadeLocal': Cannot resolve reference to bean 'stateService' while setting bean property 'facadeBean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stateService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.nuclos.server.
genericobject.ejb3.GenericObjectFacadeLocal org.nuclos.server.statemodel.ejb3.StateFacadeBean.genericObjectFacade; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'genericObjectFacadeLocal': Cannot resolve reference to bean 'genericObjectService' while setting bean property 'facadeBean'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'genericObjectService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.nuclos.server.history.ejb3.HistoryFacadeLocal org.nuclos.server.genericobject.ejb3.GenericObjectFacadeBean.historyFacade; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'historyFacadeLocal': Initialization of bean failed; nested exception is java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    org/nuclos/server/history/ejb3/HistoryFacadeBean.getHistoryData_aroundBody6(Lorg/nuclos/server/history/ejb3/HistoryFacadeBean;Lorg/nuclos/common/UID;Ljava/lang/Object;)Ljava/util/Collection; @40: invokestatic
  Reason:
    Type 'java/lang/Object' (current frame, stack[0]) is not assignable to 'org/nuclos/common/FieldMeta'

I will attach both the complete class and the full stacktrace. The complete project could be found at https://bitbucket.org/nuclos/nuclos .

We think the problem is realated to [http://stackoverflow.com/questions/15253173/how-safe-is-it-to-use-xx-usesplitverifier]. Or to say it with other words: AspectJ seems to have problems to get the StackMapTable right.

We encountered the problem with AspectJ 1.7.3, 1.7.4 and 1.8.0.M1 .
Comment 1 Thomas Pasch CLA 2013-11-08 03:52:54 EST
Created attachment 237299 [details]
java source code of the impacted class
Comment 2 Thomas Pasch CLA 2013-11-08 03:53:58 EST
Created attachment 237300 [details]
stacktrace snipplet from (tomcat) server.log
Comment 3 Thomas Pasch CLA 2013-11-08 03:58:08 EST
Created attachment 237301 [details]
corresponding class file of the impacted class (zip, as there are inner classes)
Comment 4 Thomas Pasch CLA 2013-11-08 04:03:15 EST
Created attachment 237302 [details]
Disassembled class files (with 'javap -constants -sysinfo -s -p -l -c *.class')
Comment 5 Thomas Pasch CLA 2014-04-14 04:23:32 EDT
In Java7 it is possible to circumvent the problem with -XX:-UseSplitVerifier . This disables the (new) verifier and still uses the Java6 verifier.

However this is not an option with Java8, as -XX:-UseSplitVerifier has been removed from the VM.
Comment 6 Andrew Clement CLA 2014-04-14 19:52:26 EDT
Believed fixed by 1.8.0.RC3 (same issue as https://bugs.eclipse.org/bugs/show_bug.cgi?id=432714 )
Comment 7 Kevin Lee CLA 2014-06-20 16:59:54 EDT
(In reply to Andrew Clement from comment #6)
> Believed fixed by 1.8.0.RC3 (same issue as
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=432714 )

I don't think that one is fixed. I'm using Java 8 and still have the same problem. But I'm not one hundred percent sure what I have is exactly the same as this bug as my weaveDirectory is ${project.build.directory}/classes not the source directory. I have to do it in order to use AspectJ with Lombok.

(Tested with both released and RC3)
==================================================
Invocation of init method failed; nested exception is java.lang.VerifyError: Expecting a stackmap frame at branch target 78
Exception Details:
  Location:
    com/lckymn/kevin/myapp/core/domain/personal/Address.printDetails(Lcom/lckymn/kevin/myapp/core/domain/personal/AddressDetailGroup;Ljava/util/Map;)Ljava/lang/String; @21: goto
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0000000: bb00 4959 124b b700 4d4d 2ab6 004e b900
    0000010: 5401 003a 04a7 0039 1904 b900 5a01 00c0
    0000020: 0060 4e2b 2db6 0062 b900 6602 00c0 006c
    0000030: 3a05 2c2d b600 6eb6 0072 1276 b600 722d
    0000040: 1905 b600 78b6 0072 127c b600 7257 1904
    0000050: b900 7e01 009a ffc3 042c b600 82a2 0012
    0000060: 2c2c b600 8205 642c b600 82b6 0086 572c
    0000070: 128a b600 7257 2cb6 008c b0            

  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:973) ~[spring-context-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:750) ~[spring-context-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) ~[spring-context-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973) [catalina.jar:7.0.54]
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467) [catalina.jar:7.0.54]
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.54]
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) [catalina.jar:7.0.54]
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) [catalina.jar:7.0.54]
  at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_05]
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_05]
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_05]
  at java.lang.Thread.run(Thread.java:745) [na:1.8.0_05]
Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 78
Exception Details:
  Location:
    com/lckymn/kevin/myapp/core/domain/personal/Address.printDetails(Lcom/lckymn/kevin/myapp/core/domain/personal/AddressDetailGroup;Ljava/util/Map;)Ljava/lang/String; @21: goto
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0000000: bb00 4959 124b b700 4d4d 2ab6 004e b900
    0000010: 5401 003a 04a7 0039 1904 b900 5a01 00c0
    0000020: 0060 4e2b 2db6 0062 b900 6602 00c0 006c
    0000030: 3a05 2c2d b600 6eb6 0072 1276 b600 722d
    0000040: 1905 b600 78b6 0072 127c b600 7257 1904
    0000050: b900 7e01 009a ffc3 042c b600 82a2 0012
    0000060: 2c2c b600 8205 642c b600 82b6 0086 572c
    0000070: 128a b600 7257 2cb6 008c b0            

  at java.lang.Class.forName0(Native Method) ~[na:1.8.0_05]
  at java.lang.Class.forName(Class.java:340) ~[na:1.8.0_05]
  at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:240) ~[hibernate-core-4.3.5.Final.jar:4.3.5.Final]
  at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildHibernateConfiguration(EntityManagerFactoryBuilderImpl.java:1112) ~[hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
  at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:846) ~[hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
  at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:843) ~[hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
  at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:397) ~[hibernate-core-4.3.5.Final.jar:4.3.5.Final]
  at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842) ~[hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
  at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152) ~[hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
  at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318) ~[spring-orm-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) ~[spring-beans-4.0.5.RELEASE.jar:4.0.5.RELEASE]
  ... 21 common frames omitted
==================================================
Comment 8 Andrew Clement CLA 2014-06-20 20:58:20 EDT
1.8.0 had a number of other issues with stack maps.  I recommend you try 1.8.1 that I've just built since it includes quite a few fixes:

https://bugs.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&list_id=9406620&product=AspectJ&query_format=advanced&target_milestone=1.8.1

and updates the internal Java8 to a much more recent Eclipse JDT version.

You can access it from our maven repo right now (it will be in central when I get a minute):

http://repo.spring.io/release

version: 1.8.1
Comment 9 Kevin Lee CLA 2014-06-21 23:37:54 EDT
Thank you so much, Andrew. 1.8.1 works! even without updating Eclipse JDT.

I think I still need to test more with another project which uses AspectJ a lot more than the one tested, yet it looks good so far.

The project I will test with has to be updated to use Java 8, Spring 4 and AspectJ 1.8.1 so I can't do it right now but will probably try next weekend.

Thank you.


(In reply to Andrew Clement from comment #8)
> 1.8.0 had a number of other issues with stack maps.  I recommend you try
> 1.8.1 that I've just built since it includes quite a few fixes:
> 
> https://bugs.eclipse.org/bugs/buglist.
> cgi?bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&list_id=9406620
> &product=AspectJ&query_format=advanced&target_milestone=1.8.1
> 
> and updates the internal Java8 to a much more recent Eclipse JDT version.
> 
> You can access it from our maven repo right now (it will be in central when
> I get a minute):
> 
> http://repo.spring.io/release
> 
> version: 1.8.1