summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
author David Brazdil <dbrazdil@google.com> 2018-03-14 13:57:27 +0000
committer David Brazdil <dbrazdil@google.com> 2018-03-15 12:54:42 +0000
commitfc66129b478d49f493b8262f81f8813a5f41459e (patch)
tree305594db27eaf39336175f958ee447536d9bf5d9 /runtime/class_linker.cc
parent8ce3bfaf1da2139a70b67e6b53c0110489801d40 (diff)
Warn on overriding of hidden methods
We could prevent apps from overriding hidden methods in the same manner they cannot override a package-private method - by creating a separate vtable entry for the child method. For now, start by printing a warning when a hidden method is being overridden but do not change the semantics. Bug: 64382372 Test: art/test.py -r -t 674-hiddenapi Change-Id: I9d5bfa6b833a4c0f5aaffa5f82dbe9b1e1f03f1f
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 9990a373c9..f720558e51 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -5836,6 +5836,14 @@ bool ClassLinker::LinkVirtualMethods(
// smaller as we go on.
uint32_t hash_index = hash_table.FindAndRemove(&super_method_name_comparator);
if (hash_index != hash_table.GetNotFoundIndex()) {
+ // Run a check whether we are going to override a method which is hidden
+ // to `klass`, but ignore the result as we only warn at the moment.
+ // We cannot do this test earlier because we need to establish that
+ // a method is being overridden first. ShouldBlockAccessToMember would
+ // print bogus warnings otherwise.
+ hiddenapi::ShouldBlockAccessToMember(
+ super_method, klass->GetClassLoader(), hiddenapi::kOverride);
+
ArtMethod* virtual_method = klass->GetVirtualMethodDuringLinking(
hash_index, image_pointer_size_);
if (super_method->IsFinal()) {