summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author Elliott Hughes <enh@google.com> 2012-07-13 16:21:23 -0700
committer Elliott Hughes <enh@google.com> 2012-07-13 16:21:23 -0700
commit3971737ece7c2351c7ae91f488ee73628c75b2e6 (patch)
tree77b18d613f377e8aeef2a3c46453a0a93327f604 /src
parent7c7679cd76e76b44c75a3e32a8727148d3ab9ada (diff)
Warn if we load a class that would previously have overridden a package-private method.
Change-Id: I5f21d9212ce91df1ff6d2eedfc68cb271f6e697c
Diffstat (limited to 'src')
-rw-r--r--src/class_linker.cc27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/class_linker.cc b/src/class_linker.cc
index dfed6f7a9b..5bd69e8c5e 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -2851,19 +2851,22 @@ bool ClassLinker::LinkVirtualMethods(SirtRef<Class>& klass) {
for (; j < actual_count; ++j) {
Method* super_method = vtable->Get(j);
super_mh.ChangeMethod(super_method);
- if (local_mh.HasSameNameAndSignature(&super_mh) &&
- klass->CanAccessMember(super_method->GetDeclaringClass(), super_method->GetAccessFlags())) {
- // Verify
- if (super_method->IsFinal()) {
- MethodHelper mh(local_method);
- ThrowLinkageError("Method %s.%s overrides final method in class %s",
- PrettyDescriptor(klass.get()).c_str(),
- mh.GetName(), mh.GetDeclaringClassDescriptor());
- return false;
+ if (local_mh.HasSameNameAndSignature(&super_mh)) {
+ if (klass->CanAccessMember(super_method->GetDeclaringClass(), super_method->GetAccessFlags())) {
+ if (super_method->IsFinal()) {
+ ThrowLinkageError("Method %s overrides final method in class %s",
+ PrettyMethod(local_method).c_str(),
+ super_mh.GetDeclaringClassDescriptor());
+ return false;
+ }
+ vtable->Set(j, local_method);
+ local_method->SetMethodIndex(j);
+ break;
+ } else {
+ LOG(WARNING) << "Before Android 4.1, method " << PrettyMethod(local_method)
+ << " would have incorrectly overridden the package-private method in "
+ << PrettyDescriptor(super_mh.GetDeclaringClassDescriptor());
}
- vtable->Set(j, local_method);
- local_method->SetMethodIndex(j);
- break;
}
}
if (j == actual_count) {