From 910c3fc64eaf4916ed3cbf6395f89889e6a7d5c2 Mon Sep 17 00:00:00 2001 From: "Hyang-Ah (Hana) Kim" Date: Tue, 5 May 2015 23:37:01 -0400 Subject: [PATCH] bind/java: find jbytearray class info using jbytearray object. The previous way (JNIEnv's FindClass with "[B") does not work in Android-L for some reason. Change-Id: I5cccb7bbf651df981a923ecade863302521d5c5c Reviewed-on: https://go-review.googlesource.com/9783 Reviewed-by: David Crawshaw --- bind/java/seq_android.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bind/java/seq_android.c b/bind/java/seq_android.c index b5bd470..c94526a 100644 --- a/bind/java/seq_android.c +++ b/bind/java/seq_android.c @@ -215,7 +215,12 @@ void init_seq(void *javavm, void *classfinder) { receive_handle_id = find_field(env, "go/Seq$Receive", "handle", "I"); receive_code_id = find_field(env, "go/Seq$Receive", "code", "I"); - jbytearray_clazz = find_class(env, "[B"); + // Find jbyteArray class info by instantiating a jbyteArray and getting + // its class info, because finding the jbyteArray class ("[B") using + // find_class_fn or JNIEnv's FindClass does not work on android-L. + jbyteArray a = (*env)->NewByteArray(env, 0); + jclass clazz = (*env)->GetObjectClass(env, a); + jbytearray_clazz = (*env)->NewGlobalRef(env, clazz); LOG_INFO("loaded go/Seq");