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

Compiler writes extra cast for Type[] to Object[]

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0.0-beta-1
    • Component/s: bytecode
    • Labels:
      None

      Description

      Consider the following:

      ['x'].toArray(new String[0])
      

      This produces a bytecode sequence that includes a cast from String[] to Object[]. javac for the same code omits the cast.

           9  iconst_0
          10  multianewarray java.lang.String[] [44]
          14  invokedynamic 0 cast(java.lang.String[]) : java.lang.Object[] [58]
          19  invokeinterface java.util.Collection.toArray(java.lang.Object[]) : java.lang.Object[] [64] [nargs: 2]
      

      Note: multianewarray vs anewarray was fixed by GROOVY-10031

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                emilles Eric Milles
                Reporter:
                emilles Eric Milles
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1.5h
                  1.5h