< 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

*** 1,7 **** /* ! * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 35,44 **** --- 35,45 ---- import java.util.Map; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; import jdk.internal.misc.VM; + import sun.nio.fs.DefaultFileSystemProvider; /** * 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 --- 87,96 ----
*** 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); --- 107,118 ---- return provider.getFileSystem(URI.create("file:///")); } // returns default provider private static FileSystemProvider getDefaultProvider() { ! // start with the platform's default file system provider ! FileSystemProvider provider = DefaultFileSystemProvider.instance(); // 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,190 ---- */ public static FileSystem getDefault() { if (VM.isModuleSystemInited()) { return DefaultFileSystemHolder.defaultFileSystem; } else { ! // always use the platform's default file system during startup ! return DefaultFileSystemProvider.theFileSystem(); } } /** * Returns a reference to an existing {@code FileSystem}.
< prev index next >