Groovy
  1. Groovy
  2. GROOVY-5210

Problem converting primitive array to a Set

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.4
    • Fix Version/s: 1.8.5, 2.0-beta-2, 1.7.11
    • Component/s: None
    • Labels:
      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)
      

        Activity

        Jeff Brown created issue -
        Cédric Champeau made changes -
        Field Original Value New Value
        Assignee Cedric Champeau [ melix ]
        Cédric Champeau made changes -
        Fix Version/s 1.7.11 [ 17244 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 2.0-beta-2 [ 18072 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.8.5 [ 18071 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12734133 ] Default workflow, editable Closed status [ 12745939 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12973751 ] Default workflow, editable Closed status [ 12980841 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        7h 58m 1 Cédric Champeau 23/Dec/11 02:18
        Resolved Resolved Closed Closed
        1d 49m 1 Paul King 24/Dec/11 03:08

          People

          • Assignee:
            Cédric Champeau
            Reporter:
            Jeff Brown
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development