From 2a8db3d780d8d851fa8756f65c0d95d4179bf197 Mon Sep 17 00:00:00 2001 From: Lubosz Sarnecki Date: Fri, 25 Sep 2020 19:13:22 +0200 Subject: [PATCH] aux/android/load_class: Use pkgClassLoader.loadClass to load MonadoView class. --- .../auxiliary/android/android_load_class.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/xrt/auxiliary/android/android_load_class.cpp b/src/xrt/auxiliary/android/android_load_class.cpp index 48268783e..9ebb5f7c3 100644 --- a/src/xrt/auxiliary/android/android_load_class.cpp +++ b/src/xrt/auxiliary/android/android_load_class.cpp @@ -27,6 +27,7 @@ getAppInfo(std::string const &packageName, jobject application_context) PackageManager::GET_SHARED_LIBRARY_FILES); return packageInfo.getApplicationInfo(); } catch (std::exception const &e) { + U_LOG_E("Could get App Info: %s", e.what()); return {}; } } @@ -47,9 +48,20 @@ loadClassFromPackage(ApplicationInfo applicationInfo, wrap::java::lang::ClassLoader pkgClassLoader = pkgContext.getClassLoader(); - auto loadedClass = wrap::java::lang::Class::forName( - clazz_name, true, pkgClassLoader.object()); - return loadedClass; + try { + auto loadedClass = + pkgClassLoader.loadClass(std::string(clazz_name)); + if (loadedClass.isNull()) { + U_LOG_E("Could not load class for name %s", clazz_name); + return wrap::java::lang::Class(); + } + + return loadedClass; + } catch (std::exception const &e) { + U_LOG_E("Could load class '%s' forName: %s", clazz_name, + e.what()); + return wrap::java::lang::Class(); + } } void *