Commit 414000ec authored by Vladimir Marko's avatar Vladimir Marko
Browse files

Hard-fail get-/put-object to a non-reference field.

Bug: 21886894
Change-Id: Iec870c223ce97fd90dcce05ae80c002e2b24cb5d
parent bcc9d2b5
......@@ -4060,10 +4060,15 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType&
VerifyPrimitivePut(*field_type, insn_type, vregA);
} else {
if (!insn_type.IsAssignableFrom(*field_type)) {
Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "expected field " << PrettyField(field)
<< " to be compatible with type '" << insn_type
<< "' but found type '" << *field_type
<< "' in put-object";
// If the field type is not a reference, this is a global failure rather than
// a class change failure as the instructions and the descriptors for the type
// should have been consistent within the same file at compile time.
VerifyError error = field_type->IsReferenceTypes() ? VERIFY_ERROR_BAD_CLASS_SOFT
: VERIFY_ERROR_BAD_CLASS_HARD;
Fail(error) << "expected field " << PrettyField(field)
<< " to be compatible with type '" << insn_type
<< "' but found type '" << *field_type
<< "' in put-object";
return;
}
work_line_->VerifyRegisterType(this, vregA, *field_type);
......@@ -4087,10 +4092,15 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType&
}
} else {
if (!insn_type.IsAssignableFrom(*field_type)) {
Fail(VERIFY_ERROR_BAD_CLASS_SOFT) << "expected field " << PrettyField(field)
<< " to be compatible with type '" << insn_type
<< "' but found type '" << *field_type
<< "' in get-object";
// If the field type is not a reference, this is a global failure rather than
// a class change failure as the instructions and the descriptors for the type
// should have been consistent within the same file at compile time.
VerifyError error = field_type->IsReferenceTypes() ? VERIFY_ERROR_BAD_CLASS_SOFT
: VERIFY_ERROR_BAD_CLASS_HARD;
Fail(error) << "expected field " << PrettyField(field)
<< " to be compatible with type '" << insn_type
<< "' but found type '" << *field_type
<< "' in get-object";
work_line_->SetRegisterType(this, vregA, reg_types_.Conflict());
return;
}
......
......@@ -24,4 +24,5 @@ b/21902684
b/22045582
b/22045582 (int)
b/22045582 (wide)
b/21886894
Done!
.class public LB21886894;
.super Ljava/lang/Object;
.method public constructor <init>()V
.registers 2
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public test()V
.registers 2
const v0, 0
iput-object v0, p0, Lsome/unresolved/Type;->a:I
return-void
.end method
......@@ -95,6 +95,8 @@ public class Main {
new VerifyError(), 0));
testCases.add(new TestCase("b/22045582 (wide)", "B22045582Wide", "run", null,
new VerifyError(), 0));
testCases.add(new TestCase("b/21886894", "B21886894", "test", null, new VerifyError(),
null));
}
public void runTests() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment