[libbluray-devel] [PATCH] Fix Java 8 build break with getFileSystem()
Zach Rait
zachrait at gmail.com
Wed Feb 25 08:09:56 CET 2015
I'm not sure how to propose a patch as I don't see any recent examples, but
I've included what I'd like to push below. Please let me know what the best
way to contribute to this project is—I didn't see any guidelines at
http://www.videolan.org/developers/libbluray.html, but I may have missed
something obvious.
[PATCH] Fix Java 8 build break with getFileSystem()
Unfortunately java.io.FileSystem.getFileSystem() was removed in Java 8,
so the addition of calls to it in 7fc6531ea0 broke compilation under Java 8
---
src/libbluray/bdj/java/java/io/BDFileSystem.java | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/libbluray/bdj/java/java/io/BDFileSystem.java
b/src/libbluray/bdj/java/java/io/BDFileSystem.java
index 9800022..a6892a5 100644
--- a/src/libbluray/bdj/java/java/io/BDFileSystem.java
+++ b/src/libbluray/bdj/java/java/io/BDFileSystem.java
@@ -42,6 +42,8 @@ public abstract class BDFileSystem extends FileSystem {
protected final FileSystem fs;
+ private static FileSystem nativeFileSystem;
+
public static void init(Class c) {
Field filesystem;
try {
@@ -62,18 +64,31 @@ public abstract class BDFileSystem extends FileSystem {
} catch (Throwable t) {
System.err.print("Hooking FileSystem class failed: " + t);
}
+ /* Java 8: getFileSystem() no longer exists on java.io.FileSystem
*/
+ try {
+ Class.forName("java.io.DefaultFileSystem");
+ nativeFileSystem = DefaultFileSystem.getFileSystem();
+ } catch (ClassNotFoundException e) {
+ try {
+ nativeFileSystem = (FileSystem)FileSystem.class
+ .getDeclaredMethod("getFileSystem",new Class[0])
+ .invoke(FileSystem.class, new Object[0]);
+ } catch (Throwable t) {
+ System.err.print("Couldn't find native filesystem: " + t);
+ }
+ }
}
public static String[] nativeList(File f) {
- return getFileSystem().list(f);
+ return nativeFileSystem.list(f);
}
public static boolean nativeFileExists(String path) {
- return getFileSystem().getBooleanAttributes(new File(path)) != 0;
+ return nativeFileSystem.getBooleanAttributes(new File(path)) != 0;
}
public static boolean nativeDelete(File f) {
- return getFileSystem().delete(f);
+ return nativeFileSystem.delete(f);
}
/*
--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/libbluray-devel/attachments/20150224/c7a17109/attachment.html>
More information about the libbluray-devel
mailing list