Merge "Fix verifier bug caused by confusing ArtMethod::IsDirect vs ArtMethod::IsStatic semantics."
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index c206b94..441a08a 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -3168,7 +3168,7 @@
}
// See if the method type implied by the invoke instruction matches the access flags for the
// target method.
- if ((method_type == METHOD_DIRECT && !res_method->IsDirect()) ||
+ if ((method_type == METHOD_DIRECT && (!res_method->IsDirect() || res_method->IsStatic())) ||
(method_type == METHOD_STATIC && !res_method->IsStatic()) ||
((method_type == METHOD_VIRTUAL || method_type == METHOD_INTERFACE) && res_method->IsDirect())
) {
diff --git a/test/118-noimage-dex2oat/expected.txt b/test/118-noimage-dex2oat/expected.txt
index 6825fae..bcb695d 100644
--- a/test/118-noimage-dex2oat/expected.txt
+++ b/test/118-noimage-dex2oat/expected.txt
@@ -1,6 +1,9 @@
Run -Xnoimage-dex2oat
Has image is false, is image dex2oat enabled is false, is BOOTCLASSPATH on disk is false.
+testB18485243 PASS
Run -Ximage-dex2oat
Has image is true, is image dex2oat enabled is true, is BOOTCLASSPATH on disk is true.
+testB18485243 PASS
Run default
Has image is true, is image dex2oat enabled is true, is BOOTCLASSPATH on disk is true.
+testB18485243 PASS
diff --git a/test/118-noimage-dex2oat/smali/b_18485243.smali b/test/118-noimage-dex2oat/smali/b_18485243.smali
new file mode 100644
index 0000000..41fbc74
--- /dev/null
+++ b/test/118-noimage-dex2oat/smali/b_18485243.smali
@@ -0,0 +1,22 @@
+.class public LB18485243;
+.super Ljava/lang/Object;
+.source "b_18485243.smali"
+
+.method public constructor <init>()V
+ .registers 2
+ invoke-direct {p0}, Ljava/lang/Object;-><init>()V
+ return-void
+.end method
+
+.method private static toInt()I
+ .registers 1
+ const v0, 0
+ return v0
+.end method
+
+.method public run()I
+ .registers 3
+ invoke-direct {p0}, LB18485243;->toInt()I
+ move-result v0
+ return v0
+.end method
diff --git a/test/118-noimage-dex2oat/src/Main.java b/test/118-noimage-dex2oat/src/Main.java
index c83b84d..9bf5bb3 100644
--- a/test/118-noimage-dex2oat/src/Main.java
+++ b/test/118-noimage-dex2oat/src/Main.java
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Main {
@@ -36,6 +37,8 @@
} else if (!hasImage && isBootClassPathOnDisk) {
throw new Error("Image with dex2oat enabled runs without an image file");
}
+
+ testB18485243();
}
static {
@@ -67,4 +70,19 @@
return (boolean) isBootClassPathOnDiskMethod.invoke(null, instructionSet);
}
}
+
+ private static void testB18485243() throws Exception {
+ Class<?> k = Class.forName("B18485243");
+ Object o = k.newInstance();
+ Method m = k.getDeclaredMethod("run");
+ try {
+ m.invoke(o);
+ } catch (InvocationTargetException e) {
+ Throwable actual = e.getTargetException();
+ if (!(actual instanceof IncompatibleClassChangeError)) {
+ throw new AssertionError("Expected IncompatibleClassChangeError", actual);
+ }
+ }
+ System.out.println("testB18485243 PASS");
+ }
}