diff options
author | Vladimir Marko <vmarko@google.com> | 2015-06-23 17:45:21 +0100 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2015-06-25 11:59:45 +0100 |
commit | 92067896c6583d59171dbee9c720a316d63be177 (patch) | |
tree | f4521be817b10f319beb1209fe225b2d8ba2fc15 /runtime | |
parent | 20d60dd249e07a17351427770f0e0f6c68945b7a (diff) | |
download | art-92067896c6583d59171dbee9c720a316d63be177.zip art-92067896c6583d59171dbee9c720a316d63be177.tar.gz art-92067896c6583d59171dbee9c720a316d63be177.tar.bz2 |
Hard-fail get-/put-object to a non-reference field.
Bug: 21886894
(cherry picked from commit 414000ec4d728b5c85f8c6dee4f867fecde59b01)
Change-Id: Iafc32f0e45d26f3aaa2d521b98353e7cede16c6f
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/verifier/method_verifier.cc | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index bcad9b6..89f5115 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -4006,10 +4006,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); @@ -4033,10 +4038,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; } |