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

Javier MV commented on GROOVY-7494:
-----------------------------------

Still a problem in groovy-3.0.6-indy with java 11 and Ubuntu 18.04

> ArrayStoreException assigning GStringImpl to String[] when using Indy
> ---------------------------------------------------------------------
>
>                 Key: GROOVY-7494
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7494
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.3
>         Environment: Windows 7; Java 8
>            Reporter: Ken Scoggins
>            Priority: Major
>              Labels: indy
>
> While upgrading a software baseline from Java 7/Groovy 2.0.2 to Java 8/Groovy 
> 2.4, it appears that assigning a GString with an embedded variable reference 
> to a String array is broken when using Indy. The following example 
> demonstrates this issue:
> {code}
> int a = 1
> String[] fubar = new String[1]
> fubar[0] = "Item $a"
> println fubar
> {code}
> Without Indy, it works just fine:
> {panel}
> /c/test$ groovy GroovyIndyBug.groovy
> [Item 1]
> {panel}
> With Indy, we get the ArrayStoreException
> {panel}
> /c/test$ groovy -indy GroovyIndyBug.groovy
> Caught: java.lang.ArrayStoreException: org.codehaus.groovy.runtime.GStringImpl
> java.lang.ArrayStoreException: org.codehaus.groovy.runtime.GStringImpl
>         at GroovyIndyBug.run(GroovyIndyBug.groovy:3)
> {panel}
> I tried various other assignment methods and this appears to be the only one 
> with the issue.  Oddly, even doing the same assignment, but at creation time 
> instead of after, works just fine.  Some of the other related scenarios I 
> tried are:
> {code}
> int a = 1
> String[] foo = ["Assigned At Creation $a"]
> println foo
> foo[0] = "No Embedded Variable"
> println foo
> foo[0] = "as String $a" as String
> println foo
> foo[0] = "BROKEN $a"
> println foo
> {code}
> With Indy:
> {panel}
> /c/test $ groovy -indy GroovyIndyBug.groovy
> [Assigned At Creation 1]
> [No Embedded Variable]
> [as String 1]
> Caught: java.lang.ArrayStoreException: org.codehaus.groovy.runtime.GStringImpl
> java.lang.ArrayStoreException: org.codehaus.groovy.runtime.GStringImpl
>         at GroovyIndyBug.run(GroovyIndyBug.groovy:12){panel}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to