Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.2.2, 2.4.0-rc-1
-
None
-
GNU/Linux (x64 SUSE and x86 Fedora Core 18)
Description
The attached script causes the following syntax error when run with Groovy 2.2.2.
Caught: java.lang.VerifyError: (class: ReproBug$MyClass, method: <init> signature: ()V) Expecting to find object/array on stack
java.lang.VerifyError: (class: ReproBug$MyClass, method: <init> signature: ()V) Expecting to find object/array on stack
at ReproBug.main(ReproBug.groovy:18)
The code compiles and runs fine as a Java class, which is why I think this is a bug in Groovy.
The problem requires the conjunction of two things:
1) A constructor that invokes another constructor
2) Converting an integer to a string as a parameter to the constructor
I encountered this during real-world scripting (although I used a integer literal), but was able to figure out the cause and work-around the problem. As such, this does not personally impact me; I am reporting it because I like Groovy and this is an easy way to contribute.
Since I don't know whether you prefer an attachment or an inline quote, here is the code.
public class ReproBug { static private Integer MYINT = 4; private static class MyClass { public final String value; public MyClass(String string) { value = string; } public MyClass() { this(MYINT.toString()); // <--- causes problems } } public static void main(String[] args) { System.out.println(new MyClass().value); } }
I haven't figured out how to create a Groovy unit test case. If someone can point me to an example where simply getting the script to compile is proof that the bug is fixed, I'll try to work the attached code into a Groovy unit test case.
Attachments
Attachments
Issue Links
- relates to
-
GROOVY-11483 reference to outer class non-private static field before special ctor call
- Resolved