I really like the features in Groovy, but I can't get them to work with co-compilation at all. Example:
Bird.groovy:
trait FlyingAbility {
String fly() { "I'm flying!" }
}
class Bird implements FlyingAbility {}
JavaClass.java:
public class JavaClass {
public static void main(String[] args) {
Bird b = new Bird();
}
}
Generated stub:
public class Bird
extends java.lang.Object implements
FlyingAbility {
;
public groovy.lang.MetaClass getMetaClass() { return (groovy.lang.MetaClass)null;}
public void setMetaClass(groovy.lang.MetaClass mc) { }
public java.lang.Object invokeMethod(java.lang.String method, java.lang.Object arguments) { return null;}
public java.lang.Object getProperty(java.lang.String property) { return null;}
public void setProperty(java.lang.String property, java.lang.Object value) { }
}
This leads to a java compiler that complains that FlyingAbility is not defined (and is not an interface). I find it hard to believe that this is not supported: am I missing something?
source
share