[ https://issues.apache.org/jira/browse/GROOVY-7609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14959306#comment-14959306 ]
Pascal Schumacher commented on GROOVY-7609: ------------------------------------------- [~mjolnir11] Can you post a small, self-contained example, so that we can reproduce this? Thanks! > java.lang.VerifyError when initializing object of inner class within the > constructor of its containing class > ------------------------------------------------------------------------------------------------------------ > > Key: GROOVY-7609 > URL: https://issues.apache.org/jira/browse/GROOVY-7609 > Project: Groovy > Issue Type: Bug > Affects Versions: 2.4.3 > Reporter: Josh Diaz > Priority: Blocker > > When trying to initialize an object of an inner class, from the constructor > of it's containing class, a java.lang.VerifyError is thrown. This code worked > fine in Java, but when I switched to Groovy, it throws the VerifyError. > Stacktrace: > java.lang.VerifyError: (class: > page_objects/Login$LoginNavigationBar$ExploreDestinationsDropdown, method: > <init> signature: (Lpage_objects/Login$LoginNavigationBar;)V) Expecting to > find object/array on stack > at java.lang.Class.getDeclaredConstructors0(Native Method) > at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) > at java.lang.Class.getDeclaredConstructors(Class.java:2020) > at > org.codehaus.groovy.reflection.CachedClass$2$1.run(CachedClass.java:71) > at java.security.AccessController.doPrivileged(Native Method) > at > org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:69) > at > org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:66) > at > org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46) > at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33) > at > org.codehaus.groovy.reflection.CachedClass.getConstructors(CachedClass.java:265) > at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:215) > at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:225) > at > groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createNormalMetaClass(MetaClassRegistry.java:168) > at > groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createWithCustomLookup(MetaClassRegistry.java:158) > at > groovy.lang.MetaClassRegistry$MetaClassCreationHandle.create(MetaClassRegistry.java:141) > at > org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:250) > at > org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:282) > at > org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:255) > at > org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:872) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallConstructorSite(CallSiteArray.java:84) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:232) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:244) > at page_objects.Login$LoginNavigationBar.<init>(Login.groovy:173) > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > at java.lang.reflect.Constructor.newInstance(Constructor.java:422) > at > org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) > at > org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:232) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:244) > at page_objects.Login.<init>(Login.groovy:25) > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > at java.lang.reflect.Constructor.newInstance(Constructor.java:422) > at > org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) > at > org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) > at > org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:232) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:244) > at test_classes.BaseTest.beforeMethod(BaseTest.groovy:74) > at test_classes.UseMyWeekTest.super$2$beforeMethod(UseMyWeekTest.groovy) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:497) > at > org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) > at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207) > at > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:130) > at test_classes.UseMyWeekTest.beforeMethod(UseMyWeekTest.groovy:24) > Offending Code: > {code} > class LoginNavigationBar > { > ExploreDestinationsDropdown exploreDestinationsDropdown > private LoginNavigationBar() > { > // THIS IS THE LINE THAT PRODUCES THE ERROR > exploreDestinationsDropdown = new ExploreDestinationsDropdown() > } > class ExploreDestinationsDropdown extends > NavigationBarDropdown<ExploreDestinationsDropdown> > { > private ExploreDestinationsDropdown() > { > super(Login.this.sw, 0) > } > } > } > {code} > It also may be useful to know that LoginNavigationBar itself is an inner > class of Login. So ExploreDestinationsDropwown is an inner class of an inner > class. Also, the constructor for LoginNavigationBar is being called from the > constructor of Login, the enclosing class. -- This message was sent by Atlassian JIRA (v6.3.4#6332)