[libbluray-devel] BD-J: native open method was changed around j8u40

hpi1 git at videolan.org
Mon Apr 6 13:59:10 CEST 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Apr  6 14:51:28 2015 +0300| [f45b6c52406c8a40d41e7dd45af9aeec15cc6688] | committer: hpi1

BD-J: native open method was changed around j8u40

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

 ChangeLog                                           |    1 +
 src/libbluray/bdj/java/java/io/FileInputStream.java |   19 ++++++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cd4e4ee..a0580db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@
 - Accept directory name (without .jar file name) in LIBBLURAY_CP.
 - Improved error resilence.
 - Improve BD-J compability.
+- Fix Java 8u40 compability.
 - Fix infinite loop with some broken HDMV menus.
 
 2015-01-26: Version 0.7.0
diff --git a/src/libbluray/bdj/java/java/io/FileInputStream.java b/src/libbluray/bdj/java/java/io/FileInputStream.java
index 04f5bf7..2dff711 100644
--- a/src/libbluray/bdj/java/java/io/FileInputStream.java
+++ b/src/libbluray/bdj/java/java/io/FileInputStream.java
@@ -57,7 +57,7 @@ public class FileInputStream extends InputStream
                 logger.info("Using cached " + cachedName + " for " + name);
                 name = cachedName;
             }
-            open(name);
+            openImpl(name);
         } else {
             /* relative paths are problematic ... */
             /* Those should be mapped to xlet home directory, which is inside .jar file. */
@@ -70,7 +70,7 @@ public class FileInputStream extends InputStream
                 logger.error("no home found for " + name + " at " + Logger.dumpStack());
                 throw new FileNotFoundException(name);
             }
-            open(home + name);
+            openImpl(home + name);
         }
 
         available = 1024;
@@ -93,9 +93,22 @@ public class FileInputStream extends InputStream
         available = 1024;
     }
 
-    private native void open(String name) throws FileNotFoundException;
+    /* open()/open0() wrapper to select correct native method at runtime */
+    private void openImpl(String name) throws FileNotFoundException {
+        try {
+            open(name);
+        } catch (UnsatisfiedLinkError e) {
+            /* OpenJDK 8 b40 */
+            open0(name);
+        }
+    }
+
     private native int  readBytes(byte b[], int off, int len) throws IOException;
     private native int  close0();
+    /* OpenJDK 6, OpenJDK 7, PhoneME, ... */
+    private native void open(String name) throws FileNotFoundException;
+    /* OpenJDK 8 */
+    private native void open0(String name) throws FileNotFoundException;
 
     //public  native int  read() throws IOException;
     //public  native long skip(long n) throws IOException;



More information about the libbluray-devel mailing list