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

Unexpected Array conversion on variable assignement

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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[]);
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: