Replacing default FileSystemProvider
Michael Hall
mik3hall at gmail.com
Sun Mar 21 10:04:05 UTC 2021
> On Mar 21, 2021, at 4:15 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
>
> On 21/03/2021 08:35, Michael Hall wrote:
>> :
>>
>> So far I haven’t been able to duplicate the error with the simple test case. The error does appear to begin right after 1.8 at java 9.
>>
>> It seems similar to these issues…
>> https://bugs.openjdk.java.net/browse/JDK-8058876 <https://bugs.openjdk.java.net/browse/JDK-8058876>. Overriding the default file system provider fails with a modular image
>> https://bugs.openjdk.java.net/browse/JDK-8059939 <https://bugs.openjdk.java.net/browse/JDK-8059939>. java/nio/file/spi/SetDefaultProvider.java fails with modular image
>>
> Those issues were in the jigsaw repo so didn't impact any GA release.
>
> That said, there has been refactoring in this area since JDK 8 in order to allow access to the file system during VM initialization. This all happens before a custom file system provider is located and set. So are you saying that the NPE started with JDK 9 or a more recent release? We have tests that exercise this mechanism so I would be surprised if there is something fundamentally broken. The only other thing that comes to mind is the zip/JAR code which has changed significantly in recent releases (the zip/JAR code needs to use the builtin file system provider when accessing the file system to load the custom file system provider). Finally, just to rule this out, your provider isn't making direct use of the sun.nio.* classes, right?
>
> -Alan
Starts at 9. 1.8 works
/usr/libexec/java_home -v 1.8 --exec java -cp .:outputdir/HalfPipe.app/Contents/app/macnio2.jar -Djava.library.path=outputdir/HalfPipe.app/Conents/app -Djava.nio.file.spi.DefaultFileSystemProvider=us.hall.trz.osx.MacFileSystemProvider Test
class us.hall.trz.osx.MacFileSystem
Java 9 does not
(base) Michaels-MacBook-Pro:halfpipe_jpkg mjh$ /usr/libexec/java_home -v 9 --exec java -cp .:outputdir/HalfPipe.app/Contents/app/macnio2.jar -Djava.library.path=outputdir/HalfPipe.app/Conents/app -Djava.nio.file.spi.DefaultFileSystemProvider=us.hall.trz.osx.MacFileSystemProvider Test
Exception in thread "main" java.lang.Error: java.lang.NullPointerException
at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.getDefaultProvider(FileSystems.java:141)
at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.access$100(FileSystems.java:102)
at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder$1.run(FileSystems.java:111)
at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder$1.run(FileSystems.java:109)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.defaultFileSystem(FileSystems.java:109)
at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.<clinit>(FileSystems.java:103)
at java.base/java.nio.file.FileSystems.getDefault(FileSystems.java:190)
at Test.main(Test.java:6)
Caused by: java.lang.NullPointerException
at java.base/java.io.File.toPath(File.java:2300)
/usr/libexec/java_home -v 9 --exec java -version
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
The double NPE looks like the jigsaw issues I thought.
More information about the nio-dev
mailing list