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

Jose Ignacio Acin Pozo commented on GROOVY-7933:
------------------------------------------------

Should @CompileStatic and interpreted behaviour actually be different? I think 
it sort of makes sense as @CompileStatic methods should be chosen at compile 
time(like Java does) instead of runtime (like Groovy does):

>From http://groovy-lang.org/differences.html#_multi_methods :

"In Groovy, the methods which will be invoked are chosen at runtime. This is 
called runtime dispatch or multi-methods. It means that the method will be 
chosen based on the types of the arguments at runtime. In Java, this is the 
opposite: methods are chosen at compile time, based on the declared types."

>From 
>http://docs.groovy-lang.org/latest/html/gapi/groovy/transform/CompileStatic.html
> :

"This will let the Groovy compiler use compile time checks in the style of Java 
then perform static compilation, thus bypassing the Groovy meta object 
protocol. When a class is annotated, all methods, properties, files, inner 
classes, etc. of the annotated class will be type checked."

Also more info taken from here 
http://java-performance.info/static-code-compilation-groovy-2-0/ :

"Static compilation allows Groovy 2.0 to generate direct method calls, which 
are no longer using Groovy runtime as an intermediary. This feature actually 
allows you to avoid going into the Groovy runtime for the huge share of methods 
– think how many overloaded methods do you usually have in your code – 
non-overloaded methods could always be safely converted into the normal method 
calls."


> Incorrect boxing of boolean primitive types
> -------------------------------------------
>
>                 Key: GROOVY-7933
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7933
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.7
>            Reporter: Henri Tremblay
>
> A boolean primitive type seems to be boxed for no apparent reason. See the 
> example below. The problem disappear when using @CompileStatic or if 
> explicitly casting to (boolean).
> {code:java}
> public class Demo {
>    public void a(boolean a){
>        System.out.println("boolean was called");
>    }
>    public void a(Object a){
>        System.out.println("Object was called");
>    }
> }
> class Groovy {
>    static void main(String[] args) {
>        def demo = new Demo()
>        demo.a(true)
>    }
> }
> {code}
> *Output:*
> Object was called



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to