Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0.0
-
Fix Version/s: 2.0.1
-
Component/s: Static compilation
-
Labels:None
-
Environment:* Groovy: 2.0.0
* JVM: Java HotSpot(TM) 64-Bit Server VM (20.6-b01-415, Apple Inc.)
* JRE: 1.6.0_31
* OS: Mac OS X (10.6.8, x86_64)
-
Number of attachments :
Description
If you enter the following into the GroovyConsole:
import groovy.transform.* @CompileStatic class Test { List<Integer> elements public Test( List<Integer> elements ) { this.elements = elements } void regularEach() { int idx = 0 elements.each { Integer elem -> "$elem:${idx++}" } } } new Test( [1,2,3] )
You get the Error:
java.lang.VerifyError: (class: Test, method: regularEach signature: ()V) Register 1 contains wrong type at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) at java.lang.Class.getDeclaredConstructors(Class.java:1836) at org.codehaus.groovy.reflection.CachedClass$2$1.run(CachedClass.java:69) at java.security.AccessController.doPrivileged(Native Method) at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:66) at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:64) 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:258) at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:185) at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:189) at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createNormalMetaClass(MetaClassRegistry.java:157) at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createWithCustomLookup(MetaClassRegistry.java:147) at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.create(MetaClassRegistry.java:130) at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:165) at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:182) at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:302) at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:767) 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:182) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190) at ConsoleScript6.run(ConsoleScript6:19) ...
I'm guessing it's a problem with the each call manipulating the idx variable inside the loop...
Which is fair enough
(but I guess the error message could be nicer)