[GitHub] groovy pull request #566: Added IgnoreDefaultEqualsAndToString

2017-06-25 Thread pditommaso
GitHub user pditommaso opened a pull request:

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

Added IgnoreDefaultEqualsAndToString

This annotation allows custom `Collection` and `Map` objects to bypass the 
default Groovy format and equality methods ie. `toString` and `equals`.

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

$ git pull https://github.com/pditommaso/groovy 
ignore-default-groovy-methods

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

https://github.com/apache/groovy/pull/566.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 #566


commit 8a9f43b4c937c8bce8674f75d1fe7b9575b7c740
Author: Paolo Di Tommaso 
Date:   2017-06-25T18:26:18Z

Added @IgnoreDefaultEqualsAndToString annotation that allows by-pass  
Groovy equals and toString methods for Map and Collection objects




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Updated] (GROOVY-8220) GroovyCastException with CompileStatic

2017-06-25 Thread John Wagenleitner (JIRA)

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

John Wagenleitner updated GROOVY-8220:
--
Affects Version/s: 2.4.12

> GroovyCastException with CompileStatic
> --
>
> Key: GROOVY-8220
> URL: https://issues.apache.org/jira/browse/GROOVY-8220
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.0-beta-1, 2.4.12
>Reporter: paolo di tommaso
>
> {code}
> @groovy.transform.CompileStatic
> class Foo {
> CharSequence makeEnv( env, StringBuilder result = new StringBuilder() ) {
> if( env instanceof File ) {
> env = env.toPath()
> }
> if( env instanceof String && env.contains('=') ) {
> result << 'export ' << env << ';'
> }
> return result.toString()
> }
> }
> assert new Foo().makeEnv('X=1') == 'export X=1;'
> Exception thrown
> org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast 
> object 'X=1' with class 'java.lang.String' to class 'java.lang.Iterable'
>   at Foo.makeEnv(ConsoleScript5:10)
>   at Foo.makeEnv(ConsoleScript5:4)
>   at Foo$makeEnv.call(Unknown Source)
>   at ConsoleScript5.run(ConsoleScript5:20)
> {code}
> Without CompileStatic it works as expected. 



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


[jira] [Commented] (GROOVY-8220) GroovyCastException with CompileStatic

2017-06-25 Thread John Wagenleitner (JIRA)

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

John Wagenleitner commented on GROOVY-8220:
---

Fix for GROOVY-8157 seems to be the cause.

> GroovyCastException with CompileStatic
> --
>
> Key: GROOVY-8220
> URL: https://issues.apache.org/jira/browse/GROOVY-8220
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.0-beta-1
>Reporter: paolo di tommaso
>
> {code}
> @groovy.transform.CompileStatic
> class Foo {
> CharSequence makeEnv( env, StringBuilder result = new StringBuilder() ) {
> if( env instanceof File ) {
> env = env.toPath()
> }
> if( env instanceof String && env.contains('=') ) {
> result << 'export ' << env << ';'
> }
> return result.toString()
> }
> }
> assert new Foo().makeEnv('X=1') == 'export X=1;'
> Exception thrown
> org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast 
> object 'X=1' with class 'java.lang.String' to class 'java.lang.Iterable'
>   at Foo.makeEnv(ConsoleScript5:10)
>   at Foo.makeEnv(ConsoleScript5:4)
>   at Foo$makeEnv.call(Unknown Source)
>   at ConsoleScript5.run(ConsoleScript5:20)
> {code}
> Without CompileStatic it works as expected. 



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


[jira] [Commented] (GROOVY-8237) Invalid type inference when using CompileStatic annotation

2017-06-25 Thread John Wagenleitner (JIRA)

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

John Wagenleitner commented on GROOVY-8237:
---

I tested and it looks like the fix for GROOVY-8157 causes this.

> Invalid type inference when using CompileStatic annotation
> --
>
> Key: GROOVY-8237
> URL: https://issues.apache.org/jira/browse/GROOVY-8237
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.12
>Reporter: paolo di tommaso
>
> With Groovy 2.4.12 the following snippet report an error 
> {code}
> @groovy.transform.CompileStatic
> class Foo {
>   String parse(Reader reader) {
> if ( reader == null ) {
>   reader = new BufferedReader(reader)
> }
>  
> def c 
> while ((c = reader.read()) != -1) 
>print c as char
>   }
> }
> new Foo().parse( new StringReader('abc') )
> {code}
> The following exception is thrown 
> {code}
> org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast 
> object 'java.io.StringReader@7a636960' with class 'java.io.StringReader' to 
> class 'java.io.BufferedReader'
> {code}



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


[jira] [Commented] (GROOVY-8237) Invalid type inference when using CompileStatic annotation

2017-06-25 Thread paolo di tommaso (JIRA)

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

paolo di tommaso commented on GROOVY-8237:
--

It seems the same as https://issues.apache.org/jira/browse/GROOVY-8220

> Invalid type inference when using CompileStatic annotation
> --
>
> Key: GROOVY-8237
> URL: https://issues.apache.org/jira/browse/GROOVY-8237
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.12
>Reporter: paolo di tommaso
>
> With Groovy 2.4.12 the following snippet report an error 
> {code}
> @groovy.transform.CompileStatic
> class Foo {
>   String parse(Reader reader) {
> if ( reader == null ) {
>   reader = new BufferedReader(reader)
> }
>  
> def c 
> while ((c = reader.read()) != -1) 
>print c as char
>   }
> }
> new Foo().parse( new StringReader('abc') )
> {code}
> The following exception is thrown 
> {code}
> org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast 
> object 'java.io.StringReader@7a636960' with class 'java.io.StringReader' to 
> class 'java.io.BufferedReader'
> {code}



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


[jira] [Commented] (GROOVY-8197) Make JUnit3/4 GroovyRunners

2017-06-25 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on GROOVY-8197:


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

https://github.com/apache/groovy/pull/564#discussion_r123887454
  
--- Diff: 
subprojects/groovy-testng/src/test/groovy/org/codehaus/groovy/testng/TestNgRunnerTest.groovy
 ---
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.testng
--- End diff --

should we take this opportunity to also move to org.apache package along 
with the actual runner of course? It's basically an internal class but for BC 
I'd leave the current runner (just extending the org.apache one) as Deprecated 
in 2.5 and possibly removed in 2.6/master.


> Make JUnit3/4 GroovyRunners
> ---
>
> Key: GROOVY-8197
> URL: https://issues.apache.org/jira/browse/GROOVY-8197
> Project: Groovy
>  Issue Type: Brainstorming
>  Components: groovy-runtime
>Affects Versions: 2.5.0-alpha-1, 2.4.11
>Reporter: John Wagenleitner
>Priority: Minor
>
> Current {{GroovyShell}} currently has reflective methods to detect and run 
> JUnit3 and JUnit4 classes.  These methods might work god as {{GroovyRunner}} 
> classes and they could be added to the RUNNER_REGISTRY in {{GroovySystem}}.
> Runners should be able to be registered during class loading (like most other 
> things) rather than during Grape processing.



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


[GitHub] groovy pull request #564: GROOVY-8197: Make JUnit3/4 GroovyRunners

2017-06-25 Thread paulk-asert
Github user paulk-asert commented on a diff in the pull request:

https://github.com/apache/groovy/pull/564#discussion_r123887454
  
--- Diff: 
subprojects/groovy-testng/src/test/groovy/org/codehaus/groovy/testng/TestNgRunnerTest.groovy
 ---
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.testng
--- End diff --

should we take this opportunity to also move to org.apache package along 
with the actual runner of course? It's basically an internal class but for BC 
I'd leave the current runner (just extending the org.apache one) as Deprecated 
in 2.5 and possibly removed in 2.6/master.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (GROOVY-8236) Report more meaningful error for versions of Groovy not supporting @Repeatable

2017-06-25 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on GROOVY-8236:


GitHub user paulk-asert opened a pull request:

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

GROOVY-8236: Report more meaningful error for versions of Groovy not …

…supporting @Repeatable

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

$ git pull https://github.com/paulk-asert/groovy groovy8236

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

https://github.com/apache/groovy/pull/565.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 #565


commit b3a0e1634749dbd703f705795a767b71c11a7bec
Author: paulk 
Date:   2017-06-25T11:57:36Z

GROOVY-8236: Report more meaningful error for versions of Groovy not 
supporting @Repeatable




> Report more meaningful error for versions of Groovy not supporting @Repeatable
> --
>
> Key: GROOVY-8236
> URL: https://issues.apache.org/jira/browse/GROOVY-8236
> Project: Groovy
>  Issue Type: New Feature
> Environment: groovy 2.4.11
>Reporter: Dmitry Lukyanov
>
> I cloned the issue. As well as providing support for @Repeatable, we should 
> give a more meaningful error message for any streams of Groovy where we don't 
> support it. I'd guess supported (2.5.0), unsupported (2.4.x); but in any 
> case, this issue is to handle the unsupported case.
> Instead of:
> {noformat}
> java.lang.annotation.AnnotationFormatError ...
> {noformat}
> We could have something like:
> {noformat}
> Annotation @MyAnnotation has RUNTIME retention and 2 occurrences.
> Automatic repeated annotations are not allowed in this version of Groovy.
> Consider explicitly adding the @MyAnnotationArray collector annotation.
> {noformat}
>  original description -
> raised on stackoverflow: 
> https://stackoverflow.com/questions/44532632/is-the-repeatable-annotation-not-supported-by-groovy/44628119#44628119
> Problem: the following code in groovy 2.4.11 / java8
> {code}
>@MyAnnotation(value = "val1")
>@MyAnnotation(value = "val2")
>void annotatedMethod() { println("annotated method called") }
> {code}
> should be compiled to this:
> {code}
>@MyAnnotationArray({@MyAnnotation("val1"), @MyAnnotation("val2")})
>void annotatedMethod() { println("annotated method called") }
> {code}
> but actually compiled to this:
> {code}
>@MyAnnotation(value = "val1")
>@MyAnnotation(value = "val2")
>void annotatedMethod() { println("annotated method called") }
> {code}
> The full groovy script to reproduce problem is below.
> It throws exception: 
> {color:red}java.lang.annotation.AnnotationFormatError: Duplicate annotation 
> for class: interface MyAnnotation: @MyAnnotation(value=val2){color}
> at line `List annos = m.getAnnotations()`
> {code}
> import java.lang.annotation.*
> class MyClass 
> {
> @MyAnnotation(value = "val1")
> @MyAnnotation(value = "val2")
> //change annotation to next line and the code will work
> //@MyAnnotationArray( [@MyAnnotation("val1"), @MyAnnotation("val2")] )
> public void annotatedMethod()
> {
>   System.out.println("annotated method called");
> }
>public static void main(String... args)
>{
>   MyClass ob = new MyClass()
>   ob.annotatedMethod()
>   java.lang.reflect.Method m = ob.getClass().getMethod("annotatedMethod")
>   List annos = m.getAnnotations()
>   println("annos = $annos")
>}
> }
> @Target(ElementType.METHOD)
> @Retention(RetentionPolicy.RUNTIME)
> @Repeatable(MyAnnotationArray) 
> public @interface MyAnnotation
> {
> String value() default "val0";
> }
> @Retention(RetentionPolicy.RUNTIME)
> public @interface MyAnnotationArray 
> {
>MyAnnotation[] value()
> }
> {code}



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


[GitHub] groovy pull request #565: GROOVY-8236: Report more meaningful error for vers...

2017-06-25 Thread paulk-asert
GitHub user paulk-asert opened a pull request:

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

GROOVY-8236: Report more meaningful error for versions of Groovy not …

…supporting @Repeatable

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

$ git pull https://github.com/paulk-asert/groovy groovy8236

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

https://github.com/apache/groovy/pull/565.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 #565


commit b3a0e1634749dbd703f705795a767b71c11a7bec
Author: paulk 
Date:   2017-06-25T11:57:36Z

GROOVY-8236: Report more meaningful error for versions of Groovy not 
supporting @Repeatable




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Created] (GROOVY-8237) Invalid type inference when using CompileStatic annotation

2017-06-25 Thread paolo di tommaso (JIRA)
paolo di tommaso created GROOVY-8237:


 Summary: Invalid type inference when using CompileStatic annotation
 Key: GROOVY-8237
 URL: https://issues.apache.org/jira/browse/GROOVY-8237
 Project: Groovy
  Issue Type: Bug
Affects Versions: 2.4.12
Reporter: paolo di tommaso


With Groovy 2.4.12 the following snippet report an error 

{code}
@groovy.transform.CompileStatic
class Foo {

  String parse(Reader reader) {
if ( reader == null ) {
  reader = new BufferedReader(reader)
}
 
def c 
while ((c = reader.read()) != -1) 
   print c as char
  }
}

new Foo().parse( new StringReader('abc') )
{code}

The following exception is thrown 

{code}
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast 
object 'java.io.StringReader@7a636960' with class 'java.io.StringReader' to 
class 'java.io.BufferedReader'
{code}



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