groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jochen Theodorou (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7764) Joint compilation does not work with AST-transformed Groovy
Date Sat, 16 Sep 2017 19:18:01 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-7764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16169025#comment-16169025
] 

Jochen Theodorou commented on GROOVY-7764:
------------------------------------------

The only way I see to fix this is to give up on stubbed compilation. In that way the groovy
compiler needs to be fed with all the information it needs for compilation, which includes
information about java files. In an environment like eclipse I see this having the possibility
to work. Independent of an IDE we would need a java parser, that creates an at least partially
filled AST. I am actually working on something like that, but progress is slow, since I do
not have enough time to get something really done here these days. IF somebody knows an alternative
solution, any idea is welcome. 

But maybe I explain one more time the technical reason why things are as they are.. To compile
a class "class Foo extends Bar" I need to know what Bar means. If Bar is a java class and
maybe Bar depends on a Groovy class again, then the Groovy compiler alone cannot get this
information anymore. So we do a trick here. We create a stub for all Groovy classes and call
the java compiler to compile everything for us. After that we have a Bar class file we can
inspect and extract the exact information from. With this information we can then compile
the Groovy classes. 

Transforms that act after the phase we use to generate the stubs in cannot be reflected in
the stubs. That is basically for everything that depends on classes. The normal local transform
is triggered by the class of the annotation. So for those it is always after stub generation.
 That is why the problem is so annoying.

> Joint compilation does not work with AST-transformed Groovy
> -----------------------------------------------------------
>
>                 Key: GROOVY-7764
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7764
>             Project: Groovy
>          Issue Type: Bug
>          Components: Stub generator / Joint compiler
>    Affects Versions: 2.4.6
>            Reporter: O. Rei├čig
>         Attachments: foo.zip
>
>
> When using AST transformations together with joint compilation the generated stubs don't
mind the transformations, which may yield invalid classes, that javac will fail to compile.
> Example:
> {code}
> [...]
> class GroovyTest implements Callable {
>     @Delegate
>     private final Callable c = { println "Hello World" }
> }
> {code}
> will get compiled into the following stub:
> {code}
> [...]
> public class GroovyTest
>   extends java.lang.Object  implements
>     java.util.concurrent.Callable,    groovy.lang.GroovyObject {
> ;
> 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) { }
> }
> {code}
> which claims to implement {{Callable}}, but lacks a {{call}} method.
> I don't know if this is specific to {{@Delegate}}, but noticed similar behaviour with
{{@InheritConstructors}}.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message