CHECKCAST always succeeds on null
This commit is contained in:
@@ -172,7 +172,9 @@ class SingleInstructionInterpreter(private val eval: Eval) : Interpreter<Value>(
|
|||||||
|
|
||||||
CHECKCAST -> {
|
CHECKCAST -> {
|
||||||
val targetType = Type.getObjectType((insn as TypeInsnNode).desc)
|
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)
|
ObjectValue(value.obj(), targetType)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -48,6 +48,22 @@ class TestData {
|
|||||||
return "str";
|
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 Integer integerValueOf() { return 1; }
|
||||||
|
|
||||||
static Byte byteValueOf() { return 1; }
|
static Byte byteValueOf() { return 1; }
|
||||||
@@ -549,3 +565,5 @@ class TestData {
|
|||||||
int[] i = (int[]) null;
|
int[] i = (int[]) null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user