[GitHub] groovy pull request #837: GROOVY-8917: Failed to infer parameter type of som...

2018-12-10 Thread danielsun1106
Github user danielsun1106 commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240468415
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

@paulk-asert I've refined the PR according to your suggestion ;-)


---


[jira] [Commented] (GROOVY-8917) Failed to infer parameter type of some SAM, e.g. BinaryOperator

2018-12-10 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on GROOVY-8917:


Github user danielsun1106 commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240468415
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

@paulk-asert I've refined the PR according to your suggestion ;-)


> Failed to infer parameter type of some SAM, e.g. BinaryOperator
> ---
>
> Key: GROOVY-8917
> URL: https://issues.apache.org/jira/browse/GROOVY-8917
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniel Sun
>Assignee: Daniel Sun
>Priority: Major
>
> {code:java}
> import groovy.transform.CompileStatic
> import java.util.stream.Collectors
> import java.util.stream.Stream
> 
> @CompileStatic
> public class Test1 {
> public static void main(String[] args) {
> p();
> }
> 
> public static void p() {
> // If we do not explicitly declare the type of parameter, STC 
> fails
> assert 13 == [1, 2, 3].stream().reduce(7, (Integer r, Integer 
> e) -> r + e);
> }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8918) Illegal Reflective Access reported during Gradle build

2018-12-10 Thread will mason (JIRA)
will mason created GROOVY-8918:
--

 Summary: Illegal Reflective Access reported during Gradle build
 Key: GROOVY-8918
 URL: https://issues.apache.org/jira/browse/GROOVY-8918
 Project: Groovy
  Issue Type: Bug
  Components: Compiler
Affects Versions: 2.4.15
 Environment: Linux 64-bit , gradle 4.10.3, JDK 8 u192 with Netbeans 8.2
Reporter: will mason


The following code is emitted for a Java/Groovy build using Gradle v4.10.3 and 
using the Spock BDD testing framework, JDK 8 targeting JRE 8.  The message says 
to report this.  

I didn't find an open bug with this message -- Towit, I'm reporting it.

{code:java}
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by 
org.codehaus.groovy.reflection.CachedClass 
(file:/scr/root/.caches/william/gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-all/2.4.15/5f71e0843ea6c949920f3219c6c961a3895e53c4/groovy-all-2.4.15-indy.jar)
 to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of 
org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal 
reflective access operations
WARNING: All illegal access operations will be denied in a future release
Note: Creating bean classes for 2 type elements
warning: Implicitly compiled files were not subject to annotation processing.
  Use -implicit to specify a policy for implicit compilation.
{code}




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8917) Failed to infer parameter type of some SAM, e.g. BinaryOperator

2018-12-10 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on GROOVY-8917:


Github user danielsun1106 commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240451854
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

Gotcha. I will use the map you suggest instead.


> Failed to infer parameter type of some SAM, e.g. BinaryOperator
> ---
>
> Key: GROOVY-8917
> URL: https://issues.apache.org/jira/browse/GROOVY-8917
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniel Sun
>Assignee: Daniel Sun
>Priority: Major
>
> {code:java}
> import groovy.transform.CompileStatic
> import java.util.stream.Collectors
> import java.util.stream.Stream
> 
> @CompileStatic
> public class Test1 {
> public static void main(String[] args) {
> p();
> }
> 
> public static void p() {
> // If we do not explicitly declare the type of parameter, STC 
> fails
> assert 13 == [1, 2, 3].stream().reduce(7, (Integer r, Integer 
> e) -> r + e);
> }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] groovy pull request #837: GROOVY-8917: Failed to infer parameter type of som...

2018-12-10 Thread danielsun1106
Github user danielsun1106 commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240451854
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

Gotcha. I will use the map you suggest instead.


---


[jira] [Commented] (GROOVY-8917) Failed to infer parameter type of some SAM, e.g. BinaryOperator

2018-12-10 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on GROOVY-8917:


Github user paulk-asert commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240451723
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

And I guess also `TypeUtil#PRIMITIVE_TYPE_TO_WRAPPED_CLASS_MAP` would be 
better named `PRIMITIVE_CLASS_TO_WRAPPED_CLASS_MAP`.


> Failed to infer parameter type of some SAM, e.g. BinaryOperator
> ---
>
> Key: GROOVY-8917
> URL: https://issues.apache.org/jira/browse/GROOVY-8917
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniel Sun
>Assignee: Daniel Sun
>Priority: Major
>
> {code:java}
> import groovy.transform.CompileStatic
> import java.util.stream.Collectors
> import java.util.stream.Stream
> 
> @CompileStatic
> public class Test1 {
> public static void main(String[] args) {
> p();
> }
> 
> public static void p() {
> // If we do not explicitly declare the type of parameter, STC 
> fails
> assert 13 == [1, 2, 3].stream().reduce(7, (Integer r, Integer 
> e) -> r + e);
> }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] groovy pull request #837: GROOVY-8917: Failed to infer parameter type of som...

2018-12-10 Thread paulk-asert
Github user paulk-asert commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240451723
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

And I guess also `TypeUtil#PRIMITIVE_TYPE_TO_WRAPPED_CLASS_MAP` would be 
better named `PRIMITIVE_CLASS_TO_WRAPPED_CLASS_MAP`.


---


[jira] [Commented] (GROOVY-8917) Failed to infer parameter type of some SAM, e.g. BinaryOperator

2018-12-10 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on GROOVY-8917:


Github user paulk-asert commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240451547
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

I was referring to `ClassHelper#PRIMITIVE_TYPE_TO_WRAPPER_TYPE_MAP` not 
`TypeUtil#PRIMITIVE_TYPE_TO_WRAPPED_CLASS_MAP`.


> Failed to infer parameter type of some SAM, e.g. BinaryOperator
> ---
>
> Key: GROOVY-8917
> URL: https://issues.apache.org/jira/browse/GROOVY-8917
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniel Sun
>Assignee: Daniel Sun
>Priority: Major
>
> {code:java}
> import groovy.transform.CompileStatic
> import java.util.stream.Collectors
> import java.util.stream.Stream
> 
> @CompileStatic
> public class Test1 {
> public static void main(String[] args) {
> p();
> }
> 
> public static void p() {
> // If we do not explicitly declare the type of parameter, STC 
> fails
> assert 13 == [1, 2, 3].stream().reduce(7, (Integer r, Integer 
> e) -> r + e);
> }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] groovy pull request #837: GROOVY-8917: Failed to infer parameter type of som...

2018-12-10 Thread paulk-asert
Github user paulk-asert commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240451547
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

I was referring to `ClassHelper#PRIMITIVE_TYPE_TO_WRAPPER_TYPE_MAP` not 
`TypeUtil#PRIMITIVE_TYPE_TO_WRAPPED_CLASS_MAP`.


---


[jira] [Commented] (GROOVY-8917) Failed to infer parameter type of some SAM, e.g. BinaryOperator

2018-12-10 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on GROOVY-8917:


Github user paulk-asert commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240451187
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

Both appear to be Map to me?


> Failed to infer parameter type of some SAM, e.g. BinaryOperator
> ---
>
> Key: GROOVY-8917
> URL: https://issues.apache.org/jira/browse/GROOVY-8917
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniel Sun
>Assignee: Daniel Sun
>Priority: Major
>
> {code:java}
> import groovy.transform.CompileStatic
> import java.util.stream.Collectors
> import java.util.stream.Stream
> 
> @CompileStatic
> public class Test1 {
> public static void main(String[] args) {
> p();
> }
> 
> public static void p() {
> // If we do not explicitly declare the type of parameter, STC 
> fails
> assert 13 == [1, 2, 3].stream().reduce(7, (Integer r, Integer 
> e) -> r + e);
> }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] groovy pull request #837: GROOVY-8917: Failed to infer parameter type of som...

2018-12-10 Thread paulk-asert
Github user paulk-asert commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240451187
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

Both appear to be Map to me?


---


[jira] [Commented] (GROOVY-8917) Failed to infer parameter type of some SAM, e.g. BinaryOperator

2018-12-10 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on GROOVY-8917:


Github user danielsun1106 commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240445739
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

@paulk-asert As we can see, the existing type mapping is Class to Class,  
but we need map ClassNode to ClassNode. Though we can convert ClassNode to 
Class and get the mapping result then convert the result to ClassNode, it is 
less efficient.


https://github.com/apache/groovy/blob/9cea59b95367c1d563e719ebeddcdecb58199750/src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java#L213


> Failed to infer parameter type of some SAM, e.g. BinaryOperator
> ---
>
> Key: GROOVY-8917
> URL: https://issues.apache.org/jira/browse/GROOVY-8917
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniel Sun
>Assignee: Daniel Sun
>Priority: Major
>
> {code:java}
> import groovy.transform.CompileStatic
> import java.util.stream.Collectors
> import java.util.stream.Stream
> 
> @CompileStatic
> public class Test1 {
> public static void main(String[] args) {
> p();
> }
> 
> public static void p() {
> // If we do not explicitly declare the type of parameter, STC 
> fails
> assert 13 == [1, 2, 3].stream().reduce(7, (Integer r, Integer 
> e) -> r + e);
> }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] groovy pull request #837: GROOVY-8917: Failed to infer parameter type of som...

2018-12-10 Thread danielsun1106
Github user danielsun1106 commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240445739
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

@paulk-asert As we can see, the existing type mapping is Class to Class,  
but we need map ClassNode to ClassNode. Though we can convert ClassNode to 
Class and get the mapping result then convert the result to ClassNode, it is 
less efficient.


https://github.com/apache/groovy/blob/9cea59b95367c1d563e719ebeddcdecb58199750/src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java#L213


---


[jira] [Resolved] (GROOVY-8742) Line number information for method is confusing debugger

2018-12-10 Thread Paul King (JIRA)


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

Paul King resolved GROOVY-8742.
---
   Resolution: Fixed
 Assignee: Paul King
Fix Version/s: 2.4.16
   2.5.5
   3.0.0-alpha-4

>From my and Eric's testing we believe this was resolved as part of GROOVY-7647.

> Line number information for method is confusing debugger
> 
>
> Key: GROOVY-8742
> URL: https://issues.apache.org/jira/browse/GROOVY-8742
> Project: Groovy
>  Issue Type: Bug
>  Components: bytecode, class generator
>Affects Versions: 2.4.15
>Reporter: Eric Milles
>Assignee: Paul King
>Priority: Major
> Fix For: 3.0.0-alpha-4, 2.5.5, 2.4.16
>
>
> I have been investigating a case where the IDE will not break on a line 
> breakpoint in a test method.  This method has no parameters or local 
> variables (this affects its line number table in the bytecode) and the code 
> is all on one line, with a chain of three method calls.  When line-breaking 
> the code or assigning to temporary, the line numbers table changes and the 
> line breakpoints work as expected.
> {code:groovy}
> package a
> import org.junit.*
> final class Tests {
>   @Test
>   void testSomething() { // line 29
> Assert.assertFalse(this.method(one(), "two", Three.class)) // line 30
>   }
>   boolean method(... args) { true }
>   def one() {}
> }
> {code}
> When compiled with Groovy 2.4 and normal/dynamic groovy, the method has line 
> information:
> {code}
>   Line numbers:
> [pc: 4, line: 29]
> [pc: 19, line: 30]
> [pc: 68, line: 30]
>   Local variable table:
> [pc: 0, pc: 109] local: this index: 0 type: a.Tests
> {code}
> I have not tried with the "fast path" optimization disabled.  I think its 
> prelude is what bumps the PC from 0 to 4 and results in the two PC entries 
> for line 30 (pc 19 and pc 68).
> If I assign the result of {{method}} to a new local variable, the line 
> numbers are altered:
> {code}
>   Line numbers:
> [pc: 6, line: 30]
> [pc: 63, line: 30]
> [pc: 100, line: 31]
>   Local variable table:
> [pc: 0, pc: 113] local: this index: 0 type: a.Tests
> [pc: 6, pc: 113] local: variable index: 2 type: java.lang.Object
> {code}
> If I compile with invoke dynamic on, I get this for the original code:
> {code}
>   Line numbers:
> [pc: 0, line: 30]
>   Local variable table:
> [pc: 0, pc: 30] local: this index: 0 type: a.Tests
> {code}
> I'm not sure the exact outcome expected here in terms of the bytecode, but I 
> looked at similar methods from Java sources.  For a Java test method, the 
> line number table began with {{[pc: 0, line: whatever]}}.
> I looked at GROOVY-4505, which mentions that 
> {{AsmClassGenerator.visitBlockStatement}} should not be writing line number 
> information for the block statement (the source of line 29).  
> {{StatementWriter.writeBlockStatement}} indeed retains a note about this.  
> However, the overload in {{OptimizingStatementWriter}} still triggers 
> `onLineNumber` from its `writeBlockStatement` -> {{writeGuards}}.  Should 
> {{onLineNumber}} check for {{BlockStatement}} and exit early?  I tried this 
> quickly and it did alter the line numbers table, but it did not help my 
> debugger find the breakpoint on line 30.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (GROOVY-8917) Failed to infer parameter type of some SAM, e.g. BinaryOperator

2018-12-10 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on GROOVY-8917:


Github user paulk-asert commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240369943
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

Isn't this already in ClassHelper#PRIMITIVE_TYPE_TO_WRAPPER_TYPE_MAP?


> Failed to infer parameter type of some SAM, e.g. BinaryOperator
> ---
>
> Key: GROOVY-8917
> URL: https://issues.apache.org/jira/browse/GROOVY-8917
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniel Sun
>Assignee: Daniel Sun
>Priority: Major
>
> {code:java}
> import groovy.transform.CompileStatic
> import java.util.stream.Collectors
> import java.util.stream.Stream
> 
> @CompileStatic
> public class Test1 {
> public static void main(String[] args) {
> p();
> }
> 
> public static void p() {
> // If we do not explicitly declare the type of parameter, STC 
> fails
> assert 13 == [1, 2, 3].stream().reduce(7, (Integer r, Integer 
> e) -> r + e);
> }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] groovy pull request #837: GROOVY-8917: Failed to infer parameter type of som...

2018-12-10 Thread paulk-asert
Github user paulk-asert commented on a diff in the pull request:

https://github.com/apache/groovy/pull/837#discussion_r240369943
  
--- Diff: src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java 
---
@@ -213,4 +220,15 @@ private static String makeRefDescription(String name) {
 long.class, Long.class,
 short.class, Short.class
 );
+
+private static final Map 
PRIMITIVE_CLASSNODE_TO_WRAPPED_CLASSNODE_MAP = Maps.of(
+ClassHelper.byte_TYPE, ClassHelper.Byte_TYPE,
+ClassHelper.boolean_TYPE, ClassHelper.Boolean_TYPE,
+ClassHelper.char_TYPE, ClassHelper.Character_TYPE,
+ClassHelper.double_TYPE, ClassHelper.Double_TYPE,
+ClassHelper.float_TYPE, ClassHelper.Float_TYPE,
+ClassHelper.int_TYPE, ClassHelper.Integer_TYPE,
+ClassHelper.long_TYPE, ClassHelper.Long_TYPE,
+ClassHelper.short_TYPE, ClassHelper.Short_TYPE
+);
--- End diff --

Isn't this already in ClassHelper#PRIMITIVE_TYPE_TO_WRAPPER_TYPE_MAP?


---


[jira] [Commented] (GROOVY-8917) Failed to infer parameter type of some SAM, e.g. BinaryOperator

2018-12-10 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on GROOVY-8917:


GitHub user danielsun1106 opened a pull request:

https://github.com/apache/groovy/pull/837

GROOVY-8917: Failed to infer parameter type of some SAM, e.g. BinaryO…

…perator

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/danielsun1106/groovy refine-type-inference

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/groovy/pull/837.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #837


commit 3669f04205265b62e3a3f339aa1b81fbf3003ecb
Author: danielsun1106 
Date:   2018-12-10T19:06:29Z

GROOVY-8917: Failed to infer parameter type of some SAM, e.g. BinaryOperator




> Failed to infer parameter type of some SAM, e.g. BinaryOperator
> ---
>
> Key: GROOVY-8917
> URL: https://issues.apache.org/jira/browse/GROOVY-8917
> Project: Groovy
>  Issue Type: Bug
>Reporter: Daniel Sun
>Assignee: Daniel Sun
>Priority: Major
>
> {code:java}
> import groovy.transform.CompileStatic
> import java.util.stream.Collectors
> import java.util.stream.Stream
> 
> @CompileStatic
> public class Test1 {
> public static void main(String[] args) {
> p();
> }
> 
> public static void p() {
> // If we do not explicitly declare the type of parameter, STC 
> fails
> assert 13 == [1, 2, 3].stream().reduce(7, (Integer r, Integer 
> e) -> r + e);
> }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] groovy pull request #837: GROOVY-8917: Failed to infer parameter type of som...

2018-12-10 Thread danielsun1106
GitHub user danielsun1106 opened a pull request:

https://github.com/apache/groovy/pull/837

GROOVY-8917: Failed to infer parameter type of some SAM, e.g. BinaryO…

…perator

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/danielsun1106/groovy refine-type-inference

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/groovy/pull/837.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #837


commit 3669f04205265b62e3a3f339aa1b81fbf3003ecb
Author: danielsun1106 
Date:   2018-12-10T19:06:29Z

GROOVY-8917: Failed to infer parameter type of some SAM, e.g. BinaryOperator




---


[jira] [Commented] (GROOVY-8913) Parrot Parser: partially-parenthesized binary expression parsed as cast and unary plus

2018-12-10 Thread Daniel Sun (JIRA)


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

Daniel Sun commented on GROOVY-8913:


FYI, https://github.com/tunnelvisionlabs/antlr4/issues/37


> Parrot Parser: partially-parenthesized binary expression parsed as cast and 
> unary plus
> --
>
> Key: GROOVY-8913
> URL: https://issues.apache.org/jira/browse/GROOVY-8913
> Project: Groovy
>  Issue Type: Bug
>  Components: parser-antlr4
>Affects Versions: 2.6.0-alpha-4
>Reporter: Eric Milles
>Assignee: Daniel Sun
>Priority: Major
>
> Groovy 2.6 (and possibly/probably 3.0) is parsing this expression differently 
> from 2.5:
> {code:groovy}
> def x = (a.b) + c()
> {code}
> In Groovy 2.5, this is a DeclarationExpression with a VariableExpression for 
> the left expression and a BinaryExpression (with PLUS operator) for the right 
> expression.  Parrot Parser is seeing the right expression as a CastExpression 
> with a UnaryPlusExpression.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8917) Failed to infer parameter type of some SAM, e.g. BinaryOperator

2018-12-10 Thread Daniel Sun (JIRA)
Daniel Sun created GROOVY-8917:
--

 Summary: Failed to infer parameter type of some SAM, e.g. 
BinaryOperator
 Key: GROOVY-8917
 URL: https://issues.apache.org/jira/browse/GROOVY-8917
 Project: Groovy
  Issue Type: Bug
Reporter: Daniel Sun
Assignee: Daniel Sun




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

@CompileStatic
public class Test1 {
public static void main(String[] args) {
p();
}

public static void p() {
// If we do not explicitly declare the type of parameter, STC 
fails
assert 13 == [1, 2, 3].stream().reduce(7, (Integer r, Integer 
e) -> r + e);
}
}
{code}




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (GROOVY-8916) JsonOutput unable to serialize Locale object

2018-12-10 Thread JIRA
Sébastien Gadot created GROOVY-8916:
---

 Summary: JsonOutput unable to serialize Locale object
 Key: GROOVY-8916
 URL: https://issues.apache.org/jira/browse/GROOVY-8916
 Project: Groovy
  Issue Type: Bug
  Components: groovy-runtime
Affects Versions: 2.4.15
Reporter: Sébastien Gadot


Trying to serialize an object containing a Locale throws StackOverflowException

example :

 

 
{code:java}
JsonOutput.toJson([loc: Locale.FRANCE])
// expected {"loc": "fr_FR"}
// got StackOverflowException

{code}
{code:java}
java.lang.StackOverflowError
at 
java.lang.reflect.InvocationTargetException.(InvocationTargetException.java:72)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:59)
at groovy.lang.PropertyValue.getValue(PropertyValue.java:42)
at 
org.codehaus.groovy.runtime.DefaultGroovyMethods.getProperties(DefaultGroovyMethods.java:474)
at groovy.json.JsonOutput.getObjectProperties(JsonOutput.java:338)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:331)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:469)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:332)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:469)
{code}
 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)