Groovy
  1. Groovy
  2. GROOVY-2527

Unexpected Array conversion on variable assignement

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.1
    • Fix Version/s: 1.6-rc-2
    • Component/s: bytecode
    • Labels:
      None

      Description

      This is how Groovy 1.5.1 deals with array assignments:

      String[] _abc = [ "A", "B", "C" ] as String[]
      
      assert _abc instanceof String[] == true
      assert _abc instanceof Object[] == true
      
      Object[] _xyz = _abc
      
      assert _xyz instanceof Object[] == true
      assert _xyz instanceof String[] == false
      

      And this is Java:

      String[] abc = new String[] { "a", "b", "c" };
      
      assertTrue(abc instanceof String[]);
      assertTrue(abc instanceof Object[]);
      
      Object[] xyz = abc;
      
      assertTrue(xyz instanceof String[]);
      assertTrue(xyz instanceof Object[]);
      

        Activity

        Steven Devijver created issue -
        Hide
        Paul King added a comment -

        add code tags

        Show
        Paul King added a comment - add code tags
        Paul King made changes -
        Field Original Value New Value
        Description This is how Groovy 1.5.1 deals with array assignments:

        String[] _abc = [ "A", "B", "C" ] as String[]

        assert _abc instanceof String[] == true
        assert _abc instanceof Object[] == true

        Object[] _xyz = _abc

        assert _xyz instanceof Object[] == true
        assert _xyz instanceof String[] == false

        And this is Java:

        String[] abc = new String[] { "a", "b", "c" };

        assertTrue(abc instanceof String[]);
        assertTrue(abc instanceof Object[]);

        Object[] xyz = abc;

        assertTrue(xyz instanceof String[]);
        assertTrue(xyz instanceof Object[]);

        This is how Groovy 1.5.1 deals with array assignments:

        {code}
        String[] _abc = [ "A", "B", "C" ] as String[]

        assert _abc instanceof String[] == true
        assert _abc instanceof Object[] == true

        Object[] _xyz = _abc

        assert _xyz instanceof Object[] == true
        assert _xyz instanceof String[] == false
        {code}

        And this is Java:

        {code}
        String[] abc = new String[] { "a", "b", "c" };

        assertTrue(abc instanceof String[]);
        assertTrue(abc instanceof Object[]);

        Object[] xyz = abc;

        assertTrue(xyz instanceof String[]);
        assertTrue(xyz instanceof Object[]);
        {code}
        Hide
        Paul King added a comment -

        Fixed. Thanks for spotting this.

        Show
        Paul King added a comment - Fixed. Thanks for spotting this.
        Paul King made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Paul King [ paulk ]
        Resolution Fixed [ 1 ]
        Fix Version/s 1.6 [ 13832 ]
        Hide
        Paul King added a comment -

        close off release 1.5.4

        Show
        Paul King added a comment - close off release 1.5.4
        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 [ 12731577 ] Default workflow, editable Closed status [ 12743377 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12969576 ] Default workflow, editable Closed status [ 12977333 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        17h 50m 1 Paul King 22/Jan/08 04:46
        Resolved Resolved Closed Closed
        16d 20h 40m 1 Paul King 08/Feb/08 01:26

          People

          • Assignee:
            Paul King
            Reporter:
            Steven Devijver
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development