summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/mirror/class-inl.h2
-rw-r--r--test/040-miranda/expected.txt2
-rw-r--r--test/040-miranda/src/Main.java13
-rw-r--r--test/JniTest/JniTest.java22
-rw-r--r--test/JniTest/jni_test.cc8
-rwxr-xr-xtest/run-test23
6 files changed, 59 insertions, 11 deletions
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 4dcce1e8a1..3a28974e4b 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -248,7 +248,7 @@ inline ArtMethod* Class::FindVirtualMethodForVirtualOrInterface(ArtMethod* metho
if (method->IsDirect()) {
return method;
}
- if (method->GetDeclaringClass()->IsInterface()) {
+ if (method->GetDeclaringClass()->IsInterface() && !method->IsMiranda()) {
return FindVirtualMethodForInterface(method);
}
return FindVirtualMethodForVirtual(method);
diff --git a/test/040-miranda/expected.txt b/test/040-miranda/expected.txt
index e22bbd974c..011be2af86 100644
--- a/test/040-miranda/expected.txt
+++ b/test/040-miranda/expected.txt
@@ -10,3 +10,5 @@ MirandaAbstract / MirandaClass2:
inInterface: true
inInterface2: 28
inAbstract: true
+Test getting miranda method via reflection:
+ caught expected NoSuchMethodException
diff --git a/test/040-miranda/src/Main.java b/test/040-miranda/src/Main.java
index 1fd8287ba0..ff5eba0a17 100644
--- a/test/040-miranda/src/Main.java
+++ b/test/040-miranda/src/Main.java
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+import java.lang.reflect.Method;
+
/**
* Miranda testing.
*/
@@ -37,5 +39,16 @@ public class Main {
System.out.println(" inInterface: " + mira2.inInterface());
System.out.println(" inInterface2: " + mira2.inInterface2());
System.out.println(" inAbstract: " + mira2.inAbstract());
+
+ System.out.println("Test getting miranda method via reflection:");
+ try {
+ Class mirandaClass = Class.forName("MirandaAbstract");
+ Method mirandaMethod = mirandaClass.getDeclaredMethod("inInterface", (Class[]) null);
+ System.out.println(" did not expect to find miranda method");
+ } catch (NoSuchMethodException nsme) {
+ System.out.println(" caught expected NoSuchMethodException");
+ } catch (Exception e) {
+ System.out.println(" caught unexpected exception " + e);
+ }
}
}
diff --git a/test/JniTest/JniTest.java b/test/JniTest/JniTest.java
index 7014ef9334..a1b1f0c69d 100644
--- a/test/JniTest/JniTest.java
+++ b/test/JniTest/JniTest.java
@@ -14,11 +14,14 @@
* limitations under the License.
*/
+import java.lang.reflect.Method;
+
class JniTest {
public static void main(String[] args) {
System.loadLibrary("arttest");
testFindClassOnAttachedNativeThread();
testCallStaticVoidMethodOnSubClass();
+ testGetMirandaMethod();
}
private static native void testFindClassOnAttachedNativeThread();
@@ -42,4 +45,23 @@ class JniTest {
private static class testCallStaticVoidMethodOnSubClass_SubClass
extends testCallStaticVoidMethodOnSubClass_SuperClass {
}
+
+ private static native Method testGetMirandaMethodNative();
+
+ private static void testGetMirandaMethod() {
+ Method m = testGetMirandaMethodNative();
+ if (m.getDeclaringClass() != testGetMirandaMethod_MirandaInterface.class) {
+ throw new AssertionError();
+ }
+ }
+
+ private static abstract class testGetMirandaMethod_MirandaAbstract implements testGetMirandaMethod_MirandaInterface {
+ public boolean inAbstract() {
+ return true;
+ }
+ }
+
+ private static interface testGetMirandaMethod_MirandaInterface {
+ public boolean inInterface();
+ }
}
diff --git a/test/JniTest/jni_test.cc b/test/JniTest/jni_test.cc
index 72a3309d9d..cfcbb64f38 100644
--- a/test/JniTest/jni_test.cc
+++ b/test/JniTest/jni_test.cc
@@ -81,3 +81,11 @@ extern "C" JNIEXPORT void JNICALL Java_JniTest_testCallStaticVoidMethodOnSubClas
env->CallStaticVoidMethod(sub_class, execute);
}
+
+extern "C" JNIEXPORT jobject JNICALL Java_JniTest_testGetMirandaMethodNative(JNIEnv* env, jclass) {
+ jclass abstract_class = env->FindClass("JniTest$testGetMirandaMethod_MirandaAbstract");
+ assert(abstract_class != NULL);
+ jmethodID miranda_method = env->GetMethodID(abstract_class, "inInterface", "()Z");
+ assert(miranda_method != NULL);
+ return env->ToReflectedMethod(abstract_class, miranda_method, JNI_FALSE);
+}
diff --git a/test/run-test b/test/run-test
index f706110a2c..c3943e70be 100755
--- a/test/run-test
+++ b/test/run-test
@@ -65,7 +65,7 @@ target_mode="yes"
dev_mode="no"
update_mode="no"
debug_mode="no"
-dalvik_mode="no"
+runtime="art"
usage="no"
build_only="no"
@@ -77,6 +77,7 @@ while true; do
shift
elif [ "x$1" = "x--jvm" ]; then
target_mode="no"
+ runtime="jvm"
RUN="${progdir}/etc/reference-run-test-classes"
NEED_DEX="false"
shift
@@ -85,7 +86,7 @@ while true; do
shift
elif [ "x$1" = "x--dalvik" ]; then
lib="libdvm.so"
- dalvik_mode="yes"
+ runtime="dalvik"
shift
elif [ "x$1" = "x--image" ]; then
shift
@@ -155,15 +156,11 @@ while true; do
fi
done
-run_args="${run_args} --lib $lib"
+if [ ! "$runtime" = "jvm" ]; then
+ run_args="${run_args} --lib $lib"
+fi
-if [ "$dalvik_mode" = "no" ]; then
- if [ "$target_mode" = "no" ]; then
- run_args="${run_args} --boot -Ximage:${ANDROID_HOST_OUT}/framework/core.art"
- else
- run_args="${run_args} --boot -Ximage:/data/art-test/core.art"
- fi
-else
+if [ "$runtime" = "dalvik" ]; then
if [ "$target_mode" = "no" ]; then
framework="${OUT}/system/framework"
bpath="${framework}/core.jar:${framework}/conscrypt.jar:${framework}/okhttp.jar:${framework}/core-junit.jar:${framework}/bouncycastle.jar:${framework}/ext.jar"
@@ -171,6 +168,12 @@ else
else
true # defaults to using target BOOTCLASSPATH
fi
+elif [ "$runtime" = "art" ]; then
+ if [ "$target_mode" = "no" ]; then
+ run_args="${run_args} --boot -Ximage:${ANDROID_HOST_OUT}/framework/core.art"
+ else
+ run_args="${run_args} --boot -Ximage:/data/art-test/core.art"
+ fi
fi
if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then