[libbluray-devel] bdj: Try to detect (and ignore) JVM from Java 9 or later

hpi1 git at videolan.org
Mon Aug 27 11:36:04 CEST 2018


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Aug 27 11:37:26 2018 +0300| [485ee838d923fb89d0675694602a75c0de4bf2b8] | committer: hpi1

bdj: Try to detect (and ignore) JVM from Java 9 or later

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=485ee838d923fb89d0675694602a75c0de4bf2b8
---

 src/libbluray/bdj/bdj.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index 638f2879..a49caa79 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -122,11 +122,13 @@ static void *_load_jvm_win32(const char **p_java_home)
     HKEY hkey;
 
     r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, buf_loc, 0, KEY_READ, &hkey);
+# if 0
     if (r != ERROR_SUCCESS) {
         /* Try Java 9 */
         wcscpy(buf_loc, L"SOFTWARE\\JavaSoft\\JRE\\");
         r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, buf_loc, 0, KEY_READ, &hkey);
     }
+# endif
     if (r != ERROR_SUCCESS) {
         BD_DEBUG(DBG_BDJ | DBG_CRIT, "Error opening registry key SOFTWARE\\JavaSoft\\Java Runtime Environment\\\n");
         return NULL;
@@ -307,6 +309,13 @@ static void *_jvm_dlopen(const char *java_home, const char *jvm_dir, const char
         }
         BD_DEBUG(DBG_BDJ, "Opening %s ...\n", path);
         void *h = dl_dlopen(path, NULL);
+
+        if (h && dl_dlsym(h, "JVM_DefineModule")) {
+            BD_DEBUG(DBG_CRIT | DBG_BDJ, "Ignoring JVM %s: looks like Java 9 or later\n", path);
+            dl_dlclose(h);
+            h = NULL;
+        }
+
         X_FREE(path);
         return h;
     } else {



More information about the libbluray-devel mailing list