bind: support casting of Java objects

Generate Cast functions that take a proxy for a Java class or interface,
and return a new proxy with the same reference. The Cast functions
panic if the underlying Java object is not an instance of the expected
type.

Change-Id: I08a5bf9a79139f0fac5dd102c7b028c8c989fc6d
Reviewed-on: https://go-review.googlesource.com/30095
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
Elias Naur
2016-10-05 08:40:06 +00:00
parent 69dc8e1c38
commit e76ec53021
7 changed files with 208 additions and 7 deletions
+8
View File
@@ -382,3 +382,11 @@ void go_seq_release_byte_array(JNIEnv *env, jbyteArray arr, jbyte* ptr) {
(*env)->ReleaseByteArrayElements(env, arr, ptr, 0);
}
}
int go_seq_isinstanceof(jint refnum, jclass clazz) {
JNIEnv *env = go_seq_push_local_frame(0);
jobject obj = go_seq_from_refnum(env, refnum, NULL, NULL);
jboolean isinst = (*env)->IsInstanceOf(env, obj, clazz);
go_seq_pop_local_frame(env);
return isinst;
}