< prev index next >

src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java

Print this page
8213406: (fs) More than one instance of built-in FileSystem observed in heap
Reviewed-by: alanb, cushon, weijun
   1 /*
   2  * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  25 
  26 package sun.nio.fs;
  27 
  28 import java.nio.file.*;
  29 import java.nio.file.attribute.*;
  30 import java.nio.channels.*;
  31 import java.net.URI;
  32 import java.util.concurrent.ExecutorService;
  33 import java.io.*;
  34 import java.util.*;
  35 import java.security.AccessController;
  36 import jdk.internal.misc.Unsafe;
  37 import jdk.internal.util.StaticProperty;
  38 import sun.nio.ch.ThreadPool;
  39 import sun.security.util.SecurityConstants;
  40 
  41 import static sun.nio.fs.WindowsNativeDispatcher.*;
  42 import static sun.nio.fs.WindowsSecurity.*;
  43 import static sun.nio.fs.WindowsConstants.*;
  44 
  45 public class WindowsFileSystemProvider
  46     extends AbstractFileSystemProvider
  47 {
  48     private static final Unsafe unsafe = Unsafe.getUnsafe();
  49 
  50     private final WindowsFileSystem theFileSystem;
  51 
  52     public WindowsFileSystemProvider() {
  53         theFileSystem = new WindowsFileSystem(this, StaticProperty.userDir());




  54     }
  55 
  56     @Override
  57     public String getScheme() {
  58         return "file";
  59     }
  60 
  61     private void checkUri(URI uri) {
  62         if (!uri.getScheme().equalsIgnoreCase(getScheme()))
  63             throw new IllegalArgumentException("URI does not match this provider");
  64         if (uri.getRawAuthority() != null)
  65             throw new IllegalArgumentException("Authority component present");
  66         String path = uri.getPath();
  67         if (path == null)
  68             throw new IllegalArgumentException("Path component is undefined");
  69         if (!path.equals("/"))
  70             throw new IllegalArgumentException("Path component should be '/'");
  71         if (uri.getRawQuery() != null)
  72             throw new IllegalArgumentException("Query component present");
  73         if (uri.getRawFragment() != null)


   1 /*
   2  * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  25 
  26 package sun.nio.fs;
  27 
  28 import java.nio.file.*;
  29 import java.nio.file.attribute.*;
  30 import java.nio.channels.*;
  31 import java.net.URI;
  32 import java.util.concurrent.ExecutorService;
  33 import java.io.*;
  34 import java.util.*;
  35 import java.security.AccessController;
  36 import jdk.internal.misc.Unsafe;
  37 import jdk.internal.util.StaticProperty;
  38 import sun.nio.ch.ThreadPool;
  39 import sun.security.util.SecurityConstants;
  40 
  41 import static sun.nio.fs.WindowsNativeDispatcher.*;
  42 import static sun.nio.fs.WindowsSecurity.*;
  43 import static sun.nio.fs.WindowsConstants.*;
  44 
  45 class WindowsFileSystemProvider
  46     extends AbstractFileSystemProvider
  47 {
  48     private static final Unsafe unsafe = Unsafe.getUnsafe();
  49 
  50     private final WindowsFileSystem theFileSystem;
  51 
  52     public WindowsFileSystemProvider() {
  53         theFileSystem = new WindowsFileSystem(this, StaticProperty.userDir());
  54     }
  55 
  56     WindowsFileSystem theFileSystem() {
  57         return theFileSystem;
  58     }
  59 
  60     @Override
  61     public String getScheme() {
  62         return "file";
  63     }
  64 
  65     private void checkUri(URI uri) {
  66         if (!uri.getScheme().equalsIgnoreCase(getScheme()))
  67             throw new IllegalArgumentException("URI does not match this provider");
  68         if (uri.getRawAuthority() != null)
  69             throw new IllegalArgumentException("Authority component present");
  70         String path = uri.getPath();
  71         if (path == null)
  72             throw new IllegalArgumentException("Path component is undefined");
  73         if (!path.equals("/"))
  74             throw new IllegalArgumentException("Path component should be '/'");
  75         if (uri.getRawQuery() != null)
  76             throw new IllegalArgumentException("Query component present");
  77         if (uri.getRawFragment() != null)


< prev index next >