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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 7
    • tools
    • b59
    • unknown
    • generic
    • Verified

        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);
                    }

              sadayapalam Srikanth Adayapalam (Inactive)
              mcimadamore Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: