[jira] [Commented] (GROOVY-8338) Calling Stream.of from groovy class in JDK 9 fails

2018-01-12 Thread Paul King (JIRA)

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

Paul King commented on GROOVY-8338:
---

Well, I don't care whether it is closed or remains open so long as we know what 
parts have been fixed so far and what cases are still left to do. I wasn't 
following as closely as I possibly should have early on and I have kind of lost 
track. [~blackdrag] what's your understanding of the current status? Some cases 
fail for master in JDK9 and some issues on 2_4_X?

> Calling Stream.of from groovy class in JDK 9 fails
> --
>
> Key: GROOVY-8338
> URL: https://issues.apache.org/jira/browse/GROOVY-8338
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.4.12
>Reporter: Marcus Nylander
>
> Trying to call Stream.of from groovy class (groovy version 2.4.12) using JDK 
> 9 (jdk 9 181) fails. 
> Example:
> {code}
> package test
> import java.util.stream.Stream
> class B {
> static void main(String[] args) {
> Stream.of("1").forEach({ println(it) })
> }
> }
> {code}
> The code above fails with:
> Exception in thread "main" java.lang.IncompatibleClassChangeError: Method 
> java.util.stream.Stream.of(Ljava/lang/Object;)Ljava/util/stream/Stream; must 
> be InterfaceMethodref constant
>   at java_util_stream_Stream$of.call(Unknown Source)
>   at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>   at test.B.main(B.groovy:7)
> The same occurs for other interface static methods also:
> {code}
> public interface D {
> static D of(String s) {
> return new D() {
> };
> }
> }
> class C {
> static void main(String[] args) {
> D.of("1")
> }
> }
> {code}
> Also fails with:
> Exception in thread "main" java.lang.IncompatibleClassChangeError: Method 
> test.D.of(Ljava/lang/String;)Ltest/D; must be InterfaceMethodref constant
>   at test.D$of.call(Unknown Source)
>   at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>   at test.C.main(C.groovy:7)
> Running with JDK 8 works fine.



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


[jira] [Updated] (GROOVY-8338) Calling Stream.of from groovy class in JDK 9 fails

2018-01-12 Thread Jochen Theodorou (JIRA)

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

Jochen Theodorou updated GROOVY-8338:
-
Fix Version/s: (was: 2.4.14)

> Calling Stream.of from groovy class in JDK 9 fails
> --
>
> Key: GROOVY-8338
> URL: https://issues.apache.org/jira/browse/GROOVY-8338
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.4.12
>Reporter: Marcus Nylander
>
> Trying to call Stream.of from groovy class (groovy version 2.4.12) using JDK 
> 9 (jdk 9 181) fails. 
> Example:
> {code}
> package test
> import java.util.stream.Stream
> class B {
> static void main(String[] args) {
> Stream.of("1").forEach({ println(it) })
> }
> }
> {code}
> The code above fails with:
> Exception in thread "main" java.lang.IncompatibleClassChangeError: Method 
> java.util.stream.Stream.of(Ljava/lang/Object;)Ljava/util/stream/Stream; must 
> be InterfaceMethodref constant
>   at java_util_stream_Stream$of.call(Unknown Source)
>   at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>   at test.B.main(B.groovy:7)
> The same occurs for other interface static methods also:
> {code}
> public interface D {
> static D of(String s) {
> return new D() {
> };
> }
> }
> class C {
> static void main(String[] args) {
> D.of("1")
> }
> }
> {code}
> Also fails with:
> Exception in thread "main" java.lang.IncompatibleClassChangeError: Method 
> test.D.of(Ljava/lang/String;)Ltest/D; must be InterfaceMethodref constant
>   at test.D$of.call(Unknown Source)
>   at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>   at test.C.main(C.groovy:7)
> Running with JDK 8 works fine.



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


[jira] [Commented] (GROOVY-8338) Calling Stream.of from groovy class in JDK 9 fails

2018-01-12 Thread Jochen Theodorou (JIRA)

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

Jochen Theodorou commented on GROOVY-8338:
--

then most likely somebody else has to solve the problem

> Calling Stream.of from groovy class in JDK 9 fails
> --
>
> Key: GROOVY-8338
> URL: https://issues.apache.org/jira/browse/GROOVY-8338
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.4.12
>Reporter: Marcus Nylander
>
> Trying to call Stream.of from groovy class (groovy version 2.4.12) using JDK 
> 9 (jdk 9 181) fails. 
> Example:
> {code}
> package test
> import java.util.stream.Stream
> class B {
> static void main(String[] args) {
> Stream.of("1").forEach({ println(it) })
> }
> }
> {code}
> The code above fails with:
> Exception in thread "main" java.lang.IncompatibleClassChangeError: Method 
> java.util.stream.Stream.of(Ljava/lang/Object;)Ljava/util/stream/Stream; must 
> be InterfaceMethodref constant
>   at java_util_stream_Stream$of.call(Unknown Source)
>   at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>   at test.B.main(B.groovy:7)
> The same occurs for other interface static methods also:
> {code}
> public interface D {
> static D of(String s) {
> return new D() {
> };
> }
> }
> class C {
> static void main(String[] args) {
> D.of("1")
> }
> }
> {code}
> Also fails with:
> Exception in thread "main" java.lang.IncompatibleClassChangeError: Method 
> test.D.of(Ljava/lang/String;)Ltest/D; must be InterfaceMethodref constant
>   at test.D$of.call(Unknown Source)
>   at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>   at test.C.main(C.groovy:7)
> Running with JDK 8 works fine.



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


[jira] [Reopened] (GROOVY-8338) Calling Stream.of from groovy class in JDK 9 fails

2018-01-12 Thread Jochen Theodorou (JIRA)

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

Jochen Theodorou reopened GROOVY-8338:
--

> Calling Stream.of from groovy class in JDK 9 fails
> --
>
> Key: GROOVY-8338
> URL: https://issues.apache.org/jira/browse/GROOVY-8338
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.4.12
>Reporter: Marcus Nylander
>Assignee: Jochen Theodorou
> Fix For: 2.4.14
>
>
> Trying to call Stream.of from groovy class (groovy version 2.4.12) using JDK 
> 9 (jdk 9 181) fails. 
> Example:
> {code}
> package test
> import java.util.stream.Stream
> class B {
> static void main(String[] args) {
> Stream.of("1").forEach({ println(it) })
> }
> }
> {code}
> The code above fails with:
> Exception in thread "main" java.lang.IncompatibleClassChangeError: Method 
> java.util.stream.Stream.of(Ljava/lang/Object;)Ljava/util/stream/Stream; must 
> be InterfaceMethodref constant
>   at java_util_stream_Stream$of.call(Unknown Source)
>   at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>   at test.B.main(B.groovy:7)
> The same occurs for other interface static methods also:
> {code}
> public interface D {
> static D of(String s) {
> return new D() {
> };
> }
> }
> class C {
> static void main(String[] args) {
> D.of("1")
> }
> }
> {code}
> Also fails with:
> Exception in thread "main" java.lang.IncompatibleClassChangeError: Method 
> test.D.of(Ljava/lang/String;)Ltest/D; must be InterfaceMethodref constant
>   at test.D$of.call(Unknown Source)
>   at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>   at test.C.main(C.groovy:7)
> Running with JDK 8 works fine.



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


[jira] [Assigned] (GROOVY-8338) Calling Stream.of from groovy class in JDK 9 fails

2018-01-12 Thread Jochen Theodorou (JIRA)

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

Jochen Theodorou reassigned GROOVY-8338:


Assignee: (was: Jochen Theodorou)

> Calling Stream.of from groovy class in JDK 9 fails
> --
>
> Key: GROOVY-8338
> URL: https://issues.apache.org/jira/browse/GROOVY-8338
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.4.12
>Reporter: Marcus Nylander
> Fix For: 2.4.14
>
>
> Trying to call Stream.of from groovy class (groovy version 2.4.12) using JDK 
> 9 (jdk 9 181) fails. 
> Example:
> {code}
> package test
> import java.util.stream.Stream
> class B {
> static void main(String[] args) {
> Stream.of("1").forEach({ println(it) })
> }
> }
> {code}
> The code above fails with:
> Exception in thread "main" java.lang.IncompatibleClassChangeError: Method 
> java.util.stream.Stream.of(Ljava/lang/Object;)Ljava/util/stream/Stream; must 
> be InterfaceMethodref constant
>   at java_util_stream_Stream$of.call(Unknown Source)
>   at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>   at test.B.main(B.groovy:7)
> The same occurs for other interface static methods also:
> {code}
> public interface D {
> static D of(String s) {
> return new D() {
> };
> }
> }
> class C {
> static void main(String[] args) {
> D.of("1")
> }
> }
> {code}
> Also fails with:
> Exception in thread "main" java.lang.IncompatibleClassChangeError: Method 
> test.D.of(Ljava/lang/String;)Ltest/D; must be InterfaceMethodref constant
>   at test.D$of.call(Unknown Source)
>   at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
>   at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>   at test.C.main(C.groovy:7)
> Running with JDK 8 works fine.



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


[jira] [Updated] (GROOVY-8447) It is allowed to define local variable of void type

2018-01-12 Thread Daniil Ovchinnikov (JIRA)

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

Daniil Ovchinnikov updated GROOVY-8447:
---
Description: 
{code:title=bugs.groovy}
void ff = 1
println ff
{code}

{noformat}
java.lang.ClassFormatError: Field "ff" in class playground has illegal 
signature "V"
{noformat}


  was:

{noformat}
java.lang.ClassFormatError: Field "ff" in class playground has illegal 
signature "V"
{noformat}



> It is allowed to define local variable of void type
> ---
>
> Key: GROOVY-8447
> URL: https://issues.apache.org/jira/browse/GROOVY-8447
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.13
>Reporter: Daniil Ovchinnikov
>
> {code:title=bugs.groovy}
> void ff = 1
> println ff
> {code}
> {noformat}
> java.lang.ClassFormatError: Field "ff" in class playground has illegal 
> signature "V"
> {noformat}



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


[jira] [Updated] (GROOVY-8447) It is allowed to define local variable of void type

2018-01-12 Thread Daniil Ovchinnikov (JIRA)

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

Daniil Ovchinnikov updated GROOVY-8447:
---
Description: 
{code:title=bugs.groovy}
void ff = 1
println ff
{code}

{noformat}
java.lang.ClassFormatError: Field "ff" in class bugs has illegal signature "V"
{noformat}


  was:
{code:title=bugs.groovy}
void ff = 1
println ff
{code}

{noformat}
java.lang.ClassFormatError: Field "ff" in class playground has illegal 
signature "V"
{noformat}



> It is allowed to define local variable of void type
> ---
>
> Key: GROOVY-8447
> URL: https://issues.apache.org/jira/browse/GROOVY-8447
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.13
>Reporter: Daniil Ovchinnikov
>
> {code:title=bugs.groovy}
> void ff = 1
> println ff
> {code}
> {noformat}
> java.lang.ClassFormatError: Field "ff" in class bugs has illegal signature "V"
> {noformat}



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


[jira] [Created] (GROOVY-8447) It is allowed to define local variable of void type

2018-01-12 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8447:
--

 Summary: It is allowed to define local variable of void type
 Key: GROOVY-8447
 URL: https://issues.apache.org/jira/browse/GROOVY-8447
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.4.13
Reporter: Daniil Ovchinnikov



{noformat}
java.lang.ClassFormatError: Field "ff" in class playground has illegal 
signature "V"
{noformat}




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


[jira] [Created] (GROOVY-8446) void[] return type causes compiler to fail

2018-01-12 Thread Daniil Ovchinnikov (JIRA)
Daniil Ovchinnikov created GROOVY-8446:
--

 Summary: void[] return type causes compiler to fail
 Key: GROOVY-8446
 URL: https://issues.apache.org/jira/browse/GROOVY-8446
 Project: Groovy
  Issue Type: Bug
  Components: Compiler
Affects Versions: 2.4.13
Reporter: Daniil Ovchinnikov


{noformat}
$ cat playground.groovy
void[] foo() {}
$ groovy playground.groovy
BUG! exception in phase 'conversion' in source unit '%path%/playground.groovy' 
null
Caused by: java.lang.IllegalArgumentException
{noformat}



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


[jira] [Commented] (GROOVY-8445) Static analysis does not work properly when coercing Closure to FunctionInterface

2018-01-12 Thread Daniel Sun (JIRA)

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

Daniel Sun commented on GROOVY-8445:


I found the issue when I tried to implement the native lambda, which is based 
on static analysis to gain the type information.

testBinaryOperator and testUnaryOperator are skiped due to the issue:
https://github.com/apache/groovy/blob/native-lambda/src/test/groovy/transform/stc/LambdaTest.groovy



> Static analysis does not work properly when coercing Closure to 
> FunctionInterface
> -
>
> Key: GROOVY-8445
> URL: https://issues.apache.org/jira/browse/GROOVY-8445
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 3.0.0-alpha-1, 2.5.0-beta-2, 2.4.13, 2.6.0-alpha-2
>Reporter: Daniel Sun
>
> The following code fails when executing in static compilation mode.
> {code:java}
> import groovy.transform.CompileStatic
> import java.util.stream.Collectors
> import java.util.stream.Stream
> 
> @CompileStatic // if we comment this line, the code works in 
> dynamic mode.
> public class Test1 {
> public static void main(String[] args) {
> p();
> }
> 
> public static void p() {
> assert 13 == Stream.of(1, 2, 3).reduce(7, {r, e -> r + e});
> }
> }
> {code}
> Here is the error message:
> {code}
> [Static type checking] - Cannot find matching method 
> java.util.stream.Stream#reduce(int, groovy.lang.Closure). Please check if the 
> declared type is correct and if the method exists.
>  at line: 12, column: 30
> [Static type checking] - Cannot find matching method 
> java.lang.Object#plus(java.lang.Object). Please check if the declared type is 
> correct and if the method exists.
>  at line: 12, column: 68
> {code}
> Similarly, the following code fails in static compilation mode too:
> {code:java}
> import groovy.transform.CompileStatic
> import java.util.stream.Collectors
> import java.util.stream.Stream
> 
> @CompileStatic  // if we comment this line, the code works in dynamic 
> mode.
> public class Test1 {
> public static void main(String[] args) {
> p();
> }
> 
> public static void p() {
> def list = [1, 2, 3]
> list.replaceAll { e -> e + 10 }
> assert [11, 12, 13] == list
> }
> }
> {code}
> Here is the error message:
> {code}
> [Static type checking] - Cannot find matching method 
> java.util.List#replaceAll(groovy.lang.Closure). Please check if the declared 
> type is correct and if the method exists.
>  at line: 13, column: 17
> [Static type checking] - Cannot find matching method 
> java.lang.Object#plus(int). Please check if the declared type is correct and 
> if the method exists.
>  at line: 13, column: 40
> {code}



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


[jira] [Created] (GROOVY-8445) Static analysis does not work properly when coercing Closure to FunctionInterface

2018-01-12 Thread Daniel Sun (JIRA)
Daniel Sun created GROOVY-8445:
--

 Summary: Static analysis does not work properly when coercing 
Closure to FunctionInterface
 Key: GROOVY-8445
 URL: https://issues.apache.org/jira/browse/GROOVY-8445
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.6.0-alpha-2, 2.4.13, 2.5.0-beta-2, 3.0.0-alpha-1
Reporter: Daniel Sun


The following code fails when executing in static compilation mode.

{code:java}
import groovy.transform.CompileStatic
import java.util.stream.Collectors
import java.util.stream.Stream

@CompileStatic // if we comment this line, the code works in 
dynamic mode.
public class Test1 {
public static void main(String[] args) {
p();
}

public static void p() {
assert 13 == Stream.of(1, 2, 3).reduce(7, {r, e -> r + e});
}
}
{code}

Here is the error message:
{code}
[Static type checking] - Cannot find matching method 
java.util.stream.Stream#reduce(int, groovy.lang.Closure). Please check if the 
declared type is correct and if the method exists.
 at line: 12, column: 30

[Static type checking] - Cannot find matching method 
java.lang.Object#plus(java.lang.Object). Please check if the declared type is 
correct and if the method exists.
 at line: 12, column: 68
{code}

Similarly, the following code fails in static compilation mode too:

{code:java}
import groovy.transform.CompileStatic
import java.util.stream.Collectors
import java.util.stream.Stream

@CompileStatic  // if we comment this line, the code works in dynamic 
mode.
public class Test1 {
public static void main(String[] args) {
p();
}

public static void p() {
def list = [1, 2, 3]
list.replaceAll { e -> e + 10 }
assert [11, 12, 13] == list
}
}
{code}

Here is the error message:

{code}
[Static type checking] - Cannot find matching method 
java.util.List#replaceAll(groovy.lang.Closure). Please check if the declared 
type is correct and if the method exists.
 at line: 13, column: 17

[Static type checking] - Cannot find matching method 
java.lang.Object#plus(int). Please check if the declared type is correct and if 
the method exists.
 at line: 13, column: 40


{code}






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