提交 fb629b65 编写于 作者: O ohair

Merge

...@@ -102,3 +102,4 @@ ac311eb325bfc763698219252bf3cee9e091f3af jdk7-b122 ...@@ -102,3 +102,4 @@ ac311eb325bfc763698219252bf3cee9e091f3af jdk7-b122
0a56bdd709d01c1663047e55201d19152ffd3d69 jdk7-b125 0a56bdd709d01c1663047e55201d19152ffd3d69 jdk7-b125
8361ef97a0f90086c9048beaf7cea1a37216c4cd jdk7-b126 8361ef97a0f90086c9048beaf7cea1a37216c4cd jdk7-b126
29e09de1d0b4f84faea114cf10b3ec08b59acc4e jdk7-b127 29e09de1d0b4f84faea114cf10b3ec08b59acc4e jdk7-b127
f08682e23279d6cccbdcafda1eb0647ba4900874 jdk7-b128
...@@ -443,7 +443,6 @@ JAVA_JAVA_java = \ ...@@ -443,7 +443,6 @@ JAVA_JAVA_java = \
java/io/FileReader.java \ java/io/FileReader.java \
java/io/PipedReader.java \ java/io/PipedReader.java \
java/io/StringReader.java \ java/io/StringReader.java \
java/io/TempFileHelper.java \
java/io/Writer.java \ java/io/Writer.java \
java/io/BufferedWriter.java \ java/io/BufferedWriter.java \
java/io/PrintWriter.java \ java/io/PrintWriter.java \
......
...@@ -81,12 +81,12 @@ FILES_src = \ ...@@ -81,12 +81,12 @@ FILES_src = \
java/nio/file/ClosedDirectoryStreamException.java \ java/nio/file/ClosedDirectoryStreamException.java \
java/nio/file/ClosedFileSystemException.java \ java/nio/file/ClosedFileSystemException.java \
java/nio/file/ClosedWatchServiceException.java \ java/nio/file/ClosedWatchServiceException.java \
java/nio/file/CopyMoveHelper.java \
java/nio/file/CopyOption.java \ java/nio/file/CopyOption.java \
java/nio/file/DirectoryIteratorException.java \ java/nio/file/DirectoryIteratorException.java \
java/nio/file/DirectoryNotEmptyException.java \ java/nio/file/DirectoryNotEmptyException.java \
java/nio/file/DirectoryStream.java \ java/nio/file/DirectoryStream.java \
java/nio/file/FileAlreadyExistsException.java \ java/nio/file/FileAlreadyExistsException.java \
java/nio/file/FileRef.java \
java/nio/file/FileStore.java \ java/nio/file/FileStore.java \
java/nio/file/FileSystem.java \ java/nio/file/FileSystem.java \
java/nio/file/FileSystemAlreadyExistsException.java \ java/nio/file/FileSystemAlreadyExistsException.java \
...@@ -116,6 +116,7 @@ FILES_src = \ ...@@ -116,6 +116,7 @@ FILES_src = \
java/nio/file/StandardCopyOption.java \ java/nio/file/StandardCopyOption.java \
java/nio/file/StandardOpenOption.java \ java/nio/file/StandardOpenOption.java \
java/nio/file/StandardWatchEventKind.java \ java/nio/file/StandardWatchEventKind.java \
java/nio/file/TempFileHelper.java \
java/nio/file/WatchEvent.java \ java/nio/file/WatchEvent.java \
java/nio/file/WatchKey.java \ java/nio/file/WatchKey.java \
java/nio/file/WatchService.java \ java/nio/file/WatchService.java \
...@@ -127,7 +128,6 @@ FILES_src = \ ...@@ -127,7 +128,6 @@ FILES_src = \
java/nio/file/attribute/AclEntryType.java \ java/nio/file/attribute/AclEntryType.java \
java/nio/file/attribute/AclFileAttributeView.java \ java/nio/file/attribute/AclFileAttributeView.java \
java/nio/file/attribute/AttributeView.java \ java/nio/file/attribute/AttributeView.java \
java/nio/file/attribute/Attributes.java \
java/nio/file/attribute/BasicFileAttributeView.java \ java/nio/file/attribute/BasicFileAttributeView.java \
java/nio/file/attribute/BasicFileAttributes.java \ java/nio/file/attribute/BasicFileAttributes.java \
java/nio/file/attribute/DosFileAttributeView.java \ java/nio/file/attribute/DosFileAttributeView.java \
...@@ -136,8 +136,6 @@ FILES_src = \ ...@@ -136,8 +136,6 @@ FILES_src = \
java/nio/file/attribute/FileAttributeView.java \ java/nio/file/attribute/FileAttributeView.java \
java/nio/file/attribute/FileOwnerAttributeView.java \ java/nio/file/attribute/FileOwnerAttributeView.java \
java/nio/file/attribute/FileStoreAttributeView.java \ java/nio/file/attribute/FileStoreAttributeView.java \
java/nio/file/attribute/FileStoreSpaceAttributeView.java \
java/nio/file/attribute/FileStoreSpaceAttributes.java \
java/nio/file/attribute/FileTime.java \ java/nio/file/attribute/FileTime.java \
java/nio/file/attribute/GroupPrincipal.java \ java/nio/file/attribute/GroupPrincipal.java \
java/nio/file/attribute/UserDefinedFileAttributeView.java \ java/nio/file/attribute/UserDefinedFileAttributeView.java \
...@@ -246,6 +244,7 @@ FILES_src = \ ...@@ -246,6 +244,7 @@ FILES_src = \
sun/nio/fs/AbstractAclFileAttributeView.java \ sun/nio/fs/AbstractAclFileAttributeView.java \
sun/nio/fs/AbstractBasicFileAttributeView.java \ sun/nio/fs/AbstractBasicFileAttributeView.java \
sun/nio/fs/AbstractFileTypeDetector.java \ sun/nio/fs/AbstractFileTypeDetector.java \
sun/nio/fs/AbstractFileSystemProvider.java \
sun/nio/fs/AbstractPath.java \ sun/nio/fs/AbstractPath.java \
sun/nio/fs/AbstractPoller.java \ sun/nio/fs/AbstractPoller.java \
sun/nio/fs/AbstractUserDefinedFileAttributeView.java \ sun/nio/fs/AbstractUserDefinedFileAttributeView.java \
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--> -->
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2"> <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
<compilation-unit> <compilation-unit>
<package-root>${root}/src/share/classes</package-root> <package-root>${root}/src/share/classes</package-root>
<package-root>${root}/src/windows/classes</package-root> <package-root>${root}/src/windows/classes</package-root>
...@@ -39,6 +39,6 @@ ...@@ -39,6 +39,6 @@
<classpath mode="boot">${bootstrap.jdk}/jre/lib/rt.jar</classpath> <classpath mode="boot">${bootstrap.jdk}/jre/lib/rt.jar</classpath>
<built-to>${root}/build/${platform}-${arch}/classes</built-to> <built-to>${root}/build/${platform}-${arch}/classes</built-to>
<javadoc-built-to>${root}/build/javadoc/${name}</javadoc-built-to> <javadoc-built-to>${root}/build/javadoc/${name}</javadoc-built-to>
<source-level>1.5</source-level> <source-level>1.7</source-level>
</compilation-unit> </compilation-unit>
</java-data> </java-data>
...@@ -31,12 +31,12 @@ ...@@ -31,12 +31,12 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--> -->
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2"> <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
<compilation-unit> <compilation-unit>
<package-root>${root}/src/share/classes</package-root> <package-root>${root}/src/share/classes</package-root>
<classpath mode="boot">${bootstrap.jdk}/jre/lib/rt.jar</classpath> <classpath mode="boot">${bootstrap.jdk}/jre/lib/rt.jar</classpath>
<built-to>${root}/build/${platform}-${arch}/classes</built-to> <built-to>${root}/build/${platform}-${arch}/classes</built-to>
<javadoc-built-to>${root}/build/javadoc/${name}</javadoc-built-to> <javadoc-built-to>${root}/build/javadoc/${name}</javadoc-built-to>
<source-level>1.5</source-level> <source-level>1.7</source-level>
</compilation-unit> </compilation-unit>
</java-data> </java-data>
...@@ -244,6 +244,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */ ...@@ -244,6 +244,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */
for (i = 0; i < argc ; i++) { for (i = 0; i < argc ; i++) {
printf("argv[%d] = %s\n", i, argv[i]); printf("argv[%d] = %s\n", i, argv[i]);
} }
AddOption("-Dsun.java.launcher.diag=true", NULL);
} }
CreateExecutionEnvironment(&argc, &argv, CreateExecutionEnvironment(&argc, &argv,
...@@ -1009,6 +1010,8 @@ ParseArguments(int *pargc, char ***pargv, ...@@ -1009,6 +1010,8 @@ ParseArguments(int *pargc, char ***pargv,
} else if (JLI_StrCmp(arg, "-XshowSettings") == 0 || } else if (JLI_StrCmp(arg, "-XshowSettings") == 0 ||
JLI_StrCCmp(arg, "-XshowSettings:") == 0) { JLI_StrCCmp(arg, "-XshowSettings:") == 0) {
showSettings = arg; showSettings = arg;
} else if (JLI_StrCmp(arg, "-Xdiag") == 0) {
AddOption("-Dsun.java.launcher.diag=true", NULL);
/* /*
* The following case provide backward compatibility with old-style * The following case provide backward compatibility with old-style
* command line options. * command line options.
......
...@@ -656,14 +656,17 @@ public final class Connection implements Runnable { ...@@ -656,14 +656,17 @@ public final class Connection implements Runnable {
} }
nparent = notifyParent; nparent = notifyParent;
} }
} if (nparent) {
if (nparent) { LdapRequest ldr = pendingRequests;
LdapRequest ldr = pendingRequests; while (ldr != null) {
while (ldr != null) {
ldr.notify(); synchronized (ldr) {
ldr = ldr.next; ldr.notify();
ldr = ldr.next;
}
}
parent.processConnectionClosure();
} }
parent.processConnectionClosure();
} }
} }
......
...@@ -143,7 +143,7 @@ public class Continuation extends ResolveResult { ...@@ -143,7 +143,7 @@ public class Continuation extends ResolveResult {
e.setRemainingName(remainingName); e.setRemainingName(remainingName);
e.setResolvedObj(resolvedObj); e.setResolvedObj(resolvedObj);
if (starter == null) if (starter == null || starter.isEmpty())
e.setResolvedName(null); e.setResolvedName(null);
else if (remainingName == null) else if (remainingName == null)
e.setResolvedName(starter); e.setResolvedName(starter);
......
...@@ -54,6 +54,7 @@ package java.io; ...@@ -54,6 +54,7 @@ package java.io;
* *
* @see FileReader * @see FileReader
* @see InputStreamReader * @see InputStreamReader
* @see java.nio.file.Files#newBufferedReader
* *
* @author Mark Reinhold * @author Mark Reinhold
* @since JDK1.1 * @since JDK1.1
...@@ -374,6 +375,8 @@ public class BufferedReader extends Reader { ...@@ -374,6 +375,8 @@ public class BufferedReader extends Reader {
* stream has been reached * stream has been reached
* *
* @exception IOException If an I/O error occurs * @exception IOException If an I/O error occurs
*
* @see java.nio.file.Files#readAllLines
*/ */
public String readLine() throws IOException { public String readLine() throws IOException {
return readLine(false); return readLine(false);
......
...@@ -57,6 +57,7 @@ package java.io; ...@@ -57,6 +57,7 @@ package java.io;
* @see PrintWriter * @see PrintWriter
* @see FileWriter * @see FileWriter
* @see OutputStreamWriter * @see OutputStreamWriter
* @see java.nio.file.Files#newBufferedWriter
* *
* @author Mark Reinhold * @author Mark Reinhold
* @since JDK1.1 * @since JDK1.1
......
...@@ -35,8 +35,7 @@ import java.util.ArrayList; ...@@ -35,8 +35,7 @@ import java.util.ArrayList;
import java.security.AccessController; import java.security.AccessController;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.FileSystems;
import java.nio.file.attribute.FileAttribute;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
/** /**
...@@ -139,9 +138,10 @@ import sun.security.action.GetPropertyAction; ...@@ -139,9 +138,10 @@ import sun.security.action.GetPropertyAction;
* many of the limitations of the {@code java.io.File} class. * many of the limitations of the {@code java.io.File} class.
* The {@link #toPath toPath} method may be used to obtain a {@link * The {@link #toPath toPath} method may be used to obtain a {@link
* Path} that uses the abstract path represented by a {@code File} object to * Path} that uses the abstract path represented by a {@code File} object to
* locate a file. The resulting {@code Path} provides more efficient and * locate a file. The resulting {@code Path} may be used with the {@link
* extensive access to file attributes, additional file operations, and I/O * java.nio.file.Files} class to provide more efficient and extensive access to
* exceptions to help diagnose errors when an operation on a file fails. * additional file operations, file attributes, and I/O exceptions to help
* diagnose errors when an operation on a file fails.
* *
* @author unascribed * @author unascribed
* @since JDK1.0 * @since JDK1.0
...@@ -778,6 +778,12 @@ public class File ...@@ -778,6 +778,12 @@ public class File
* Tests whether the file denoted by this abstract pathname is a * Tests whether the file denoted by this abstract pathname is a
* directory. * directory.
* *
* <p> Where it is required to distinguish an I/O exception from the case
* that the file is not a directory, or where several attributes of the
* same file are required at the same time, then the {@link
* java.nio.file.Files#readAttributes(Path,Class,LinkOption[])
* Files.readAttributes} method may be used.
*
* @return <code>true</code> if and only if the file denoted by this * @return <code>true</code> if and only if the file denoted by this
* abstract pathname exists <em>and</em> is a directory; * abstract pathname exists <em>and</em> is a directory;
* <code>false</code> otherwise * <code>false</code> otherwise
...@@ -786,8 +792,6 @@ public class File ...@@ -786,8 +792,6 @@ public class File
* If a security manager exists and its <code>{@link * If a security manager exists and its <code>{@link
* java.lang.SecurityManager#checkRead(java.lang.String)}</code> * java.lang.SecurityManager#checkRead(java.lang.String)}</code>
* method denies read access to the file * method denies read access to the file
*
* @see java.nio.file.attribute.Attributes#readBasicFileAttributes
*/ */
public boolean isDirectory() { public boolean isDirectory() {
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
...@@ -804,6 +808,12 @@ public class File ...@@ -804,6 +808,12 @@ public class File
* addition, satisfies other system-dependent criteria. Any non-directory * addition, satisfies other system-dependent criteria. Any non-directory
* file created by a Java application is guaranteed to be a normal file. * file created by a Java application is guaranteed to be a normal file.
* *
* <p> Where it is required to distinguish an I/O exception from the case
* that the file is not a normal file, or where several attributes of the
* same file are required at the same time, then the {@link
* java.nio.file.Files#readAttributes(Path,Class,LinkOption[])
* Files.readAttributes} method may be used.
*
* @return <code>true</code> if and only if the file denoted by this * @return <code>true</code> if and only if the file denoted by this
* abstract pathname exists <em>and</em> is a normal file; * abstract pathname exists <em>and</em> is a normal file;
* <code>false</code> otherwise * <code>false</code> otherwise
...@@ -812,8 +822,6 @@ public class File ...@@ -812,8 +822,6 @@ public class File
* If a security manager exists and its <code>{@link * If a security manager exists and its <code>{@link
* java.lang.SecurityManager#checkRead(java.lang.String)}</code> * java.lang.SecurityManager#checkRead(java.lang.String)}</code>
* method denies read access to the file * method denies read access to the file
*
* @see java.nio.file.attribute.Attributes#readBasicFileAttributes
*/ */
public boolean isFile() { public boolean isFile() {
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
...@@ -853,6 +861,13 @@ public class File ...@@ -853,6 +861,13 @@ public class File
* Returns the time that the file denoted by this abstract pathname was * Returns the time that the file denoted by this abstract pathname was
* last modified. * last modified.
* *
* <p> Where it is required to distinguish an I/O exception from the case
* where {@code 0L} is returned, or where several attributes of the
* same file are required at the same time, or where the time of last
* access or the creation time are required, then the {@link
* java.nio.file.Files#readAttributes(Path,Class,LinkOption[])
* Files.readAttributes} method may be used.
*
* @return A <code>long</code> value representing the time the file was * @return A <code>long</code> value representing the time the file was
* last modified, measured in milliseconds since the epoch * last modified, measured in milliseconds since the epoch
* (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the * (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the
...@@ -862,8 +877,6 @@ public class File ...@@ -862,8 +877,6 @@ public class File
* If a security manager exists and its <code>{@link * If a security manager exists and its <code>{@link
* java.lang.SecurityManager#checkRead(java.lang.String)}</code> * java.lang.SecurityManager#checkRead(java.lang.String)}</code>
* method denies read access to the file * method denies read access to the file
*
* @see java.nio.file.attribute.Attributes#readBasicFileAttributes
*/ */
public long lastModified() { public long lastModified() {
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
...@@ -877,6 +890,12 @@ public class File ...@@ -877,6 +890,12 @@ public class File
* Returns the length of the file denoted by this abstract pathname. * Returns the length of the file denoted by this abstract pathname.
* The return value is unspecified if this pathname denotes a directory. * The return value is unspecified if this pathname denotes a directory.
* *
* <p> Where it is required to distinguish an I/O exception from the case
* that {@code 0L} is returned, or where several attributes of the same file
* are required at the same time, then the {@link
* java.nio.file.Files#readAttributes(Path,Class,LinkOption[])
* Files.readAttributes} method may be used.
*
* @return The length, in bytes, of the file denoted by this abstract * @return The length, in bytes, of the file denoted by this abstract
* pathname, or <code>0L</code> if the file does not exist. Some * pathname, or <code>0L</code> if the file does not exist. Some
* operating systems may return <code>0L</code> for pathnames * operating systems may return <code>0L</code> for pathnames
...@@ -886,8 +905,6 @@ public class File ...@@ -886,8 +905,6 @@ public class File
* If a security manager exists and its <code>{@link * If a security manager exists and its <code>{@link
* java.lang.SecurityManager#checkRead(java.lang.String)}</code> * java.lang.SecurityManager#checkRead(java.lang.String)}</code>
* method denies read access to the file * method denies read access to the file
*
* @see java.nio.file.attribute.Attributes#readBasicFileAttributes
*/ */
public long length() { public long length() {
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
...@@ -937,11 +954,10 @@ public class File ...@@ -937,11 +954,10 @@ public class File
* this pathname denotes a directory, then the directory must be empty in * this pathname denotes a directory, then the directory must be empty in
* order to be deleted. * order to be deleted.
* *
* <p> Note that the {@link Path} class defines the {@link Path#delete * <p> Note that the {@link java.nio.file.Files} class defines the {@link
* delete} method to throw an {@link IOException} when a file cannot be * java.nio.file.Files#delete(Path) delete} method to throw an {@link IOException}
* deleted. This is useful for error reporting and to diagnose why a file * when a file cannot be deleted. This is useful for error reporting and to
* cannot be deleted. The {@link #toPath toPath} method may be used to * diagnose why a file cannot be deleted.
* obtain a {@code Path} representing this abstract pathname.
* *
* @return <code>true</code> if and only if the file or directory is * @return <code>true</code> if and only if the file or directory is
* successfully deleted; <code>false</code> otherwise * successfully deleted; <code>false</code> otherwise
...@@ -1009,12 +1025,11 @@ public class File ...@@ -1009,12 +1025,11 @@ public class File
* will appear in any specific order; they are not, in particular, * will appear in any specific order; they are not, in particular,
* guaranteed to appear in alphabetical order. * guaranteed to appear in alphabetical order.
* *
* <p> Note that the {@link Path} class defines the {@link * <p> Note that the {@link java.nio.file.Files} class defines the {@link
* Path#newDirectoryStream newDirectoryStream} method to open a directory * java.nio.file.Files#newDirectoryStream(Path) newDirectoryStream} method to
* and iterate over the names of the files in the directory. This may use * open a directory and iterate over the names of the files in the directory.
* less resources when working with very large directories. The {@link * This may use less resources when working with very large directories, and
* #toPath toPath} method may be used to obtain a {@code Path} representing * may be more responsive when working with remote directories.
* this abstract pathname.
* *
* @return An array of strings naming the files and directories in the * @return An array of strings naming the files and directories in the
* directory denoted by this abstract pathname. The array will be * directory denoted by this abstract pathname. The array will be
...@@ -1061,6 +1076,8 @@ public class File ...@@ -1061,6 +1076,8 @@ public class File
* If a security manager exists and its {@link * If a security manager exists and its {@link
* SecurityManager#checkRead(String)} method denies read access to * SecurityManager#checkRead(String)} method denies read access to
* the directory * the directory
*
* @see java.nio.file.Files#newDirectoryStream(Path,String)
*/ */
public String[] list(FilenameFilter filter) { public String[] list(FilenameFilter filter) {
String names[] = list(); String names[] = list();
...@@ -1095,12 +1112,11 @@ public class File ...@@ -1095,12 +1112,11 @@ public class File
* will appear in any specific order; they are not, in particular, * will appear in any specific order; they are not, in particular,
* guaranteed to appear in alphabetical order. * guaranteed to appear in alphabetical order.
* *
* <p> Note that the {@link Path} class defines the {@link * <p> Note that the {@link java.nio.file.Files} class defines the {@link
* Path#newDirectoryStream newDirectoryStream} method to open a directory * java.nio.file.Files#newDirectoryStream(Path) newDirectoryStream} method
* and iterate over the names of the files in the directory. This may use * to open a directory and iterate over the names of the files in the
* less resources when working with very large directories. The {@link * directory. This may use less resources when working with very large
* #toPath toPath} method may be used to obtain a {@code Path} representing * directories.
* this abstract pathname.
* *
* @return An array of abstract pathnames denoting the files and * @return An array of abstract pathnames denoting the files and
* directories in the directory denoted by this abstract pathname. * directories in the directory denoted by this abstract pathname.
...@@ -1154,6 +1170,7 @@ public class File ...@@ -1154,6 +1170,7 @@ public class File
* the directory * the directory
* *
* @since 1.2 * @since 1.2
* @see java.nio.file.Files#newDirectoryStream(Path,String)
*/ */
public File[] listFiles(FilenameFilter filter) { public File[] listFiles(FilenameFilter filter) {
String ss[] = list(); String ss[] = list();
...@@ -1191,6 +1208,7 @@ public class File ...@@ -1191,6 +1208,7 @@ public class File
* the directory * the directory
* *
* @since 1.2 * @since 1.2
* @see java.nio.file.Files#newDirectoryStream(Path,java.nio.file.DirectoryStream.Filter)
*/ */
public File[] listFiles(FileFilter filter) { public File[] listFiles(FileFilter filter) {
String ss[] = list(); String ss[] = list();
...@@ -1207,12 +1225,6 @@ public class File ...@@ -1207,12 +1225,6 @@ public class File
/** /**
* Creates the directory named by this abstract pathname. * Creates the directory named by this abstract pathname.
* *
* <p> Note that the {@link Path} class defines the {@link Path#createDirectory
* createDirectory} method to throw an {@link IOException} when a directory
* cannot be created. This is useful for error reporting and to diagnose why
* a directory cannot be created. The {@link #toPath toPath} method may be
* used to obtain a {@code Path} representing this abstract pathname.
*
* @return <code>true</code> if and only if the directory was * @return <code>true</code> if and only if the directory was
* created; <code>false</code> otherwise * created; <code>false</code> otherwise
* *
...@@ -1278,10 +1290,9 @@ public class File ...@@ -1278,10 +1290,9 @@ public class File
* already exists. The return value should always be checked to make sure * already exists. The return value should always be checked to make sure
* that the rename operation was successful. * that the rename operation was successful.
* *
* <p> Note that the {@link Path} class defines the {@link Path#moveTo * <p> Note that the {@link java.nio.file.Files} class defines the {@link
* moveTo} method to move or rename a file in a platform independent manner. * java.nio.file.Files#move move} method to move or rename a file in a
* The {@link #toPath toPath} method may be used to obtain a {@code Path} * platform independent manner.
* representing this abstract pathname.
* *
* @param dest The new abstract pathname for the named file * @param dest The new abstract pathname for the named file
* *
...@@ -1369,10 +1380,9 @@ public class File ...@@ -1369,10 +1380,9 @@ public class File
* Sets the owner's or everybody's write permission for this abstract * Sets the owner's or everybody's write permission for this abstract
* pathname. * pathname.
* *
* <p> The {@link java.nio.file.attribute.Attributes Attributes} class * <p> The {@link java.nio.file.Files} class defines methods that operate on
* defines methods that operate on file attributes including file * file attributes including file permissions. This may be used when finer
* permissions. This may be used when finer manipulation of file permissions * manipulation of file permissions is required.
* is required.
* *
* @param writable * @param writable
* If <code>true</code>, sets the access permission to allow write * If <code>true</code>, sets the access permission to allow write
...@@ -1437,10 +1447,9 @@ public class File ...@@ -1437,10 +1447,9 @@ public class File
* Sets the owner's or everybody's read permission for this abstract * Sets the owner's or everybody's read permission for this abstract
* pathname. * pathname.
* *
* <p> The {@link java.nio.file.attribute.Attributes Attributes} class * <p> The {@link java.nio.file.Files} class defines methods that operate on
* defines methods that operate on file attributes including file * file attributes including file permissions. This may be used when finer
* permissions. This may be used when finer manipulation of file permissions * manipulation of file permissions is required.
* is required.
* *
* @param readable * @param readable
* If <code>true</code>, sets the access permission to allow read * If <code>true</code>, sets the access permission to allow read
...@@ -1511,10 +1520,9 @@ public class File ...@@ -1511,10 +1520,9 @@ public class File
* Sets the owner's or everybody's execute permission for this abstract * Sets the owner's or everybody's execute permission for this abstract
* pathname. * pathname.
* *
* <p> The {@link java.nio.file.attribute.Attributes Attributes} class * <p> The {@link java.nio.file.Files} class defines methods that operate on
* defines methods that operate on file attributes including file * file attributes including file permissions. This may be used when finer
* permissions. This may be used when finer manipulation of file permissions * manipulation of file permissions is required.
* is required.
* *
* @param executable * @param executable
* If <code>true</code>, sets the access permission to allow execute * If <code>true</code>, sets the access permission to allow execute
...@@ -1646,6 +1654,7 @@ public class File ...@@ -1646,6 +1654,7 @@ public class File
* filesystem roots. * filesystem roots.
* *
* @since 1.2 * @since 1.2
* @see java.nio.file.FileStore
*/ */
public static File[] listRoots() { public static File[] listRoots() {
return fs.listRoots(); return fs.listRoots();
...@@ -1753,7 +1762,7 @@ public class File ...@@ -1753,7 +1762,7 @@ public class File
/* -- Temporary files -- */ /* -- Temporary files -- */
static class TempDirectory { private static class TempDirectory {
private TempDirectory() { } private TempDirectory() { }
// temporary directory location // temporary directory location
...@@ -1880,11 +1889,12 @@ public class File ...@@ -1880,11 +1889,12 @@ public class File
* java.lang.String, java.io.File) * java.lang.String, java.io.File)
* createTempFile(prefix,&nbsp;suffix,&nbsp;null)}</code>. * createTempFile(prefix,&nbsp;suffix,&nbsp;null)}</code>.
* *
* <p> The {@link #createTemporaryFile(String,String,FileAttribute[])} method * <p> The {@link
* provides an alternative method to create an empty file in the * java.nio.file.Files#createTempFile(String,String,java.nio.file.attribute.FileAttribute[])
* temporary-file directory. Files created by that method may have more * Files.createTempFile} method provides an alternative method to create an
* restrictive access permissions to files created by this method and so * empty file in the temporary-file directory. Files created by that method
* may be more suited to security-sensitive applications. * may have more restrictive access permissions to files created by this
* method and so may be more suited to security-sensitive applications.
* *
* @param prefix The prefix string to be used in generating the file's * @param prefix The prefix string to be used in generating the file's
* name; must be at least three characters long * name; must be at least three characters long
...@@ -1907,6 +1917,7 @@ public class File ...@@ -1907,6 +1917,7 @@ public class File
* method does not allow a file to be created * method does not allow a file to be created
* *
* @since 1.2 * @since 1.2
* @see java.nio.file.Files#createTempDirectory(String,FileAttribute[])
*/ */
public static File createTempFile(String prefix, String suffix) public static File createTempFile(String prefix, String suffix)
throws IOException throws IOException
...@@ -1914,61 +1925,6 @@ public class File ...@@ -1914,61 +1925,6 @@ public class File
return createTempFile(prefix, suffix, null); return createTempFile(prefix, suffix, null);
} }
/**
* Creates an empty file in the default temporary-file directory, using
* the given prefix and suffix to generate its name.
*
* <p> The {@code attrs} parameter is an optional array of {@link FileAttribute
* attributes} to set atomically when creating the file. Each attribute is
* identified by its {@link FileAttribute#name name}. If more than one attribute
* of the same name is included in the array then all but the last occurrence
* is ignored.
*
* <p> Where the {@code attrs} parameter does not specify <i>access
* permissions</i> to set atomically when creating the file, then the
* resulting file may have more restrictive access permissions than files
* created by the {@link #createTempFile(java.lang.String, java.lang.String)}
* method.
*
* @param prefix
* The prefix string to be used in generating the file's
* name; must be at least three characters long
* @param suffix
* The suffix string to be used in generating the file's
* name; may be {@code null}, in which case the suffix
* {@code ".tmp"} will be used
* @param attrs
* An optional list of file attributes to set atomically when creating
* the file
*
* @return An abstract pathname denoting a newly-created empty file
*
* @throws IllegalArgumentException
* If the {@code prefix} argument contains fewer than three
* characters
* @throws UnsupportedOperationException
* If the array contains an attribute that cannot be set atomically
* when creating the file
* @throws IOException
* If a file could not be created
* @throws SecurityException
* If a security manager exists and its <code>{@link
* java.lang.SecurityManager#checkWrite(java.lang.String)}</code>
* method does not allow a file to be created.
*
* @since 1.7
*/
public static File createTemporaryFile(String prefix,
String suffix,
FileAttribute<?>... attrs)
throws IOException
{
if (prefix.length() < 3)
throw new IllegalArgumentException("Prefix string too short");
suffix = (suffix == null) ? ".tmp" : suffix;
return TempFileHelper.createFile(prefix, suffix, attrs);
}
/* -- Basic infrastructure -- */ /* -- Basic infrastructure -- */
/** /**
...@@ -2104,6 +2060,7 @@ public class File ...@@ -2104,6 +2060,7 @@ public class File
* path (see {@link java.nio.file.FileSystem#getPath FileSystem.getPath}) * path (see {@link java.nio.file.FileSystem#getPath FileSystem.getPath})
* *
* @since 1.7 * @since 1.7
* @see Path#toFile
*/ */
public Path toPath() { public Path toPath() {
Path result = filePath; Path result = filePath;
...@@ -2111,12 +2068,7 @@ public class File ...@@ -2111,12 +2068,7 @@ public class File
synchronized (this) { synchronized (this) {
result = filePath; result = filePath;
if (result == null) { if (result == null) {
if (path.length() == 0) { result = FileSystems.getDefault().getPath(path);
// assume default file system treats "." as current directory
result = Paths.get(".");
} else {
result = Paths.get(path);
}
filePath = result; filePath = result;
} }
} }
......
...@@ -42,6 +42,7 @@ import sun.nio.ch.FileChannelImpl; ...@@ -42,6 +42,7 @@ import sun.nio.ch.FileChannelImpl;
* @see java.io.File * @see java.io.File
* @see java.io.FileDescriptor * @see java.io.FileDescriptor
* @see java.io.FileOutputStream * @see java.io.FileOutputStream
* @see java.nio.file.Files#newInputStream
* @since JDK1.0 * @since JDK1.0
*/ */
public public
......
...@@ -46,6 +46,7 @@ import sun.nio.ch.FileChannelImpl; ...@@ -46,6 +46,7 @@ import sun.nio.ch.FileChannelImpl;
* @see java.io.File * @see java.io.File
* @see java.io.FileDescriptor * @see java.io.FileDescriptor
* @see java.io.FileInputStream * @see java.io.FileInputStream
* @see java.nio.file.Files#newOutputStream
* @since JDK1.0 * @since JDK1.0
*/ */
public public
......
...@@ -72,7 +72,7 @@ import sun.security.util.SecurityConstants; ...@@ -72,7 +72,7 @@ import sun.security.util.SecurityConstants;
* <DT> readlink * <DT> readlink
* <DD> read link permission. Allows the target of a * <DD> read link permission. Allows the target of a
* <a href="../nio/file/package-summary.html#links">symbolic link</a> * <a href="../nio/file/package-summary.html#links">symbolic link</a>
* to be read by invoking the {@link java.nio.file.Path#readSymbolicLink * to be read by invoking the {@link java.nio.file.Files#readSymbolicLink
* readSymbolicLink } method. * readSymbolicLink } method.
* </DL> * </DL>
* <P> * <P>
......
...@@ -70,11 +70,11 @@ public class PrintStream extends FilterOutputStream ...@@ -70,11 +70,11 @@ public class PrintStream extends FilterOutputStream
private OutputStreamWriter charOut; private OutputStreamWriter charOut;
/** /**
* nonNull is explicitly declared here so as not to create an extra * requireNonNull is explicitly declared here so as not to create an extra
* dependency on java.util.Objects.nonNull. PrintStream is loaded * dependency on java.util.Objects.requireNonNull. PrintStream is loaded
* early during system initialization. * early during system initialization.
*/ */
private static <T> T nonNull(T obj, String message) { private static <T> T requireNonNull(T obj, String message) {
if (obj == null) if (obj == null)
throw new NullPointerException(message); throw new NullPointerException(message);
return obj; return obj;
...@@ -88,7 +88,7 @@ public class PrintStream extends FilterOutputStream ...@@ -88,7 +88,7 @@ public class PrintStream extends FilterOutputStream
private static Charset toCharset(String csn) private static Charset toCharset(String csn)
throws UnsupportedEncodingException throws UnsupportedEncodingException
{ {
nonNull(csn, "charsetName"); requireNonNull(csn, "charsetName");
try { try {
return Charset.forName(csn); return Charset.forName(csn);
} catch (IllegalCharsetNameException|UnsupportedCharsetException unused) { } catch (IllegalCharsetNameException|UnsupportedCharsetException unused) {
...@@ -148,7 +148,7 @@ public class PrintStream extends FilterOutputStream ...@@ -148,7 +148,7 @@ public class PrintStream extends FilterOutputStream
* @see java.io.PrintWriter#PrintWriter(java.io.OutputStream, boolean) * @see java.io.PrintWriter#PrintWriter(java.io.OutputStream, boolean)
*/ */
public PrintStream(OutputStream out, boolean autoFlush) { public PrintStream(OutputStream out, boolean autoFlush) {
this(autoFlush, nonNull(out, "Null output stream")); this(autoFlush, requireNonNull(out, "Null output stream"));
} }
/** /**
...@@ -173,7 +173,7 @@ public class PrintStream extends FilterOutputStream ...@@ -173,7 +173,7 @@ public class PrintStream extends FilterOutputStream
throws UnsupportedEncodingException throws UnsupportedEncodingException
{ {
this(autoFlush, this(autoFlush,
nonNull(out, "Null output stream"), requireNonNull(out, "Null output stream"),
toCharset(encoding)); toCharset(encoding));
} }
......
...@@ -82,7 +82,7 @@ public class PrintWriter extends Writer { ...@@ -82,7 +82,7 @@ public class PrintWriter extends Writer {
private static Charset toCharset(String csn) private static Charset toCharset(String csn)
throws UnsupportedEncodingException throws UnsupportedEncodingException
{ {
Objects.nonNull(csn, "charsetName"); Objects.requireNonNull(csn, "charsetName");
try { try {
return Charset.forName(csn); return Charset.forName(csn);
} catch (IllegalCharsetNameException|UnsupportedCharsetException unused) { } catch (IllegalCharsetNameException|UnsupportedCharsetException unused) {
......
...@@ -54,5 +54,3 @@ ...@@ -54,5 +54,3 @@
thread = null; thread = null;
} }
} }
...@@ -68,8 +68,8 @@ public final class StackTraceElement implements java.io.Serializable { ...@@ -68,8 +68,8 @@ public final class StackTraceElement implements java.io.Serializable {
*/ */
public StackTraceElement(String declaringClass, String methodName, public StackTraceElement(String declaringClass, String methodName,
String fileName, int lineNumber) { String fileName, int lineNumber) {
this.declaringClass = Objects.nonNull(declaringClass, "Declaring class is null"); this.declaringClass = Objects.requireNonNull(declaringClass, "Declaring class is null");
this.methodName = Objects.nonNull(methodName, "Method name is null"); this.methodName = Objects.requireNonNull(methodName, "Method name is null");
this.fileName = fileName; this.fileName = fileName;
this.lineNumber = lineNumber; this.lineNumber = lineNumber;
} }
......
/* /*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -44,7 +44,7 @@ import static java.lang.annotation.ElementType.*; ...@@ -44,7 +44,7 @@ import static java.lang.annotation.ElementType.*;
* @since 1.5 * @since 1.5
* @author Josh Bloch * @author Josh Bloch
*/ */
@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, TYPE_PARAMETER}) @Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface SuppressWarnings { public @interface SuppressWarnings {
/** /**
......
...@@ -690,7 +690,7 @@ class Thread implements Runnable { ...@@ -690,7 +690,7 @@ class Thread implements Runnable {
/* Notify the group that this thread is about to be started /* Notify the group that this thread is about to be started
* so that it can be added to the group's list of threads * so that it can be added to the group's list of threads
* and the group's unstarted count can be decremented. */ * and the group's unstarted count can be decremented. */
group.threadStarting(this); group.add(this);
boolean started = false; boolean started = false;
try { try {
......
...@@ -867,21 +867,6 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler { ...@@ -867,21 +867,6 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler {
} }
} }
/**
* Notifies the group that the thread {@code t} is about to be
* started and adds the thread to this thread group.
*
* The thread is now a fully fledged member of the group, even though
* it hasn't been started yet. It will prevent the group from being
* destroyed so the unstarted Threads count is decremented.
*/
void threadStarting(Thread t) {
synchronized (this) {
add(t);
nUnstartedThreads--;
}
}
/** /**
* Adds the specified thread to this thread group. * Adds the specified thread to this thread group.
* *
...@@ -910,6 +895,12 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler { ...@@ -910,6 +895,12 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler {
// This is done last so it doesn't matter in case the // This is done last so it doesn't matter in case the
// thread is killed // thread is killed
nthreads++; nthreads++;
// The thread is now a fully fledged member of the group, even
// though it may, or may not, have been started yet. It will prevent
// the group from being destroyed so the unstarted Threads count is
// decremented.
nUnstartedThreads--;
} }
} }
......
/* /*
* Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -40,12 +40,6 @@ public enum ElementType { ...@@ -40,12 +40,6 @@ public enum ElementType {
/** Class, interface (including annotation type), or enum declaration */ /** Class, interface (including annotation type), or enum declaration */
TYPE, TYPE,
/** Uses of a type */
TYPE_USE,
/** type parameters */
TYPE_PARAMETER,
/** Field declaration (includes enum constants) */ /** Field declaration (includes enum constants) */
FIELD, FIELD,
......
/* /*
* Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -121,8 +121,8 @@ import static java.math.BigInteger.LONG_MASK; ...@@ -121,8 +121,8 @@ import static java.math.BigInteger.LONG_MASK;
* scale for each operation is listed in the table below. * scale for each operation is listed in the table below.
* *
* <table border> * <table border>
* <caption top><h3>Preferred Scales for Results of Arithmetic Operations * <caption><b>Preferred Scales for Results of Arithmetic Operations
* </h3></caption> * </b></caption>
* <tr><th>Operation</th><th>Preferred Scale of Result</th></tr> * <tr><th>Operation</th><th>Preferred Scale of Result</th></tr>
* <tr><td>Add</td><td>max(addend.scale(), augend.scale())</td> * <tr><td>Add</td><td>max(addend.scale(), augend.scale())</td>
* <tr><td>Subtract</td><td>max(minuend.scale(), subtrahend.scale())</td> * <tr><td>Subtract</td><td>max(minuend.scale(), subtrahend.scale())</td>
...@@ -661,25 +661,25 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> { ...@@ -661,25 +661,25 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
* <dd>{@code .} <i>FractionPart</i> * <dd>{@code .} <i>FractionPart</i>
* <dd><i>IntegerPart</i> * <dd><i>IntegerPart</i>
* <p> * <p>
* <dt><i>IntegerPart: * <dt><i>IntegerPart:</i>
* <dd>Digits</i> * <dd><i>Digits</i>
* <p> * <p>
* <dt><i>FractionPart: * <dt><i>FractionPart:</i>
* <dd>Digits</i> * <dd><i>Digits</i>
* <p> * <p>
* <dt><i>Exponent: * <dt><i>Exponent:</i>
* <dd>ExponentIndicator SignedInteger</i> * <dd><i>ExponentIndicator SignedInteger</i>
* <p> * <p>
* <dt><i>ExponentIndicator:</i> * <dt><i>ExponentIndicator:</i>
* <dd>{@code e} * <dd>{@code e}
* <dd>{@code E} * <dd>{@code E}
* <p> * <p>
* <dt><i>SignedInteger: * <dt><i>SignedInteger:</i>
* <dd>Sign<sub>opt</sub> Digits</i> * <dd><i>Sign<sub>opt</sub> Digits</i>
* <p> * <p>
* <dt><i>Digits: * <dt><i>Digits:</i>
* <dd>Digit * <dd><i>Digit</i>
* <dd>Digits Digit</i> * <dd><i>Digits Digit</i>
* <p> * <p>
* <dt><i>Digit:</i> * <dt><i>Digit:</i>
* <dd>any character for which {@link Character#isDigit} * <dd>any character for which {@link Character#isDigit}
......
/* /*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -53,7 +53,7 @@ package java.math; ...@@ -53,7 +53,7 @@ package java.math;
* *
*<p> *<p>
*<table border> *<table border>
* <caption top><h3>Summary of Rounding Operations Under Different Rounding Modes</h3></caption> * <caption><b>Summary of Rounding Operations Under Different Rounding Modes</b></caption>
* <tr><th></th><th colspan=8>Result of rounding input to one digit with the given * <tr><th></th><th colspan=8>Result of rounding input to one digit with the given
* rounding mode</th> * rounding mode</th>
* <tr valign=top> * <tr valign=top>
......
...@@ -248,7 +248,7 @@ public abstract class FileChannel ...@@ -248,7 +248,7 @@ public abstract class FileChannel
* FileSystemProvider#newFileChannel newFileChannel} method on the * FileSystemProvider#newFileChannel newFileChannel} method on the
* provider that created the {@code Path}. * provider that created the {@code Path}.
* *
* @param file * @param path
* The path of the file to open or create * The path of the file to open or create
* @param options * @param options
* Options specifying how the file is opened * Options specifying how the file is opened
...@@ -261,7 +261,7 @@ public abstract class FileChannel ...@@ -261,7 +261,7 @@ public abstract class FileChannel
* @throws IllegalArgumentException * @throws IllegalArgumentException
* If the set contains an invalid combination of options * If the set contains an invalid combination of options
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* If the {@code file} is associated with a provider that does not * If the {@code path} is associated with a provider that does not
* support creating file channels, or an unsupported open option is * support creating file channels, or an unsupported open option is
* specified, or the array contains an attribute that cannot be set * specified, or the array contains an attribute that cannot be set
* atomically when creating the file * atomically when creating the file
...@@ -278,13 +278,13 @@ public abstract class FileChannel ...@@ -278,13 +278,13 @@ public abstract class FileChannel
* *
* @since 1.7 * @since 1.7
*/ */
public static FileChannel open(Path file, public static FileChannel open(Path path,
Set<? extends OpenOption> options, Set<? extends OpenOption> options,
FileAttribute<?>... attrs) FileAttribute<?>... attrs)
throws IOException throws IOException
{ {
FileSystemProvider provider = file.getFileSystem().provider(); FileSystemProvider provider = path.getFileSystem().provider();
return provider.newFileChannel(file, options, attrs); return provider.newFileChannel(path, options, attrs);
} }
private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0]; private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
...@@ -295,10 +295,12 @@ public abstract class FileChannel ...@@ -295,10 +295,12 @@ public abstract class FileChannel
* <p> An invocation of this method behaves in exactly the same way as the * <p> An invocation of this method behaves in exactly the same way as the
* invocation * invocation
* <pre> * <pre>
* fc.{@link #open(Path,Set,FileAttribute[]) open}(file, options, new FileAttribute&lt;?&gt;[0]); * fc.{@link #open(Path,Set,FileAttribute[]) open}(file, opts, new FileAttribute&lt;?&gt;[0]);
* </pre> * </pre>
* where {@code opts} is a set of the options specified in the {@code
* options} array.
* *
* @param file * @param path
* The path of the file to open or create * The path of the file to open or create
* @param options * @param options
* Options specifying how the file is opened * Options specifying how the file is opened
...@@ -308,7 +310,7 @@ public abstract class FileChannel ...@@ -308,7 +310,7 @@ public abstract class FileChannel
* @throws IllegalArgumentException * @throws IllegalArgumentException
* If the set contains an invalid combination of options * If the set contains an invalid combination of options
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* If the {@code file} is associated with a provider that does not * If the {@code path} is associated with a provider that does not
* support creating file channels, or an unsupported open option is * support creating file channels, or an unsupported open option is
* specified * specified
* @throws IOException * @throws IOException
...@@ -324,12 +326,12 @@ public abstract class FileChannel ...@@ -324,12 +326,12 @@ public abstract class FileChannel
* *
* @since 1.7 * @since 1.7
*/ */
public static FileChannel open(Path file, OpenOption... options) public static FileChannel open(Path path, OpenOption... options)
throws IOException throws IOException
{ {
Set<OpenOption> set = new HashSet<OpenOption>(options.length); Set<OpenOption> set = new HashSet<OpenOption>(options.length);
Collections.addAll(set, options); Collections.addAll(set, options);
return open(file, set, NO_ATTRIBUTES); return open(path, set, NO_ATTRIBUTES);
} }
// -- Channel operations -- // -- Channel operations --
......
...@@ -47,7 +47,7 @@ import java.io.IOException; ...@@ -47,7 +47,7 @@ import java.io.IOException;
* so that method invocations on the implementation class can be chained. * so that method invocations on the implementation class can be chained.
* *
* @since 1.7 * @since 1.7
* @see java.nio.file.Path#newByteChannel * @see java.nio.file.Files#newByteChannel
*/ */
public interface SeekableByteChannel public interface SeekableByteChannel
......
...@@ -29,8 +29,6 @@ package java.nio.file; ...@@ -29,8 +29,6 @@ package java.nio.file;
* Defines access modes used to test the accessibility of a file. * Defines access modes used to test the accessibility of a file.
* *
* @since 1.7 * @since 1.7
*
* @see Path#checkAccess
*/ */
public enum AccessMode { public enum AccessMode {
......
/*
* Copyright (c) 2011, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.nio.file;
import java.nio.file.attribute.*;
import java.io.InputStream;
import java.io.IOException;
/**
* Helper class to support copying or moving files when the source and target
* are associated with different providers.
*/
class CopyMoveHelper {
private CopyMoveHelper() { }
/**
* Parses the arguments for a file copy operation.
*/
private static class CopyOptions {
boolean replaceExisting = false;
boolean copyAttributes = false;
boolean followLinks = true;
private CopyOptions() { }
static CopyOptions parse(CopyOption... options) {
CopyOptions result = new CopyOptions();
for (CopyOption option: options) {
if (option == StandardCopyOption.REPLACE_EXISTING) {
result.replaceExisting = true;
continue;
}
if (option == LinkOption.NOFOLLOW_LINKS) {
result.followLinks = false;
continue;
}
if (option == StandardCopyOption.COPY_ATTRIBUTES) {
result.copyAttributes = true;
continue;
}
if (option == null)
throw new NullPointerException();
throw new UnsupportedOperationException("'" + option +
"' is not a recognized copy option");
}
return result;
}
}
/**
* Converts the given array of options for moving a file to options suitable
* for copying the file when a move is implemented as copy + delete.
*/
private static CopyOption[] convertMoveToCopyOptions(CopyOption... options)
throws AtomicMoveNotSupportedException
{
int len = options.length;
CopyOption[] newOptions = new CopyOption[len+2];
for (int i=0; i<len; i++) {
CopyOption option = options[i];
if (option == StandardCopyOption.ATOMIC_MOVE) {
throw new AtomicMoveNotSupportedException(null, null,
"Atomic move between providers is not supported");
}
newOptions[i] = option;
}
newOptions[len] = LinkOption.NOFOLLOW_LINKS;
newOptions[len+1] = StandardCopyOption.COPY_ATTRIBUTES;
return newOptions;
}
/**
* Simple copy for use when source and target are associated with different
* providers
*/
static void copyToForeignTarget(Path source, Path target,
CopyOption... options)
throws IOException
{
CopyOptions opts = CopyOptions.parse(options);
LinkOption[] linkOptions = (opts.followLinks) ? new LinkOption[0] :
new LinkOption[] { LinkOption.NOFOLLOW_LINKS };
// attributes of source file
BasicFileAttributes attrs = Files.readAttributes(source,
BasicFileAttributes.class,
linkOptions);
if (attrs.isSymbolicLink())
throw new IOException("Copying of symbolic links not supported");
// delete target if it exists and REPLACE_EXISTING is specified
if (opts.replaceExisting) {
Files.deleteIfExists(target);
} else if (Files.exists(target))
throw new FileAlreadyExistsException(target.toString());
// create directory or copy file
if (attrs.isDirectory()) {
Files.createDirectory(target);
} else {
try (InputStream in = Files.newInputStream(source)) {
Files.copy(in, target);
}
}
// copy basic attributes to target
if (opts.copyAttributes) {
BasicFileAttributeView view =
Files.getFileAttributeView(target, BasicFileAttributeView.class, linkOptions);
try {
view.setTimes(attrs.lastModifiedTime(),
attrs.lastAccessTime(),
attrs.creationTime());
} catch (IOException x) {
// rollback
try {
Files.delete(target);
} catch (IOException ignore) { }
throw x;
}
}
}
/**
* Simple move implements as copy+delete for use when source and target are
* associated with different providers
*/
static void moveToForeignTarget(Path source, Path target,
CopyOption... options) throws IOException
{
copyToForeignTarget(source, target, convertMoveToCopyOptions(options));
Files.delete(source);
}
}
...@@ -28,8 +28,12 @@ package java.nio.file; ...@@ -28,8 +28,12 @@ package java.nio.file;
/** /**
* An object that configures how to copy or move a file. * An object that configures how to copy or move a file.
* *
* <p> Objects of this type may be used with the {@link Path#copyTo copyTo} and * <p> Objects of this type may be used with the {@link
* {@link Path#moveTo moveTo} methods to configure how a file is copied or moved. * Files#copy(Path,Path,CopyOption[]) Files.copy(Path,Path,CopyOption...)},
* {@link Files#copy(java.io.InputStream,Path,CopyOption[])
* Files.copy(InputStream,Path,CopyOption...)} and {@link Files#move
* Files.move(Path,Path,CopyOption...)} methods to configure how a file is
* copied or moved.
* *
* <p> The {@link StandardCopyOption} enumeration type defines the * <p> The {@link StandardCopyOption} enumeration type defines the
* <i>standard</i> options. * <i>standard</i> options.
......
...@@ -56,7 +56,7 @@ public final class DirectoryIteratorException ...@@ -56,7 +56,7 @@ public final class DirectoryIteratorException
* if the cause is {@code null} * if the cause is {@code null}
*/ */
public DirectoryIteratorException(IOException cause) { public DirectoryIteratorException(IOException cause) {
super(Objects.nonNull(cause)); super(Objects.requireNonNull(cause));
} }
/** /**
......
...@@ -54,7 +54,7 @@ import java.io.IOException; ...@@ -54,7 +54,7 @@ import java.io.IOException;
* construct to ensure that the stream is closed: * construct to ensure that the stream is closed:
* <pre> * <pre>
* Path dir = ... * Path dir = ...
* try (DirectoryStream&lt;Path&gt; stream = dir.newDirectoryStream()) { * try (DirectoryStream&lt;Path&gt; stream = Files.newDirectoryStream(dir)) {
* for (Path entry: stream) { * for (Path entry: stream) {
* ... * ...
* } * }
...@@ -97,8 +97,8 @@ import java.io.IOException; ...@@ -97,8 +97,8 @@ import java.io.IOException;
* both the for-each and try-with-resources constructs. * both the for-each and try-with-resources constructs.
* <pre> * <pre>
* List&lt;Path&gt; listSourceFiles(Path dir) throws IOException { * List&lt;Path&gt; listSourceFiles(Path dir) throws IOException {
* List&lt;Path&gt; result = new ArrayList&lt;Path&gt;(); * List&lt;Path&gt; result = new ArrayList&lt;&gt;();
* try (DirectoryStream&lt;Path&gt; stream = dir.newDirectoryStream("*.{c,h,cpp,hpp,java}")) { * try (DirectoryStream&lt;Path&gt; stream = Files.newDirectoryStream(dir, "*.{c,h,cpp,hpp,java}")) {
* for (Path entry: stream) { * for (Path entry: stream) {
* result.add(entry); * result.add(entry);
* } * }
...@@ -113,7 +113,7 @@ import java.io.IOException; ...@@ -113,7 +113,7 @@ import java.io.IOException;
* *
* @since 1.7 * @since 1.7
* *
* @see Path#newDirectoryStream * @see Files#newDirectoryStream(Path)
*/ */
public interface DirectoryStream<T> public interface DirectoryStream<T>
...@@ -122,9 +122,9 @@ public interface DirectoryStream<T> ...@@ -122,9 +122,9 @@ public interface DirectoryStream<T>
/** /**
* An interface that is implemented by objects that decide if a directory * An interface that is implemented by objects that decide if a directory
* entry should be accepted or filtered. A {@code Filter} is passed as the * entry should be accepted or filtered. A {@code Filter} is passed as the
* parameter to the {@link Path#newDirectoryStream(DirectoryStream.Filter) * parameter to the {@link Files#newDirectoryStream(Path,DirectoryStream.Filter)}
* newDirectoryStream} method when opening a directory to iterate over the * method when opening a directory to iterate over the entries in the
* entries in the directory. * directory.
* *
* @param <T> the type of the directory entry * @param <T> the type of the directory entry
* *
......
/*
* Copyright (c) 2007, 2009, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.nio.file;
import java.nio.file.attribute.*;
import java.util.Map;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
/**
* A reference to a file.
*
* <p> A {@code FileRef} is an object that locates a file and defines methods to
* open the file for reading or writing. It also provides access to associated
* metadata or file attributes.
*
* @since 1.7
* @see java.nio.file.attribute.Attributes
* @see java.io.File#toPath
*/
public interface FileRef {
/**
* Opens the file referenced by this object, returning an input stream to
* read from the file. The stream will not be buffered, and is not required
* to support the {@link InputStream#mark mark} or {@link InputStream#reset
* reset} methods. The stream will be safe for access by multiple concurrent
* threads. Reading commences at the beginning of the file.
*
* <p> The {@code options} parameter determines how the file is opened.
* If no options are present then it is equivalent to opening the file with
* the {@link StandardOpenOption#READ READ} option. In addition to the {@code
* READ} option, an implementation may also support additional implementation
* specific options.
*
* @return an input stream to read bytes from the file
*
* @throws IllegalArgumentException
* if an invalid combination of options is specified
* @throws UnsupportedOperationException
* if an unsupported option is specified
* @throws IOException
* if an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, the {@link SecurityManager#checkRead(String) checkRead}
* method is invoked to check read access to the file.
*/
InputStream newInputStream(OpenOption... options) throws IOException;
/**
* Opens or creates the file located by this object for writing, returning
* an output stream to write bytes to the file.
*
* <p> The {@code options} parameter determines how the file is opened.
* If no options are present then this method creates a new file for writing
* or truncates an existing file. In addition to the {@link StandardOpenOption
* standard} options, an implementation may also support additional
* implementation specific options.
*
* <p> The resulting stream will not be buffered. The stream will be safe
* for access by multiple concurrent threads.
*
* @param options
* options specifying how the file is opened
*
* @return a new output stream
*
* @throws IllegalArgumentException
* if {@code options} contains an invalid combination of options
* @throws UnsupportedOperationException
* if an unsupported option is specified
* @throws IOException
* if an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
* method is invoked to check write access to the file.
*/
OutputStream newOutputStream(OpenOption... options) throws IOException;
/**
* Returns a file attribute view of a given type.
*
* <p> A file attribute view provides a read-only or updatable view of a
* set of file attributes. This method is intended to be used where the file
* attribute view defines type-safe methods to read or update the file
* attributes. The {@code type} parameter is the type of the attribute view
* required and the method returns an instance of that type if supported.
* The {@link BasicFileAttributeView} type supports access to the basic
* attributes of a file. Invoking this method to select a file attribute
* view of that type will always return an instance of that class.
*
* <p> The {@code options} array may be used to indicate how symbolic links
* are handled by the resulting file attribute view for the case that the
* file is a symbolic link. By default, symbolic links are followed. If the
* option {@link LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} is present then
* symbolic links are not followed. This option is ignored by implementations
* that do not support symbolic links.
*
* @param type
* the {@code Class} object corresponding to the file attribute view
* @param options
* options indicating how symbolic links are handled
*
* @return a file attribute view of the specified type, or {@code null} if
* the attribute view type is not available
*
* @throws UnsupportedOperationException
* If options contains an unsupported option. This exception is
* specified to allow the {@code LinkOption} enum be extended
* in future releases.
*
* @see Attributes#readBasicFileAttributes
*/
<V extends FileAttributeView> V getFileAttributeView(Class<V> type,
LinkOption... options);
/**
* Sets the value of a file attribute.
*
* <p> The {@code attribute} parameter identifies the attribute to be set
* and takes the form:
* <blockquote>
* [<i>view-name</i><b>:</b>]<i>attribute-name</i>
* </blockquote>
* where square brackets [...] delineate an optional component and the
* character {@code ':'} stands for itself.
*
* <p> <i>view-name</i> is the {@link FileAttributeView#name name} of a {@link
* FileAttributeView} that identifies a set of file attributes. If not
* specified then it defaults to {@code "basic"}, the name of the file
* attribute view that identifies the basic set of file attributes common to
* many file systems. <i>attribute-name</i> is the name of the attribute
* within the set.
*
* <p> <b>Usage Example:</b>
* Suppose we want to set the DOS "hidden" attribute:
* <pre>
* file.setAttribute("dos:hidden", true);
* </pre>
*
* @param attribute
* the attribute to set
* @param value
* the attribute value
* @param options
* options indicating how symbolic links are handled
*
* @throws UnsupportedOperationException
* if the attribute view is not available or it does not support
* updating the attribute
* @throws IllegalArgumentException
* if the attribute value is of the correct type but has an
* inappropriate value
* @throws ClassCastException
* If the attribute value is not of the expected type or is a
* collection containing elements that are not of the expected
* type
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, its {@link SecurityManager#checkWrite(String) checkWrite}
* method denies write access to the file. If this method is invoked
* to set security sensitive attributes then the security manager
* may be invoked to check for additional permissions.
*/
void setAttribute(String attribute, Object value, LinkOption... options)
throws IOException;
/**
* Reads the value of a file attribute.
*
* <p> The {@code attribute} parameter identifies the attribute to be read
* and takes the form:
* <blockquote>
* [<i>view-name</i><b>:</b>]<i>attribute-name</i>
* </blockquote>
* where square brackets [...] delineate an optional component and the
* character {@code ':'} stands for itself.
*
* <p> <i>view-name</i> is the {@link FileAttributeView#name name} of a {@link
* FileAttributeView} that identifies a set of file attributes. If not
* specified then it defaults to {@code "basic"}, the name of the file
* attribute view that identifies the basic set of file attributes common to
* many file systems. <i>attribute-name</i> is the name of the attribute.
*
* <p> The {@code options} array may be used to indicate how symbolic links
* are handled for the case that the file is a symbolic link. By default,
* symbolic links are followed and the file attribute of the final target
* of the link is read. If the option {@link LinkOption#NOFOLLOW_LINKS
* NOFOLLOW_LINKS} is present then symbolic links are not followed and so
* the method returns the file attribute of the symbolic link.
*
* <p> <b>Usage Example:</b>
* Suppose we require the user ID of the file owner on a system that
* supports a "{@code unix}" view:
* <pre>
* int uid = (Integer)file.getAttribute("unix:uid");
* </pre>
*
* @param attribute
* the attribute to read
* @param options
* options indicating how symbolic links are handled
* @return the attribute value or {@code null} if the attribute view
* is not available or it does not support reading the attribute
*
* reading the attribute
* @throws IOException
* if an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, its {@link SecurityManager#checkRead(String) checkRead}
* method denies read access to the file. If this method is invoked
* to read security sensitive attributes then the security manager
* may be invoked to check for additional permissions.
*/
Object getAttribute(String attribute, LinkOption... options) throws IOException;
/**
* Reads a set of file attributes as a bulk operation.
*
* <p> The {@code attributes} parameter identifies the attributes to be read
* and takes the form:
* <blockquote>
* [<i>view-name</i><b>:</b>]<i>attribute-list</i>
* </blockquote>
* where square brackets [...] delineate an optional component and the
* character {@code ':'} stands for itself.
*
* <p> <i>view-name</i> is the {@link FileAttributeView#name name} of a {@link
* FileAttributeView} that identifies a set of file attributes. If not
* specified then it defaults to {@code "basic"}, the name of the file
* attribute view that identifies the basic set of file attributes common to
* many file systems.
*
* <p> The <i>attribute-list</i> component is a comma separated list of
* zero or more names of attributes to read. If the list contains the value
* {@code "*"} then all attributes are read. Attributes that are not supported
* are ignored and will not be present in the returned map. It is
* implementation specific if all attributes are read as an atomic operation
* with respect to other file system operations.
*
* <p> The following examples demonstrate possible values for the {@code
* attributes} parameter:
*
* <blockquote>
* <table border="0">
* <tr>
* <td> {@code "*"} </td>
* <td> Read all {@link BasicFileAttributes basic-file-attributes}. </td>
* </tr>
* <tr>
* <td> {@code "size,lastModifiedTime,lastAccessTime"} </td>
* <td> Reads the file size, last modified time, and last access time
* attributes. </td>
* </tr>
* <tr>
* <td> {@code "posix:*"} </td>
* <td> Read all {@link PosixFileAttributes POSIX-file-attributes}.. </td>
* </tr>
* <tr>
* <td> {@code "posix:permissions,owner,size"} </td>
* <td> Reads the POSX file permissions, owner, and file size. </td>
* </tr>
* </table>
* </blockquote>
*
* <p> The {@code options} array may be used to indicate how symbolic links
* are handled for the case that the file is a symbolic link. By default,
* symbolic links are followed and the file attribute of the final target
* of the link is read. If the option {@link LinkOption#NOFOLLOW_LINKS
* NOFOLLOW_LINKS} is present then symbolic links are not followed and so
* the method returns the file attribute of the symbolic link.
*
* @param attributes
* The attributes to read
* @param options
* Options indicating how symbolic links are handled
*
* @return A map of the attributes returned; may be empty. The map's keys
* are the attribute names, its values are the attribute values
*
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, its {@link SecurityManager#checkRead(String) checkRead}
* method denies read access to the file. If this method is invoked
* to read security sensitive attributes then the security manager
* may be invoke to check for additional permissions.
*/
Map<String,?> readAttributes(String attributes, LinkOption... options)
throws IOException;
}
...@@ -32,16 +32,13 @@ import java.io.IOException; ...@@ -32,16 +32,13 @@ import java.io.IOException;
* Storage for files. A {@code FileStore} represents a storage pool, device, * Storage for files. A {@code FileStore} represents a storage pool, device,
* partition, volume, concrete file system or other implementation specific means * partition, volume, concrete file system or other implementation specific means
* of file storage. The {@code FileStore} for where a file is stored is obtained * of file storage. The {@code FileStore} for where a file is stored is obtained
* by invoking the {@link Path#getFileStore getFileStore} method, or all file * by invoking the {@link Files#getFileStore getFileStore} method, or all file
* stores can be enumerated by invoking the {@link FileSystem#getFileStores * stores can be enumerated by invoking the {@link FileSystem#getFileStores
* getFileStores} method. * getFileStores} method.
* *
* <p> In addition to the methods defined by this class, a file store may support * <p> In addition to the methods defined by this class, a file store may support
* one or more {@link FileStoreAttributeView FileStoreAttributeView} classes * one or more {@link FileStoreAttributeView FileStoreAttributeView} classes
* that provide a read-only or updatable view of a set of file store attributes. * that provide a read-only or updatable view of a set of file store attributes.
* File stores associated with the default provider support the {@link
* FileStoreSpaceAttributeView} to read the space related attributes of the
* file store.
* *
* @since 1.7 * @since 1.7
*/ */
...@@ -86,6 +83,51 @@ public abstract class FileStore { ...@@ -86,6 +83,51 @@ public abstract class FileStore {
*/ */
public abstract boolean isReadOnly(); public abstract boolean isReadOnly();
/**
* Returns the size, in bytes, of the file store.
*
* @return the size of the file store, in bytes
*
* @throws IOException
* if an I/O error occurs
*/
public abstract long getTotalSpace() throws IOException;
/**
* Returns the number of bytes available to this Java virtual machine on the
* file store.
*
* <p> The returned number of available bytes is a hint, but not a
* guarantee, that it is possible to use most or any of these bytes. The
* number of usable bytes is most likely to be accurate immediately
* after the space attributes are obtained. It is likely to be made inaccurate
* by any external I/O operations including those made on the system outside
* of this Java virtual machine.
*
* @return the number of bytes available
*
* @throws IOException
* if an I/O error occurs
*/
public abstract long getUsableSpace() throws IOException;
/**
* Returns the number of unallocated bytes in the file store.
*
* <p> The returned number of unallocated bytes is a hint, but not a
* guarantee, that it is possible to use most or any of these bytes. The
* number of unallocated bytes is most likely to be accurate immediately
* after the space attributes are obtained. It is likely to be
* made inaccurate by any external I/O operations including those made on
* the system outside of this virtual machine.
*
* @return the number of unallocated bytes
*
* @throws IOException
* if an I/O error occurs
*/
public abstract long getUnallocatedSpace() throws IOException;
/** /**
* Tells whether or not this file store supports the file attributes * Tells whether or not this file store supports the file attributes
* identified by the given file attribute view. * identified by the given file attribute view.
...@@ -131,12 +173,6 @@ public abstract class FileStore { ...@@ -131,12 +173,6 @@ public abstract class FileStore {
* The {@code type} parameter is the type of the attribute view required and * The {@code type} parameter is the type of the attribute view required and
* the method returns an instance of that type if supported. * the method returns an instance of that type if supported.
* *
* <p> For {@code FileStore} objects created by the default provider, then
* the file stores support the {@link FileStoreSpaceAttributeView} that
* provides access to space attributes. In that case invoking this method
* with a parameter value of {@code FileStoreSpaceAttributeView.class} will
* always return an instance of that class.
*
* @param type * @param type
* the {@code Class} object corresponding to the attribute view * the {@code Class} object corresponding to the attribute view
* *
...@@ -160,10 +196,6 @@ public abstract class FileStore { ...@@ -160,10 +196,6 @@ public abstract class FileStore {
* a {@link FileStore AttributeView} that identifies a set of file attributes. * a {@link FileStore AttributeView} that identifies a set of file attributes.
* <i>attribute-name</i> is the name of the attribute. * <i>attribute-name</i> is the name of the attribute.
* *
* <p> For {@code FileStore} objects created by the default provider, then
* the file stores support the {@link FileStoreSpaceAttributeView} that
* provides access to space attributes.
*
* <p> <b>Usage Example:</b> * <p> <b>Usage Example:</b>
* Suppose we want to know if ZFS compression is enabled (assuming the "zfs" * Suppose we want to know if ZFS compression is enabled (assuming the "zfs"
* view is supported): * view is supported):
......
...@@ -38,8 +38,8 @@ import java.io.IOException; ...@@ -38,8 +38,8 @@ import java.io.IOException;
* <p> The default file system, obtained by invoking the {@link FileSystems#getDefault * <p> The default file system, obtained by invoking the {@link FileSystems#getDefault
* FileSystems.getDefault} method, provides access to the file system that is * FileSystems.getDefault} method, provides access to the file system that is
* accessible to the Java virtual machine. The {@link FileSystems} class defines * accessible to the Java virtual machine. The {@link FileSystems} class defines
* methods to create file systems that provide access to other types of file * methods to create file systems that provide access to other types of (custom)
* systems. * file systems.
* *
* <p> A file system is the factory for several types of objects: * <p> A file system is the factory for several types of objects:
* *
...@@ -214,10 +214,9 @@ public abstract class FileSystem ...@@ -214,10 +214,9 @@ public abstract class FileSystem
* Suppose we want to print the space usage for all file stores: * Suppose we want to print the space usage for all file stores:
* <pre> * <pre>
* for (FileStore store: FileSystems.getDefault().getFileStores()) { * for (FileStore store: FileSystems.getDefault().getFileStores()) {
* FileStoreSpaceAttributes attrs = Attributes.readFileStoreSpaceAttributes(store); * long total = store.getTotalSpace() / 1024;
* long total = attrs.totalSpace() / 1024; * long used = (store.getTotalSpace() - store.getUnallocatedSpace()) / 1024;
* long used = (attrs.totalSpace() - attrs.unallocatedSpace()) / 1024; * long avail = store.getUsableSpace() / 1024;
* long avail = attrs.usableSpace() / 1024;
* System.out.format("%-20s %12d %12d %12d%n", store, total, used, avail); * System.out.format("%-20s %12d %12d %12d%n", store, total, used, avail);
* } * }
* </pre> * </pre>
...@@ -244,7 +243,20 @@ public abstract class FileSystem ...@@ -244,7 +243,20 @@ public abstract class FileSystem
public abstract Set<String> supportedFileAttributeViews(); public abstract Set<String> supportedFileAttributeViews();
/** /**
* Converts a path string to a {@code Path}. * 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 #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 parsing and conversion to a path object is inherently * <p> The parsing and conversion to a path object is inherently
* implementation dependent. In the simplest case, the path string is rejected, * implementation dependent. In the simplest case, the path string is rejected,
...@@ -270,18 +282,17 @@ public abstract class FileSystem ...@@ -270,18 +282,17 @@ public abstract class FileSystem
* index} value indicating the first position in the {@code path} parameter * index} value indicating the first position in the {@code path} parameter
* that caused the path string to be rejected. * that caused the path string to be rejected.
* *
* <p> Invoking this method with an empty path string throws * @param first
* {@code InvalidPathException}. * the path string or initial part of the path string
* @param more
* additional strings to be joined to form the path string
* *
* @param path * @return the resulting {@code Path}
* The path string
*
* @return A {@code Path} object
* *
* @throws InvalidPathException * @throws InvalidPathException
* If the path string cannot be converted * If the path string cannot be converted
*/ */
public abstract Path getPath(String path); public abstract Path getPath(String first, String... more);
/** /**
* Returns a {@code PathMatcher} that performs match operations on the * Returns a {@code PathMatcher} that performs match operations on the
...@@ -290,9 +301,9 @@ public abstract class FileSystem ...@@ -290,9 +301,9 @@ public abstract class FileSystem
* *
* The {@code syntaxAndPattern} parameter identifies the syntax and the * The {@code syntaxAndPattern} parameter identifies the syntax and the
* pattern and takes the form: * pattern and takes the form:
* <blockquote> * <blockquote><pre>
* <i>syntax</i><b>:</b><i>pattern</i> * <i>syntax</i><b>:</b><i>pattern</i>
* </blockquote> * </pre></blockquote>
* where {@code ':'} stands for itself. * where {@code ':'} stands for itself.
* *
* <p> A {@code FileSystem} implementation supports the "{@code glob}" and * <p> A {@code FileSystem} implementation supports the "{@code glob}" and
...@@ -409,7 +420,7 @@ public abstract class FileSystem ...@@ -409,7 +420,7 @@ public abstract class FileSystem
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
* If the pattern syntax is not known to the implementation * If the pattern syntax is not known to the implementation
* *
* @see Path#newDirectoryStream(String) * @see Files#newDirectoryStream(Path,String)
*/ */
public abstract PathMatcher getPathMatcher(String syntaxAndPattern); public abstract PathMatcher getPathMatcher(String syntaxAndPattern);
...@@ -421,10 +432,8 @@ public abstract class FileSystem ...@@ -421,10 +432,8 @@ public abstract class FileSystem
* <p> <b>Usage Example:</b> * <p> <b>Usage Example:</b>
* Suppose we want to make "joe" the owner of a file: * Suppose we want to make "joe" the owner of a file:
* <pre> * <pre>
* Path file = ... * UserPrincipalLookupService lookupService = FileSystems.getDefault().getUserPrincipalLookupService();
* UserPrincipal joe = file.getFileSystem().getUserPrincipalLookupService() * Files.setOwner(path, lookupService.lookupPrincipalByName("joe"));
* .lookupPrincipalByName("joe");
* Attributes.setOwner(file, joe);
* </pre> * </pre>
* *
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
......
...@@ -164,8 +164,8 @@ public final class FileSystems { ...@@ -164,8 +164,8 @@ public final class FileSystems {
* to the first provider instance. The third provider class is instantiated * to the first provider instance. The third provider class is instantiated
* by invoking it with a reference to the second instance, and so on. The * by invoking it with a reference to the second instance, and so on. The
* last provider to be instantiated becomes the default provider; its {@code * last provider to be instantiated becomes the default provider; its {@code
* getFileSystem} method is invoked with the URI {@code "file:///"} to create * getFileSystem} method is invoked with the URI {@code "file:///"} to
* the default file system. * get a reference to the default file system.
* *
* <p> Subsequent invocations of this method return the file system that was * <p> Subsequent invocations of this method return the file system that was
* returned by the first invocation. * returned by the first invocation.
...@@ -238,7 +238,7 @@ public final class FileSystems { ...@@ -238,7 +238,7 @@ public final class FileSystems {
* Suppose there is a provider identified by the scheme {@code "memory"} * Suppose there is a provider identified by the scheme {@code "memory"}
* installed: * installed:
* <pre> * <pre>
* Map&lt;String,String&gt; env = new HashMap&lt;String,String&gt;(); * Map&lt;String,String&gt; env = new HashMap&lt;&gt;();
* env.put("capacity", "16G"); * env.put("capacity", "16G");
* env.put("blockSize", "4k"); * env.put("blockSize", "4k");
* FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"), env); * FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"), env);
...@@ -343,33 +343,25 @@ public final class FileSystems { ...@@ -343,33 +343,25 @@ public final class FileSystems {
* *
* <p> This method makes use of specialized providers that create pseudo file * <p> This method makes use of specialized providers that create pseudo file
* systems where the contents of one or more files is treated as a file * systems where the contents of one or more files is treated as a file
* system. The {@code file} parameter is a reference to an existing file * system.
* and the {@code env} parameter is a map of provider specific properties to
* configure the file system.
* *
* <p> This method iterates over the {@link FileSystemProvider#installedProviders() * <p> This method iterates over the {@link FileSystemProvider#installedProviders()
* installed} providers. It invokes, in turn, each provider's {@link * installed} providers. It invokes, in turn, each provider's {@link
* FileSystemProvider#newFileSystem(FileRef,Map) newFileSystem(FileRef,Map)} method. * FileSystemProvider#newFileSystem(Path,Map) newFileSystem(Path,Map)} method
* If a provider returns a file system then the iteration terminates * with an empty map. If a provider returns a file system then the iteration
* and the file system is returned. If none of the installed providers return * terminates and the file system is returned. If none of the installed
* a {@code FileSystem} then an attempt is made to locate the provider using * providers return a {@code FileSystem} then an attempt is made to locate
* the given class loader. If a provider returns a file system then the lookup * the provider using the given class loader. If a provider returns a file
* terminates and the file system is returned. * system then the lookup terminates and the file system is returned.
* *
* @param file * @param path
* a reference to a file * the path to the file
* @param env
* a map of provider specific properties to configure the file system;
* may be empty
* @param loader * @param loader
* the class loader to locate the provider or {@code null} to only * the class loader to locate the provider or {@code null} to only
* attempt to locate an installed provider * attempt to locate an installed provider
* *
* @return a new file system * @return a new file system
* *
* @throws IllegalArgumentException
* if the {@code env} parameter does not contain properties required
* by the provider, or a property value is invalid
* @throws ProviderNotFoundException * @throws ProviderNotFoundException
* if a provider supporting this file type cannot be located * if a provider supporting this file type cannot be located
* @throws ServiceConfigurationError * @throws ServiceConfigurationError
...@@ -380,18 +372,18 @@ public final class FileSystems { ...@@ -380,18 +372,18 @@ public final class FileSystems {
* if a security manager is installed and it denies an unspecified * if a security manager is installed and it denies an unspecified
* permission * permission
*/ */
public static FileSystem newFileSystem(FileRef file, public static FileSystem newFileSystem(Path path,
Map<String,?> env,
ClassLoader loader) ClassLoader loader)
throws IOException throws IOException
{ {
if (file == null) if (path == null)
throw new NullPointerException(); throw new NullPointerException();
Map<String,?> env = Collections.emptyMap();
// check installed providers // check installed providers
for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
try { try {
return provider.newFileSystem(file, env); return provider.newFileSystem(path, env);
} catch (UnsupportedOperationException uoe) { } catch (UnsupportedOperationException uoe) {
} }
} }
...@@ -402,7 +394,7 @@ public final class FileSystems { ...@@ -402,7 +394,7 @@ public final class FileSystems {
.load(FileSystemProvider.class, loader); .load(FileSystemProvider.class, loader);
for (FileSystemProvider provider: sl) { for (FileSystemProvider provider: sl) {
try { try {
return provider.newFileSystem(file, env); return provider.newFileSystem(path, env);
} catch (UnsupportedOperationException uoe) { } catch (UnsupportedOperationException uoe) {
} }
} }
......
...@@ -69,7 +69,7 @@ class FileTreeWalker { ...@@ -69,7 +69,7 @@ class FileTreeWalker {
FileVisitResult result = walk(start, FileVisitResult result = walk(start,
0, 0,
new ArrayList<AncestorDirectory>()); new ArrayList<AncestorDirectory>());
Objects.nonNull(result, "FileVisitor returned null"); Objects.requireNonNull(result, "FileVisitor returned null");
} }
/** /**
...@@ -102,12 +102,13 @@ class FileTreeWalker { ...@@ -102,12 +102,13 @@ class FileTreeWalker {
if (attrs == null) { if (attrs == null) {
try { try {
try { try {
attrs = Attributes.readBasicFileAttributes(file, linkOptions); attrs = Files.readAttributes(file, BasicFileAttributes.class, linkOptions);
} catch (IOException x1) { } catch (IOException x1) {
if (followLinks) { if (followLinks) {
try { try {
attrs = Attributes attrs = Files.readAttributes(file,
.readBasicFileAttributes(file, LinkOption.NOFOLLOW_LINKS); BasicFileAttributes.class,
LinkOption.NOFOLLOW_LINKS);
} catch (IOException x2) { } catch (IOException x2) {
exc = x2; exc = x2;
} }
...@@ -151,7 +152,7 @@ class FileTreeWalker { ...@@ -151,7 +152,7 @@ class FileTreeWalker {
} else { } else {
boolean isSameFile = false; boolean isSameFile = false;
try { try {
isSameFile = file.isSameFile(ancestor.file()); isSameFile = Files.isSameFile(file, ancestor.file());
} catch (IOException x) { } catch (IOException x) {
// ignore // ignore
} catch (SecurityException x) { } catch (SecurityException x) {
...@@ -175,7 +176,7 @@ class FileTreeWalker { ...@@ -175,7 +176,7 @@ class FileTreeWalker {
// open the directory // open the directory
try { try {
stream = file.newDirectoryStream(); stream = Files.newDirectoryStream(file);
} catch (IOException x) { } catch (IOException x) {
return visitor.visitFileFailed(file, x); return visitor.visitFileFailed(file, x);
} catch (SecurityException x) { } catch (SecurityException x) {
...@@ -212,7 +213,11 @@ class FileTreeWalker { ...@@ -212,7 +213,11 @@ class FileTreeWalker {
} finally { } finally {
try { try {
stream.close(); stream.close();
} catch (IOException x) { } } catch (IOException e) {
// IOException will be notified to postVisitDirectory
if (ioe == null)
ioe = e;
}
} }
// invoke postVisitDirectory last // invoke postVisitDirectory last
......
...@@ -30,8 +30,8 @@ import java.io.IOException; ...@@ -30,8 +30,8 @@ import java.io.IOException;
/** /**
* A visitor of files. An implementation of this interface is provided to the * A visitor of files. An implementation of this interface is provided to the
* {@link Files#walkFileTree walkFileTree} utility method to visit each file * {@link Files#walkFileTree Files.walkFileTree} methods to visit each file in
* in a tree. * a file tree.
* *
* <p> <b>Usage Examples:</b> * <p> <b>Usage Examples:</b>
* Suppose we want to delete a file tree. In that case, each directory should * Suppose we want to delete a file tree. In that case, each directory should
...@@ -43,19 +43,20 @@ import java.io.IOException; ...@@ -43,19 +43,20 @@ import java.io.IOException;
* public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) * public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
* throws IOException * throws IOException
* { * {
* file.delete(); * Files.delete(file);
* return FileVisitResult.CONTINUE; * return FileVisitResult.CONTINUE;
* } * }
* &#64;Override * &#64;Override
* public FileVisitResult postVisitDirectory(Path dir, IOException e) * public FileVisitResult postVisitDirectory(Path dir, IOException e)
* throws IOException * throws IOException
* { * {
* if (e != null) { * if (e == null) {
* Files.delete(dir);
* return FileVisitResult.CONTINUE;
* } else {
* // directory iteration failed * // directory iteration failed
* throw e; * throw e;
* } * }
* dir.delete();
* return FileVisitResult.CONTINUE;
* } * }
* }); * });
* </pre> * </pre>
...@@ -72,10 +73,12 @@ import java.io.IOException; ...@@ -72,10 +73,12 @@ import java.io.IOException;
* public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) * public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
* throws IOException * throws IOException
* { * {
* Path targetdir = target.resolve(source.relativize(dir));
* try { * try {
* dir.copyTo(target.resolve(source.relativize(dir))); * Files.copy(dir, targetdir);
* } catch (FileAlreadyExistsException e) { * } catch (FileAlreadyExistsException e) {
* // ignore * if (!Files.isDirectory(targetdir))
* throw e;
* } * }
* return CONTINUE; * return CONTINUE;
* } * }
...@@ -83,7 +86,7 @@ import java.io.IOException; ...@@ -83,7 +86,7 @@ import java.io.IOException;
* public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) * public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
* throws IOException * throws IOException
* { * {
* file.copyTo(target.resolve(source.relativize(file))); * Files.copy(file, target.resolve(source.relativize(file)));
* return CONTINUE; * return CONTINUE;
* } * }
* }); * });
......
...@@ -35,8 +35,8 @@ public enum LinkOption implements OpenOption, CopyOption { ...@@ -35,8 +35,8 @@ public enum LinkOption implements OpenOption, CopyOption {
/** /**
* Do not follow symbolic links. * Do not follow symbolic links.
* *
* @see FileRef#getFileAttributeView(Class,LinkOption[]) * @see Files#getFileAttributeView(Path,Class,LinkOption[])
* @see Path#copyTo * @see Files#copy
* @see SecureDirectoryStream#newByteChannel * @see SecureDirectoryStream#newByteChannel
*/ */
NOFOLLOW_LINKS; NOFOLLOW_LINKS;
......
...@@ -59,8 +59,8 @@ import java.security.BasicPermission; ...@@ -59,8 +59,8 @@ import java.security.BasicPermission;
* *
* @since 1.7 * @since 1.7
* *
* @see Path#createLink * @see Files#createLink
* @see Path#createSymbolicLink * @see Files#createSymbolicLink
*/ */
public final class LinkPermission extends BasicPermission { public final class LinkPermission extends BasicPermission {
static final long serialVersionUID = -1441492453772213220L; static final long serialVersionUID = -1441492453772213220L;
......
...@@ -29,8 +29,8 @@ package java.nio.file; ...@@ -29,8 +29,8 @@ package java.nio.file;
* An object that configures how to open or create a file. * An object that configures how to open or create a file.
* *
* <p> Objects of this type are used by methods such as {@link * <p> Objects of this type are used by methods such as {@link
* Path#newOutputStream(OpenOption[]) newOutputStream}, {@link * Files#newOutputStream(Path,OpenOption[]) newOutputStream}, {@link
* Path#newByteChannel newByteChannel}, {@link * Files#newByteChannel newByteChannel}, {@link
* java.nio.channels.FileChannel#open FileChannel.open}, and {@link * java.nio.channels.FileChannel#open FileChannel.open}, and {@link
* java.nio.channels.AsynchronousFileChannel#open AsynchronousFileChannel.open} * java.nio.channels.AsynchronousFileChannel#open AsynchronousFileChannel.open}
* when opening or creating a file. * when opening or creating a file.
......
...@@ -32,7 +32,7 @@ package java.nio.file; ...@@ -32,7 +32,7 @@ package java.nio.file;
* @since 1.7 * @since 1.7
* *
* @see FileSystem#getPathMatcher * @see FileSystem#getPathMatcher
* @see Path#newDirectoryStream(String) * @see Files#newDirectoryStream(Path,String)
*/ */
public interface PathMatcher { public interface PathMatcher {
......
...@@ -176,7 +176,7 @@ public final class AclEntry { ...@@ -176,7 +176,7 @@ public final class AclEntry {
*/ */
public Builder setPermissions(Set<AclEntryPermission> perms) { public Builder setPermissions(Set<AclEntryPermission> perms) {
// copy and check for erroneous elements // copy and check for erroneous elements
perms = new HashSet<AclEntryPermission>(perms); perms = EnumSet.copyOf(perms);
checkSet(perms, AclEntryPermission.class); checkSet(perms, AclEntryPermission.class);
this.perms = perms; this.perms = perms;
return this; return this;
...@@ -190,8 +190,7 @@ public final class AclEntry { ...@@ -190,8 +190,7 @@ public final class AclEntry {
* @return this builder * @return this builder
*/ */
public Builder setPermissions(AclEntryPermission... perms) { public Builder setPermissions(AclEntryPermission... perms) {
Set<AclEntryPermission> set = Set<AclEntryPermission> set = EnumSet.noneOf(AclEntryPermission.class);
new HashSet<AclEntryPermission>(perms.length);
// copy and check for null elements // copy and check for null elements
for (AclEntryPermission p: perms) { for (AclEntryPermission p: perms) {
if (p == null) if (p == null)
...@@ -214,7 +213,7 @@ public final class AclEntry { ...@@ -214,7 +213,7 @@ public final class AclEntry {
*/ */
public Builder setFlags(Set<AclEntryFlag> flags) { public Builder setFlags(Set<AclEntryFlag> flags) {
// copy and check for erroneous elements // copy and check for erroneous elements
flags = new HashSet<AclEntryFlag>(flags); flags = EnumSet.copyOf(flags);
checkSet(flags, AclEntryFlag.class); checkSet(flags, AclEntryFlag.class);
this.flags = flags; this.flags = flags;
return this; return this;
...@@ -228,7 +227,7 @@ public final class AclEntry { ...@@ -228,7 +227,7 @@ public final class AclEntry {
* @return this builder * @return this builder
*/ */
public Builder setFlags(AclEntryFlag... flags) { public Builder setFlags(AclEntryFlag... flags) {
Set<AclEntryFlag> set = new HashSet<AclEntryFlag>(flags.length); Set<AclEntryFlag> set = EnumSet.noneOf(AclEntryFlag.class);
// copy and check for null elements // copy and check for null elements
for (AclEntryFlag f: flags) { for (AclEntryFlag f: flags) {
if (f == null) if (f == null)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册