Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5.2, 1.6-rc-2
-
None
Description
This is related to the issue that was fixed in GROOVY-2320. Consider the following Java code:
import java.util.concurrent.*; public class Test { public static void main(String[] args) { assert "x" == new CallableTask().call(); } abstract static class AbstractCallableTask<T> implements Callable<T> { } abstract static class SubclassCallableTask<T> extends AbstractCallableTask<T> { } static class CallableTask extends SubclassCallableTask<String> { public String call() { return "x"; } } }
This code compiles and works as expected, but I can't get the Groovy version to work:
import java.util.concurrent.*; assert "x" == new CallableTask().call(); abstract class AbstractCallableTask<T> implements Callable<T> { } abstract class SubclassCallableTask<T> extends AbstractCallableTask<T> { } class CallableTask extends SubclassCallableTask<String> { public String call() { return "x"; } }
I get the following exception:
$ groovy Test.groovy org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Test.groovy: 9: Can't have an abstract method in a non-abstract class. The class 'CallableTask' must be declared abstract or the method 'java.lang.Object call()' must be implemented. @ line 9, column 1. class CallableTask extends SubclassCallableTask<String> { ^ 1 error
I've tested with 1.5.0 and trunk. I have a patch to GenericsTest.groovy attached. I ran into this problem in the course of working with a Groovy subclass of this class: https://svn.mpl.ird.fr/ichthyop/trunk/ichthyop/util/SafeSwingWorker.java