Details
Description
Repro:
Compile and run the following:
class Test
{
String string
URI[] uris
public Test(String string, URI[] uris)
{
this.string = string
this.uris = uris
}
public Test(String string, List uris)
{
this(string, uris.collect { new URI(it) } as URI[])
}
public static void main(String[] args)
{
def test = new Test('hello', ["world"])
println test.string
println test.strings
}
}
Observed Result:
$ groovyc Test.groovy $ groovy Test Caught: java.lang.VerifyError: (class: Test, method: <init> signature: (Ljava/lang/String;Ljava/util/List;)V) Expecting to find object/array on stack
Expected Result:
hello [world]
Sorry, it should be "println test.uris" at the end of the main method, and the expected result is
hello {world}A work-around is to refactor out
uris.collect { new URI(it) } as URI[]as a method and call it:
this(string, toUriArray(uris))