Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2527

Unexpected Array conversion on variable assignement

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.1
    • 1.6-rc-2
    • bytecode
    • 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[]);
      

      Attachments

        Activity

          People

            paulk Paul King
            devijvers Steven Devijver
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: