Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
Latest CVS Head, Mac 10.3.2, java 1.4.2
Description
The simplest class definition to reproduce this error:
class Bug {
String x = ""
static void main(args)
{ x = 13 }}
Trying to run groovy on this:
$ groovy Bug.groovy
Exception in thread "main" java.lang.VerifyError: (class: Bug, method: main signature: ([Ljava/lang/String;)V) Incompatible type for getting or setting field
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1610)
at java.lang.Class.getDeclaredConstructors(Class.java:1169)
at groovy.lang.MetaClass.<init>(MetaClass.java:137)
at groovy.lang.MetaClassRegistry.getMetaClass(MetaClassRegistry.java:100)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:123)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:106)
at groovy.lang.GroovyShell.run(GroovyShell.java:222)
at groovy.lang.GroovyShell.main(GroovyShell.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.codehaus.classworlds.Launcher.launchStandard(Launcher.java:410)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:344)
at org.codehaus.classworlds.Launcher.main(Launcher.java:474)
If I change the x = 13 to some variable name different than "x", it works. It seems that the local variable defined in the static method is clashing with the non-static class property.