Replacing default FileSystemProvider

Michael Hall mik3hall at gmail.com
Fri Mar 26 02:25:30 UTC 2021



> On Mar 25, 2021, at 7:20 AM, Michael Hall <mik3hall at gmail.com> wrote:
> 
> 
> 
>> On Mar 25, 2021, at 6:40 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
>> 
>> On 24/03/2021 14:06, Michael Hall wrote:
>>> :
>>> 
>>> Double checking the bug report seems to show that jar or modular jar are the only not exploded options(?) I was hoping for a workaround that didn’t require exploded but for now I guess I’ll settle for that.
>>> 
>> I think the bug is specified to the case that the default file system provider is deployed in a JAR file on the class path. Hopefully that will be fixed soon. The other cases, where the default file system provider is exploded on the class path, or deployed as a module on the module path (exploded or modular JAR) should not be impacted by the bug.
>> 
>> -Alan
> 
> It seemed to occur for me with a modular jar. But I haven’t done anything modular yet so may not of done it correctly. I will look further into the test cases you indicated. Otherwise I will watch the bug for resolution.
> 
> Thanks again for the time. 

Possibly of additional interest. 

Partly out of curiosity and partly because I often test from there I tried to make my default FileSystemProvider available to an OS/X application.
I modified the .cfg file to include the -Djava.nio.file.spi.DefaultFileSystemProvider parm, added $APPDIR as a class path entry, and included the exploded classes.

Starting up includes a console that shows the error...

Caused by: java.lang.ClassCastException: class us.hall.trz.osx.MacPath cannot be cast to class sun.nio.fs.UnixPath (us.hall.trz.osx.MacPath is in unnamed module of loader 'app'; sun.nio.fs.UnixPath is in module java.base of loader 'bootstrap')
	at java.base/sun.nio.fs.UnixPath.compareTo(Unknown Source)
	at java.base/javax.crypto.JceSecurity.setupJurisdictionPolicies(Unknown Source)
	at java.base/javax.crypto.JceSecurity$1.run(Unknown Source)
	at java.base/javax.crypto.JceSecurity$1.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	... 38 more

My own MacPath class has…
    @Override
    public int compareTo(Path other) {
    	if (other instanceof MacPath)
    		return proxy.compareTo(((MacPath)other).proxy);
    	return proxy.compareTo(other);
    }
Trying to passthrough defer everything to the platform proxy instance. Maybe for Path that is Unix if the Mac doesn’t have it’s own Path class. I’m not sure how the Unix provider gets involved although the Mac might extend that.
This came out of startup. I have not made any direct attempt to use any FileServer functionality at this point.
 



More information about the nio-dev mailing list