[jira] [Closed] (GROOVY-8356) Use javax.validation 2.0 API results in GroovyBugError

2017-10-18 Thread Graeme Rocher (JIRA)

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

Graeme Rocher closed GROOVY-8356.
-
   Resolution: Fixed
Fix Version/s: 2.5.0-beta-2

Actually this is fixed in beta 2, sorry for the hassle

> Use javax.validation 2.0 API results in GroovyBugError
> --
>
> Key: GROOVY-8356
> URL: https://issues.apache.org/jira/browse/GROOVY-8356
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.12, 2.5.0-beta-2
>Reporter: Graeme Rocher
> Fix For: 2.5.0-beta-2
>
>
> If you use the javax.validation 2.0 API using certain annotations results in:
> {code}
> BUG! exception in phase 'class generation' in source unit 
> '.../validation/ValidatedSpec.groovy' unsupported Target TYPE_USE
> {code}
> Example code:
> {code}
> class Foo {
> String testMe(@Pattern(regexp = "\\d+") String number) {
> return number
> }
> }
> {code}
> Seems 
> https://github.com/apache/groovy/blob/GROOVY_2_5_X/src/main/org/codehaus/groovy/vmplugin/v5/Java5.java#L327
>  needs updating for Java 8 `TYPE_USE`



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


[jira] [Commented] (GROOVY-8355) Instanceof inference does not work on field assigning

2017-10-18 Thread Daniil Ovchinnikov (JIRA)

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

Daniil Ovchinnikov commented on GROOVY-8355:


It turns out that in the example above the user should write:
{code}
str = "str"
if (str instanceof String) {
  str.toUppercase()
}
{code}

> Instanceof inference does not work on field assigning
> -
>
> Key: GROOVY-8355
> URL: https://issues.apache.org/jira/browse/GROOVY-8355
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Reporter: Alexey Afanasiev
>
> If instanceof inference works as expected 
> [https://issues.apache.org/jira/browse/GROOVY-8293] So probably this code 
> should work to:
> {code}
> import groovy.transform.CompileStatic
> @CompileStatic
> class Foo {
> Object str = new Object()
> def bar() {
> str = "str"
> str.toUpperCase() // here compile error
> }
> }
> {code}



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


[jira] [Commented] (GROOVY-8355) Instanceof inference does not work on field assigning

2017-10-18 Thread Daniil Ovchinnikov (JIRA)

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

Daniil Ovchinnikov commented on GROOVY-8355:


I think that {{str = "str"}} is more _telling the compiler that the type is a 
String_ than {{if (str instanceof String) {}}.


> Instanceof inference does not work on field assigning
> -
>
> Key: GROOVY-8355
> URL: https://issues.apache.org/jira/browse/GROOVY-8355
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Reporter: Alexey Afanasiev
>
> If instanceof inference works as expected 
> [https://issues.apache.org/jira/browse/GROOVY-8293] So probably this code 
> should work to:
> {code}
> import groovy.transform.CompileStatic
> @CompileStatic
> class Foo {
> Object str = new Object()
> def bar() {
> str = "str"
> str.toUpperCase() // here compile error
> }
> }
> {code}



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


[jira] [Reopened] (GROOVY-7772) Class. had better to have same meaning of Class::instanceMethod of Java8

2017-10-18 Thread Paul King (JIRA)

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

Paul King reopened GROOVY-7772:
---

I'll temporarily re-open this until we understand current status a bit better. 
My goal will be to close again once we have created a new issue probably to 
document the current status.

> Class. had better to have same meaning of 
> Class::instanceMethod of Java8
> ---
>
> Key: GROOVY-7772
> URL: https://issues.apache.org/jira/browse/GROOVY-7772
> Project: Groovy
>  Issue Type: Improvement
>  Components: groovy-runtime
>Affects Versions: 2.4.6
>Reporter: UEHARA Junji
>Assignee: Daniel Sun
>Priority: Minor
> Fix For: 2.6.0-alpha-1
>
>
> Groovy's operator .& for method is similar functionality to Java8's method 
> reference operator ::.
> ||No.||lhs||rhs||meaing of Groovy's .& (Closure) ||meaning of java8's :: 
> (FunctionalInterface)||
> |1|instance|instanceMethod| { ..args -> instance.instanceMethod(args) | same 
> as groovy |
> |2|Class|staticMethod| { ..args -> Class.staticMethod(args) | same as groovy |
> |3|instance|staticMethod| ERROR groovy.lang.MissingMethodException: | Error 
> same as groovy (compile error) |
> |4|Class|instanceMethod|error| Function, where method 
> instance method of Class which is declared as ```RetType 
> instanceMethod(Args..) {...}```. In other words it is interpreted as a 
> function which takes LHS Class as the first parameter which additionally 
> inserted to the method.)|
> IMHO, i'd like to propose to change the No 4 pattern semantics of groovy  
> same as Java 8 's. Because:
>  * You can write:
> {code}
> ["a,b,c"].collect ( String. )
> {code}
> instaed of
> {code}
> ["a,b,c"].collect { it.toUpperCase() }
> {code}
> * Can have correspond operator to java8's ::. which is understandablea and 
> needed for Java programmers.



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


[jira] [Commented] (GROOVY-8355) Instanceof inference does not work on field assigning

2017-10-18 Thread Alexey Afanasiev (JIRA)

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

Alexey Afanasiev commented on GROOVY-8355:
--

So the only difference is in instanceof we trust user and in assignment we 
don't. I can't argue with developer expectations in both cases, because i don't 
really know them. But i suppose developers should understand, assignment is 
much stronger instruction than instanceof check.

> Instanceof inference does not work on field assigning
> -
>
> Key: GROOVY-8355
> URL: https://issues.apache.org/jira/browse/GROOVY-8355
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Reporter: Alexey Afanasiev
>
> If instanceof inference works as expected 
> [https://issues.apache.org/jira/browse/GROOVY-8293] So probably this code 
> should work to:
> {code}
> import groovy.transform.CompileStatic
> @CompileStatic
> class Foo {
> Object str = new Object()
> def bar() {
> str = "str"
> str.toUpperCase() // here compile error
> }
> }
> {code}



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


[jira] [Created] (GROOVY-8357) EncodingGroovyMethods.decodeBase64() throws "bad character in base64 value" when meets \t \r

2017-10-18 Thread Xin (JIRA)
Xin created GROOVY-8357:
---

 Summary: EncodingGroovyMethods.decodeBase64() throws "bad 
character in base64 value" when meets \t \r
 Key: GROOVY-8357
 URL: https://issues.apache.org/jira/browse/GROOVY-8357
 Project: Groovy
  Issue Type: Bug
  Components: groovy-runtime
Reporter: Xin


EncodingGroovyMethods.decodeBase64() throws "bad character in base64 value" 
RuntimeException when the method meets \t \r character.
I found in 
org.codehaus.groovy.runtime.EncodingGroovyMethodsSupport.TRANSLATE_TABLE has a 
mistake:
static final byte[] TRANSLATE_TABLE = (
"\u0042\u0042\u0042\u0042\u0042\u0042\u0042\u0042"
//{color:red}\t{color}
{color:yellow}\n{color}{color:blue}\r{color}
+ 
"\u0042{color:red}\u0042{color}{color:yellow}\u0041{color}\u0041\u0042{color:blue}\u0042{color}\u0041\u0042"
...
I mark them in color.
I believe it's an offset mistake.



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


[jira] [Commented] (GROOVY-8355) Instanceof inference does not work on field assigning

2017-10-18 Thread JIRA

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

Cédric Champeau commented on GROOVY-8355:
-

This works as expected. You cannot compare the two situations as they are very 
different. In one case, there's an explicit intent, expressed by an 
`instanceof` check. We are _trusting_ the user here. It's a big difference 
between inferring and trusting. If the user says "believe me, here it's a 
String", and "I am inferring that this is a String". If the user is wrong, 
there's going to be a runtime error, but we shouldn't prevent them from doing 
what they think is right. It's not different from plain Java.

> Instanceof inference does not work on field assigning
> -
>
> Key: GROOVY-8355
> URL: https://issues.apache.org/jira/browse/GROOVY-8355
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Reporter: Alexey Afanasiev
>
> If instanceof inference works as expected 
> [https://issues.apache.org/jira/browse/GROOVY-8293] So probably this code 
> should work to:
> {code}
> import groovy.transform.CompileStatic
> @CompileStatic
> class Foo {
> Object str = new Object()
> def bar() {
> str = "str"
> str.toUpperCase() // here compile error
> }
> }
> {code}



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


[jira] [Commented] (GROOVY-8355) Instanceof inference does not work on field assigning

2017-10-18 Thread Alexey Afanasiev (JIRA)

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

Alexey Afanasiev commented on GROOVY-8355:
--

[~shils] Exactly. Could you read  
https://issues.apache.org/jira/browse/GROOVY-8293 this issue conversation ?

> Instanceof inference does not work on field assigning
> -
>
> Key: GROOVY-8355
> URL: https://issues.apache.org/jira/browse/GROOVY-8355
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Reporter: Alexey Afanasiev
>
> If instanceof inference works as expected 
> [https://issues.apache.org/jira/browse/GROOVY-8293] So probably this code 
> should work to:
> {code}
> import groovy.transform.CompileStatic
> @CompileStatic
> class Foo {
> Object str = new Object()
> def bar() {
> str = "str"
> str.toUpperCase() // here compile error
> }
> }
> {code}



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