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

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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 4.0.0-beta-1
    • bytecode
    • 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

              emilles Eric Milles
              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