Issue Details (XML | Word | Printable)

Key: GROOVY-1913
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Jochen Theodorou
Reporter: Vinícius Godoy de Mendonça
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

Problem when running script that uses java covariants

Created: 23/May/07 02:27 PM   Updated: 11/Oct/07 08:00 PM   Resolved: 11/Oct/07 08:00 PM
Return to search
Component/s: groovy-jdk
Affects Version/s: 1.0
Fix Version/s: 1.1-rc-1

Time Tracking:
Not Specified

Environment: Eclipse plugin or groovy class loader, java 5 or 6

Testcase included: yes


 Description  « Hide

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)



Jochen Theodorou added a comment - 11/Oct/07 08:00 PM

looks like the HEAD version is doing fine here... the exception is a bit irritating...

Exception in thread "main" java.lang.NoSuchMethodError: Simple.getSimple()LComplex;

that is no Groovy exception, it is a Java exception. Or to be clearer an exception from reflection. most probably the base call class was used in a wrong way, but that part changed pretty much. I guess it is fixed, but to be really sure I need your feedback. If the problem still remains, then reopen this issue please