Why does Path check for the Default FileSystem?

Michael Hall mik3hall at gmail.com
Wed Mar 24 10:35:11 UTC 2021



> On Mar 24, 2021, at 3:49 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> 
> On 23/03/2021 18:57, Michael Hall wrote:
>> :
>> 
>> No, that doesn’t do it either. It seems to get back to the ClassNotFoundException without the jar after getting into the Path code?
>> 
>> 	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)
>> 	at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
>> 	at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.defaultFileSystem(FileSystems.java:100)
>> 	at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.<clinit>(FileSystems.java:94)
>> 	at java.base/java.nio.file.FileSystems.getDefault(FileSystems.java:182)
>> 	at java.base/java.nio.file.Path.of(Path.java:147)
>> 	at java.base/java.nio.file.Paths.get(Paths.java:69)
>> 
>> Verbose class loading similar to before…
>> 
>> [0.035s][info][class,load] java.lang.SecurityException source: jrt:/java.base
>> Error: A JNI error has occurred, please check your installation and try again
>> Exception in thread "main" [0.035s][info][class,load] java.lang.Throwable$PrintStreamOrWriter source: jrt:/java.base
>> [0.035s][info][class,load] java.lang.Throwable$WrappedPrintStream source: jrt:/java.base
>> [0.035s][info][class,load] java.util.IdentityHashMap source: shared objects file
>> [0.035s][info][class,load] java.util.IdentityHashMap$KeySet source: shared objects file
>> java.lang.Error: java.lang.ClassNotFoundException: us.hall.trz.osx.MacFileSystemProvider
>> 
>> It would be nice if I knew the source of the SecurityException before it percolates out to the strange ClassNotFoundException’s
>> 
>> My question as to why does it need to be only the DefaultProvider still remains? That still seems to totally defeat passthrough.
>> 
>> https://docs.oracle.com/javase/8/docs/technotes/guides/io/fsp/filesystemprovider.html <https://docs.oracle.com/javase/8/docs/technotes/guides/io/fsp/filesystemprovider.html>
>> 	• Replacing or supplementing the default file system provider. The custom provider can augment the default provider by performing specific operations, such as logging all system operations, and delegate to the default provider for other routine operations.
>> 
>> This is what I am trying to do but the code doesn’t seem to allow delegating?
>> 
> I just tried the TestProvider that we have in the test tree and it works as the default file system provider when exploded on the file system (not packaged as a JAR file on the class path as thee is an issue there). I commented out the override of toFile() and it does the right thing. So I'm not 100% sure how you are running into an issue, I think we need something that reproduces it.
> 
> -Alan

I will try to look at it some more today but I do seem to be running into more problems. I tried modular jar, not sure if correctly, and it was the same situation. It wouldn’t work unless the classes are also exploded. Exploded I run into the Path toFile error. I am working with a test class written against my old provider. But if I can’t get anywhere there I can try to reproduce with the zip you included with the bug report.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20210324/bdb3269f/attachment-0001.htm>


More information about the nio-dev mailing list