Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8.4
-
None
-
None
Description
When I try to convert a primitive array to java.util.Set using the "as" operator, it looks like Groovy tries to create an instance of java.util.Set (as opposed to creating an instance of some class which implements java.util.Set).
demo.groovy
def intArray = [1, 2, 3] as int[]
def setOfInt = intArray as Set
println setOfInt
conversion_problem $ groovy -version Groovy Version: 1.8.4 JVM: 1.6.0_29 conversion_problem $ groovy demo.groovy Caught: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Could not instantiate instance of: java.util.Set. Reason: java.lang.InstantiationException: java.util.Set org.codehaus.groovy.runtime.typehandling.GroovyCastException: Could not instantiate instance of: java.util.Set. Reason: java.lang.InstantiationException: java.util.Set at demo.run(demo.groovy:2)