groovy
  1. groovy
  2. GROOVY-2527

Unexpected Array conversion on variable assignement

    Details

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

      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

        Hide
        Paul King added a comment -

        add code tags

        Show
        Paul King added a comment - add code tags
        Hide
        Paul King added a comment -

        Fixed. Thanks for spotting this.

        Show
        Paul King added a comment - Fixed. Thanks for spotting this.
        Hide
        Paul King added a comment -

        close off release 1.5.4

        Show
        Paul King added a comment - close off release 1.5.4

          People

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

            Dates

            • Created:
              Updated:
              Resolved: