Why does Path check for the Default FileSystem?

Michael Hall mik3hall at gmail.com
Tue Mar 23 18:57:12 UTC 2021



> On Mar 23, 2021, at 12:44 PM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> 
> On 23/03/2021 13:47, Michael Hall wrote:
>> :
>> My Default Path class has…
>> 
>>     @Override
>>     public final File toFile() {
>>     	return proxy.toFile();
>>     }
>> 
> This will delegate to the built-in provider's toFile that will not match the default file system. If you remove the override of toFile then I would expect it should work.
> 
> -Alan

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?

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


More information about the nio-dev mailing list