Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.3.2
-
None
-
None
Description
I created a groovy class containing a delegate. The delegate has a getter:
class SomeGroovyClass { @Delegate SomeDelegate delegate SomeGroovyClass(SomeDelegate delegate) { this.delegate = delegate } } class SomeDelegate { String value SomeDelegate(String value) { this.value = value } }
I have a java client creating the groovy class:
public class Client { public static void main(String[] args) { SomeDelegate delegate = new SomeDelegate("val1"); System.out.println(delegate.getValue()); SomeGroovyClass groovyClass = new SomeGroovyClass(delegate); System.out.println(groovyClass.getValue()); } }
When I compile this using the GMavenPlus plugin in maven, I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project delegateTest: Compilation failure
[ERROR] C:\dev\projects\delegateTest\src\main\java\Client.java:[24,38] error: cannot find symbol
This is because the generated stub doesn't contain the getValue() method from the delegate:
import java.lang.*; import java.io.*; import java.net.*; import java.util.*; import groovy.lang.*; import groovy.util.*; public class SomeGroovyClass extends java.lang.Object implements groovy.lang.GroovyObject { public SomeGroovyClass (SomeDelegate delegate) {} 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) { } public SomeDelegate getDelegate() { return (SomeDelegate)null;} public void setDelegate(SomeDelegate value) { } }
You can find a sample in attachment using maven
Attachments
Attachments
Issue Links
- is related to
-
GROOVY-7764 Joint compilation does not work with AST-transformed Groovy
- Open
-
GROOVY-3683 groovyc can't joint compile a Java class that uses a delegate method from a Groovy class with an @Delegate property annotation
- Open
-
GROOVY-4647 A class using the @Delegate annotation does not implement the delegate's interfaces from the Java side when join compiling
- Open