CHECKCAST always succeeds on null

This commit is contained in:
Natalia Ukhorskaya
2014-04-07 20:03:11 +04:00
parent 92edc8299e
commit 964b81ce6a
2 changed files with 21 additions and 1 deletions
@@ -172,7 +172,9 @@ class SingleInstructionInterpreter(private val eval: Eval) : Interpreter<Value>(
CHECKCAST -> {
val targetType = Type.getObjectType((insn as TypeInsnNode).desc)
if (eval.isInstanceOf(value, targetType)) {
if (value == NULL_VALUE) {
NULL_VALUE
} else if (eval.isInstanceOf(value, targetType)) {
ObjectValue(value.obj(), targetType)
}
else {
@@ -48,6 +48,22 @@ class TestData {
return "str";
}
static void checkCastNull() {
CheckCastToNull klass = new CheckCastToNull();
klass.f1(null);
klass.f2(null);
klass.f3(null);
Integer integer = (Integer) null;
Object object = (Object) null;
}
static class CheckCastToNull {
void f1(Integer p) {}
void f2(Integer[] p) {}
void f3(Integer[][] p) {}
}
static Integer integerValueOf() { return 1; }
static Byte byteValueOf() { return 1; }
@@ -549,3 +565,5 @@ class TestData {
int[] i = (int[]) null;
}
}