[jira] [Created] (GROOVY-10407) unchecked method invocation warning in generated stubs

2021-12-07 Thread Joseph Price (Jira)
Joseph Price created GROOVY-10407:
-

 Summary:  unchecked method invocation warning in generated stubs 
 Key: GROOVY-10407
 URL: https://issues.apache.org/jira/browse/GROOVY-10407
 Project: Groovy
  Issue Type: Bug
  Components: Compiler
Affects Versions: 3.0.9
Reporter: Joseph Price


 

When calling a groovy class from java that takes a Map in the constructor, the 
generated stubs have what looks to be a second constructor that takes a null 
for the parameter, that casted to a raw Map. Since this happens in generated 
code not under my control, this prevents enabling -Werror across the project. 
Providing type arguments for the map or leaving the cast off would fix the 
warning, but I also wonder if suppressing the constructor is possible.

Below are the commands I ran, along with the contents of the java and groovy 
files:
{code:java}
groovyc -j  -FWerror -FXlint:unchecked Test.java Base.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Compile error during compilation with javac.
/var/folders/mm/8s324dkd6sb1ktx0g48pbvhcgq/T/groovy-generated--java-source3303303787390544788/Base.java:13:
 warning: [unchecked] unchecked method invocation: constructor  in class 
Parent is applied to given types
super ((java.util.Map)null);
      ^
  required: Map
  found: Map
/var/folders/mm/8s324dkd6sb1ktx0g48pbvhcgq/T/groovy-generated--java-source3303303787390544788/Base.java:13:
 warning: [unchecked] unchecked conversion
super ((java.util.Map)null);
       ^
  required: Map
  found:    Map
error: warnings found and -Werror specified
1 error
2 warnings                                                                      
{code}
 
{code:java}
cat -p Base.groovy

class Parent {
  Parent(Map map) {
  }
}

class Base extends Parent {
  Base(Map map) {
    super(map);
  }
}                                                                               

cat -p Test.java

import java.util.Map;
class Test {
  Base b = new Base(Map.of());
} {code}
 

 

 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Resolved] (GROOVY-6653) StackOverflow Exception when calling super.method when extending java class

2021-12-07 Thread Eric Milles (Jira)


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

Eric Milles resolved GROOVY-6653.
-
Fix Version/s: 4.0.0-rc-2
   Resolution: Fixed

https://github.com/apache/groovy/commit/19ade45010b92ae959d3b06909e99e93d6d07e53

> StackOverflow Exception when calling super.method when extending java class
> ---
>
> Key: GROOVY-6653
> URL: https://issues.apache.org/jira/browse/GROOVY-6653
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.2.1
>Reporter: Aleh Bich
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-rc-2
>
> Attachments: erroroutput.txt
>
>
> You can get StackOverflowError when running following code:
> {code:title=A.java}
> package test.java;
> public abstract class A {
> protected String getText(T arg){
> return "Class A.";
> }
> }
> {code}
> {code:title=C.java}
> package test.java;
> public class C extends A {
> @Override
> protected String getText(String arg){
> return super.getText(arg) + "Class C. ";
> }
> }
> {code}
> {code:title=D.groovy}
> package test.java
> class D extends C {
> @Override
> protected String getText(String arg) {
> return super.getText(arg) + 'Class D.';
> }
> public static void main(String[] args) {
> D d = new D();
> String res = d.getText(null);
> println(res);
> }
> }
> {code}
> This bug occurs when class A is generic and method has parameterized argument.
> {code:title=Output}
> Exception in thread "main" java.lang.StackOverflowError
>   at test.java.D.getText(D.groovy)
>   at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
>   at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.lang.reflect.Method.invoke(Method.java:601)
>   at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
>   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
>   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1085)
>   at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:128)
>   at test.java.D.getText(D.groovy:6)
>   at test.java.D.getText(D.groovy)
> {code}
> This bug looks similar to GROOVY-5385



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (GROOVY-10405) @AutoClone breaks in Java17 for File properties

2021-12-07 Thread Paul King (Jira)


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

Paul King commented on GROOVY-10405:


FYI, this is fixed on 4.0.0-rc-1.

> @AutoClone breaks in Java17 for File properties
> ---
>
> Key: GROOVY-10405
> URL: https://issues.apache.org/jira/browse/GROOVY-10405
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.9
> Environment: Java11 vs Java17
> Windows10, Ubuntu
>Reporter: Aleks Tamarkin
>Priority: Major
>
> The following code works on Java11 but breaks on Java17
>  
> {code:java}
> import groovy.transform.AutoClone
> @AutoClone
> class Foo {
>     File file
>     String string
> }
> def foo = new Foo(file: new File('bar'), string: 'qux')
> foo.clone()
> {code}
> The error is
> {code:java}
> groovy.lang.MissingMethodException: No signature of method: 
> java.lang.Object.clone() is applicable for argument types: () values: []
> Possible solutions: collect(), collect(groovy.lang.Closure), 
> collect(java.util.Collection, groovy.lang.Closure), find(), any(), 
> use([Ljava.lang.Object;){code}
> This can be reproduced in GroovyConsole



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Updated] (GROOVY-10406) Dollar slashy string is too greedy

2021-12-07 Thread Paul King (Jira)


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

Paul King updated GROOVY-10406:
---
Affects Version/s: 4.0.0-rc-1

> Dollar slashy string is too greedy
> --
>
> Key: GROOVY-10406
> URL: https://issues.apache.org/jira/browse/GROOVY-10406
> Project: Groovy
>  Issue Type: Bug
>  Components: lexer
>Affects Versions: 3.0.9, 4.0.0-rc-1
>Reporter: Daniil Ovchinnikov
>Priority: Major
> Attachments: screenshot-1.png
>
>
> This code compiles fine in 2.5.14, but fails to compile in 3.0.9.
> {code:groovy}
> println([$/$$/$ : /$$/])
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Updated] (GROOVY-10406) Dollar slashy string is too greedy

2021-12-07 Thread Paul King (Jira)


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

Paul King updated GROOVY-10406:
---
Attachment: screenshot-1.png

> Dollar slashy string is too greedy
> --
>
> Key: GROOVY-10406
> URL: https://issues.apache.org/jira/browse/GROOVY-10406
> Project: Groovy
>  Issue Type: Bug
>  Components: lexer
>Affects Versions: 3.0.9
>Reporter: Daniil Ovchinnikov
>Priority: Major
> Attachments: screenshot-1.png
>
>
> This code compiles fine in 2.5.14, but fails to compile in 3.0.9.
> {code:groovy}
> println([$/$$/$ : /$$/])
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (GROOVY-10406) Dollar slashy string is too greedy

2021-12-07 Thread Paul King (Jira)


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

Paul King commented on GROOVY-10406:


Another example:
{code:java}
assert ($/$$/$ + 'x' + /$$/) == '$x$$'   // Unexpected input: '$/) == '$' at 
line: 1, column: 26
{code}
And the CST:
 !screenshot-1.png! 

> Dollar slashy string is too greedy
> --
>
> Key: GROOVY-10406
> URL: https://issues.apache.org/jira/browse/GROOVY-10406
> Project: Groovy
>  Issue Type: Bug
>  Components: lexer
>Affects Versions: 3.0.9
>Reporter: Daniil Ovchinnikov
>Priority: Major
> Attachments: screenshot-1.png
>
>
> This code compiles fine in 2.5.14, but fails to compile in 3.0.9.
> {code:groovy}
> println([$/$$/$ : /$$/])
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Created] (GROOVY-10406) Dollar slashy string is too greedy

2021-12-07 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-10406:
---

 Summary: Dollar slashy string is too greedy
 Key: GROOVY-10406
 URL: https://issues.apache.org/jira/browse/GROOVY-10406
 Project: Groovy
  Issue Type: Bug
  Components: lexer
Affects Versions: 3.0.9
Reporter: Daniil Ovchinnikov


This code compiles fine in 2.5.14, but fails to compile in 3.0.9.

{code:groovy}
println([$/$$/$ : /$$/])
{code}




--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[GitHub] [groovy] eric-milles opened a new pull request #1662: GROOVY-9391: Cannot cast or coerce `super`

2021-12-07 Thread GitBox


eric-milles opened a new pull request #1662:
URL: https://github.com/apache/groovy/pull/1662


   https://issues.apache.org/jira/browse/GROOVY-9391


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@groovy.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] eric-milles edited a comment on pull request #1661: GROOVY-10278, GROOVY-10281: refactor `CompilerConfiguration` somewhat

2021-12-07 Thread GitBox


eric-milles edited a comment on pull request #1661:
URL: https://github.com/apache/groovy/pull/1661#issuecomment-987998605


   Such as what?  If you gave some examples, I might be able to provide 
reasoning.  The purpose of the draft was to discuss these items rather than 
just be dismissive.
   
   What is the concern with leveraging `TraceClassVisitor` which is provided 
instead of maintaining `LoggableClassVisitor` which tries to do the same job 
and I've found many problems with the flushing and the multiple instance 
creation?
   
   If you are referencing the replacement of `isPostJDK5()`, then my raised 
concerns earlier are that "is post" is not the correct semantic.  It is really 
"is at least" and the use if `isAtLeast(targetBytecode,JDK5)` is conveys that 
semantic and does not require a new public API method for every Java release, 
which are coming every 6 months now, not every few years.  Again, this is 
demonstrated for discussion purposes.  It is not a must have.
   
   I disagree with lifting one-time use values up to the top of a class file.  
I disagree with adding public API for something that *might* be useful but has 
no track record of need.  These are specific examples that can foster further 
discussion.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@groovy.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] eric-milles commented on pull request #1661: GROOVY-10278, GROOVY-10281: refactor `CompilerConfiguration` somewhat

2021-12-07 Thread GitBox


eric-milles commented on pull request #1661:
URL: https://github.com/apache/groovy/pull/1661#issuecomment-988005664


   Now if the new methods added were `isAtLeastJDK9` and so on and 
`isPostJDK5`, etc. were removed or scheduled for removal, then my only concern 
would be the need to add a new method every six months.  That kind of work 
should be automated IMO.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@groovy.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] eric-milles edited a comment on pull request #1661: GROOVY-10278, GROOVY-10281: refactor `CompilerConfiguration` somewhat

2021-12-07 Thread GitBox


eric-milles edited a comment on pull request #1661:
URL: https://github.com/apache/groovy/pull/1661#issuecomment-987998605


   Such as what?  If you gave some examples, I might be able to provide 
reasoning.  The purpose of the draft was to discuss these items rather than 
just be dismissive.
   
   If you are referencing the replacement of `isPostJDK5()`, then my raised 
concerns earlier are that "is post" is not the correct semantic.  It is really 
"is at least" and the use if `isAtLeast(targetBytecode,JDK5)` is conveys that 
semantic and does not require a new public API method for every Java release, 
which are coming every 6 months now, not every few years.  Again, this is 
demonstrated for discussion purposes.  It is not a must have.
   
   I disagree with lifting one-time use values up to the top of a class file.  
I disagree with adding public API for something that *might* be useful but has 
no track record of need.  These are specific examples that can foster further 
discussion.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@groovy.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[jira] [Created] (GROOVY-10405) @AutoClone breaks in Java17 for File properties

2021-12-07 Thread Aleks Tamarkin (Jira)
Aleks Tamarkin created GROOVY-10405:
---

 Summary: @AutoClone breaks in Java17 for File properties
 Key: GROOVY-10405
 URL: https://issues.apache.org/jira/browse/GROOVY-10405
 Project: Groovy
  Issue Type: Bug
Affects Versions: 3.0.9
 Environment: Java11 vs Java17
Windows10, Ubuntu
Reporter: Aleks Tamarkin


The following code works on Java11 but breaks on Java17



 
{code:java}
import groovy.transform.AutoClone
@AutoClone
class Foo {
    File file
    String string
}
def foo = new Foo(file: new File('bar'), string: 'qux')
foo.clone()
{code}

The error is
{code:java}
groovy.lang.MissingMethodException: No signature of method: 
java.lang.Object.clone() is applicable for argument types: () values: []
Possible solutions: collect(), collect(groovy.lang.Closure), 
collect(java.util.Collection, groovy.lang.Closure), find(), any(), 
use([Ljava.lang.Object;){code}

This can be reproduced in GroovyConsole



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[GitHub] [groovy] eric-milles commented on pull request #1661: GROOVY-10278, GROOVY-10281: refactor `CompilerConfiguration` somewhat

2021-12-07 Thread GitBox


eric-milles commented on pull request #1661:
URL: https://github.com/apache/groovy/pull/1661#issuecomment-987998605


   Such as what?  If you gave some examples, I might be able to provide 
reasoning.  The purpose of the draft was to discuss these items rather than 
just be dismissive.
   
   I disagree with lifting one-time use values up to the top of a class file.  
I disagree with adding public API for something that *might* be useful but has 
no track record of need.  These are specific examples that can foster further 
discussion.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@groovy.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org