Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.2.2
-
None
Description
Compiling:
package bugreport.test import groovy.beans.Bindable import groovy.transform.CompileStatic import java.beans.PropertyChangeListener @CompileStatic class GetListeners { @Bindable String test = "a test" public void testGetListeners(){ getPropertyChangeListeners().each {PropertyChangeListener pcl -> println "$pcl"} } }
yields:
Groovyc: java.lang.ArrayIndexOutOfBoundsException: Internal compiler error while compiling C:\Users\strue\nca2\nca\playground\dpviewer\dpviewerfx\src\main\groovy\bugreport\test\GetListeners.groovy
Method: MethodNode@1847509784[[Ljava.beans.PropertyChangeListener; getPropertyChangeListeners(java.lang.String)]
Line -1, expecting casting to java.beans.PropertyChangeListener[] but operand stack is empty
at org.codehaus.groovy.classgen.asm.OperandStack.doConvertAndCast(OperandStack.java:323)
at org.codehaus.groovy.classgen.asm.OperandStack.doGroovyCast(OperandStack.java:290)
at org.codehaus.groovy.classgen.asm.StatementWriter.writeReturn(StatementWriter.java:584)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:543)
at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:47)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:357)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:314)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:434)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1055)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:177)
at org.codehaus.groovy.control.CompilationUnit$15.call(CompilationUnit.java:794)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1036)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:572)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)
at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:54)
at org.jetbrains.groovy.compiler.rt.DependentGroovycRunner.runGroovyc(DependentGroovycRunner.java:80)
at org.jetbrains.groovy.compiler.rt.GroovycRunner.main(GroovycRunner.java:85)
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:483)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)
The problem disappears when I remove the @CompileStatic from the class
I get a similar error when compiling similar code in our production context:
Groovyc: A groovyc error occurred while trying to load one of the classes in project dependencies, please ensure it's present. See the message and the stack trace below for reference
java.lang.VerifyError: (class:XXXX, method: getPropertyChangeListeners signature: (Ljava/lang/String; )[Ljava/beans/PropertyChangeListener0; ) Unable to pop operand off an empty stack
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2570)
at java.lang.Class.getDeclaredFields(Class.java:1903)
at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:351)
at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:258)
at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:973)
at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:968)
at org.codehaus.groovy.control.ResolveVisitor.checkCyclicInheritence(ResolveVisitor.java:1204)
at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1181)
at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:141)
at org.codehaus.groovy.control.CompilationUnit$10.call(CompilationUnit.java:632)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:523)
at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:54)
at org.jetbrains.groovy.compiler.rt.DependentGroovycRunner.runGroovyc(DependentGroovycRunner.java:80)
at org.jetbrains.groovy.compiler.rt.GroovycRunner.main(GroovycRunner.java:85)
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:483)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)