Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
1.0
-
None
-
Eclipse plugin or groovy class loader, java 5 or 6
Description
Given the following java classes:
public abstract class Simple { public Simple getSimple() { return this; } } class NotSoSimple extends Simple { @Override public NotSoSimple getSimple() { return this; } } class Complex extends NotSoSimple { @Override public Complex getSimple() { return this; } }
And the following Groovy Script:
class CovariantProblem { static void main(args) { def complex = new Complex() complex.getSimple() } }
Groovy complains that there's no method getSimple() in Simple class.
The problem occurs both in Groovy Eclipse plugin and in Groovy classloader, as shown in the exception above:
Exception in thread "main" java.lang.NoSuchMethodError: Simple.getSimple()LComplex;
at gjdk.Complex_GroovyReflector.invoke(Unknown Source)
at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:713)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:119)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(ScriptBytecodeAdapter.java:211)
at CovariantProblem.main(CovariantProblem.groovy:6)