Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7040592

Gen.java: fix code for handling 'null' literal when expected type is array

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7
    • Fix Version/s: 9
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b59
    • CPU:
      unknown
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        In Gen.visitLiteral, a null literal is treated as an array if the dimension of the expected array is 1. Moving forward, it would be nice to update the code in Gen so that either:

        *) we always generate a cast from null to expected type (regardless of dimension)

        *) we never generate a cast from null to XYZ (regardless of dimension of XYZ); this seems to be the way in which other compilers handle similar situations

        If we go for the first solution, the patch for 7040104 can go away; if we go for the latter, the same patch has to be modified, so that the element type of 'null' is 'null' (so that you can perform multiple array selections).

        The code in question is:

         if (types.dimensions(pt) > 1) {
                        code.emitop2(checkcast, makeRef(tree.pos(), pt));
                        result = items.makeStackItem(pt);
                    } else {
                        result = items.makeStackItem(tree.type);
                    }

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                sadayapalam Srikanth Adayapalam
                Reporter:
                mcimadamore Maurizio Cimadamore
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: