diff options
author | Mathieu Chartier <mathieuc@google.com> | 2015-07-10 18:26:41 -0700 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2015-07-11 15:31:26 -0700 |
commit | 997673870a487baa136f1b13f81ae26dd3005e14 (patch) | |
tree | a3699812d1bce24da0c08b8268c0cc5195fd29bf /test | |
parent | 25e1af5b4e1ce7e03a188ca1d0197a9f5b6acaf8 (diff) | |
download | art-997673870a487baa136f1b13f81ae26dd3005e14.zip art-997673870a487baa136f1b13f81ae26dd3005e14.tar.gz art-997673870a487baa136f1b13f81ae26dd3005e14.tar.bz2 |
Fix proxy handling in FindDeclaredVirtualMethod
Added missing GetInterfaceMethodIfProxy and test.
Fixed formatting.
Bug: 22411819
https://code.google.com/p/android-developer-preview/issues/detail?id=2635
(cherry picked from commit 72156e28fd6bc72ac965b29446f8801b2e82f2fd)
Change-Id: I3eece9c72091bb9d0262aacf0a75ec6908b5f4d2
Diffstat (limited to 'test')
-rw-r--r-- | test/004-JniTest/jni_test.cc | 4 | ||||
-rw-r--r-- | test/004-JniTest/src/Main.java | 28 |
2 files changed, 32 insertions, 0 deletions
diff --git a/test/004-JniTest/jni_test.cc b/test/004-JniTest/jni_test.cc index ca256ec..db0dd32 100644 --- a/test/004-JniTest/jni_test.cc +++ b/test/004-JniTest/jni_test.cc @@ -626,3 +626,7 @@ extern "C" JNIEXPORT void JNICALL Java_Main_testNewStringObject(JNIEnv* env, jcl assert(strcmp(test_array, chars6) == 0); env->ReleaseStringUTFChars(s6, chars6); } + +extern "C" JNIEXPORT jlong JNICALL Java_Main_testGetMethodID(JNIEnv* env, jclass, jclass c) { + return reinterpret_cast<jlong>(env->GetMethodID(c, "a", "()V")); +} diff --git a/test/004-JniTest/src/Main.java b/test/004-JniTest/src/Main.java index a81ec6d..decefac 100644 --- a/test/004-JniTest/src/Main.java +++ b/test/004-JniTest/src/Main.java @@ -14,7 +14,9 @@ * limitations under the License. */ +import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; +import java.lang.reflect.Proxy; public class Main { public static void main(String[] args) { @@ -35,6 +37,7 @@ public class Main { testCallNonvirtual(); testNewStringObject(); testRemoveLocalObject(); + testProxyGetMethodID(); } private static native void testFindClassOnAttachedNativeThread(); @@ -194,6 +197,31 @@ public class Main { private static native void testCallNonvirtual(); private static native void testNewStringObject(); + + private interface SimpleInterface { + void a(); + } + + private static class DummyInvocationHandler implements InvocationHandler { + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return null; + } + } + + private static void testProxyGetMethodID() { + InvocationHandler handler = new DummyInvocationHandler(); + SimpleInterface proxy = + (SimpleInterface) Proxy.newProxyInstance(SimpleInterface.class.getClassLoader(), + new Class[] {SimpleInterface.class}, handler); + if (testGetMethodID(SimpleInterface.class) == 0) { + throw new AssertionError(); + } + if (testGetMethodID(proxy.getClass()) == 0) { + throw new AssertionError(); + } + } + + private static native long testGetMethodID(Class<?> c); } class JniCallNonvirtualTest { |