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

André Filipe Aloise updated GROOVY-9815:
----------------------------------------
    Description: 
Consider the following reproducer: [https://github.com/ptomaszek/vertx-groovy]

 As it can be seen, there are two main classes: one with Groovy and one with 
Java. Both of them are simple reproducers of Vert.x Promises. When an object of 
Promisse calls it's future() method, it seems to create a new Future instance 
everytime, instead of just returning the existing one.

 The code within the reproducer has similar codes in Groovy and Java. When 
MainJava runs, it prints true, which is the expected behaviour. When MainGroovy 
runs, it prints false unless the class is annotated with @CompileStatic. 

Another reproducer is [https://github.com/tienquanutc/vertx-promise-groovy-bug] 
. This one also has two classes with similar codes. As promise.future() gets 
called four times, JMain classes prints 1 which is ok, but GMain prints 4. This 
one also works as expected with Groovy using @CompileStatic. 

This can be related to the fact that Promise and Future share the same 
implementation 
([https://github.com/eclipse-vertx/vert.x/tree/3.9/src/main/java/io/vertx/core)].
 Apparently when Groovy resolves the future() method call dynamically, it 
invokes the Future.future() static method instead of the instance 
Promise.future() method. 

There's also some healthy discussion here 
[https://github.com/vert-x3/vertx-lang-groovy/issues/113] 

I don't think it's a bug with Vert.x, since the code with Java works correctly.

  was:
Consider the following reproducer:

 

[https://github.com/ptomaszek/vertx-groovy]

 

As it can be seen, there are two main classes: one with Groovy and one with 
Java. Both of them are simple reproducers of Vert.x Promises. When an object of 
Promisse calls it's future() method, it seems to create a new Future instance 
everytime, instead of just returning the existing one.

 

The code within the reproducer has similar codes in Groovy and Java. When 
MainJava runs, it prints true, which is the expected behaviour. When MainGroovy 
runs, it prints false unless the class is annotated with @CompileStatic.

 

Another reproducer is [https://github.com/tienquanutc/vertx-promise-groovy-bug] 
. This one also has two classes with similar codes. As promise.future() gets 
called four times, JMain classes prints 1 which is ok, but GMain prints 4. This 
one also works as expected with Groovy using @CompileStatic.

 

This can be related to the fact that Promise and Future share the same 
implementation 
([https://github.com/eclipse-vertx/vert.x/tree/3.9/src/main/java/io/vertx/core)].
 Apparently when Groovy resolves the future() method call dynamically, it 
invokes the Future.future() static method instead of the instance 
Promise.future() method.

 

There's also some healthy discussion here 
https://github.com/vert-x3/vertx-lang-groovy/issues/113

 

I don't think it's a bug with Vert.x, since the code with Java works correctly.


> Object not bound with Groovy (but works fine in Java)
> -----------------------------------------------------
>
>                 Key: GROOVY-9815
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9815
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.6
>         Environment: OS: Windows 10
> AdoptJDK Hotspot 1.8.0.272
>            Reporter: André Filipe Aloise
>            Priority: Major
>
> Consider the following reproducer: [https://github.com/ptomaszek/vertx-groovy]
>  As it can be seen, there are two main classes: one with Groovy and one with 
> Java. Both of them are simple reproducers of Vert.x Promises. When an object 
> of Promisse calls it's future() method, it seems to create a new Future 
> instance everytime, instead of just returning the existing one.
>  The code within the reproducer has similar codes in Groovy and Java. When 
> MainJava runs, it prints true, which is the expected behaviour. When 
> MainGroovy runs, it prints false unless the class is annotated with 
> @CompileStatic. 
> Another reproducer is 
> [https://github.com/tienquanutc/vertx-promise-groovy-bug] . This one also has 
> two classes with similar codes. As promise.future() gets called four times, 
> JMain classes prints 1 which is ok, but GMain prints 4. This one also works 
> as expected with Groovy using @CompileStatic. 
> This can be related to the fact that Promise and Future share the same 
> implementation 
> ([https://github.com/eclipse-vertx/vert.x/tree/3.9/src/main/java/io/vertx/core)].
>  Apparently when Groovy resolves the future() method call dynamically, it 
> invokes the Future.future() static method instead of the instance 
> Promise.future() method. 
> There's also some healthy discussion here 
> [https://github.com/vert-x3/vertx-lang-groovy/issues/113] 
> I don't think it's a bug with Vert.x, since the code with Java works 
> correctly.



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

Reply via email to