Replacing default FileSystemProvider
Brian Burkhalter
brian.burkhalter at oracle.com
Fri Mar 19 20:53:24 UTC 2021
This is the correct forum.
I would have to investigate this to give you an answer. Certainly Alan will have something to write but as he is in Europe I doubt it will be today.
If this thread is not resolved before then, I will look into this on Monday.
> On Mar 19, 2021, at 1:11 PM, Michael Hall <mik3hall at gmail.com> wrote:
>
> This may not be the correct forum to ask about this. If I should try posting to StackOverflow or elsewhere that’s fine if you indicate that.
>
> I wrote a Mac specific FileSystemProvider sometime back that replaced the default, prior to Java 9 modular.I get exceptions shortened to ones that follow at the end. I shortened that to as simple a test case as possible.
>
> public class Test {
>
> public static void main(String [] args) {
> System.out.println(FileSystems.getDefault());
> }
>
> }
>
> class TestProvider extends FileSystemProvider {
> private final FileSystemProvider priorProvider;
> private static final String scheme = "file”;
>
> …
>
> }
>
> Which gets the same exceptions. I’ve noticed there were similar issues with getDefault() returning null about the time of Java 9 modular.
> Are any of these issues still open? Is there anything different that should be done now? Is there any documentation I should look at?
>
> The exceptions…
>
> java -cp test.jar -Djava.nio.file.spi.DefaultFileSystemProvider=org.test.TestProvider -d . Test.java
> Exception in thread "main" java.lang.Error: java.lang.NullPointerException: Cannot invoke "java.nio.file.FileSystem.getPath(String, String[])" because the return value of "java.nio.file.FileSystems.getDefault()" is null
> at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.getDefaultProvider(FileSystems.java:133)
> at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder$1.run(FileSystems.java:102)
> at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder$1.run(FileSystems.java:100)
>
> Both the old code and the simpler test case seem to get these in pairs.
>
> Caused by: java.lang.NullPointerException: Cannot invoke "java.nio.file.FileSystem.getPath(String, String[])" because the return value of "java.nio.file.FileSystems.getDefault()" is null
> at java.base/java.io.File.toPath(File.java:2316)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20210319/4e95dcfa/attachment-0001.htm>
More information about the nio-dev
mailing list