-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b59
-
unknown
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8085476 | emb-9 | Srikanth Adayapalam | P4 | Resolved | Fixed | team |
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);
}
*) 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);
}
- backported by
-
JDK-8085476 Gen.java: fix code for handling 'null' literal when expected type is array
-
- Resolved
-
- relates to
-
JDK-7040104 javac NPE on Object a[]; Object o = (a=null)[0];
-
- Closed
-