8194746: (fs) Add equivalents of Paths.get to Path interface
Summary: Copy Paths.get() methods to Path.get() methods and have former call latter
Reviewed-by: alanb, forax, chegar, psandoz
--- a/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystemProvider.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystemProvider.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -103,8 +103,8 @@
@Override
FileTypeDetector getFileTypeDetector() {
String userHome = GetPropertyAction.privilegedGetProperty("user.home");
- Path userMimeTypes = Paths.get(userHome, ".mime.types");
- Path etcMimeTypes = Paths.get("/etc/mime.types");
+ Path userMimeTypes = Path.of(userHome, ".mime.types");
+ Path etcMimeTypes = Path.of("/etc/mime.types");
return chain(new MimeTypesFileTypeDetector(userMimeTypes),
new MimeTypesFileTypeDetector(etcMimeTypes));
--- a/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystemProvider.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystemProvider.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -26,7 +26,6 @@
package sun.nio.fs;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.nio.file.spi.FileTypeDetector;
import sun.security.action.GetPropertyAction;
@@ -46,7 +45,7 @@
@Override
FileTypeDetector getFileTypeDetector() {
- Path userMimeTypes = Paths.get(GetPropertyAction
+ Path userMimeTypes = Path.of(GetPropertyAction
.privilegedGetProperty("user.home"), ".mime.types");
return chain(new MimeTypesFileTypeDetector(userMimeTypes),
--- a/src/java.base/share/classes/java/lang/invoke/ProxyClassesDumper.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/ProxyClassesDumper.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -30,7 +30,6 @@
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Objects;
@@ -63,7 +62,7 @@
}
try {
path = path.trim();
- final Path dir = Paths.get(path.length() == 0 ? "." : path);
+ final Path dir = Path.of(path.length() == 0 ? "." : path);
AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Void run() {
--- a/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -34,7 +34,6 @@
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
@@ -346,11 +345,11 @@
int i = name.lastIndexOf('.');
Path path;
if (i > 0) {
- Path dir = Paths.get(name.substring(0, i).replace('.', File.separatorChar));
+ Path dir = Path.of(name.substring(0, i).replace('.', File.separatorChar));
Files.createDirectories(dir);
path = dir.resolve(name.substring(i+1, name.length()) + ".class");
} else {
- path = Paths.get(name + ".class");
+ path = Path.of(name + ".class");
}
Files.write(path, classFile);
return null;
--- a/src/java.base/share/classes/java/nio/file/Path.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/java/nio/file/Path.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -28,6 +28,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URI;
+import java.nio.file.spi.FileSystemProvider;
import java.util.Iterator;
import java.util.NoSuchElementException;
@@ -93,13 +94,125 @@
* multiple concurrent threads.
*
* @since 1.7
- * @see Paths
*/
public interface Path
extends Comparable<Path>, Iterable<Path>, Watchable
{
/**
+ * Returns a {@code Path} by converting a path string, or a sequence of
+ * strings that when joined form a path string. If {@code more} does not
+ * specify any elements then the value of the {@code first} parameter is
+ * the path string to convert. If {@code more} specifies one or more
+ * elements then each non-empty string, including {@code first}, is
+ * considered to be a sequence of name elements and is joined to form a
+ * path string. The details as to how the Strings are joined is provider
+ * specific but typically they will be joined using the
+ * {@link FileSystem#getSeparator name-separator} as the separator.
+ * For example, if the name separator is "{@code /}" and
+ * {@code getPath("/foo","bar","gus")} is invoked, then the path string
+ * {@code "/foo/bar/gus"} is converted to a {@code Path}. A {@code Path}
+ * representing an empty path is returned if {@code first} is the empty
+ * string and {@code more} does not contain any non-empty strings.
+ *
+ * <p> The {@code Path} is obtained by invoking the {@link FileSystem#getPath
+ * getPath} method of the {@link FileSystems#getDefault default} {@link
+ * FileSystem}.
+ *
+ * <p> Note that while this method is very convenient, using it will imply
+ * an assumed reference to the default {@code FileSystem} and limit the
+ * utility of the calling code. Hence it should not be used in library code
+ * intended for flexible reuse. A more flexible alternative is to use an
+ * existing {@code Path} instance as an anchor, such as:
+ * <pre>{@code
+ * Path dir = ...
+ * Path path = dir.resolve("file");
+ * }</pre>
+ *
+ * @param first
+ * the path string or initial part of the path string
+ * @param more
+ * additional strings to be joined to form the path string
+ *
+ * @return the resulting {@code Path}
+ *
+ * @throws InvalidPathException
+ * if the path string cannot be converted to a {@code Path}
+ *
+ * @see FileSystem#getPath
+ *
+ * @since 11
+ */
+ public static Path of(String first, String... more) {
+ return FileSystems.getDefault().getPath(first, more);
+ }
+
+ /**
+ * Returns a {@code Path} by converting a URI.
+ *
+ * <p> This method iterates over the {@link FileSystemProvider#installedProviders()
+ * installed} providers to locate the provider that is identified by the
+ * URI {@link URI#getScheme scheme} of the given URI. URI schemes are
+ * compared without regard to case. If the provider is found then its {@link
+ * FileSystemProvider#getPath getPath} method is invoked to convert the
+ * URI.
+ *
+ * <p> In the case of the default provider, identified by the URI scheme
+ * "file", the given URI has a non-empty path component, and undefined query
+ * and fragment components. Whether the authority component may be present
+ * is platform specific. The returned {@code Path} is associated with the
+ * {@link FileSystems#getDefault default} file system.
+ *
+ * <p> The default provider provides a similar <em>round-trip</em> guarantee
+ * to the {@link java.io.File} class. For a given {@code Path} <i>p</i> it
+ * is guaranteed that
+ * <blockquote>{@code
+ * Path.of(}<i>p</i>{@code .}{@link Path#toUri() toUri}{@code ()).equals(}
+ * <i>p</i>{@code .}{@link Path#toAbsolutePath() toAbsolutePath}{@code ())}
+ * </blockquote>
+ * so long as the original {@code Path}, the {@code URI}, and the new {@code
+ * Path} are all created in (possibly different invocations of) the same
+ * Java virtual machine. Whether other providers make any guarantees is
+ * provider specific and therefore unspecified.
+ *
+ * @param uri
+ * the URI to convert
+ *
+ * @return the resulting {@code Path}
+ *
+ * @throws IllegalArgumentException
+ * if preconditions on the {@code uri} parameter do not hold. The
+ * format of the URI is provider specific.
+ * @throws FileSystemNotFoundException
+ * The file system, identified by the URI, does not exist and
+ * cannot be created automatically, or the provider identified by
+ * the URI's scheme component is not installed
+ * @throws SecurityException
+ * if a security manager is installed and it denies an unspecified
+ * permission to access the file system
+ *
+ * @since 11
+ */
+ public static Path of(URI uri) {
+ String scheme = uri.getScheme();
+ if (scheme == null)
+ throw new IllegalArgumentException("Missing scheme");
+
+ // check for default provider to avoid loading of installed providers
+ if (scheme.equalsIgnoreCase("file"))
+ return FileSystems.getDefault().provider().getPath(uri);
+
+ // try to find provider
+ for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
+ if (provider.getScheme().equalsIgnoreCase(scheme)) {
+ return provider.getPath(uri);
+ }
+ }
+
+ throw new FileSystemNotFoundException("Provider \"" + scheme + "\" not installed");
+ }
+
+ /**
* Returns the file system that created this object.
*
* @return the file system that created this object
@@ -527,7 +640,7 @@
* to the {@link java.io.File} class. For a given {@code Path} <i>p</i> it
* is guaranteed that
* <blockquote>
- * {@link Paths#get(URI) Paths.get}{@code (}<i>p</i>{@code .toUri()).equals(}<i>p</i>
+ * {@link Path#of(URI) Path.of}{@code (}<i>p</i>{@code .toUri()).equals(}<i>p</i>
* {@code .}{@link #toAbsolutePath() toAbsolutePath}{@code ())}
* </blockquote>
* so long as the original {@code Path}, the {@code URI}, and the new {@code
--- a/src/java.base/share/classes/java/nio/file/Paths.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/java/nio/file/Paths.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -32,7 +32,13 @@
* This class consists exclusively of static methods that return a {@link Path}
* by converting a path string or {@link URI}.
*
+ * @apiNote
+ * It is recommended to obtain a {@code Path} via the {@code Path.of} methods
+ * instead of via the {@code get} methods defined in this class as this class
+ * may be deprecated in a future release.
+ *
* @since 1.7
+ * @see Path
*/
public final class Paths {
@@ -40,33 +46,11 @@
/**
* Converts a path string, or a sequence of strings that when joined form
- * a path string, to a {@code Path}. If {@code more} does not specify any
- * elements then the value of the {@code first} parameter is the path string
- * to convert. If {@code more} specifies one or more elements then each
- * non-empty string, including {@code first}, is considered to be a sequence
- * of name elements (see {@link Path}) and is joined to form a path string.
- * The details as to how the Strings are joined is provider specific but
- * typically they will be joined using the {@link FileSystem#getSeparator
- * name-separator} as the separator. For example, if the name separator is
- * "{@code /}" and {@code getPath("/foo","bar","gus")} is invoked, then the
- * path string {@code "/foo/bar/gus"} is converted to a {@code Path}.
- * A {@code Path} representing an empty path is returned if {@code first}
- * is the empty string and {@code more} does not contain any non-empty
- * strings.
+ * a path string, to a {@code Path}.
*
- * <p> The {@code Path} is obtained by invoking the {@link FileSystem#getPath
- * getPath} method of the {@link FileSystems#getDefault default} {@link
- * FileSystem}.
- *
- * <p> Note that while this method is very convenient, using it will imply
- * an assumed reference to the default {@code FileSystem} and limit the
- * utility of the calling code. Hence it should not be used in library code
- * intended for flexible reuse. A more flexible alternative is to use an
- * existing {@code Path} instance as an anchor, such as:
- * <pre>
- * Path dir = ...
- * Path path = dir.resolve("file");
- * </pre>
+ * @implSpec
+ * This method simply invokes {@link Path#of(String,String...)
+ * Path.of(String, String...)} with the given parameters.
*
* @param first
* the path string or initial part of the path string
@@ -79,38 +63,17 @@
* if the path string cannot be converted to a {@code Path}
*
* @see FileSystem#getPath
+ * @see Path#of(String,String...)
*/
public static Path get(String first, String... more) {
- return FileSystems.getDefault().getPath(first, more);
+ return Path.of(first, more);
}
/**
* Converts the given URI to a {@link Path} object.
*
- * <p> This method iterates over the {@link FileSystemProvider#installedProviders()
- * installed} providers to locate the provider that is identified by the
- * URI {@link URI#getScheme scheme} of the given URI. URI schemes are
- * compared without regard to case. If the provider is found then its {@link
- * FileSystemProvider#getPath getPath} method is invoked to convert the
- * URI.
- *
- * <p> In the case of the default provider, identified by the URI scheme
- * "file", the given URI has a non-empty path component, and undefined query
- * and fragment components. Whether the authority component may be present
- * is platform specific. The returned {@code Path} is associated with the
- * {@link FileSystems#getDefault default} file system.
- *
- * <p> The default provider provides a similar <em>round-trip</em> guarantee
- * to the {@link java.io.File} class. For a given {@code Path} <i>p</i> it
- * is guaranteed that
- * <blockquote>{@code
- * Paths.get(}<i>p</i>{@code .}{@link Path#toUri() toUri}{@code ()).equals(}
- * <i>p</i>{@code .}{@link Path#toAbsolutePath() toAbsolutePath}{@code ())}
- * </blockquote>
- * so long as the original {@code Path}, the {@code URI}, and the new {@code
- * Path} are all created in (possibly different invocations of) the same
- * Java virtual machine. Whether other providers make any guarantees is
- * provider specific and therefore unspecified.
+ * @implSpec
+ * This method simply invokes {@link Path#of(URI) * Path.of(URI)} with the given parameter.
*
* @param uri
* the URI to convert
@@ -127,23 +90,10 @@
* @throws SecurityException
* if a security manager is installed and it denies an unspecified
* permission to access the file system
+ *
+ * @see Path#of(URI)
*/
public static Path get(URI uri) {
- String scheme = uri.getScheme();
- if (scheme == null)
- throw new IllegalArgumentException("Missing scheme");
-
- // check for default provider to avoid loading of installed providers
- if (scheme.equalsIgnoreCase("file"))
- return FileSystems.getDefault().provider().getPath(uri);
-
- // try to find provider
- for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
- if (provider.getScheme().equalsIgnoreCase(scheme)) {
- return provider.getPath(uri);
- }
- }
-
- throw new FileSystemNotFoundException("Provider \"" + scheme + "\" not installed");
+ return Path.of(uri);
}
}
--- a/src/java.base/share/classes/java/nio/file/TempFileHelper.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/java/nio/file/TempFileHelper.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -46,7 +46,7 @@
// temporary directory location
private static final Path tmpdir =
- Paths.get(GetPropertyAction.privilegedGetProperty("java.io.tmpdir"));
+ Path.of(GetPropertyAction.privilegedGetProperty("java.io.tmpdir"));
private static final boolean isPosix =
FileSystems.getDefault().supportedFileAttributeViews().contains("posix");
--- a/src/java.base/share/classes/java/util/Scanner.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/java/util/Scanner.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -2897,7 +2897,7 @@
* letters:
*
* <pre>{@code
- * try (Scanner sc = new Scanner(Paths.get("input.txt"))) {
+ * try (Scanner sc = new Scanner(Path.of("input.txt"))) {
* Pattern pat = Pattern.compile("[A-Z]{7,}");
* List<String> capWords = sc.findAll(pat)
* .map(MatchResult::group)
--- a/src/java.base/share/classes/jdk/internal/loader/BootLoader.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/jdk/internal/loader/BootLoader.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -32,7 +32,6 @@
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
@@ -243,8 +242,8 @@
mn = location.substring(5, location.length());
} else if (location.startsWith("file:/")) {
// named module in exploded image
- Path path = Paths.get(URI.create(location));
- Path modulesDir = Paths.get(JAVA_HOME, "modules");
+ Path path = Path.of(URI.create(location));
+ Path modulesDir = Path.of(JAVA_HOME, "modules");
if (path.startsWith(modulesDir)) {
mn = path.getFileName().toString();
}
@@ -267,7 +266,7 @@
private static URL toFileURL(String location) {
return AccessController.doPrivileged(new PrivilegedAction<>() {
public URL run() {
- Path path = Paths.get(location);
+ Path path = Path.of(location);
if (Files.isRegularFile(path)) {
try {
return path.toUri().toURL();
@@ -285,7 +284,7 @@
private static Manifest getManifest(String location) {
return AccessController.doPrivileged(new PrivilegedAction<>() {
public Manifest run() {
- Path jar = Paths.get(location);
+ Path jar = Path.of(location);
try (InputStream in = Files.newInputStream(jar);
JarInputStream jis = new JarInputStream(in, false)) {
return jis.getManifest();
--- a/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -28,7 +28,7 @@
import java.io.IOException;
import java.net.URL;
import java.nio.file.InvalidPathException;
-import java.nio.file.Paths;
+import java.nio.file.Path;
import java.security.CodeSource;
import java.security.PermissionCollection;
import java.util.jar.Manifest;
@@ -223,7 +223,7 @@
// Use an intermediate File object to construct a URI/URL without
// authority component as URLClassPath can't handle URLs with a UNC
// server name in the authority component.
- return Paths.get(s).toRealPath().toFile().toURI().toURL();
+ return Path.of(s).toRealPath().toFile().toURI().toURL();
} catch (InvalidPathException | IOException ignore) {
// malformed path string or class path element does not exist
return null;
--- a/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -34,7 +34,6 @@
import java.lang.module.ResolvedModule;
import java.net.URI;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -539,7 +538,7 @@
Path[] paths = new Path[dirs.length];
int i = 0;
for (String dir: dirs) {
- paths[i++] = Paths.get(dir);
+ paths[i++] = Path.of(dir);
}
return ModulePath.of(patcher, paths);
}
--- a/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -30,7 +30,6 @@
import java.lang.module.ResolvedModule;
import java.net.URI;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayDeque;
import java.util.Collections;
import java.util.Deque;
@@ -129,7 +128,7 @@
() -> new InternalError("Selected module " + name + " not on module path"));
URI uri = rm.reference().location().get();
- Path path = Paths.get(uri);
+ Path path = Path.of(uri);
String fn = path.getFileName().toString();
if (!fn.endsWith(".jar") && !fn.endsWith(".jmod")) {
throw new UnsupportedOperationException(path + " is not a modular JAR or jmod file");
--- a/src/java.base/share/classes/jdk/internal/module/ModulePath.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/jdk/internal/module/ModulePath.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -43,7 +43,6 @@
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Collections;
@@ -360,7 +359,7 @@
URI uri = mref.location().orElse(null);
if (uri != null) {
if (uri.getScheme().equalsIgnoreCase("file")) {
- Path file = Paths.get(uri);
+ Path file = Path.of(uri);
return file.getFileName().toString();
} else {
return uri.toString();
--- a/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -38,7 +38,6 @@
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayDeque;
@@ -185,7 +184,7 @@
// probe to see if this is an images build
String home = System.getProperty("java.home");
- Path modules = Paths.get(home, "lib", "modules");
+ Path modules = Path.of(home, "lib", "modules");
if (Files.isRegularFile(modules)) {
if (USE_FAST_PATH) {
SystemModules systemModules = allSystemModules();
@@ -205,7 +204,7 @@
}
// exploded build (do not cache module finder)
- Path dir = Paths.get(home, "modules");
+ Path dir = Path.of(home, "modules");
if (!Files.isDirectory(dir))
throw new InternalError("Unable to detect the run-time image");
ModuleFinder f = ModulePath.of(ModuleBootstrap.patcher(), dir);
--- a/src/java.base/share/classes/sun/security/provider/PolicyFile.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/sun/security/provider/PolicyFile.java Thu Mar 22 12:30:47 2018 -0700
@@ -30,7 +30,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URI;
-import java.nio.file.Paths;
+import java.nio.file.Path;
import java.util.*;
import java.security.*;
import java.security.cert.Certificate;
@@ -278,7 +278,7 @@
public URL run() {
String sep = File.separator;
try {
- return Paths.get(System.getProperty("java.home"),
+ return Path.of(System.getProperty("java.home"),
"lib", "security",
"default.policy").toUri().toURL();
} catch (MalformedURLException mue) {
--- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java Thu Mar 22 12:30:47 2018 -0700
@@ -27,7 +27,7 @@
import java.io.*;
import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.nio.file.Path;
import java.security.CodeSigner;
import java.security.CryptoPrimitive;
import java.security.KeyStore;
@@ -2189,7 +2189,7 @@
inplaceBackupName = srcksfname + ".old" + (n == 1 ? "" : n);
File bkFile = new File(inplaceBackupName);
if (!bkFile.exists()) {
- Files.copy(Paths.get(srcksfname), bkFile.toPath());
+ Files.copy(Path.of(srcksfname), bkFile.toPath());
break;
}
}
--- a/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -84,9 +84,9 @@
@Override
FileTypeDetector getFileTypeDetector() {
- Path userMimeTypes = Paths.get(
+ Path userMimeTypes = Path.of(
GetPropertyAction.privilegedGetProperty("user.home"), ".mime.types");
- Path etcMimeTypes = Paths.get("/etc/mime.types");
+ Path etcMimeTypes = Path.of("/etc/mime.types");
return chain(new MimeTypesFileTypeDetector(userMimeTypes),
new MimeTypesFileTypeDetector(etcMimeTypes));
--- a/src/java.base/unix/classes/sun/nio/fs/UnixFileStore.java Thu Mar 22 12:29:52 2018 -0700
+++ b/src/java.base/unix/classes/sun/nio/fs/UnixFileStore.java Thu Mar 22 12:30:47 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -260,7 +260,7 @@
private static Properties loadProperties() {
Properties result = new Properties();
String fstypes = System.getProperty("java.home") + "/lib/fstypes.properties";
- Path file = Paths.get(fstypes);
+ Path file = Path.of(fstypes);
try {
try (ReadableByteChannel rbc = Files.newByteChannel(file)) {
result.load(Channels.newReader(rbc, "UTF-8"));