summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2015-12-10 16:23:41 -0800
committer Andreas Gampe <agampe@google.com> 2015-12-11 11:00:45 -0800
commit97b113596576ee026c9d3e100e472e343bfda7fa (patch)
tree11f1f64ab646077857a2153fee23a499359ca6af
parent748047de833061466e230baf374480a147568f73 (diff)
ART: Weaken dex file verifier abstract check
We decided to not reject dex files with non-abstract classes containing abstract methods (even though that's broken code). Just log a warning instead. Reported by Nikolay Serdjuk. Bug: 26143249 Change-Id: Iaf981dba70c7c4b9c844ad9f2806278072e3ed52
-rw-r--r--runtime/dex_file_verifier.cc9
-rw-r--r--test/800-smali/expected.txt1
-rw-r--r--test/800-smali/smali/b_26143249.smali20
-rw-r--r--test/800-smali/src/Main.java2
4 files changed, 28 insertions, 4 deletions
diff --git a/runtime/dex_file_verifier.cc b/runtime/dex_file_verifier.cc
index 440d696ea9..727f4fc659 100644
--- a/runtime/dex_file_verifier.cc
+++ b/runtime/dex_file_verifier.cc
@@ -2508,11 +2508,12 @@ bool DexFileVerifier::CheckMethodAccessFlags(uint32_t method_index,
method_access_flags);
return false;
}
- // Abstract methods must be in an abstract class or interface.
+ // Abstract methods should be in an abstract class or interface.
if ((class_access_flags & (kAccInterface | kAccAbstract)) == 0) {
- *error_msg = StringPrintf("Method %" PRIu32 " is abstract, but the declaring class "
- "is neither abstract nor an interface", method_index);
- return false;
+ LOG(WARNING) << "Method " << PrettyMethod(method_index, *dex_file_)
+ << " is abstract, but the declaring class is neither abstract nor an "
+ << "interface in dex file "
+ << dex_file_->GetLocation();
}
}
// Interfaces are special.
diff --git a/test/800-smali/expected.txt b/test/800-smali/expected.txt
index ebefeea405..27f5b5d552 100644
--- a/test/800-smali/expected.txt
+++ b/test/800-smali/expected.txt
@@ -48,4 +48,5 @@ b/23502994 (if-eqz)
b/23502994 (check-cast)
b/25494456
b/21869691
+b/26143249
Done!
diff --git a/test/800-smali/smali/b_26143249.smali b/test/800-smali/smali/b_26143249.smali
new file mode 100644
index 0000000000..aa69e84bfa
--- /dev/null
+++ b/test/800-smali/smali/b_26143249.smali
@@ -0,0 +1,20 @@
+# Make sure we accept non-abstract classes with abstract members.
+
+.class public LB26143249;
+
+.super Ljava/lang/Object;
+
+.method public constructor <init>()V
+ .registers 1
+ invoke-direct {p0}, Ljava/lang/Object;-><init>()V
+ return-void
+.end method
+
+.method public run()V
+ .registers 1
+ invoke-virtual {p0}, LB26143249;->abs()V
+ return-void
+.end method
+
+.method public abstract abs()V
+.end method
diff --git a/test/800-smali/src/Main.java b/test/800-smali/src/Main.java
index 3b62a46fd3..cc3b0b44f9 100644
--- a/test/800-smali/src/Main.java
+++ b/test/800-smali/src/Main.java
@@ -141,6 +141,8 @@ public class Main {
null));
testCases.add(new TestCase("b/21869691", "B21869691A", "run", null,
new IncompatibleClassChangeError(), null));
+ testCases.add(new TestCase("b/26143249", "B26143249", "run", null,
+ new AbstractMethodError(), null));
}
public void runTests() {