app/internal/window: don't rely on JNI_OnCreate for getting the JavaVM

We're about to remove the global JNI_OnLoad constructor, and the
JavaVM singleton is just as easily fetched from a Java JNI callback.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-05-05 18:55:14 +02:00
parent c7c5b87264
commit 0c0a22bee7
3 changed files with 8 additions and 7 deletions
+3 -5
View File
@@ -88,6 +88,9 @@ func jniGetStaticMethodID(env *C.JNIEnv, class C.jclass, method, sig string) C.j
//export runGoMain
func runGoMain(env *C.JNIEnv, class C.jclass, jdataDir C.jbyteArray, context C.jobject) {
if res := C.gio_jni_GetJavaVM(env, &theJVM); res != 0 {
panic("gio: GetJavaVM failed")
}
dirBytes := C.gio_jni_GetByteArrayElements(env, jdataDir)
if dirBytes == nil {
panic("runGoMain: GetByteArrayElements failed")
@@ -113,11 +116,6 @@ func GetDataDir() string {
return <-dataDirChan
}
//export setJVM
func setJVM(vm *C.JavaVM) {
theJVM = vm
}
//export onCreateView
func onCreateView(env *C.JNIEnv, class C.jclass, view C.jobject) C.jlong {
view = C.gio_jni_NewGlobalRef(env, view)