From 21db695e799bc212e3e9b2534d0c48d6ca78e4ef Mon Sep 17 00:00:00 2001 From: Ben Doherty Date: Thu, 28 Oct 2021 16:02:23 -0700 Subject: [PATCH] Call VirtualMachineEnv::JNI_OnLoad for non-Android Java builds (better fix) (#4779) --- android/filament-android/src/main/cpp/Filament.cpp | 10 ++++------ .../src/opengl/platforms/PlatformEGLAndroid.cpp | 5 ----- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/android/filament-android/src/main/cpp/Filament.cpp b/android/filament-android/src/main/cpp/Filament.cpp index 03ac36b840..0ae41e9270 100644 --- a/android/filament-android/src/main/cpp/Filament.cpp +++ b/android/filament-android/src/main/cpp/Filament.cpp @@ -16,9 +16,7 @@ #include -namespace filament { - extern jint JNI_OnLoad(JavaVM* vm, void* reserved); -}; +#include "private/backend/VirtualMachineEnv.h" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { JNIEnv* env; @@ -26,9 +24,9 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { return -1; } -#if ANDROID - ::filament::JNI_OnLoad(vm, reserved); -#endif + // This must be called when the library is loaded. We need this to get a reference to the + // global VM + ::filament::VirtualMachineEnv::JNI_OnLoad(vm); return JNI_VERSION_1_6; } diff --git a/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp b/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp index 572ee44c80..fdbdbe0fe5 100644 --- a/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp +++ b/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp @@ -245,11 +245,6 @@ AcquiredImage PlatformEGLAndroid::transformAcquiredImage(AcquiredImage source) n return { eglImage, patchedCallback, closure, source.handler }; } -// This must be called when the library is loaded. We need this to get a reference to the global VM -void JNI_OnLoad(JavaVM* vm, void* reserved) { - ::filament::VirtualMachineEnv::JNI_OnLoad(vm); -} - } // namespace filament // ---------------------------------------------------------------------------------------------