< prev index next >

src/java.base/share/classes/java/nio/file/FileSystems.java

Print this page
8213406: (fs) More than one instance of built-in FileSystem observed in heap
Reviewed-by: alanb, cushon, weijun

*** 35,44 **** --- 35,46 ---- import java.util.Map; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; import jdk.internal.misc.VM; + import static sun.nio.fs.BuiltinFileSystemProvider.BUILTIN_FILE_SYSTEM; + import static sun.nio.fs.BuiltinFileSystemProvider.BUILTIN_FILE_SYSTEM_PROVIDER; /** * Factory methods for file systems. This class defines the {@link #getDefault * getDefault} method to get the default file system and factory methods to * construct other types of file systems.
*** 86,105 **** */ public final class FileSystems { private FileSystems() { } - // Built-in file system provider - private static final FileSystemProvider builtinFileSystemProvider = - sun.nio.fs.DefaultFileSystemProvider.create(); - - // built-in file system - private static class BuiltinFileSystemHolder { - static final FileSystem builtinFileSystem = - builtinFileSystemProvider.getFileSystem(URI.create("file:///")); - } - // lazy initialization of default file system private static class DefaultFileSystemHolder { static final FileSystem defaultFileSystem = defaultFileSystem(); // returns default file system --- 88,97 ----
*** 116,126 **** return provider.getFileSystem(URI.create("file:///")); } // returns default provider private static FileSystemProvider getDefaultProvider() { ! FileSystemProvider provider = builtinFileSystemProvider; // if the property java.nio.file.spi.DefaultFileSystemProvider is // set then its value is the name of the default provider (or a list) String prop = "java.nio.file.spi.DefaultFileSystemProvider"; String propValue = System.getProperty(prop); --- 108,118 ---- return provider.getFileSystem(URI.create("file:///")); } // returns default provider private static FileSystemProvider getDefaultProvider() { ! FileSystemProvider provider = BUILTIN_FILE_SYSTEM_PROVIDER; // if the property java.nio.file.spi.DefaultFileSystemProvider is // set then its value is the name of the default provider (or a list) String prop = "java.nio.file.spi.DefaultFileSystemProvider"; String propValue = System.getProperty(prop);
*** 187,197 **** */ public static FileSystem getDefault() { if (VM.isModuleSystemInited()) { return DefaultFileSystemHolder.defaultFileSystem; } else { ! return BuiltinFileSystemHolder.builtinFileSystem; } } /** * Returns a reference to an existing {@code FileSystem}. --- 179,189 ---- */ public static FileSystem getDefault() { if (VM.isModuleSystemInited()) { return DefaultFileSystemHolder.defaultFileSystem; } else { ! return BUILTIN_FILE_SYSTEM; } } /** * Returns a reference to an existing {@code FileSystem}.
< prev index next >