On Mon, 8 Jun 2026 14:19:38 GMT, Dusan Balek <[email protected]> wrote:

> Automatic cleanup on FileSystem::close could be problematic. Consider the 
> following code snippet:
> 
> ```
> FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"), 
> Map.of("java.home", targetJavaHome));
> FileSystemProvider provider = fs.provider();
> fs.close(); // URLClassLoader is closed automatically now
> ...
> FileSystem newFs = provider.newFileSystem(URI.create("jrt:/"), Map.of());
> // Now any call to newFs instance that require additional class loading 
> crashes
> ```

Ah my mistake, it creates a ClassLoader for each jrt provider, not each jrt 
file system. So you are right, the close delegate to the URLClassLoader.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/31417#issuecomment-4650074065

Reply via email to