Details
Description
Take a simple abstract groovy class:
--- Foo.groovy
abstract class Foo {}
---
compile it with groovyc. Take a simple java class
--- FooSub.java
class FooSub extends Foo {}
---
try and compile it with javac. It will fail because the GroovyObject methods added to Foo are marked synthetic so it doesn't think GroovyObject has been implemented in the hierarchy. Neither javac or the Eclipse Compiler for Java (ECJ) allow synthetic methods to satisfy an interface implementation (and Foo has had GroovyObject added to it by groovyc). It is the word 'abstract' on Foo that causes both javac and ECJ to check this situation and report the problem.
I've discussed things with Jochen and we are thinking about removing synthetic for these methods if they are being added to a groovy type that is abstract.
Joint compilation works because the stubs don't show that the methods will be abstract when the java code is compiled.
Attachments
Issue Links
| This issue is duplicated by: | ||||
| GROOVY-3318 | Javac doesn't see synthetic Groovy methods in Groovy-compiled superclass |
|
|
|
Patch for the src/main/org/codehaus/groovy/classgen/Verifier.java that will add them as non-synthetic if the target node is abstract. All 5 groovy object methods get this behaviour. (setMetaClass/getMetaClass/getProperty/setProperty/invokeMethod).
This resolves the problem for me.