groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Bowman (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7829) the split method on string produces an unexpected data type "[Ljava.lang.String;"
Date Thu, 28 Apr 2016 16:06:13 GMT

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

Andrew Bowman commented on GROOVY-7829:
---------------------------------------

Ah.  I see that now.  Apologies for the wasted time.  Thank you, John.  



> the split method on string produces an unexpected data type "[Ljava.lang.String;"
> ---------------------------------------------------------------------------------
>
>                 Key: GROOVY-7829
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7829
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.5
>         Environment: JVM: 1.8.0_20
>            Reporter: Andrew Bowman
>            Priority: Minor
>
> {code}
> def x = '123'
> def no = x.split('')
> def yes = x.collect{it}
> assert yes == ['1','2','3']
> assert no  == ['1','2','3']
> assert yes == no
> println yes.getClass()
> println no.getClass()
> println yes.remove('1')
> println no.remove('1')
> class java.util.ArrayList
> class [Ljava.lang.String;
> true
> Exception thrown
> groovy.lang.MissingMethodException: No signature of method: [Ljava.lang.String;.remove()
is applicable for argument types: (java.lang.String) values: [1]
> Possible solutions: reverse(), reverse(boolean), join(java.lang.String), getAt(java.lang.String)
> 	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
> 	at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:49)
> 	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
> 	at ConsoleScript118.run(ConsoleScript118:71)
> 	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
> 	at groovy.lang.GroovyShell.run(GroovyShell.java:524)
> 	at groovy.lang.GroovyShell.run(GroovyShell.java:503)
> 	at groovy.lang.GroovyShell.run(GroovyShell.java:170)
> 	at groovy.lang.GroovyShell$run$1.call(Unknown Source)
> 	at groovy.ui.Console$_runScriptImpl_closure17.doCall(Console.groovy:989)
> 	at groovy.ui.Console$_runScriptImpl_closure17.doCall(Console.groovy)
> 	at sun.reflect.GeneratedMethodAccessor746.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:483)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message