Circular loading of installed providers detected

Alan Bateman Alan.Bateman at oracle.com
Wed Sep 29 19:02:00 UTC 2021


On 29/09/2021 18:28, Michael Hall wrote:
> I have a FileSystemProvider with something like…
>
>     public MacFileSystemProvider() {
>      	List<FileSystemProvider> providers = FileSystemProvider.installedProviders();
>      	for (FileSystemProvider provider : providers) {
>
> To search for the platform ‘file’ scheme provider to set as it’s priorProvider.
>
> I was trying to launch code that apparently attemps to reinstantiate a new no args instance (JShell via API)
> getting…
>
> Caused by: java.lang.Error: Circular loading of installed providers detected
> 	at java.base/java.nio.file.spi.FileSystemProvider.installedProviders(Unknown Source)
> 	at us.hall.trz.osx.MacFileSystemProvider.<init>(MacFileSystemProvider.java:41)
> 	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>>
> This isn’t really circular it is just being done a second time.
>
> Should it be up to installedProviders() to know it has already been done and return what it already loaded?
>
> Or should my code handle this probably by changing it’s saved priorProvider to static and not trying to set it again if it is not null?
>
If you change the public constructor to have a FileSystemProvider 
parameter then it will be called with a reference to the built-in 
provider. That should avoid the need to iterated through the installed 
providers.

-Alan.


More information about the nio-dev mailing list