[libbluray-devel] BDJ: fix setting File.fs in Java 8 (File.fs is declared final)

hpi1 git at videolan.org
Sun May 4 16:52:26 CEST 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sun May  4 17:09:11 2014 +0300| [e897820373257e4a3d4e0c5210018687955dc33a] | committer: hpi1

BDJ: fix setting File.fs in Java 8 (File.fs is declared final)

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

 src/libbluray/bdj/java/java/io/BDFileSystem.java |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/libbluray/bdj/java/java/io/BDFileSystem.java b/src/libbluray/bdj/java/java/io/BDFileSystem.java
index e99d9d0..2438145 100644
--- a/src/libbluray/bdj/java/java/io/BDFileSystem.java
+++ b/src/libbluray/bdj/java/java/io/BDFileSystem.java
@@ -29,6 +29,7 @@ package java.io;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 
 import java.net.URL;
 
@@ -47,6 +48,11 @@ public abstract class BDFileSystem extends FileSystem {
             filesystem = c.getDeclaredField("fs");
             filesystem.setAccessible(true);
 
+            /* Java 8: remove "final" modifier from the field */
+            Field modifiersField = Field.class.getDeclaredField("modifiers");
+            modifiersField.setAccessible(true);
+            modifiersField.setInt(filesystem, filesystem.getModifiers() & ~Modifier.FINAL);
+
             FileSystem fs = (FileSystem)filesystem.get(null);
             if (fs instanceof BDFileSystemImpl) {
                 //System.err.print("FileSystem already wrapped");



More information about the libbluray-devel mailing list