[ 
https://issues.apache.org/jira/browse/GROOVY-9506?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniil Ovchinnikov updated GROOVY-9506:
---------------------------------------
    Description: 
{code:title=playground.groovy}
@groovy.transform.AutoImplement
class C implements Runnable {}

class Main {
    static void main(String[] args) {
        def c = new C()
        c.run()
    }
}
{code}

{code:title=I.java}
public interface I {
  void foo();
}
{code}

{noformat}
$ groovyc I.java playground.groovy -j
$ java -cp .:$GROOVY_HOME/lib/groovy-2.5.10.jar Main
Exception in thread "main" java.lang.NullPointerException
        at 
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:37)
        at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
        at Main.main(playground.groovy:9)
{noformat}

What happens:
1. {{org.codehaus.groovy.tools.javac.JavaStubGenerator#printClassContents}} 
applies its {{Verifier}}. 
2. {{org.codehaus.groovy.classgen.Verifier#addGroovyObjectInterfaceAndMethods}} 
adds {{GroovyObject}} interface and {{GroovyObject}}'s methods via 
{{org.codehaus.groovy.classgen.Verifier#addMethod}}.
3. {{Verifier#addMethod}} is overridden in {{#printClassContents}}' 
{{Verifier}} to skip adding methods to the class node.
4. at the moment when {{@AutoImplement}} kicks in there exists the 
{{GroovyObject}} interface and no methods in the class node, so the 
transformation adds default method implementations.

Related: https://youtrack.jetbrains.com/issue/IDEA-237148

  was:
{code:title=playground.groovy}
@groovy.transform.AutoImplement
class C implements Runnable {}

class Main {
    static void main(String[] args) {
        def c = new C()
        c.run()
    }
}
{code}

{code:title=I.java}
public interface I {
  void foo();
}
{code}

{noformat}
$ groovyc I.java playground.groovy -j
$ java -cp .:$GROOVY_HOME/lib/groovy-2.5.10.jar Main
Exception in thread "main" java.lang.NullPointerException
        at 
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:37)
        at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
        at Main.main(playground.groovy:9)
{noformat}

What happens:
1. {{org.codehaus.groovy.tools.javac.JavaStubGenerator#printClassContents}} 
applies its {{Verifier}}. 
2. {{org.codehaus.groovy.classgen.Verifier#addGroovyObjectInterfaceAndMethods}} 
adds {{GroovyObject}} interface and {{GroovyObject}}'s methods}} via 
{{org.codehaus.groovy.classgen.Verifier#addMethod}}.
3. {{Verifier#addMethod}} is overridden in {{#printClassContents}}' 
{{Verifier}} to skip adding methods to the class node.
4. at the moment when {{@AutoImplement}} kicks in there exists the 
{{GroovyObject}} interface and no methods in the class node, so the 
transformation adds default method implementations.

Related: https://youtrack.jetbrains.com/issue/IDEA-237148


> Joint compilation is broken
> ---------------------------
>
>                 Key: GROOVY-9506
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9506
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.10
>            Reporter: Daniil Ovchinnikov
>            Priority: Critical
>
> {code:title=playground.groovy}
> @groovy.transform.AutoImplement
> class C implements Runnable {}
> class Main {
>     static void main(String[] args) {
>         def c = new C()
>         c.run()
>     }
> }
> {code}
> {code:title=I.java}
> public interface I {
>   void foo();
> }
> {code}
> {noformat}
> $ groovyc I.java playground.groovy -j
> $ java -cp .:$GROOVY_HOME/lib/groovy-2.5.10.jar Main
> Exception in thread "main" java.lang.NullPointerException
>       at 
> org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:37)
>       at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
>       at Main.main(playground.groovy:9)
> {noformat}
> What happens:
> 1. {{org.codehaus.groovy.tools.javac.JavaStubGenerator#printClassContents}} 
> applies its {{Verifier}}. 
> 2. 
> {{org.codehaus.groovy.classgen.Verifier#addGroovyObjectInterfaceAndMethods}} 
> adds {{GroovyObject}} interface and {{GroovyObject}}'s methods via 
> {{org.codehaus.groovy.classgen.Verifier#addMethod}}.
> 3. {{Verifier#addMethod}} is overridden in {{#printClassContents}}' 
> {{Verifier}} to skip adding methods to the class node.
> 4. at the moment when {{@AutoImplement}} kicks in there exists the 
> {{GroovyObject}} interface and no methods in the class node, so the 
> transformation adds default method implementations.
> Related: https://youtrack.jetbrains.com/issue/IDEA-237148



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to