Generate not-null assertions after getting a field

This commit is contained in:
Alexander Udalov
2012-10-02 22:09:02 +04:00
parent 27bea0a607
commit fcbc95bbb4
5 changed files with 31 additions and 1 deletions
@@ -420,6 +420,14 @@ public class AsmUtil {
genMethodThrow(mv, STUB_EXCEPTION, STUB_EXCEPTION_MESSAGE);
}
public static void genNotNullAssertionForField(
@NotNull InstructionAdapter v,
@NotNull GenerationState state,
@NotNull PropertyDescriptor descriptor
) {
genNotNullAssertion(v, state, descriptor, "checkFieldIsNotNull");
}
public static void genNotNullAssertionForMethod(
@NotNull InstructionAdapter v,
@NotNull GenerationState state,
@@ -982,6 +982,7 @@ public abstract class StackValue {
if (getter == null) {
v.visitFieldInsn(isStatic ? GETSTATIC : GETFIELD, methodOwner.getInternalName(), descriptor.getName().getName(),
this.type.getDescriptor());
genNotNullAssertionForField(v, state, descriptor);
}
else {
v.visitMethodInsn(invokeOpcode, methodOwner.getInternalName(), getter.getName(), getter.getDescriptor());