summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Igor Murashkin <iam@google.com> 2016-02-01 17:40:19 -0800
committer Igor Murashkin <iam@google.com> 2016-02-02 10:56:01 -0800
commitf1b4c41dba8ea69c25f7db53eec97a8936e0d7f0 (patch)
tree58f355d69363c4daa453680f49cd9b2743e40bfa
parentdf187e4cc8b1b2dc6cb0043eb91d1dfd72cb490b (diff)
runtime: Fix field resolution with access checks (runtest 073)
Fixes field resolution not to take static/instance into account until after the field is completely resolved. Only the [i|s][put|get] instructions themselves have enough context on whether the field must be static or not (and throw an ICCE on a mismatch). This makes us more JLS 13.4.8 compatible and also fixes a run-test failure for interpreter-access-checks configuration. Bug: 22414682 Change-Id: I78b17187e59f8f78569fcd8ffdf1cf1603a2d4b2
-rw-r--r--runtime/entrypoints/entrypoint_utils-inl.h26
-rw-r--r--test/Android.run-test.mk1
2 files changed, 25 insertions, 2 deletions
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h
index 0663b7ef78..51611753c8 100644
--- a/runtime/entrypoints/entrypoint_utils-inl.h
+++ b/runtime/entrypoints/entrypoint_utils-inl.h
@@ -316,7 +316,31 @@ inline ArtField* FindFieldFromCode(uint32_t field_idx, ArtMethod* referrer,
default: is_primitive = true; is_set = true; is_static = true; break;
}
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
- ArtField* resolved_field = class_linker->ResolveField(field_idx, referrer, is_static);
+
+ ArtField* resolved_field;
+ if (access_check) {
+ // Slow path: According to JLS 13.4.8, a linkage error may occur if a compile-time
+ // qualifying type of a field and the resolved run-time qualifying type of a field differed
+ // in their static-ness.
+ //
+ // In particular, don't assume the dex instruction already correctly knows if the
+ // real field is static or not. The resolution must not be aware of this.
+ ArtMethod* method = referrer->GetInterfaceMethodIfProxy(sizeof(void*));
+
+ StackHandleScope<2> hs(self);
+ Handle<mirror::DexCache> h_dex_cache(hs.NewHandle(method->GetDexCache()));
+ Handle<mirror::ClassLoader> h_class_loader(hs.NewHandle(method->GetClassLoader()));
+
+ resolved_field = class_linker->ResolveFieldJLS(*method->GetDexFile(),
+ field_idx,
+ h_dex_cache,
+ h_class_loader);
+ } else {
+ // Fast path: Verifier already would've called ResolveFieldJLS and we wouldn't
+ // be executing here if there was a static/non-static mismatch.
+ resolved_field = class_linker->ResolveField(field_idx, referrer, is_static);
+ }
+
if (UNLIKELY(resolved_field == nullptr)) {
DCHECK(self->IsExceptionPending()); // Throw exception and unwind.
return nullptr; // Failure.
diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk
index b79602a5ad..8dafd293fd 100644
--- a/test/Android.run-test.mk
+++ b/test/Android.run-test.mk
@@ -302,7 +302,6 @@ TEST_ART_BROKEN_NO_RELOCATE_TESTS :=
# Temporarily disable some broken tests when forcing access checks in interpreter b/22414682
TEST_ART_BROKEN_INTERPRETER_ACCESS_CHECK_TESTS := \
- 073-mismatched-field \
135-MirandaDispatch \
137-cfi \
412-new-array \