This commit is contained in:
Kelly O'Hair 2011-02-10 20:48:02 -08:00
commit e77e12013b
336 changed files with 13336 additions and 9408 deletions

View File

@ -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

View File

@ -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 \

View File

@ -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 = \
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 = \
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 = \
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 = \
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 \

View File

@ -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 @@
<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>

View File

@ -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>

View File

@ -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,
} 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.

View File

@ -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();
} }
} }

View File

@ -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);

View File

@ -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 {
* 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);

View File

@ -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

View File

@ -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;
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
/** /**
* 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
* 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
* 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
* 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
* 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
* 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
/* -- 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
* 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
* 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
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
* 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
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;
} }
} }

View File

@ -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

View File

@ -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

View File

@ -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>

View File

@ -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
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
* @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
throws UnsupportedEncodingException throws UnsupportedEncodingException
{ {
this(autoFlush, this(autoFlush,
nonNull(out, "Null output stream"), requireNonNull(out, "Null output stream"),
toCharset(encoding)); toCharset(encoding));
} }

View File

@ -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) {

View File

@ -54,5 +54,3 @@
thread = null; thread = null;
} }
} }

View File

@ -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;
} }

View File

@ -1,5 +1,5 @@
/* /*
* 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.*;
* @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 {
/** /**

View File

@ -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 {

View File

@ -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 {
// 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--;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* 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 {
/** 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,

View File

@ -1,5 +1,5 @@
/* /*
* 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;
* 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> {
* <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}

View File

@ -1,5 +1,5 @@
/* /*
* 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;
* *
*<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>

View File

@ -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
* @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
* *
* @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
* <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
* @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
* *
* @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 --

View File

@ -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

View 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 {

View File

@ -0,0 +1,158 @@
/*
* 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);
}
}

View 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.

View File

@ -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));
} }
/** /**

View File

@ -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;
* 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;
* *
* @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>
/** /**
* 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
* *

View File

@ -1,322 +0,0 @@
/*
* 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;
}

View File

@ -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 {
*/ */
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 {
* 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 {
* 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):

View File

@ -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
* 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
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
* 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
* *
* 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
* @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
* <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

View File

@ -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 {
* 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 {
* *
* <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 {
* 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 {
.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) {
} }
} }

View File

@ -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 {
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 {
} 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 {
// 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 {
} 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

View File

@ -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;
* 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;
* 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;
* 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;
* } * }
* }); * });

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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;

View 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.

File diff suppressed because it is too large Load Diff

View 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 {

View File

@ -39,14 +39,27 @@ public final class Paths {
private Paths() { } private Paths() { }
/** /**
* Constructs a {@code Path} by converting the given path string. * Converts a path string, or a sequence of strings that when joined form
* a path string, to a {@code Path}. If {@code more} does not specify any
* elements then the value of the {@code first} parameter is the path string
* to convert. If {@code more} specifies one or more elements then each
* non-empty string, including {@code first}, is considered to be a sequence
* of name elements (see {@link Path}) and is joined to form a path string.
* The details as to how the Strings are joined is provider specific but
* typically they will be joined using the {@link FileSystem#getSeparator
* name-separator} as the separator. For example, if the name separator is
* "{@code /}" and {@code getPath("/foo","bar","gus")} is invoked, then the
* path string {@code "/foo/bar/gus"} is converted to a {@code Path}.
* A {@code Path} representing an empty path is returned if {@code first}
* is the empty string and {@code more} does not contain any non-empty
* strings.
* *
* <p> The {@code Path} is obtained by invoking the {@link FileSystem#getPath * <p> The {@code Path} is obtained by invoking the {@link FileSystem#getPath
* getPath} method of the {@link FileSystems#getDefault default} {@link * getPath} method of the {@link FileSystems#getDefault default} {@link
* FileSystem}. * FileSystem}.
* *
* <p> Note that while this method is very convenient, using it will * <p> Note that while this method is very convenient, using it will imply
* imply an assumed reference to the default FileSystem and limit the * an assumed reference to the default {@code FileSystem} and limit the
* utility of the calling code. Hence it should not be used in library code * utility of the calling code. Hence it should not be used in library code
* intended for flexible reuse. A more flexible alternative is to use an * intended for flexible reuse. A more flexible alternative is to use an
* existing {@code Path} instance as an anchor, such as: * existing {@code Path} instance as an anchor, such as:
@ -55,8 +68,10 @@ public final class Paths {
* Path path = dir.resolve("file"); * Path path = dir.resolve("file");
* </pre> * </pre>
* *
* @param path * @param first
* the path string to convert * the path string or initial part of the path string
* @param more
* additional strings to be joined to form the path string
* *
* @return the resulting {@code Path} * @return the resulting {@code Path}
* *
@ -65,8 +80,8 @@ public final class Paths {
* *
* @see FileSystem#getPath * @see FileSystem#getPath
*/ */
public static Path get(String path) { public static Path get(String first, String... more) {
return FileSystems.getDefault().getPath(path); return FileSystems.getDefault().getPath(first, more);
} }
/** /**

View File

@ -43,7 +43,7 @@ import java.io.IOException;
* *
* <p> A {@code SecureDirectoryStream} requires corresponding support from the * <p> A {@code SecureDirectoryStream} requires corresponding support from the
* underlying operating system. Where an implementation supports this features * underlying operating system. Where an implementation supports this features
* then the {@code DirectoryStream} returned by the {@link Path#newDirectoryStream * then the {@code DirectoryStream} returned by the {@link Files#newDirectoryStream
* newDirectoryStream} method will be a {@code SecureDirectoryStream} and must * newDirectoryStream} method will be a {@code SecureDirectoryStream} and must
* be cast to that type in order to invoke the methods defined by this interface. * be cast to that type in order to invoke the methods defined by this interface.
* *
@ -56,20 +56,15 @@ import java.io.IOException;
* @since 1.7 * @since 1.7
*/ */
public abstract class SecureDirectoryStream<T> public interface SecureDirectoryStream<T>
implements DirectoryStream<T> extends DirectoryStream<T>
{ {
/**
* Initialize a new instance of this class.
*/
protected SecureDirectoryStream() { }
/** /**
* Opens the directory identified by the given path, returning a {@code * Opens the directory identified by the given path, returning a {@code
* SecureDirectoryStream} to iterate over the entries in the directory. * SecureDirectoryStream} to iterate over the entries in the directory.
* *
* <p> This method works in exactly the manner specified by the {@link * <p> This method works in exactly the manner specified by the {@link
* Path#newDirectoryStream() newDirectoryStream} method for the case that * Files#newDirectoryStream(Path) newDirectoryStream} method for the case that
* the {@code path} parameter is an {@link Path#isAbsolute absolute} path. * the {@code path} parameter is an {@link Path#isAbsolute absolute} path.
* When the parameter is a relative path then the directory to open is * When the parameter is a relative path then the directory to open is
* relative to this open directory. The {@link * relative to this open directory. The {@link
@ -99,8 +94,7 @@ public abstract class SecureDirectoryStream<T>
* installed, the {@link SecurityManager#checkRead(String) checkRead} * installed, the {@link SecurityManager#checkRead(String) checkRead}
* method is invoked to check read access to the directory. * method is invoked to check read access to the directory.
*/ */
public abstract SecureDirectoryStream<T> newDirectoryStream(T path, SecureDirectoryStream<T> newDirectoryStream(T path, LinkOption... options)
LinkOption... options)
throws IOException; throws IOException;
/** /**
@ -108,11 +102,11 @@ public abstract class SecureDirectoryStream<T>
* channel to access the file. * channel to access the file.
* *
* <p> This method works in exactly the manner specified by the {@link * <p> This method works in exactly the manner specified by the {@link
* Path#newByteChannel Path.newByteChannel} method for the * Files#newByteChannel Files.newByteChannel} method for the
* case that the {@code path} parameter is an {@link Path#isAbsolute absolute} * case that the {@code path} parameter is an {@link Path#isAbsolute absolute}
* path. When the parameter is a relative path then the file to open or * path. When the parameter is a relative path then the file to open or
* create is relative to this open directory. In addition to the options * create is relative to this open directory. In addition to the options
* defined by the {@code Path.newByteChannel} method, the {@link * defined by the {@code Files.newByteChannel} method, the {@link
* LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} option may be used to * LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} option may be used to
* ensure that this method fails if the file is a symbolic link. * ensure that this method fails if the file is a symbolic link.
* *
@ -149,15 +143,15 @@ public abstract class SecureDirectoryStream<T>
* checkWrite} method is invoked to check write access to the path * checkWrite} method is invoked to check write access to the path
* if the file is opened for writing. * if the file is opened for writing.
*/ */
public abstract SeekableByteChannel newByteChannel(T path, SeekableByteChannel newByteChannel(T path,
Set<? extends OpenOption> options, Set<? extends OpenOption> options,
FileAttribute<?>... attrs) FileAttribute<?>... attrs)
throws IOException; throws IOException;
/** /**
* Deletes a file. * Deletes a file.
* *
* <p> Unlike the {@link Path#delete delete()} method, this method does * <p> Unlike the {@link Files#delete delete()} method, this method does
* not first examine the file to determine if the file is a directory. * not first examine the file to determine if the file is a directory.
* Whether a directory is deleted by this method is system dependent and * Whether a directory is deleted by this method is system dependent and
* therefore not specified. If the file is a symbolic link, then the link * therefore not specified. If the file is a symbolic link, then the link
@ -179,12 +173,12 @@ public abstract class SecureDirectoryStream<T>
* installed, the {@link SecurityManager#checkDelete(String) checkDelete} * installed, the {@link SecurityManager#checkDelete(String) checkDelete}
* method is invoked to check delete access to the file * method is invoked to check delete access to the file
*/ */
public abstract void deleteFile(T path) throws IOException; void deleteFile(T path) throws IOException;
/** /**
* Deletes a directory. * Deletes a directory.
* *
* <p> Unlike the {@link Path#delete delete()} method, this method * <p> Unlike the {@link Files#delete delete()} method, this method
* does not first examine the file to determine if the file is a directory. * does not first examine the file to determine if the file is a directory.
* Whether non-directories are deleted by this method is system dependent and * Whether non-directories are deleted by this method is system dependent and
* therefore not specified. When the parameter is a relative path then the * therefore not specified. When the parameter is a relative path then the
@ -207,12 +201,12 @@ public abstract class SecureDirectoryStream<T>
* installed, the {@link SecurityManager#checkDelete(String) checkDelete} * installed, the {@link SecurityManager#checkDelete(String) checkDelete}
* method is invoked to check delete access to the directory * method is invoked to check delete access to the directory
*/ */
public abstract void deleteDirectory(T path) throws IOException; void deleteDirectory(T path) throws IOException;
/** /**
* Move a file from this directory to another directory. * Move a file from this directory to another directory.
* *
* <p> This method works in a similar manner to {@link Path#moveTo moveTo} * <p> This method works in a similar manner to {@link Files#move move}
* method when the {@link StandardCopyOption#ATOMIC_MOVE ATOMIC_MOVE} option * method when the {@link StandardCopyOption#ATOMIC_MOVE ATOMIC_MOVE} option
* is specified. That is, this method moves a file as an atomic file system * is specified. That is, this method moves a file as an atomic file system
* operation. If the {@code srcpath} parameter is an {@link Path#isAbsolute * operation. If the {@code srcpath} parameter is an {@link Path#isAbsolute
@ -247,7 +241,7 @@ public abstract class SecureDirectoryStream<T>
* method is invoked to check write access to both the source and * method is invoked to check write access to both the source and
* target file. * target file.
*/ */
public abstract void move(T srcpath, SecureDirectoryStream<T> targetdir, T targetpath) void move(T srcpath, SecureDirectoryStream<T> targetdir, T targetpath)
throws IOException; throws IOException;
/** /**
@ -273,7 +267,7 @@ public abstract class SecureDirectoryStream<T>
* this directory stream, or {@code null} if the attribute view * this directory stream, or {@code null} if the attribute view
* type is not available * type is not available
*/ */
public abstract <V extends FileAttributeView> V getFileAttributeView(Class<V> type); <V extends FileAttributeView> V getFileAttributeView(Class<V> type);
/** /**
* Returns a new file attribute view to access the file attributes of a file * Returns a new file attribute view to access the file attributes of a file
@ -306,7 +300,7 @@ public abstract class SecureDirectoryStream<T>
* type is not available * type is not available
* *
*/ */
public abstract <V extends FileAttributeView> V getFileAttributeView(T path, <V extends FileAttributeView> V getFileAttributeView(T path,
Class<V> type, Class<V> type,
LinkOption... options); LinkOption... options);
} }

View File

@ -57,8 +57,8 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
public FileVisitResult preVisitDirectory(T dir, BasicFileAttributes attrs) public FileVisitResult preVisitDirectory(T dir, BasicFileAttributes attrs)
throws IOException throws IOException
{ {
Objects.nonNull(dir); Objects.requireNonNull(dir);
Objects.nonNull(attrs); Objects.requireNonNull(attrs);
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
} }
@ -72,8 +72,8 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
public FileVisitResult visitFile(T file, BasicFileAttributes attrs) public FileVisitResult visitFile(T file, BasicFileAttributes attrs)
throws IOException throws IOException
{ {
Objects.nonNull(file); Objects.requireNonNull(file);
Objects.nonNull(attrs); Objects.requireNonNull(attrs);
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
} }
@ -87,7 +87,7 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
public FileVisitResult visitFileFailed(T file, IOException exc) public FileVisitResult visitFileFailed(T file, IOException exc)
throws IOException throws IOException
{ {
Objects.nonNull(file); Objects.requireNonNull(file);
throw exc; throw exc;
} }
@ -104,7 +104,7 @@ public class SimpleFileVisitor<T> implements FileVisitor<T> {
public FileVisitResult postVisitDirectory(T dir, IOException exc) public FileVisitResult postVisitDirectory(T dir, IOException exc)
throws IOException throws IOException
{ {
Objects.nonNull(dir); Objects.requireNonNull(dir);
if (exc != null) if (exc != null)
throw exc; throw exc;
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;

View File

@ -23,54 +23,82 @@
* questions. * questions.
*/ */
package java.io; package java.nio.file;
import java.nio.file.FileSystems; import java.util.Set;
import java.nio.file.InvalidPathException; import java.util.EnumSet;
import java.nio.file.FileAlreadyExistsException; import java.security.SecureRandom;
import static java.security.AccessController.*;
import java.io.IOException;
import java.nio.file.attribute.FileAttribute; import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions; import java.nio.file.attribute.PosixFilePermissions;
import static java.nio.file.attribute.PosixFilePermission.*; import static java.nio.file.attribute.PosixFilePermission.*;
import java.util.Set; import sun.security.action.GetPropertyAction;
import java.util.EnumSet;
/** /**
* Helper class to support creation of temporary files and directory with * Helper class to support creation of temporary files and directories with
* initial attributes. * initial attributes.
*/ */
class TempFileHelper { class TempFileHelper {
private TempFileHelper() { } private TempFileHelper() { }
// temporary directory location
private static final Path tmpdir =
Paths.get(doPrivileged(new GetPropertyAction("java.io.tmpdir")));
private static final boolean isPosix =
FileSystems.getDefault().supportedFileAttributeViews().contains("posix");
// file name generation, same as java.io.File for now
private static final SecureRandom random = new SecureRandom();
private static Path generatePath(String prefix, String suffix, Path dir) {
long n = random.nextLong();
n = (n == Long.MIN_VALUE) ? 0 : Math.abs(n);
Path name = dir.getFileSystem().getPath(prefix + Long.toString(n) + suffix);
// the generated name should be a simple file name
if (name.getParent() != null)
throw new IllegalArgumentException("Invalid prefix or suffix");
return dir.resolve(name);
}
// default file and directory permissions (lazily initialized) // default file and directory permissions (lazily initialized)
private static class PermissionsHolder { private static class PosixPermissions {
static final boolean hasPosixPermissions = FileSystems.getDefault()
.supportedFileAttributeViews().contains("posix");
static final FileAttribute<Set<PosixFilePermission>> filePermissions = static final FileAttribute<Set<PosixFilePermission>> filePermissions =
PosixFilePermissions.asFileAttribute(EnumSet.of(OWNER_READ, OWNER_WRITE)); PosixFilePermissions.asFileAttribute(EnumSet.of(OWNER_READ, OWNER_WRITE));
static final FileAttribute<Set<PosixFilePermission>> directoryPermissions = static final FileAttribute<Set<PosixFilePermission>> dirPermissions =
PosixFilePermissions.asFileAttribute(EnumSet PosixFilePermissions.asFileAttribute(EnumSet
.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE)); .of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE));
} }
/** /**
* Creates a file or directory in the temporary directory. * Creates a file or directory in in the given given directory (or in the
* temporary directory if dir is {@code null}).
*/ */
private static File create(String prefix, private static Path create(Path dir,
String prefix,
String suffix, String suffix,
FileAttribute[] attrs, boolean createDirectory,
boolean isDirectory) FileAttribute[] attrs)
throws IOException throws IOException
{ {
if (prefix == null)
prefix = "";
if (suffix == null)
suffix = (createDirectory) ? "" : ".tmp";
if (dir == null)
dir = tmpdir;
// in POSIX environments use default file and directory permissions // in POSIX environments use default file and directory permissions
// if initial permissions not given by caller. // if initial permissions not given by caller.
if (PermissionsHolder.hasPosixPermissions) { if (isPosix && (dir.getFileSystem() == FileSystems.getDefault())) {
if (attrs.length == 0) { if (attrs.length == 0) {
// no attributes so use default permissions // no attributes so use default permissions
attrs = new FileAttribute<?>[1]; attrs = new FileAttribute<?>[1];
attrs[0] = (isDirectory) ? PermissionsHolder.directoryPermissions : attrs[0] = (createDirectory) ? PosixPermissions.dirPermissions :
PermissionsHolder.filePermissions; PosixPermissions.filePermissions;
} else { } else {
// check if posix permissions given; if not use default // check if posix permissions given; if not use default
boolean hasPermissions = false; boolean hasPermissions = false;
@ -84,9 +112,9 @@ class TempFileHelper {
FileAttribute<?>[] copy = new FileAttribute<?>[attrs.length+1]; FileAttribute<?>[] copy = new FileAttribute<?>[attrs.length+1];
System.arraycopy(attrs, 0, copy, 0, attrs.length); System.arraycopy(attrs, 0, copy, 0, attrs.length);
attrs = copy; attrs = copy;
attrs[attrs.length-1] = (isDirectory) ? attrs[attrs.length-1] = (createDirectory) ?
PermissionsHolder.directoryPermissions : PosixPermissions.dirPermissions :
PermissionsHolder.filePermissions; PosixPermissions.filePermissions;
} }
} }
} }
@ -94,24 +122,25 @@ class TempFileHelper {
// loop generating random names until file or directory can be created // loop generating random names until file or directory can be created
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
for (;;) { for (;;) {
File tmpdir = File.TempDirectory.location(); Path f;
File f = File.TempDirectory.generateFile(prefix, suffix, tmpdir);
try { try {
if (isDirectory) { f = generatePath(prefix, suffix, dir);
f.toPath().createDirectory(attrs);
} else {
f.toPath().createFile(attrs);
}
return f;
} catch (InvalidPathException e) { } catch (InvalidPathException e) {
// don't reveal temporary directory location // don't reveal temporary directory location
if (sm != null) if (sm != null)
throw new IllegalArgumentException("Invalid prefix or suffix"); throw new IllegalArgumentException("Invalid prefix or suffix");
throw e; throw e;
}
try {
if (createDirectory) {
return Files.createDirectory(f, attrs);
} else {
return Files.createFile(f, attrs);
}
} catch (SecurityException e) { } catch (SecurityException e) {
// don't reveal temporary directory location // don't reveal temporary directory location
if (sm != null) if (dir == tmpdir && sm != null)
throw new SecurityException("Unable to create temporary file"); throw new SecurityException("Unable to create temporary file or directory");
throw e; throw e;
} catch (FileAlreadyExistsException e) { } catch (FileAlreadyExistsException e) {
// ignore // ignore
@ -120,20 +149,27 @@ class TempFileHelper {
} }
/** /**
* Creates a file in the temporary directory. * Creates a temporary file in the given directory, or in in the
* temporary directory if dir is {@code null}.
*/ */
static File createFile(String prefix, String suffix, FileAttribute[] attrs) static Path createTempFile(Path dir,
String prefix,
String suffix,
FileAttribute[] attrs)
throws IOException throws IOException
{ {
return create(prefix, suffix, attrs, false); return create(dir, prefix, suffix, false, attrs);
} }
/** /**
* Creates a directory in the temporary directory. * Creates a temporary directory in the given directory, or in in the
* temporary directory if dir is {@code null}.
*/ */
static File createDirectory(String prefix, FileAttribute[] attrs) static Path createTempDirectory(Path dir,
String prefix,
FileAttribute[] attrs)
throws IOException throws IOException
{ {
return create(prefix, "", attrs, true); return create(dir, prefix, null, true, attrs);
} }
} }

View File

@ -44,7 +44,7 @@ package java.nio.file;
* @since 1.7 * @since 1.7
*/ */
public abstract class WatchEvent<T> { public interface WatchEvent<T> {
/** /**
* An event kind, for the purposes of identification. * An event kind, for the purposes of identification.
@ -64,11 +64,6 @@ public abstract class WatchEvent<T> {
Class<T> type(); Class<T> type();
} }
/**
* Initializes a new instance of this class.
*/
protected WatchEvent() { }
/** /**
* An event modifier that qualifies how a {@link Watchable} is registered * An event modifier that qualifies how a {@link Watchable} is registered
* with a {@link WatchService}. * with a {@link WatchService}.
@ -90,7 +85,7 @@ public abstract class WatchEvent<T> {
* *
* @return the event kind * @return the event kind
*/ */
public abstract Kind<T> kind(); Kind<T> kind();
/** /**
* Returns the event count. If the event count is greater than {@code 1} * Returns the event count. If the event count is greater than {@code 1}
@ -98,7 +93,7 @@ public abstract class WatchEvent<T> {
* *
* @return the event count * @return the event count
*/ */
public abstract int count(); int count();
/** /**
* Returns the context for the event. * Returns the context for the event.
@ -112,5 +107,5 @@ public abstract class WatchEvent<T> {
* *
* @return the event context; may be {@code null} * @return the event context; may be {@code null}
*/ */
public abstract T context(); T context();
} }

View File

@ -81,11 +81,7 @@ import java.util.List;
* @since 1.7 * @since 1.7
*/ */
public abstract class WatchKey { public interface WatchKey {
/**
* Initializes a new instance of this class.
*/
protected WatchKey() { }
/** /**
* Tells whether or not this watch key is valid. * Tells whether or not this watch key is valid.
@ -95,7 +91,7 @@ public abstract class WatchKey {
* *
* @return {@code true} if, and only if, this watch key is valid * @return {@code true} if, and only if, this watch key is valid
*/ */
public abstract boolean isValid(); boolean isValid();
/** /**
* Retrieves and removes all pending events for this watch key, returning * Retrieves and removes all pending events for this watch key, returning
@ -105,7 +101,7 @@ public abstract class WatchKey {
* *
* @return the list of the events retrieved; may be empty * @return the list of the events retrieved; may be empty
*/ */
public abstract List<WatchEvent<?>> pollEvents(); List<WatchEvent<?>> pollEvents();
/** /**
* Resets this watch key. * Resets this watch key.
@ -121,7 +117,7 @@ public abstract class WatchKey {
* {@code false} if the watch key could not be reset because it is * {@code false} if the watch key could not be reset because it is
* no longer {@link #isValid valid} * no longer {@link #isValid valid}
*/ */
public abstract boolean reset(); boolean reset();
/** /**
* Cancels the registration with the watch service. Upon return the watch key * Cancels the registration with the watch service. Upon return the watch key
@ -134,5 +130,21 @@ public abstract class WatchKey {
* <p> If this watch key has already been cancelled then invoking this * <p> If this watch key has already been cancelled then invoking this
* method has no effect. Once cancelled, a watch key remains forever invalid. * method has no effect. Once cancelled, a watch key remains forever invalid.
*/ */
public abstract void cancel(); void cancel();
/**
* Returns the object for which this watch key was created. This method will
* continue to return the object even after the key is cancelled.
*
* <p> As the {@code WatchService} is intended to map directly on to the
* native file event notification facility (where available) then many of
* details on how registered objects are watched is highly implementation
* specific. When watching a directory for changes for example, and the
* directory is moved or renamed in the file system, there is no guarantee
* that the watch key will be cancelled and so the object returned by this
* method may no longer be a valid path to the directory.
*
* @return the object for which this watch key was created
*/
//T watchable();
} }

View File

@ -103,13 +103,9 @@ import java.util.concurrent.TimeUnit;
* @see FileSystem#newWatchService * @see FileSystem#newWatchService
*/ */
public abstract class WatchService public interface WatchService
implements Closeable extends Closeable
{ {
/**
* Initializes a new instance of this class.
*/
protected WatchService() { }
/** /**
* Closes this watch service. * Closes this watch service.
@ -129,7 +125,7 @@ public abstract class WatchService
* if an I/O error occurs * if an I/O error occurs
*/ */
@Override @Override
public abstract void close() throws IOException; void close() throws IOException;
/** /**
* Retrieves and removes the next watch key, or {@code null} if none are * Retrieves and removes the next watch key, or {@code null} if none are
@ -140,7 +136,7 @@ public abstract class WatchService
* @throws ClosedWatchServiceException * @throws ClosedWatchServiceException
* if this watch service is closed * if this watch service is closed
*/ */
public abstract WatchKey poll(); WatchKey poll();
/** /**
* Retrieves and removes the next watch key, waiting if necessary up to the * Retrieves and removes the next watch key, waiting if necessary up to the
@ -160,7 +156,7 @@ public abstract class WatchService
* @throws InterruptedException * @throws InterruptedException
* if interrupted while waiting * if interrupted while waiting
*/ */
public abstract WatchKey poll(long timeout, TimeUnit unit) WatchKey poll(long timeout, TimeUnit unit)
throws InterruptedException; throws InterruptedException;
/** /**
@ -174,5 +170,5 @@ public abstract class WatchService
* @throws InterruptedException * @throws InterruptedException
* if interrupted while waiting * if interrupted while waiting
*/ */
public abstract WatchKey take() throws InterruptedException; WatchKey take() throws InterruptedException;
} }

View File

@ -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 {
* @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 {
*/ */
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 {
* @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)

View File

@ -65,7 +65,7 @@ import java.io.IOException;
* UserPrincipalLookupService} may be used to obtain a {@link UserPrincipal} * UserPrincipalLookupService} may be used to obtain a {@link UserPrincipal}
* to represent these special identities by invoking the {@link * to represent these special identities by invoking the {@link
* UserPrincipalLookupService#lookupPrincipalByName lookupPrincipalByName} * UserPrincipalLookupService#lookupPrincipalByName lookupPrincipalByName}
* method. * method. </p>
* *
* <p> <b>Usage Example:</b> * <p> <b>Usage Example:</b>
* Suppose we wish to add an entry to an existing ACL to grant "joe" access: * Suppose we wish to add an entry to an existing ACL to grant "joe" access:
@ -75,7 +75,7 @@ import java.io.IOException;
* .lookupPrincipalByName("joe"); * .lookupPrincipalByName("joe");
* *
* // get view * // get view
* AclFileAttributeView view = file.getFileAttributeView(AclFileAttributeView.class); * AclFileAttributeView view = Files.getFileAttributeView(file, AclFileAttributeView.class);
* *
* // create ACE to give "joe" read access * // create ACE to give "joe" read access
* AclEntry entry = AclEntry.newBuilder() * AclEntry entry = AclEntry.newBuilder()
@ -110,11 +110,11 @@ import java.io.IOException;
* </table> * </table>
* </blockquote> * </blockquote>
* *
* <p> The {@link FileRef#getAttribute getAttribute} method may be used to read * <p> The {@link Files#getAttribute getAttribute} method may be used to read
* the ACL or owner attributes as if by invoking the {@link #getAcl getAcl} or * the ACL or owner attributes as if by invoking the {@link #getAcl getAcl} or
* {@link #getOwner getOwner} methods. * {@link #getOwner getOwner} methods.
* *
* <p> The {@link FileRef#setAttribute setAttribute} method may be used to * <p> The {@link Files#setAttribute setAttribute} method may be used to
* update the ACL or owner attributes as if by invoking the {@link #setAcl setAcl} * update the ACL or owner attributes as if by invoking the {@link #setAcl setAcl}
* or {@link #setOwner setOwner} methods. * or {@link #setOwner setOwner} methods.
* *
@ -122,8 +122,8 @@ import java.io.IOException;
* *
* <p> Implementations supporting this attribute view may also support setting * <p> Implementations supporting this attribute view may also support setting
* the initial ACL when creating a file or directory. The initial ACL * the initial ACL when creating a file or directory. The initial ACL
* may be provided to methods such as {@link Path#createFile createFile} or {@link * may be provided to methods such as {@link Files#createFile createFile} or {@link
* Path#createDirectory createDirectory} as an {@link FileAttribute} with {@link * Files#createDirectory createDirectory} as an {@link FileAttribute} with {@link
* FileAttribute#name name} {@code "acl:acl"} and a {@link FileAttribute#value * FileAttribute#name name} {@code "acl:acl"} and a {@link FileAttribute#value
* value} that is the list of {@code AclEntry} objects. * value} that is the list of {@code AclEntry} objects.
* *
@ -135,8 +135,6 @@ import java.io.IOException;
* translation. * translation.
* *
* @since 1.7 * @since 1.7
* @see Attributes#getAcl
* @see Attributes#setAcl
*/ */
public interface AclFileAttributeView public interface AclFileAttributeView

View File

@ -1,460 +0,0 @@
/*
* 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.attribute;
import java.nio.file.*;
import java.io.IOException;
import java.util.*;
/**
* This class consists exclusively of static methods that operate on or return
* the attributes of files or file stores. These methods provide for convenient
* use of the {@link AttributeView attribute-views} defined in this package.
*
* @since 1.7
*/
public final class Attributes {
private Attributes() { }
/**
* Reads the basic file attributes of a file.
*
* <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 attributes of the final target
* of the link are 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 attributes of the symbolic link itself.
* This option should be used where there is a need to determine if a
* file is a symbolic link:
* <pre>
* boolean isSymbolicLink = Attributes.readBasicFileAttributes(file, NOFOLLOW_LINKS).isSymbolicLink();
* </pre>
*
* <p> It is implementation specific if all file attributes are read as an
* atomic operation with respect to other file system operations.
*
* @param file
* A file reference that locates the file
* @param options
* Options indicating how symbolic links are handled
*
* @return The basic file attributes
*
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
* In the case of the default provider, the security manager's {@link
* SecurityManager#checkRead(String) checkRead} method is invoked
* to check read access to file
*
* @see BasicFileAttributeView#readAttributes
*/
public static BasicFileAttributes readBasicFileAttributes(FileRef file,
LinkOption... options)
throws IOException
{
return file.getFileAttributeView(BasicFileAttributeView.class, options)
.readAttributes();
}
/**
* Reads the POSIX file attributes of a file.
*
* <p> The {@code file} parameter locates a file that supports the {@link
* PosixFileAttributeView}. This file attribute view provides access to a
* subset of the file attributes commonly associated with files on file
* systems used by operating systems that implement the Portable Operating
* System Interface (POSIX) family of standards. It is implementation
* specific if all file attributes are read as an atomic operation with
* respect to other file system operations.
*
* <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 attributes of the final target
* of the link are 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 attributes of the symbolic link itself.
*
* @param file
* A file reference that locates the file
* @param options
* Options indicating how symbolic links are handled
*
* @return The POSIX file attributes
*
* @throws UnsupportedOperationException
* If the {@code PosixFileAttributeView} is not available
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
* or its {@link SecurityManager#checkRead(String) checkRead} method
* denies read access to the file.
*
* @see PosixFileAttributeView#readAttributes
*/
public static PosixFileAttributes readPosixFileAttributes(FileRef file,
LinkOption... options)
throws IOException
{
PosixFileAttributeView view =
file.getFileAttributeView(PosixFileAttributeView.class, options);
if (view == null)
throw new UnsupportedOperationException();
return view.readAttributes();
}
/**
* Reads the DOS file attributes of a file.
*
* <p> The {@code file} parameter locates a file that supports the {@link
* DosFileAttributeView}. This file attribute view provides access to
* legacy "DOS" attributes supported by the file systems such as File
* Allocation Table (FAT), commonly used in <em>consumer devices</em>. It is
* implementation specific if all file attributes are read as an atomic
* operation with respect to other file system operations.
*
* <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 attributes of the final target
* of the link are 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 attributes of the symbolic link itself.
*
* @param file
* A file reference that locates the file
* @param options
* Options indicating how symbolic links are handled
*
* @return The DOS file attributes
*
* @throws UnsupportedOperationException
* If the {@code DosFileAttributeView} is not available
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
* In the case of the default provider, the security manager's {@link
* SecurityManager#checkRead(String) checkRead} method is invoked
* to check read access to file
*
* @see DosFileAttributeView#readAttributes
*/
public static DosFileAttributes readDosFileAttributes(FileRef file,
LinkOption... options)
throws IOException
{
DosFileAttributeView view =
file.getFileAttributeView(DosFileAttributeView.class, options);
if (view == null)
throw new UnsupportedOperationException();
return view.readAttributes();
}
/**
* Returns the owner of a file.
*
* <p> The {@code file} parameter locates a file that supports the {@link
* FileOwnerAttributeView}. This file attribute view provides access to
* a file attribute that is the owner of the file.
*
* @param file
* A file reference that locates the file
*
* @return A user principal representing the owner of the file
*
* @throws UnsupportedOperationException
* If the {@code FileOwnerAttributeView} is not available
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
* or its {@link SecurityManager#checkRead(String) checkRead} method
* denies read access to the file.
*
* @see FileOwnerAttributeView#getOwner
*/
public static UserPrincipal getOwner(FileRef file) throws IOException {
FileOwnerAttributeView view =
file.getFileAttributeView(FileOwnerAttributeView.class);
if (view == null)
throw new UnsupportedOperationException();
return view.getOwner();
}
/**
* Updates the file owner.
*
* <p> The {@code file} parameter locates a file that supports the {@link
* FileOwnerAttributeView}. This file attribute view provides access to
* a file attribute that is the owner of the file.
*
* @param file
* A file reference that locates the file
* @param owner
* The new file owner
*
* @throws UnsupportedOperationException
* If the {@code FileOwnerAttributeView} is not available
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
* or its {@link SecurityManager#checkWrite(String) checkWrite}
* method denies write access to the file.
*
* @see FileOwnerAttributeView#setOwner
*/
public static void setOwner(FileRef file, UserPrincipal owner)
throws IOException
{
FileOwnerAttributeView view =
file.getFileAttributeView(FileOwnerAttributeView.class);
if (view == null)
throw new UnsupportedOperationException();
view.setOwner(owner);
}
/**
* Reads a file's Access Control List (ACL).
*
* <p> The {@code file} parameter locates a file that supports the {@link
* AclFileAttributeView}. This file attribute view provides access to ACLs
* based on the ACL model specified in
* <a href="http://www.ietf.org/rfc/rfc3530.txt"><i>RFC&nbsp;3530</i></a>.
*
* @param file
* A file reference that locates the file
*
* @return An ordered list of {@link AclEntry entries} representing the
* ACL. The returned list is modifiable.
*
* @throws UnsupportedOperationException
* If the {@code AclAttributeView} is not available
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
* or its {@link SecurityManager#checkRead(String) checkRead} method
* denies read access to the file.
*
* @see AclFileAttributeView#getAcl
*/
public static List<AclEntry> getAcl(FileRef file) throws IOException {
AclFileAttributeView view =
file.getFileAttributeView(AclFileAttributeView.class);
if (view == null)
throw new UnsupportedOperationException();
return view.getAcl();
}
/**
* Updates a file's Access Control List (ACL).
*
* <p> The {@code file} parameter locates a file that supports the {@link
* AclFileAttributeView}. This file attribute view provides access to ACLs
* based on the ACL model specified in
* <a href="http://www.ietf.org/rfc/rfc3530.txt"><i>RFC&nbsp;3530</i></a>.
*
* @param file
* A file reference that locates the file
* @param acl
* The new file ACL
*
* @throws UnsupportedOperationException
* If the {@code AclFileAttributeView} is not available
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
* or its {@link SecurityManager#checkWrite(String) checkWrite}
* method denies write access to the file.
*
* @see AclFileAttributeView#setAcl
*/
public static void setAcl(FileRef file, List<AclEntry> acl)
throws IOException
{
AclFileAttributeView view =
file.getFileAttributeView(AclFileAttributeView.class);
if (view == null)
throw new UnsupportedOperationException();
view.setAcl(acl);
}
/**
* Updates a file's last modified time attribute. The file time is converted
* to the epoch and precision supported by the file system. Converting from
* finer to coarser granularities result in precision loss. The behavior of
* this method when attempting to set a timestamp to a value that is outside
* the range supported by the underlying file store is not defined. It may
* or not fail by throwing an {@code IOException}.
*
* <p> If the file system does not support a last modified time attribute
* then this method has no effect.
*
* <p> <b>Usage Example:</b>
* Suppose we want to set the last modified time to the current time:
* <pre>
* FileTime now = FileTime.fromMillis(System.currentTimeMillis());
* Attributes.setLastModifiedTime(file, now);
* </pre>
*
* @param file
* A file reference that locates the file
* @param lastModifiedTime
* The new last modified time
*
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
* In the case of the default provider, the security manager's {@link
* SecurityManager#checkWrite(String) checkWrite} method is invoked
* to check write access to file
*
* @see BasicFileAttributeView#setTimes
*/
public static void setLastModifiedTime(FileRef file,
FileTime lastModifiedTime)
throws IOException
{
if (lastModifiedTime == null)
throw new NullPointerException("'lastModifiedTime' is null");
file.getFileAttributeView(BasicFileAttributeView.class)
.setTimes(lastModifiedTime, null, null);
}
/**
* Updates a file's last access time attribute. The file time is converted
* to the epoch and precision supported by the file system. Converting from
* finer to coarser granularities result in precision loss. The behavior of
* this method when attempting to set a timestamp to a value that is outside
* the range supported by the underlying file store is not defined. It may
* or not fail by throwing an {@code IOException}.
*
* <p> If the file system does not support a last access time attribute then
* this method has no effect.
*
* @param file
* A file reference that locates the file
* @param lastAccessTime
* The new last access time
*
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
* In the case of the default provider, the security manager's {@link
* SecurityManager#checkWrite(String) checkWrite} method is invoked
* to check write access to file
*
* @see BasicFileAttributeView#setTimes
*/
public static void setLastAccessTime(FileRef file,
FileTime lastAccessTime)
throws IOException
{
if (lastAccessTime == null)
throw new NullPointerException("'lastAccessTime' is null");
file.getFileAttributeView(BasicFileAttributeView.class)
.setTimes(null, lastAccessTime, null);
}
/**
* Sets a file's POSIX permissions.
*
* <p> The {@code file} parameter is a reference to an existing file. It
* supports the {@link PosixFileAttributeView} that provides access to file
* attributes commonly associated with files on file systems used by
* operating systems that implement the Portable Operating System Interface
* (POSIX) family of standards.
*
* @param file
* A file reference that locates the file
* @param perms
* The new set of permissions
*
* @throws UnsupportedOperationException
* If {@code PosixFileAttributeView} is not available
* @throws ClassCastException
* If the sets contains elements that are not of type {@code
* PosixFilePermission}
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, it denies {@link RuntimePermission}<tt>("accessUserInformation")</tt>
* or its {@link SecurityManager#checkWrite(String) checkWrite}
* method denies write access to the file.
*
* @see PosixFileAttributeView#setPermissions
*/
public static void setPosixFilePermissions(FileRef file,
Set<PosixFilePermission> perms)
throws IOException
{
PosixFileAttributeView view =
file.getFileAttributeView(PosixFileAttributeView.class);
if (view == null)
throw new UnsupportedOperationException();
view.setPermissions(perms);
}
/**
* Reads the space attributes of a file store.
*
* <p> The {@code store} parameter is a file store that supports the
* {@link FileStoreSpaceAttributeView} providing access to the space related
* attributes of the file store. It is implementation specific if all attributes
* are read as an atomic operation with respect to other file system operations.
*
* @param store
* The file store
*
* @return The file store space attributes
*
* @throws UnsupportedOperationException
* If the file store space attribute view is not supported
* @throws IOException
* If an I/O error occurs
*
* @see FileStoreSpaceAttributeView#readAttributes()
*/
public static FileStoreSpaceAttributes readFileStoreSpaceAttributes(FileStore store)
throws IOException
{
FileStoreSpaceAttributeView view =
store.getFileStoreAttributeView(FileStoreSpaceAttributeView.class);
if (view == null)
throw new UnsupportedOperationException();
return view.readAttributes();
}
}

View File

@ -85,16 +85,15 @@ import java.io.IOException;
* </table> * </table>
* </blockquote> * </blockquote>
* *
* <p> The {@link java.nio.file.FileRef#getAttribute getAttribute} method may be * <p> The {@link java.nio.file.Files#getAttribute getAttribute} method may be
* used to read any of these attributes as if by invoking the {@link * used to read any of these attributes as if by invoking the {@link
* #readAttributes() readAttributes()} method. * #readAttributes() readAttributes()} method.
* *
* <p> The {@link java.nio.file.FileRef#setAttribute setAttribute} method may be * <p> The {@link java.nio.file.Files#setAttribute setAttribute} method may be
* used to update the file's last modified time, last access time or create time * used to update the file's last modified time, last access time or create time
* attributes as if by invoking the {@link #setTimes setTimes} method. * attributes as if by invoking the {@link #setTimes setTimes} method.
* *
* @since 1.7 * @since 1.7
* @see Attributes
*/ */
public interface BasicFileAttributeView public interface BasicFileAttributeView
@ -131,9 +130,10 @@ public interface BasicFileAttributeView
* <p> This method updates the file's timestamp attributes. The values are * <p> This method updates the file's timestamp attributes. The values are
* converted to the epoch and precision supported by the file system. * converted to the epoch and precision supported by the file system.
* Converting from finer to coarser granularities result in precision loss. * Converting from finer to coarser granularities result in precision loss.
* The behavior of this method when attempting to set a timestamp to a value * The behavior of this method when attempting to set a timestamp that is
* that is outside the range supported by the underlying file store is not * not supported or to a value that is outside the range supported by the
* defined. It may or not fail by throwing an {@code IOException}. * underlying file store is not defined. It may or not fail by throwing an
* {@code IOException}.
* *
* <p> If any of the {@code lastModifiedTime}, {@code lastAccessTime}, * <p> If any of the {@code lastModifiedTime}, {@code lastAccessTime},
* or {@code createTime} parameters has the value {@code null} then the * or {@code createTime} parameters has the value {@code null} then the
@ -146,6 +146,14 @@ public interface BasicFileAttributeView
* lastAccessTime} and {@code createTime} parameters are {@code null} then * lastAccessTime} and {@code createTime} parameters are {@code null} then
* this method has no effect. * this method has no effect.
* *
* <p> <b>Usage Example:</b>
* Suppose we want to change a file's creation time.
* <pre>
* Path path = ...
* FileTime time = ...
* Files.getFileAttributeView(path, BasicFileAttributeView.class).setTimes(null, null, time);
* </pre>
*
* @param lastModifiedTime * @param lastModifiedTime
* the new last modified time, or {@code null} to not change the * the new last modified time, or {@code null} to not change the
* value * value
@ -160,6 +168,8 @@ public interface BasicFileAttributeView
* In the case of the default provider, a security manager is * In the case of the default provider, a security manager is
* installed, its {@link SecurityManager#checkWrite(String) checkWrite} * installed, its {@link SecurityManager#checkWrite(String) checkWrite}
* method is invoked to check write access to the file * method is invoked to check write access to the file
*
* @see java.nio.file.Files#setLastModifiedTime
*/ */
void setTimes(FileTime lastModifiedTime, void setTimes(FileTime lastModifiedTime,
FileTime lastAccessTime, FileTime lastAccessTime,

View File

@ -34,8 +34,8 @@ package java.nio.file.attribute;
* *
* <p> <b>Usage Example:</b> * <p> <b>Usage Example:</b>
* <pre> * <pre>
* FileRef file = ... * Path file = ...
* BasicFileAttributes attrs = Attributes.readBasicFileAttributes(file); * BasicFileAttributes attrs = Files.readAttributes(file, BasicFileAttributes.class);
* </pre> * </pre>
* *
* @since 1.7 * @since 1.7
@ -48,25 +48,40 @@ public interface BasicFileAttributes {
/** /**
* Returns the time of last modification. * Returns the time of last modification.
* *
* <p> If the file system implementation does not support a time stamp
* to indicate the time of last modification then this method returns an
* implementation specific default value, typically a {@code FileTime}
* representing the epoch (1970-01-01T00:00:00Z).
*
* @return a {@code FileTime} representing the time the file was last * @return a {@code FileTime} representing the time the file was last
* modified or {@code null} if the attribute is not supported. * modified
*/ */
FileTime lastModifiedTime(); FileTime lastModifiedTime();
/** /**
* Returns the time of last access if supported. * Returns the time of last access.
* *
* @return a {@code FileTime} representing the time of last access or * <p> If the file system implementation does not support a time stamp
* {@code null} if the attribute is not supported. * to indicate the time of last access then this method returns
* an implementation specific default value, typically the {@link
* #lastModifiedTime() last-modified-time} or a {@code FileTime}
* representing the epoch (1970-01-01T00:00:00Z).
*
* @return a {@code FileTime} representing the time of last access
*/ */
FileTime lastAccessTime(); FileTime lastAccessTime();
/** /**
* Returns the creation time if supported. The creation time is the time * Returns the creation time. The creation time is the time that the file
* that the file was created. * was created.
* *
* @return a {@code FileTime} representing the time the file was created * <p> If the file system implementation does not support a time stamp
* or {@code null} if the attribute is not supported. * to indicate the time when the file was created then this method returns
* an implementation specific default value, typically the {@link
* #lastModifiedTime() last-modified-time} or a {@code FileTime}
* representing the epoch (1970-01-01T00:00:00Z).
*
* @return a {@code FileTime} representing the time the file was created
*/ */
FileTime creationTime(); FileTime creationTime();
@ -120,7 +135,7 @@ public interface BasicFileAttributes {
* *
* <p> File keys returned by this method can be compared for equality and are * <p> File keys returned by this method can be compared for equality and are
* suitable for use in collections. If the file system and files remain static, * suitable for use in collections. If the file system and files remain static,
* and two files are the {@link java.nio.file.Path#isSameFile same} with * and two files are the {@link java.nio.file.Files#isSameFile same} with
* non-{@code null} file keys, then their file keys are equal. * non-{@code null} file keys, then their file keys are equal.
* *
* @see java.nio.file.Files#walkFileTree * @see java.nio.file.Files#walkFileTree

View File

@ -65,12 +65,12 @@ import java.io.IOException;
* </table> * </table>
* </blockquote> * </blockquote>
* *
* <p> The {@link java.nio.file.FileRef#getAttribute getAttribute} method may * <p> The {@link java.nio.file.Files#getAttribute getAttribute} method may
* be used to read any of these attributes, or any of the attributes defined by * be used to read any of these attributes, or any of the attributes defined by
* {@link BasicFileAttributeView} as if by invoking the {@link #readAttributes * {@link BasicFileAttributeView} as if by invoking the {@link #readAttributes
* readAttributes()} method. * readAttributes()} method.
* *
* <p> The {@link java.nio.file.FileRef#setAttribute setAttribute} method may * <p> The {@link java.nio.file.Files#setAttribute setAttribute} method may
* be used to update the file's last modified time, last access time or create * be used to update the file's last modified time, last access time or create
* time attributes as defined by {@link BasicFileAttributeView}. It may also be * time attributes as defined by {@link BasicFileAttributeView}. It may also be
* used to update the DOS attributes as if by invoking the {@link #setReadOnly * used to update the DOS attributes as if by invoking the {@link #setReadOnly

View File

@ -29,13 +29,13 @@ package java.nio.file.attribute;
* File attributes associated with a file in a file system that supports * File attributes associated with a file in a file system that supports
* legacy "DOS" attributes. * legacy "DOS" attributes.
* *
* <p> The DOS attributes of a file are retrieved using a {@link * <p> <b>Usage Example:</b>
* DosFileAttributeView} by invoking its {@link DosFileAttributeView#readAttributes * <pre>
* readAttributes} method. * Path file = ...
* DosFileAttributes attrs = Files.readAttributes(file, DosFileAttributes.class);
* </pre>
* *
* @since 1.7 * @since 1.7
*
* @see Attributes#readDosFileAttributes
*/ */
public interface DosFileAttributes public interface DosFileAttributes

View File

@ -28,8 +28,8 @@ package java.nio.file.attribute;
/** /**
* An object that encapsulates the value of a file attribute that can be set * An object that encapsulates the value of a file attribute that can be set
* atomically when creating a new file or directory by invoking the {@link * atomically when creating a new file or directory by invoking the {@link
* java.nio.file.Path#createFile createFile} or {@link * java.nio.file.Files#createFile createFile} or {@link
* java.nio.file.Path#createDirectory createDirectory} methods. * java.nio.file.Files#createDirectory createDirectory} methods.
* *
* @param <T> The type of the file attribute value * @param <T> The type of the file attribute value
* *

View File

@ -33,7 +33,7 @@ package java.nio.file.attribute;
* *
* @since 1.7 * @since 1.7
* *
* @see java.nio.file.FileRef#getFileAttributeView(Class,java.nio.file.LinkOption[]) * @see java.nio.file.Files#getFileAttributeView(Path,Class,java.nio.file.LinkOption[])
*/ */
public interface FileAttributeView public interface FileAttributeView

View File

@ -37,8 +37,8 @@ import java.io.IOException;
* <p> The {@link #getOwner getOwner} or {@link #setOwner setOwner} methods may * <p> The {@link #getOwner getOwner} or {@link #setOwner setOwner} methods may
* be used to read or update the owner of the file. * be used to read or update the owner of the file.
* *
* <p> The {@link java.nio.file.FileRef#getAttribute getAttribute} and * <p> The {@link java.nio.file.Files#getAttribute getAttribute} and
* {@link java.nio.file.FileRef#setAttribute setAttribute} methods may also be * {@link java.nio.file.Files#setAttribute setAttribute} methods may also be
* used to read or update the owner. In that case, the owner attribute is * used to read or update the owner. In that case, the owner attribute is
* identified by the name {@code "owner"}, and the value of the attribute is * identified by the name {@code "owner"}, and the value of the attribute is
* a {@link UserPrincipal}. * a {@link UserPrincipal}.

View File

@ -1,83 +0,0 @@
/*
* 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.attribute;
import java.io.IOException;
/**
* A file store attribute view that supports reading of space attributes.
*
* <p> Where dynamic access to file attributes is required, the attributes
* supported by this attribute view have the following names and types:
* <blockquote>
* <table border="1" cellpadding="8">
* <tr>
* <th> Name </th>
* <th> Type </th>
* </tr>
* <tr>
* <td> "totalSpace" </td>
* <td> {@link Long} </td>
* </tr>
* <tr>
* <td> "usableSpace" </td>
* <td> {@link Long} </td>
* </tr>
* <tr>
* <td> "unallocatedSpace" </td>
* <td> {@link Long} </td>
* </tr>
* </table>
* </blockquote>
* <p> The {@link java.nio.file.FileStore#getAttribute getAttribute} method may
* be used to read any of these attributes.
*
* @since 1.7
*/
public interface FileStoreSpaceAttributeView
extends FileStoreAttributeView
{
/**
* Returns the name of the attribute view. Attribute views of this type
* have the name {@code "space"}.
*/
@Override
String name();
/**
* Reads the disk space attributes as a bulk operation.
*
* <p> It is file system specific if all attributes are read as an
* atomic operation with respect to other file system operations.
*
* @return The disk space attributes
*
* @throws IOException
* If an I/O error occurs
*/
FileStoreSpaceAttributes readAttributes() throws IOException;
}

View File

@ -1,66 +0,0 @@
/*
* 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.attribute;
/**
* Space related attributes of a file store.
*
* @since 1.7
*
* @see Attributes#readFileStoreSpaceAttributes
*/
public interface FileStoreSpaceAttributes {
/**
* Returns the size, in bytes, of the file store.
*/
long totalSpace();
/**
* 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.
*/
long usableSpace();
/**
* 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.
*/
long unallocatedSpace();
}

View File

@ -35,20 +35,53 @@ import java.util.concurrent.TimeUnit;
/** /**
* Represents the value of a file's time stamp attribute. For example, it may * Represents the value of a file's time stamp attribute. For example, it may
* represent the time that the file was last modified, accessed, or created. * represent the time that the file was last
* {@link BasicFileAttributes#lastModifiedTime() modified},
* {@link BasicFileAttributes#lastAccessTime() accessed},
* or {@link BasicFileAttributes#creationTime() created}.
* *
* <p> Instances of this class are immutable. * <p> Instances of this class are immutable.
* *
* @since 1.7 * @since 1.7
* @see BasicFileAttributes * @see java.nio.file.Files#setLastModifiedTime
* @see Attributes#setLastModifiedTime * @see java.nio.file.Files#getLastModifiedTime
*/ */
public final class FileTime implements Comparable<FileTime> { public final class FileTime
implements Comparable<FileTime>
{
/**
* The value since the epoch; can be negative.
*/
private final long value; private final long value;
private final TimeUnit unit;
private String valueAsString; // created lazily
/**
* The unit of granularity to interpret the value.
*/
private final TimeUnit unit;
/**
* The value return by toString (created lazily)
*/
private String valueAsString;
/**
* The value in days and excess nanos (created lazily)
*/
private DaysAndNanos daysAndNanos;
/**
* Returns a DaysAndNanos object representing the value.
*/
private DaysAndNanos asDaysAndNanos() {
if (daysAndNanos == null)
daysAndNanos = new DaysAndNanos(value, unit);
return daysAndNanos;
}
/**
* Initializes a new instance of this class.
*/
private FileTime(long value, TimeUnit unit) { private FileTime(long value, TimeUnit unit) {
if (unit == null) if (unit == null)
throw new NullPointerException(); throw new NullPointerException();
@ -143,9 +176,8 @@ public final class FileTime implements Comparable<FileTime> {
*/ */
@Override @Override
public int hashCode() { public int hashCode() {
// hash value for fixed granularity to satisfy contract with equals // hashcode of days/nanos representation to satisfy contract with equals
long ms = toMillis(); return asDaysAndNanos().hashCode();
return (int)(ms ^ (ms >>> 32));
} }
/** /**
@ -162,46 +194,12 @@ public final class FileTime implements Comparable<FileTime> {
@Override @Override
public int compareTo(FileTime other) { public int compareTo(FileTime other) {
// same granularity // same granularity
if (unit == other.unit) if (unit == other.unit) {
return (value < other.value) ? -1 : (value == other.value ? 0 : 1); return (value < other.value) ? -1 : (value == other.value ? 0 : 1);
} else {
// compare in days // compare using days/nanos representation when unit differs
long thisValueInDays = unit.toDays(value); return asDaysAndNanos().compareTo(other.asDaysAndNanos());
long otherValueInDays = other.unit.toDays(other.value);
if (thisValueInDays != otherValueInDays)
return (thisValueInDays < otherValueInDays) ? -1 : 1;
// compare remainder in nanoseconds
long thisRemainder = remainderInNanos(thisValueInDays);
long otherRemainder = other.remainderInNanos(otherValueInDays);
return (thisRemainder < otherRemainder) ? -1 :
(thisRemainder == otherRemainder) ? 0 : 1;
}
private long remainderInNanos(long days) {
// constants for conversion
final long C0 = 1L;
final long C1 = C0 * 24L;
final long C2 = C1 * 60L;
final long C3 = C2 * 60L;
final long C4 = C3 * 1000L;
final long C5 = C4 * 1000L;
final long C6 = C5 * 1000L;
long scale;
switch (unit) {
case DAYS : scale = C0; break;
case HOURS : scale = C1; break;
case MINUTES : scale = C2; break;
case SECONDS : scale = C3; break;
case MILLISECONDS : scale = C4; break;
case MICROSECONDS : scale = C5; break;
case NANOSECONDS : scale = C6; break;
default:
throw new AssertionError("Unit not handled");
} }
long rem = value - (days * scale);
return unit.toNanos(rem);
} }
/** /**
@ -239,26 +237,12 @@ public final class FileTime implements Comparable<FileTime> {
// nothing to do when seconds/minutes/hours/days // nothing to do when seconds/minutes/hours/days
String fractionAsString = ""; String fractionAsString = "";
if (unit.compareTo(TimeUnit.SECONDS) < 0) { if (unit.compareTo(TimeUnit.SECONDS) < 0) {
// constants for conversion long fraction = asDaysAndNanos().fractionOfSecondInNanos();
final long C0 = 1L;
final long C1 = C0 * 1000L;
final long C2 = C1 * 1000L;
final long C3 = C2 * 1000L;
long scale;
int width;
switch (unit) {
case MILLISECONDS : scale = C1; width = 3; break;
case MICROSECONDS : scale = C2; width = 6; break;
case NANOSECONDS : scale = C3; width = 9; break;
default:
throw new AssertionError("Unit not handled");
}
long fraction = value % scale;
if (fraction != 0L) { if (fraction != 0L) {
// fraction must be positive // fraction must be positive
if (fraction < 0L) { if (fraction < 0L) {
fraction += scale; final long MAX_FRACTION_PLUS_1 = 1000L * 1000L * 1000L;
fraction += MAX_FRACTION_PLUS_1;
if (ms != Long.MIN_VALUE) ms--; if (ms != Long.MIN_VALUE) ms--;
} }
@ -266,7 +250,7 @@ public final class FileTime implements Comparable<FileTime> {
// stripping any trailing zeros // stripping any trailing zeros
String s = Long.toString(fraction); String s = Long.toString(fraction);
int len = s.length(); int len = s.length();
width -= len; int width = 9 - len;
StringBuilder sb = new StringBuilder("."); StringBuilder sb = new StringBuilder(".");
while (width-- > 0) { while (width-- > 0) {
sb.append('0'); sb.append('0');
@ -302,4 +286,76 @@ public final class FileTime implements Comparable<FileTime> {
} }
return v; return v;
} }
/**
* Represents a FileTime's value as two longs: the number of days since
* the epoch, and the excess (in nanoseconds). This is used for comparing
* values with different units of granularity.
*/
private static class DaysAndNanos implements Comparable<DaysAndNanos> {
// constants for conversion
private static final long C0 = 1L;
private static final long C1 = C0 * 24L;
private static final long C2 = C1 * 60L;
private static final long C3 = C2 * 60L;
private static final long C4 = C3 * 1000L;
private static final long C5 = C4 * 1000L;
private static final long C6 = C5 * 1000L;
/**
* The value (in days) since the epoch; can be negative.
*/
private final long days;
/**
* The excess (in nanoseconds); can be negative if days <= 0.
*/
private final long excessNanos;
/**
* Initializes a new instance of this class.
*/
DaysAndNanos(long value, TimeUnit unit) {
long scale;
switch (unit) {
case DAYS : scale = C0; break;
case HOURS : scale = C1; break;
case MINUTES : scale = C2; break;
case SECONDS : scale = C3; break;
case MILLISECONDS : scale = C4; break;
case MICROSECONDS : scale = C5; break;
case NANOSECONDS : scale = C6; break;
default : throw new AssertionError("Unit not handled");
}
this.days = unit.toDays(value);
this.excessNanos = unit.toNanos(value - (this.days * scale));
}
/**
* Returns the fraction of a second, in nanoseconds.
*/
long fractionOfSecondInNanos() {
return excessNanos % (1000L * 1000L * 1000L);
}
@Override
public boolean equals(Object obj) {
return (obj instanceof DaysAndNanos) ?
compareTo((DaysAndNanos)obj) == 0 : false;
}
@Override
public int hashCode() {
return (int)(days ^ (days >>> 32) ^
excessNanos ^ (excessNanos >>> 32));
}
@Override
public int compareTo(DaysAndNanos other) {
if (this.days != other.days)
return (this.days < other.days) ? -1 : 1;
return (this.excessNanos < other.excessNanos) ? -1 :
(this.excessNanos == other.excessNanos) ? 0 : 1;
}
}
} }

View File

@ -60,8 +60,8 @@ import java.io.IOException;
* <p> <b>Usage Example:</b> * <p> <b>Usage Example:</b>
* Suppose we need to print out the owner and access permissions of a file: * Suppose we need to print out the owner and access permissions of a file:
* <pre> * <pre>
* FileRef file = ... * Path file = ...
* PosixFileAttributes attrs = file.getFileAttributeView(PosixFileAttributeView.class) * PosixFileAttributes attrs = Files.getFileAttributeView(file, PosixFileAttributeView.class)
* .readAttributes(); * .readAttributes();
* System.out.format("%s %s%n", * System.out.format("%s %s%n",
* attrs.owner().getName(), * attrs.owner().getName(),
@ -90,12 +90,12 @@ import java.io.IOException;
* </table> * </table>
* </blockquote> * </blockquote>
* *
* <p> The {@link FileRef#getAttribute getAttribute} method may be used to read * <p> The {@link Files#getAttribute getAttribute} method may be used to read
* any of these attributes, or any of the attributes defined by {@link * any of these attributes, or any of the attributes defined by {@link
* BasicFileAttributeView} as if by invoking the {@link #readAttributes * BasicFileAttributeView} as if by invoking the {@link #readAttributes
* readAttributes()} method. * readAttributes()} method.
* *
* <p> The {@link FileRef#setAttribute setAttribute} method may be used to update * <p> The {@link Files#setAttribute setAttribute} method may be used to update
* the file's last modified time, last access time or create time attributes as * the file's last modified time, last access time or create time attributes as
* defined by {@link BasicFileAttributeView}. It may also be used to update * defined by {@link BasicFileAttributeView}. It may also be used to update
* the permissions, owner, or group-owner as if by invoking the {@link * the permissions, owner, or group-owner as if by invoking the {@link
@ -105,8 +105,8 @@ import java.io.IOException;
* <h4> Setting Initial Permissions </h4> * <h4> Setting Initial Permissions </h4>
* <p> Implementations supporting this attribute view may also support setting * <p> Implementations supporting this attribute view may also support setting
* the initial permissions when creating a file or directory. The * the initial permissions when creating a file or directory. The
* initial permissions are provided to the {@link Path#createFile createFile} * initial permissions are provided to the {@link Files#createFile createFile}
* or {@link Path#createDirectory createDirectory} methods as a {@link * or {@link Files#createDirectory createDirectory} methods as a {@link
* FileAttribute} with {@link FileAttribute#name name} {@code "posix:permissions"} * FileAttribute} with {@link FileAttribute#name name} {@code "posix:permissions"}
* and a {@link FileAttribute#value value} that is the set of permissions. The * and a {@link FileAttribute#value value} that is the set of permissions. The
* following example uses the {@link PosixFilePermissions#asFileAttribute * following example uses the {@link PosixFilePermissions#asFileAttribute
@ -117,7 +117,7 @@ import java.io.IOException;
* Path path = ... * Path path = ...
* Set&lt;PosixFilePermission&gt; perms = * Set&lt;PosixFilePermission&gt; perms =
* EnumSet.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ); * EnumSet.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ);
* path.createFile(PosixFilePermissions.asFileAttribute(perms)); * Files.createFile(path, PosixFilePermissions.asFileAttribute(perms));
* </pre> * </pre>
* *
* <p> When the access permissions are set at file creation time then the actual * <p> When the access permissions are set at file creation time then the actual
@ -128,13 +128,11 @@ import java.io.IOException;
* the access permissions, and the underlying file system supports access * the access permissions, and the underlying file system supports access
* permissions, then it is required that the value of the actual access * permissions, then it is required that the value of the actual access
* permissions will be equal or less than the value of the attribute * permissions will be equal or less than the value of the attribute
* provided to the {@link java.nio.file.Path#createFile createFile} or * provided to the {@link Files#createFile createFile} or {@link
* {@link java.nio.file.Path#createDirectory createDirectory} methods. In * Files#createDirectory createDirectory} methods. In other words, the file may
* other words, the file may be more secure than requested. * be more secure than requested.
* *
* @since 1.7 * @since 1.7
*
* @see Attributes#readPosixFileAttributes
*/ */
public interface PosixFileAttributeView public interface PosixFileAttributeView

View File

@ -37,8 +37,6 @@ import java.util.Set;
* PosixFileAttributeView#readAttributes readAttributes} method. * PosixFileAttributeView#readAttributes readAttributes} method.
* *
* @since 1.7 * @since 1.7
*
* @see Attributes#readPosixFileAttributes
*/ */
public interface PosixFileAttributes public interface PosixFileAttributes

View File

@ -25,14 +25,12 @@
package java.nio.file.attribute; package java.nio.file.attribute;
import java.util.*;
/** /**
* Defines the bits for use with the {@link PosixFileAttributes#permissions() * Defines the bits for use with the {@link PosixFileAttributes#permissions()
* permissions} attribute. * permissions} attribute.
* *
* <p> The {@link PosixFileAttributes} class defines method methods for * <p> The {@link PosixFilePermissions} class defines methods for manipulating
* manipulating {@link Set sets} of permissions. * set of permissions.
* *
* @since 1.7 * @since 1.7
*/ */

View File

@ -126,7 +126,7 @@ public final class PosixFilePermissions {
public static Set<PosixFilePermission> fromString(String perms) { public static Set<PosixFilePermission> fromString(String perms) {
if (perms.length() != 9) if (perms.length() != 9)
throw new IllegalArgumentException("Invalid mode"); throw new IllegalArgumentException("Invalid mode");
Set<PosixFilePermission> result = new HashSet<PosixFilePermission>(); Set<PosixFilePermission> result = EnumSet.noneOf(PosixFilePermission.class);
if (isR(perms.charAt(0))) result.add(OWNER_READ); if (isR(perms.charAt(0))) result.add(OWNER_READ);
if (isW(perms.charAt(1))) result.add(OWNER_WRITE); if (isW(perms.charAt(1))) result.add(OWNER_WRITE);
if (isX(perms.charAt(2))) result.add(OWNER_EXECUTE); if (isX(perms.charAt(2))) result.add(OWNER_EXECUTE);
@ -141,8 +141,8 @@ public final class PosixFilePermissions {
/** /**
* Creates a {@link FileAttribute}, encapsulating a copy of the given file * Creates a {@link FileAttribute}, encapsulating a copy of the given file
* permissions, suitable for passing to the {@link java.nio.file.Path#createFile * permissions, suitable for passing to the {@link java.nio.file.Files#createFile
* createFile} or {@link java.nio.file.Path#createDirectory createDirectory} * createFile} or {@link java.nio.file.Files#createDirectory createDirectory}
* methods. * methods.
* *
* @param perms * @param perms

View File

@ -59,9 +59,9 @@ import java.io.IOException;
* attributes. * attributes.
* *
* <p> Where dynamic access to file attributes is required, the {@link * <p> Where dynamic access to file attributes is required, the {@link
* java.nio.file.FileRef#getAttribute getAttribute} method may be used to read * java.nio.file.Files#getAttribute getAttribute} method may be used to read
* the attribute value. The attribute value is returned as a byte array (byte[]). * the attribute value. The attribute value is returned as a byte array (byte[]).
* The {@link java.nio.file.FileRef#setAttribute setAttribute} method may be used * The {@link java.nio.file.Files#setAttribute setAttribute} method may be used
* to write the value of a user-defined attribute from a buffer (as if by * to write the value of a user-defined attribute from a buffer (as if by
* invoking the {@link #write write} method), or byte array (byte[]). * invoking the {@link #write write} method), or byte array (byte[]).
* *
@ -132,8 +132,8 @@ public interface UserDefinedFileAttributeView
* Suppose we want to read a file's MIME type that is stored as a user-defined * Suppose we want to read a file's MIME type that is stored as a user-defined
* attribute with the name "{@code user.mimetype}". * attribute with the name "{@code user.mimetype}".
* <pre> * <pre>
* UserDefinedFileAttributeView view = file * UserDefinedFileAttributeView view =
* .getFileAttributeView(UserDefinedFileAttributeView.class); * Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);
* String name = "user.mimetype"; * String name = "user.mimetype";
* ByteBuffer buf = ByteBuffer.allocate(view.size(name)); * ByteBuffer buf = ByteBuffer.allocate(view.size(name));
* view.read(name, buf); * view.read(name, buf);
@ -189,8 +189,8 @@ public interface UserDefinedFileAttributeView
* <p> <b>Usage Example:</b> * <p> <b>Usage Example:</b>
* Suppose we want to write a file's MIME type as a user-defined attribute: * Suppose we want to write a file's MIME type as a user-defined attribute:
* <pre> * <pre>
* UserDefinedFileAttributeView view = file * UserDefinedFileAttributeView view =
* .getFileAttributeView(UserDefinedFileAttributeView.class); * FIles.getFileAttributeView(path, UserDefinedFileAttributeView.class);
* view.write("user.mimetype", Charset.defaultCharset().encode("text/html")); * view.write("user.mimetype", Charset.defaultCharset().encode("text/html"));
* </pre> * </pre>
* *

View File

@ -46,8 +46,6 @@
* <td>Can read or update user-defined file attributes</td></tr> * <td>Can read or update user-defined file attributes</td></tr>
* <tr><td valign=top><tt>&nbsp;&nbsp;<i>{@link java.nio.file.attribute.FileStoreAttributeView}</i></tt></td> * <tr><td valign=top><tt>&nbsp;&nbsp;<i>{@link java.nio.file.attribute.FileStoreAttributeView}</i></tt></td>
* <td>Can read or update file system attributes</td></tr> * <td>Can read or update file system attributes</td></tr>
* <tr><td valign=top><tt>&nbsp;&nbsp;&nbsp;&nbsp;<i>{@link java.nio.file.attribute.FileStoreSpaceAttributeView}&nbsp;&nbsp;</i></tt></td>
* <td>Can read file system <em>space usage</em> related attributes</td></tr>
* </table></blockquote> * </table></blockquote>
* *
* <p> An attribute view provides a read-only or updatable view of the non-opaque * <p> An attribute view provides a read-only or updatable view of the non-opaque
@ -55,7 +53,7 @@
* The {@link java.nio.file.attribute.FileAttributeView} interface is * The {@link java.nio.file.attribute.FileAttributeView} interface is
* extended by several other interfaces that that views to specific sets of file * extended by several other interfaces that that views to specific sets of file
* attributes. {@code FileAttributeViews} are selected by invoking the {@link * attributes. {@code FileAttributeViews} are selected by invoking the {@link
* java.nio.file.FileRef#getFileAttributeView} method with a * java.nio.file.Files#getFileAttributeView} method with a
* <em>type-token</em> to identify the required view. Views can also be identified * <em>type-token</em> to identify the required view. Views can also be identified
* by name. The {@link java.nio.file.attribute.FileStoreAttributeView} interface * by name. The {@link java.nio.file.attribute.FileStoreAttributeView} interface
* provides access to file store attributes. A {@code FileStoreAttributeView} of * provides access to file store attributes. A {@code FileStoreAttributeView} of
@ -83,13 +81,6 @@
* on the model defined by <a href="http://www.ietf.org/rfc/rfc3530.txt"> * on the model defined by <a href="http://www.ietf.org/rfc/rfc3530.txt">
* <i>RFC&nbsp;3530: Network File System (NFS) version 4 Protocol</i></a>. * <i>RFC&nbsp;3530: Network File System (NFS) version 4 Protocol</i></a>.
* *
* <p> The {@link java.nio.file.attribute.FileStoreSpaceAttributeView} class
* defines methods to read file system space usage related attributes of a file system.
*
* <p> The {@link java.nio.file.attribute.Attributes} utility class defines
* static methods to access file or file system attribute using the above
* attribute views.
*
* <p> In addition to attribute views, this package also defines classes and * <p> In addition to attribute views, this package also defines classes and
* interfaces that are used when accessing attributes: * interfaces that are used when accessing attributes:
* *

View File

@ -31,7 +31,7 @@
* systems. The API to access file and file system attributes is defined in the * systems. The API to access file and file system attributes is defined in the
* {@link java.nio.file.attribute} package. The {@link java.nio.file.spi} * {@link java.nio.file.attribute} package. The {@link java.nio.file.spi}
* package is used by service provider implementors wishing to extend the * package is used by service provider implementors wishing to extend the
* platform default provider, or to construct other provider implementations. * platform default provider, or to construct other provider implementations. </p>
* *
* <a name="links"><h3>Symbolic Links</h3></a> * <a name="links"><h3>Symbolic Links</h3></a>
* Many operating systems and file systems support for <em>symbolic links</em>. * Many operating systems and file systems support for <em>symbolic links</em>.
@ -43,7 +43,7 @@
* target of the link. This package includes support for symbolic links where * target of the link. This package includes support for symbolic links where
* implementations provide these semantics. File systems may support other types * implementations provide these semantics. File systems may support other types
* that are semantically close but support for these other types of links is * that are semantically close but support for these other types of links is
* not included in this package. * not included in this package. </p>
* *
* <a name="interop"><h3>Interoperability</h3></a> * <a name="interop"><h3>Interoperability</h3></a>
* The {@link java.io.File} class defines the {@link java.io.File#toPath * The {@link java.io.File} class defines the {@link java.io.File#toPath
@ -52,7 +52,7 @@
* {@code Path} can be used to operate on the same file as the {@code File} * {@code Path} can be used to operate on the same file as the {@code File}
* object. The {@code Path} specification provides further information * object. The {@code Path} specification provides further information
* on the <a href="Path.html#interop">interoperability</a> between {@code Path} * on the <a href="Path.html#interop">interoperability</a> between {@code Path}
* and {@code java.io.File} objects. * and {@code java.io.File} objects. </p>
* *
* <h3>Visibility</h3> * <h3>Visibility</h3>
* The view of the files and file system provided by classes in this package are * The view of the files and file system provided by classes in this package are
@ -63,7 +63,7 @@
* network-filesystem protocols. This is true regardless of the language in which * network-filesystem protocols. This is true regardless of the language in which
* these other programs are written, and whether they are running on the same machine * these other programs are written, and whether they are running on the same machine
* or on some other machine. The exact nature of any such inconsistencies are * or on some other machine. The exact nature of any such inconsistencies are
* system-dependent and are therefore unspecified. * system-dependent and are therefore unspecified. </p>
* *
* <a name="integrity"><h3>Synchronized I/O File Integrity</h3></a> * <a name="integrity"><h3>Synchronized I/O File Integrity</h3></a>
* The {@link java.nio.file.StandardOpenOption#SYNC SYNC} and {@link * The {@link java.nio.file.StandardOpenOption#SYNC SYNC} and {@link
@ -80,14 +80,14 @@
* crash. If the file does not reside on a local device then no such guarantee * crash. If the file does not reside on a local device then no such guarantee
* is made. Whether this guarantee is possible with other {@link * is made. Whether this guarantee is possible with other {@link
* java.nio.file.spi.FileSystemProvider provider} implementations is provider * java.nio.file.spi.FileSystemProvider provider} implementations is provider
* specific. * specific. </p>
* *
* <h3>General Exceptions</h3> * <h3>General Exceptions</h3>
* Unless otherwise noted, passing a {@code null} argument to a constructor * Unless otherwise noted, passing a {@code null} argument to a constructor
* or method of any class or interface in this package will cause a {@link * or method of any class or interface in this package will cause a {@link
* java.lang.NullPointerException NullPointerException} to be thrown. Additionally, * java.lang.NullPointerException NullPointerException} to be thrown. Additionally,
* invoking a method with a collection containing a {@code null} element will * invoking a method with a collection containing a {@code null} element will
* cause a {@code NullPointerException}, unless otherwise specified. * cause a {@code NullPointerException}, unless otherwise specified. </p>
* *
* <p> Unless otherwise noted, methods that attempt to access the file system * <p> Unless otherwise noted, methods that attempt to access the file system
* will throw {@link java.nio.file.ClosedFileSystemException} when invoked on * will throw {@link java.nio.file.ClosedFileSystemException} when invoked on
@ -95,12 +95,13 @@
* {@link java.nio.file.FileSystem#close closed}. Additionally, any methods * {@link java.nio.file.FileSystem#close closed}. Additionally, any methods
* that attempt write access to a file system will throw {@link * that attempt write access to a file system will throw {@link
* java.nio.file.ReadOnlyFileSystemException} when invoked on an object associated * java.nio.file.ReadOnlyFileSystemException} when invoked on an object associated
* with a {@link java.nio.file.FileSystem} that only provides read-only access. * with a {@link java.nio.file.FileSystem} that only provides read-only
* access. </p>
* *
* <p> Unless otherwise noted, invoking a method of any class or interface in * <p> Unless otherwise noted, invoking a method of any class or interface in
* this package created by one {@link java.nio.file.spi.FileSystemProvider * this package created by one {@link java.nio.file.spi.FileSystemProvider
* provider} with a parameter that is an object created by another provider, * provider} with a parameter that is an object created by another provider,
* will throw {@link java.nio.file.ProviderMismatchException}. * will throw {@link java.nio.file.ProviderMismatchException}. </p>
* *
* <h3>Optional Specific Exceptions</h3> * <h3>Optional Specific Exceptions</h3>
* Most of the methods defined by classes in this package that access the * Most of the methods defined by classes in this package that access the

View File

@ -26,17 +26,21 @@
package java.nio.file.spi; package java.nio.file.spi;
import java.nio.file.*; import java.nio.file.*;
import java.nio.file.attribute.FileAttribute; import java.nio.file.attribute.*;
import java.nio.channels.*; import java.nio.channels.*;
import java.net.URI; import java.net.URI;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.io.IOException;
/** /**
* Service-provider class for file systems. * Service-provider class for file systems. The methods defined by the {@link
* java.nio.file.Files} class will typically delegate to an instance of this
* class.
* *
* <p> A file system provider is a concrete implementation of this class that * <p> A file system provider is a concrete implementation of this class that
* implements the abstract methods defined by this class. A provider is * implements the abstract methods defined by this class. A provider is
@ -64,13 +68,6 @@ import java.io.IOException;
* the {@code newFileSystem} method is invoked. In the case of the default * the {@code newFileSystem} method is invoked. In the case of the default
* provider, the {@code FileSystem} is created when the provider is initialized. * provider, the {@code FileSystem} is created when the provider is initialized.
* *
* <p> In addition to file systems, a provider is also a factory for {@link
* FileChannel} and {@link AsynchronousFileChannel} channels. The {@link
* #newFileChannel newFileChannel} and {@link #newAsynchronousFileChannel
* AsynchronousFileChannel} methods are defined to open or create files, returning
* a channel to access the file. These methods are invoked by static factory
* methods defined in the {@link java.nio.channels} package.
*
* <p> All of the methods in this class are safe for use by multiple concurrent * <p> All of the methods in this class are safe for use by multiple concurrent
* threads. * threads.
* *
@ -202,9 +199,10 @@ public abstract class FileSystemProvider {
* *
* <p> This method throws {@link FileSystemAlreadyExistsException} if the * <p> This method throws {@link FileSystemAlreadyExistsException} if the
* file system already exists because it was previously created by an * file system already exists because it was previously created by an
* invocation of this method. Once a file system is {@link FileSystem#close * invocation of this method. Once a file system is {@link
* closed} it is provider-dependent if the provider allows a new file system * java.nio.file.FileSystem#close closed} it is provider-dependent if the
* to be created with the same URI as a file system it previously created. * provider allows a new file system to be created with the same URI as a
* file system it previously created.
* *
* @param uri * @param uri
* URI reference * URI reference
@ -234,20 +232,21 @@ public abstract class FileSystemProvider {
* *
* <p> This method returns a reference to a {@code FileSystem} that was * <p> This method returns a reference to a {@code FileSystem} that was
* created by invoking the {@link #newFileSystem(URI,Map) newFileSystem(URI,Map)} * created by invoking the {@link #newFileSystem(URI,Map) newFileSystem(URI,Map)}
* method. File systems created the {@link #newFileSystem(FileRef,Map) * method. File systems created the {@link #newFileSystem(Path,Map)
* newFileSystem(FileRef,Map)} method are not returned by this method. * newFileSystem(Path,Map)} method are not returned by this method.
* The file system is identified by its {@code URI}. Its exact form * The file system is identified by its {@code URI}. Its exact form
* is highly provider dependent. In the case of the default provider the URI's * is highly provider dependent. In the case of the default provider the URI's
* path component is {@code "/"} and the authority, query and fragment components * path component is {@code "/"} and the authority, query and fragment components
* are undefined (Undefined components are represented by {@code null}). * are undefined (Undefined components are represented by {@code null}).
* *
* <p> Once a file system created by this provider is {@link FileSystem#close * <p> Once a file system created by this provider is {@link
* closed} it is provider-dependent if this method returns a reference to * java.nio.file.FileSystem#close closed} it is provider-dependent if this
* the closed file system or throws {@link FileSystemNotFoundException}. * method returns a reference to the closed file system or throws {@link
* If the provider allows a new file system to be created with the same URI * FileSystemNotFoundException}. If the provider allows a new file system to
* as a file system it previously created then this method throws the * be created with the same URI as a file system it previously created then
* exception if invoked after the file system is closed (and before a new * this method throws the exception if invoked after the file system is
* instance is created by the {@link #newFileSystem newFileSystem} method). * closed (and before a new instance is created by the {@link #newFileSystem
* newFileSystem} method).
* *
* <p> If a security manager is installed then a provider implementation * <p> If a security manager is installed then a provider implementation
* may require to check a permission before returning a reference to an * may require to check a permission before returning a reference to an
@ -306,17 +305,16 @@ public abstract class FileSystemProvider {
* *
* <p> This method is intended for specialized providers of pseudo file * <p> This method is intended for specialized providers of 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. The {@code env} parameter is a map of provider specific properties
* and the {@code env} parameter is a map of provider specific properties to * to configure the file system.
* configure the file system.
* *
* <p> If this provider does not support the creation of such file systems * <p> If this provider does not support the creation of such file systems
* or if the provider does not recognize the file type of the given file then * or if the provider does not recognize the file type of the given file then
* it throws {@code UnsupportedOperationException}. The default implementation * it throws {@code UnsupportedOperationException}. The default implementation
* of this method throws {@code UnsupportedOperationException}. * of this method throws {@code UnsupportedOperationException}.
* *
* @param file * @param path
* The file * The path to the file
* @param env * @param env
* A map of provider specific properties to configure the file system; * A map of provider specific properties to configure the file system;
* may be empty * may be empty
@ -336,32 +334,121 @@ public abstract class FileSystemProvider {
* 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 FileSystem newFileSystem(FileRef file, Map<String,?> env) public FileSystem newFileSystem(Path path, Map<String,?> env)
throws IOException throws IOException
{ {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** /**
* Opens or creates a file for reading and/or writing, returning a file * Opens a file, returning an input stream to read from the file. This
* channel to access the file. * method works in exactly the manner specified by the {@link
* Files#newInputStream} method.
* *
* <p> This method is invoked by the {@link FileChannel#open(Path,Set,FileAttribute[]) * <p> The default implementation of this method opens a channel to the file
* FileChannel.open} method to open a file channel. A provider that does not * as if by invoking the {@link #newByteChannel} method and constructs a
* support all the features required to construct a file channel throws * stream that reads bytes from the channel. This method should be overridden
* {@code UnsupportedOperationException}. The default provider is required * where appropriate.
* to support the creation of file channels. When not overridden, the
* default implementation throws {@code UnsupportedOperationException}.
* *
* @param path * @param path
* The path of the file to open or create * the path to the file to open
* @param options * @param options
* Options specifying how the file is opened * options specifying how the file is opened
*
* @return a new input stream
*
* @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.
*/
public InputStream newInputStream(Path path, OpenOption... options)
throws IOException
{
if (options.length > 0) {
for (OpenOption opt: options) {
if (opt != StandardOpenOption.READ)
throw new UnsupportedOperationException("'" + opt + "' not allowed");
}
}
return Channels.newInputStream(Files.newByteChannel(path));
}
/**
* Opens or creates a file, returning an output stream that may be used to
* write bytes to the file. This method works in exactly the manner
* specified by the {@link Files#newOutputStream} method.
*
* <p> The default implementation of this method opens a channel to the file
* as if by invoking the {@link #newByteChannel} method and constructs a
* stream that writes bytes to the channel. This method should be overridden
* where appropriate.
*
* @param path
* the path to the file to open or create
* @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. The {@link
* SecurityManager#checkDelete(String) checkDelete} method is
* invoked to check delete access if the file is opened with the
* {@code DELETE_ON_CLOSE} option.
*/
public OutputStream newOutputStream(Path path, OpenOption... options)
throws IOException
{
int len = options.length;
Set<OpenOption> opts = new HashSet<OpenOption>(len + 3);
if (len == 0) {
opts.add(StandardOpenOption.CREATE);
opts.add(StandardOpenOption.TRUNCATE_EXISTING);
} else {
for (OpenOption opt: options) {
if (opt == StandardOpenOption.READ)
throw new IllegalArgumentException("READ not allowed");
opts.add(opt);
}
}
opts.add(StandardOpenOption.WRITE);
return Channels.newOutputStream(newByteChannel(path, opts));
}
/**
* Opens or creates a file for reading and/or writing, returning a file
* channel to access the file. This method works in exactly the manner
* specified by the {@link FileChannel#open(Path,Set,FileAttribute[])
* FileChannel.open} method. A provider that does not support all the
* features required to construct a file channel throws {@code
* UnsupportedOperationException}. The default provider is required to
* support the creation of file channels. When not overridden, the default
* implementation throws {@code UnsupportedOperationException}.
*
* @param path
* the path of the file to open or create
* @param options
* options specifying how the file is opened
* @param attrs * @param attrs
* An optional list of file attributes to set atomically when * an optional list of file attributes to set atomically when
* creating the file * creating the file
* *
* @return A new file channel * @return a new file channel
* *
* @throws IllegalArgumentException * @throws IllegalArgumentException
* If the set contains an invalid combination of options * If the set contains an invalid combination of options
@ -387,11 +474,10 @@ public abstract class FileSystemProvider {
/** /**
* Opens or creates a file for reading and/or writing, returning an * Opens or creates a file for reading and/or writing, returning an
* asynchronous file channel to access the file. * asynchronous file channel to access the file. This method works in
* * exactly the manner specified by the {@link
* <p> This method is invoked by the {@link
* AsynchronousFileChannel#open(Path,Set,ExecutorService,FileAttribute[]) * AsynchronousFileChannel#open(Path,Set,ExecutorService,FileAttribute[])
* AsynchronousFileChannel.open} method to open an asynchronous file channel. * AsynchronousFileChannel.open} method.
* A provider that does not support all the features required to construct * A provider that does not support all the features required to construct
* an asynchronous file channel throws {@code UnsupportedOperationException}. * an asynchronous file channel throws {@code UnsupportedOperationException}.
* The default provider is required to support the creation of asynchronous * The default provider is required to support the creation of asynchronous
@ -399,17 +485,17 @@ public abstract class FileSystemProvider {
* method throws {@code UnsupportedOperationException}. * method throws {@code UnsupportedOperationException}.
* *
* @param path * @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
* @param executor * @param executor
* The thread pool or {@code null} to associate the channel with * the thread pool or {@code null} to associate the channel with
* the default thread pool * the default thread pool
* @param attrs * @param attrs
* An optional list of file attributes to set atomically when * an optional list of file attributes to set atomically when
* creating the file * creating the file
* *
* @return A new asynchronous file channel * @return a new asynchronous file channel
* *
* @throws IllegalArgumentException * @throws IllegalArgumentException
* If the set contains an invalid combination of options * If the set contains an invalid combination of options
@ -434,4 +520,569 @@ public abstract class FileSystemProvider {
{ {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/**
* Opens or creates a file, returning a seekable byte channel to access the
* file. This method works in exactly the manner specified by the {@link
* Files#newByteChannel(Path,Set,FileAttribute[])} method.
*
* @param path
* the path to the file to open or create
* @param options
* options specifying how the file is opened
* @param attrs
* an optional list of file attributes to set atomically when
* creating the file
*
* @return a new seekable byte channel
*
* @throws IllegalArgumentException
* if the set contains an invalid combination of options
* @throws UnsupportedOperationException
* if an unsupported open option is specified or the array contains
* attributes that cannot be set atomically when creating the file
* @throws FileAlreadyExistsException
* if a file of that name already exists and the {@link
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
* <i>(optional specific exception)</i>
* @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 path if the file is
* opened for reading. The {@link SecurityManager#checkWrite(String)
* checkWrite} method is invoked to check write access to the path
* if the file is opened for writing. The {@link
* SecurityManager#checkDelete(String) checkDelete} method is
* invoked to check delete access if the file is opened with the
* {@code DELETE_ON_CLOSE} option.
*/
public abstract SeekableByteChannel newByteChannel(Path path,
Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException;
/**
* Opens a directory, returning a {@code DirectoryStream} to iterate over
* the entries in the directory. This method works in exactly the manner
* specified by the {@link
* Files#newDirectoryStream(java.nio.file.Path, java.nio.file.DirectoryStream.Filter)}
* method.
*
* @param dir
* the path to the directory
* @param filter
* the directory stream filter
*
* @return a new and open {@code DirectoryStream} object
*
* @throws NotDirectoryException
* if the file could not otherwise be opened because it is not
* a directory <i>(optional specific exception)</i>
* @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 directory.
*/
public abstract DirectoryStream<Path> newDirectoryStream(Path dir,
DirectoryStream.Filter<? super Path> filter) throws IOException;
/**
* Creates a new directory. This method works in exactly the manner
* specified by the {@link Files#createDirectory} method.
*
* @param dir
* the directory to create
* @param attrs
* an optional list of file attributes to set atomically when
* creating the directory
*
* @throws UnsupportedOperationException
* if the array contains an attribute that cannot be set atomically
* when creating the directory
* @throws FileAlreadyExistsException
* if a directory could not otherwise be created because a file of
* that name already exists <i>(optional specific exception)</i>
* @throws IOException
* if an I/O error occurs or the parent directory does not exist
* @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 new directory.
*/
public abstract void createDirectory(Path dir, FileAttribute<?>... attrs)
throws IOException;
/**
* Creates a symbolic link to a target. This method works in exactly the
* manner specified by the {@link Files#createSymbolicLink} method.
*
* <p> The default implementation of this method throws {@code
* UnsupportedOperationException}.
*
* @param link
* the path of the symbolic link to create
* @param target
* the target of the symbolic link
* @param attrs
* the array of attributes to set atomically when creating the
* symbolic link
*
* @throws UnsupportedOperationException
* if the implementation does not support symbolic links or the
* array contains an attribute that cannot be set atomically when
* creating the symbolic link
* @throws FileAlreadyExistsException
* if a file with the name already exists <i>(optional specific
* exception)</i>
* @throws IOException
* if an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager
* is installed, it denies {@link LinkPermission}<tt>("symbolic")</tt>
* or its {@link SecurityManager#checkWrite(String) checkWrite}
* method denies write access to the path of the symbolic link.
*/
public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs)
throws IOException
{
throw new UnsupportedOperationException();
}
/**
* Creates a new link (directory entry) for an existing file. This method
* works in exactly the manner specified by the {@link Files#createLink}
* method.
*
* <p> The default implementation of this method throws {@code
* UnsupportedOperationException}.
*
* @param link
* the link (directory entry) to create
* @param existing
* a path to an existing file
*
* @throws UnsupportedOperationException
* if the implementation does not support adding an existing file
* to a directory
* @throws FileAlreadyExistsException
* if the entry could not otherwise be created because a file of
* that name already exists <i>(optional specific exception)</i>
* @throws IOException
* if an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager
* is installed, it denies {@link LinkPermission}<tt>("hard")</tt>
* or its {@link SecurityManager#checkWrite(String) checkWrite}
* method denies write access to either the link or the
* existing file.
*/
public void createLink(Path link, Path existing) throws IOException {
throw new UnsupportedOperationException();
}
/**
* Deletes a file. This method works in exactly the manner specified by the
* {@link Files#delete} method.
*
* @param path
* the path to the file to delete
*
* @throws NoSuchFileException
* if the file does not exist <i>(optional specific exception)</i>
* @throws DirectoryNotEmptyException
* if the file is a directory and could not otherwise be deleted
* because the directory is not empty <i>(optional specific
* exception)</i>
* @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#checkDelete(String)} method
* is invoked to check delete access to the file
*/
public abstract void delete(Path path) throws IOException;
/**
* Deletes a file if it exists. This method works in exactly the manner
* specified by the {@link Files#deleteIfExists} method.
*
* <p> The default implementation of this method simply invokes {@link
* #delete} ignoring the {@code NoSuchFileException} when the file does not
* exist. It may be overridden where appropriate.
*
* @param path
* the path to the file to delete
*
* @return {@code true} if the file was deleted by this method; {@code
* false} if the file could not be deleted because it did not
* exist
*
* @throws DirectoryNotEmptyException
* if the file is a directory and could not otherwise be deleted
* because the directory is not empty <i>(optional specific
* exception)</i>
* @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#checkDelete(String)} method
* is invoked to check delete access to the file
*/
public boolean deleteIfExists(Path path) throws IOException {
try {
delete(path);
return true;
} catch (NoSuchFileException ignore) {
return false;
}
}
/**
* Reads the target of a symbolic link. This method works in exactly the
* manner specified by the {@link Files#readSymbolicLink} method.
*
* <p> The default implementation of this method throws {@code
* UnsupportedOperationException}.
*
* @param link
* the path to the symbolic link
*
* @throws UnsupportedOperationException
* if the implementation does not support symbolic links
* @throws NotLinkException
* if the target could otherwise not be read because the file
* is not a symbolic link <i>(optional specific exception)</i>
* @throws IOException
* if an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager
* is installed, it checks that {@code FilePermission} has been
* granted with the "{@code readlink}" action to read the link.
*/
public Path readSymbolicLink(Path link) throws IOException {
throw new UnsupportedOperationException();
}
/**
* Copy a file to a target file. This method works in exactly the manner
* specified by the {@link Files#copy(Path,Path,CopyOption[])} method
* except that both the source and target paths must be associated with
* this provider.
*
* @param source
* the path to the file to copy
* @param target
* the path to the target file
* @param options
* options specifying how the copy should be done
*
* @throws UnsupportedOperationException
* if the array contains a copy option that is not supported
* @throws FileAlreadyExistsException
* if the target file exists but cannot be replaced because the
* {@code REPLACE_EXISTING} option is not specified <i>(optional
* specific exception)</i>
* @throws DirectoryNotEmptyException
* the {@code REPLACE_EXISTING} option is specified but the file
* cannot be replaced because it is a non-empty directory
* <i>(optional specific exception)</i>
* @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 source file, the
* {@link SecurityManager#checkWrite(String) checkWrite} is invoked
* to check write access to the target file. If a symbolic link is
* copied the security manager is invoked to check {@link
* LinkPermission}{@code ("symbolic")}.
*/
public abstract void copy(Path source, Path target, CopyOption... options)
throws IOException;
/**
* Move or rename a file to a target file. This method works in exactly the
* manner specified by the {@link Files#move} method except that both the
* source and target paths must be associated with this provider.
*
* @param source
* the path to the file to move
* @param target
* the path to the target file
* @param options
* options specifying how the move should be done
*
* @throws UnsupportedOperationException
* if the array contains a copy option that is not supported
* @throws FileAlreadyExistsException
* if the target file exists but cannot be replaced because the
* {@code REPLACE_EXISTING} option is not specified <i>(optional
* specific exception)</i>
* @throws DirectoryNotEmptyException
* the {@code REPLACE_EXISTING} option is specified but the file
* cannot be replaced because it is a non-empty directory
* <i>(optional specific exception)</i>
* @throws AtomicMoveNotSupportedException
* if the options array contains the {@code ATOMIC_MOVE} option but
* the file cannot be moved as an atomic file system operation.
* @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 both the source and
* target file.
*/
public abstract void move(Path source, Path target, CopyOption... options)
throws IOException;
/**
* Tests if two paths locate the same file. This method works in exactly the
* manner specified by the {@link Files#isSameFile} method.
*
* @param path
* one path to the file
* @param path2
* the other path
*
* @return {@code true} if, and only if, the two paths locate the same file
*
* @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 both files.
*/
public abstract boolean isSameFile(Path path, Path path2)
throws IOException;
/**
* Tells whether or not a file is considered <em>hidden</em>. This method
* works in exactly the manner specified by the {@link Files#isHidden}
* method.
*
* <p> This method is invoked by the {@link Files#isHidden isHidden} method.
*
* @param path
* the path to the file to test
*
* @return {@code true} if the file is considered hidden
*
* @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.
*/
public abstract boolean isHidden(Path path) throws IOException;
/**
* Returns the {@link FileStore} representing the file store where a file
* is located. This method works in exactly the manner specified by the
* {@link Files#getFileStore} method.
*
* @param path
* the path to the file
*
* @return the file store where the file is stored
*
* @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, and in
* addition it checks {@link RuntimePermission}<tt>
* ("getFileStoreAttributes")</tt>
*/
public abstract FileStore getFileStore(Path path) throws IOException;
/**
* Checks the existence, and optionally the accessibility, of a file.
*
* <p> This method may be used by the {@link Files#isReadable isReadable},
* {@link Files#isWritable isWritable} and {@link Files#isExecutable
* isExecutable} methods to check the accessibility of a file.
*
* <p> This method checks the existence of a file and that this Java virtual
* machine has appropriate privileges that would allow it access the file
* according to all of access modes specified in the {@code modes} parameter
* as follows:
*
* <table border=1 cellpadding=5 summary="">
* <tr> <th>Value</th> <th>Description</th> </tr>
* <tr>
* <td> {@link AccessMode#READ READ} </td>
* <td> Checks that the file exists and that the Java virtual machine has
* permission to read the file. </td>
* </tr>
* <tr>
* <td> {@link AccessMode#WRITE WRITE} </td>
* <td> Checks that the file exists and that the Java virtual machine has
* permission to write to the file, </td>
* </tr>
* <tr>
* <td> {@link AccessMode#EXECUTE EXECUTE} </td>
* <td> Checks that the file exists and that the Java virtual machine has
* permission to {@link Runtime#exec execute} the file. The semantics
* may differ when checking access to a directory. For example, on UNIX
* systems, checking for {@code EXECUTE} access checks that the Java
* virtual machine has permission to search the directory in order to
* access file or subdirectories. </td>
* </tr>
* </table>
*
* <p> If the {@code modes} parameter is of length zero, then the existence
* of the file is checked.
*
* <p> This method follows symbolic links if the file referenced by this
* object is a symbolic link. Depending on the implementation, this method
* may require to read file permissions, access control lists, or other
* file attributes in order to check the effective access to the file. To
* determine the effective access to a file may require access to several
* attributes and so in some implementations this method may not be atomic
* with respect to other file system operations.
*
* @param path
* the path to the file to check
* @param modes
* The access modes to check; may have zero elements
*
* @throws UnsupportedOperationException
* an implementation is required to support checking for
* {@code READ}, {@code WRITE}, and {@code EXECUTE} access. This
* exception is specified to allow for the {@code Access} enum to
* be extended in future releases.
* @throws NoSuchFileException
* if a file does not exist <i>(optional specific exception)</i>
* @throws AccessDeniedException
* the requested access would be denied or the access cannot be
* determined because the Java virtual machine has insufficient
* privileges or other reasons. <i>(optional specific exception)</i>
* @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}
* is invoked when checking read access to the file or only the
* existence of the file, the {@link SecurityManager#checkWrite(String)
* checkWrite} is invoked when checking write access to the file,
* and {@link SecurityManager#checkExec(String) checkExec} is invoked
* when checking execute access.
*/
public abstract void checkAccess(Path path, AccessMode... modes)
throws IOException;
/**
* Returns a file attribute view of a given type. This method works in
* exactly the manner specified by the {@link Files#getFileAttributeView}
* method.
*
* @param path
* the path to the file
* @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
*/
public abstract <V extends FileAttributeView> V
getFileAttributeView(Path path, Class<V> type, LinkOption... options);
/**
* Reads a file's attributes as a bulk operation. This method works in
* exactly the manner specified by the {@link
* Files#readAttributes(Path,Class,LinkOption[])} method.
*
* @param path
* the path to the file
* @param type
* the {@code Class} of the file attributes required
* to read
* @param options
* options indicating how symbolic links are handled
*
* @return the file attributes
*
* @throws UnsupportedOperationException
* if an attributes of the given type are not supported
* @throws IOException
* if an I/O error occurs
* @throws SecurityException
* In the case of the default provider, a security manager is
* installed, its {@link SecurityManager#checkRead(String) checkRead}
* method is invoked to check read access to the file
*/
public abstract <A extends BasicFileAttributes> A
readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException;
/**
* Reads a set of file attributes as a bulk operation. This method works in
* exactly the manner specified by the {@link
* Files#readAttributes(Path,String,LinkOption[])} method.
*
* @param path
* the path to the file
* @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.
*/
public abstract Map<String,Object> readAttributes(Path path, String attributes,
LinkOption... options)
throws IOException;
/**
* Sets the value of a file attribute. This method works in exactly the
* manner specified by the {@link Files#setAttribute} method.
*
* @param path
* the path to the file
* @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.
*/
public abstract void setAttribute(Path path, String attribute,
Object value, LinkOption... options)
throws IOException;
} }

View File

@ -25,7 +25,7 @@
package java.nio.file.spi; package java.nio.file.spi;
import java.nio.file.FileRef; import java.nio.file.Path;
import java.io.IOException; import java.io.IOException;
/** /**
@ -42,7 +42,7 @@ import java.io.IOException;
* href="../attribute/package-summary.html"> attribute</a> or the bytes in a * href="../attribute/package-summary.html"> attribute</a> or the bytes in a
* file may be examined to guess its file type. * file may be examined to guess its file type.
* *
* @see java.nio.file.Files#probeContentType(FileRef) * @see java.nio.file.Files#probeContentType(Path)
* *
* @since 1.7 * @since 1.7
*/ */
@ -83,8 +83,8 @@ public abstract class FileTypeDetector {
* Message Bodies</i></a>. The string must be parsable according to the * Message Bodies</i></a>. The string must be parsable according to the
* grammar in the RFC 2045. * grammar in the RFC 2045.
* *
* @param file * @param path
* The file to probe * the path to the file to probe
* *
* @return The content type or {@code null} if the file type is not * @return The content type or {@code null} if the file type is not
* recognized * recognized
@ -101,6 +101,6 @@ public abstract class FileTypeDetector {
* *
* @see java.nio.file.Files#probeContentType * @see java.nio.file.Files#probeContentType
*/ */
public abstract String probeContentType(FileRef file) public abstract String probeContentType(Path path)
throws IOException; throws IOException;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, 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
@ -66,6 +66,20 @@ import java.security.spec.AlgorithmParameterSpec;
* default modulus prime size of 1024 bits for the generation of DSA * default modulus prime size of 1024 bits for the generation of DSA
* parameters. * parameters.
* *
* <p> Every implementation of the Java platform is required to support the
* following standard <code>AlgorithmParameterGenerator</code> algorithms and
* keysizes in parentheses:
* <ul>
* <li><tt>DiffieHellman</tt> (1024)</li>
* <li><tt>DSA</tt> (1024)</li>
* </ul>
* These algorithms are described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#AlgorithmParameterGenerator">
* AlgorithmParameterGenerator section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
* Consult the release documentation for your implementation to see if any
* other algorithms are supported.
*
* @author Jan Luehe * @author Jan Luehe
* *
* *
@ -126,9 +140,9 @@ public class AlgorithmParameterGenerator {
* *
* @param algorithm the name of the algorithm this * @param algorithm the name of the algorithm this
* parameter generator is associated with. * parameter generator is associated with.
* See Appendix A in the <a href= * See the AlgorithmParameterGenerator section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#AlgorithmParameterGenerator">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @return the new AlgorithmParameterGenerator object. * @return the new AlgorithmParameterGenerator object.
@ -168,9 +182,9 @@ public class AlgorithmParameterGenerator {
* *
* @param algorithm the name of the algorithm this * @param algorithm the name of the algorithm this
* parameter generator is associated with. * parameter generator is associated with.
* See Appendix A in the <a href= * See the AlgorithmParameterGenerator section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#AlgorithmParameterGenerator">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the string name of the Provider. * @param provider the string name of the Provider.
@ -214,9 +228,9 @@ public class AlgorithmParameterGenerator {
* *
* @param algorithm the string name of the algorithm this * @param algorithm the string name of the algorithm this
* parameter generator is associated with. * parameter generator is associated with.
* See Appendix A in the <a href= * See the AlgorithmParameterGenerator section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#AlgorithmParameterGenerator">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the Provider object. * @param provider the Provider object.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, 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
@ -46,6 +46,22 @@ import java.security.spec.InvalidParameterSpecException;
* <code>getParameterSpec</code>, and a byte encoding of the parameters is * <code>getParameterSpec</code>, and a byte encoding of the parameters is
* obtained via a call to <code>getEncoded</code>. * obtained via a call to <code>getEncoded</code>.
* *
* <p> Every implementation of the Java platform is required to support the
* following standard <code>AlgorithmParameters</code> algorithms:
* <ul>
* <li><tt>AES</tt></li>
* <li><tt>DES</tt></li>
* <li><tt>DESede</tt></li>
* <li><tt>DiffieHellman</tt></li>
* <li><tt>DSA</tt></li>
* </ul>
* These algorithms are described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#AlgorithmParameters">
* AlgorithmParameters section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
* Consult the release documentation for your implementation to see if any
* other algorithms are supported.
*
* @author Jan Luehe * @author Jan Luehe
* *
* *
@ -111,9 +127,9 @@ public class AlgorithmParameters {
* parameter encoding. * parameter encoding.
* *
* @param algorithm the name of the algorithm requested. * @param algorithm the name of the algorithm requested.
* See Appendix A in the <a href= * See the AlgorithmParameters section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#AlgorithmParameters">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @return the new parameter object. * @return the new parameter object.
@ -153,9 +169,9 @@ public class AlgorithmParameters {
* parameter encoding. * parameter encoding.
* *
* @param algorithm the name of the algorithm requested. * @param algorithm the name of the algorithm requested.
* See Appendix A in the <a href= * See the AlgorithmParameters section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#AlgorithmParameters">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the name of the provider. * @param provider the name of the provider.
@ -200,9 +216,9 @@ public class AlgorithmParameters {
* parameter encoding. * parameter encoding.
* *
* @param algorithm the name of the algorithm requested. * @param algorithm the name of the algorithm requested.
* See Appendix A in the <a href= * See the AlgorithmParameters section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#AlgorithmParameters">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the name of the provider. * @param provider the name of the provider.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, 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
@ -67,8 +67,21 @@ import sun.security.jca.GetInstance.Instance;
* sig.verify(signature); * sig.verify(signature);
* </pre> * </pre>
* *
* @author Jan Luehe * <p> Every implementation of the Java platform is required to support the
* following standard <code>KeyFactory</code> algorithms:
* <ul>
* <li><tt>DiffieHellman</tt></li>
* <li><tt>DSA</tt></li>
* <li><tt>RSA</tt></li>
* </ul>
* These algorithms are described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyFactory">
* KeyFactory section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
* Consult the release documentation for your implementation to see if any
* other algorithms are supported.
* *
* @author Jan Luehe
* *
* @see Key * @see Key
* @see PublicKey * @see PublicKey
@ -141,9 +154,9 @@ public class KeyFactory {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param algorithm the name of the requested key algorithm. * @param algorithm the name of the requested key algorithm.
* See Appendix A in the <a href= * See the KeyFactory section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyFactory">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @return the new KeyFactory object. * @return the new KeyFactory object.
@ -172,9 +185,9 @@ public class KeyFactory {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param algorithm the name of the requested key algorithm. * @param algorithm the name of the requested key algorithm.
* See Appendix A in the <a href= * See the KeyFactory section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyFactory">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the name of the provider. * @param provider the name of the provider.
@ -211,9 +224,9 @@ public class KeyFactory {
* does not have to be registered in the provider list. * does not have to be registered in the provider list.
* *
* @param algorithm the name of the requested key algorithm. * @param algorithm the name of the requested key algorithm.
* See Appendix A in the <a href= * See the KeyFactory section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyFactory">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the provider. * @param provider the provider.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, 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
@ -105,8 +105,22 @@ import sun.security.jca.GetInstance.Instance;
* the superclass are intended for cryptographic service providers who wish to * the superclass are intended for cryptographic service providers who wish to
* supply their own implementations of key pair generators. * supply their own implementations of key pair generators.
* *
* @author Benjamin Renaud * <p> Every implementation of the Java platform is required to support the
* following standard <code>KeyPairGenerator</code> algorithms and keysizes in
* parentheses:
* <ul>
* <li><tt>DiffieHellman</tt> (1024)</li>
* <li><tt>DSA</tt> (1024)</li>
* <li><tt>RSA</tt> (1024, 2048)</li>
* </ul>
* These algorithms are described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyPairGenerator">
* KeyPairGenerator section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
* Consult the release documentation for your implementation to see if any
* other algorithms are supported.
* *
* @author Benjamin Renaud
* *
* @see java.security.spec.AlgorithmParameterSpec * @see java.security.spec.AlgorithmParameterSpec
*/ */
@ -122,9 +136,9 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
* Creates a KeyPairGenerator object for the specified algorithm. * Creates a KeyPairGenerator object for the specified algorithm.
* *
* @param algorithm the standard string name of the algorithm. * @param algorithm the standard string name of the algorithm.
* See Appendix A in the <a href= * See the KeyPairGenerator section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyPairGenerator">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
*/ */
protected KeyPairGenerator(String algorithm) { protected KeyPairGenerator(String algorithm) {
@ -133,9 +147,9 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
/** /**
* Returns the standard name of the algorithm for this key pair generator. * Returns the standard name of the algorithm for this key pair generator.
* See Appendix A in the <a href= * See the KeyPairGenerator section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyPairGenerator">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @return the standard string name of the algorithm. * @return the standard string name of the algorithm.
@ -171,9 +185,9 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param algorithm the standard string name of the algorithm. * @param algorithm the standard string name of the algorithm.
* See Appendix A in the <a href= * See the KeyPairGenerator section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyPairGenerator">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @return the new KeyPairGenerator object. * @return the new KeyPairGenerator object.
@ -227,9 +241,9 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param algorithm the standard string name of the algorithm. * @param algorithm the standard string name of the algorithm.
* See Appendix A in the <a href= * See the KeyPairGenerator section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyPairGenerator">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the string name of the provider. * @param provider the string name of the provider.
@ -266,9 +280,9 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
* does not have to be registered in the provider list. * does not have to be registered in the provider list.
* *
* @param algorithm the standard string name of the algorithm. * @param algorithm the standard string name of the algorithm.
* See Appendix A in the <a href= * See the KeyPairGenerator section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyPairGenerator">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the provider. * @param provider the provider.

View File

@ -164,8 +164,19 @@ import javax.security.auth.callback.*;
* different passwords or other protection parameters * different passwords or other protection parameters
* may also be used. * may also be used.
* *
* @author Jan Luehe * <p> Every implementation of the Java platform is required to support
* the following standard <code>KeyStore</code> type:
* <ul>
* <li><tt>PKCS12</tt></li>
* </ul>
* This type is described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyStore">
* KeyStore section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
* Consult the release documentation for your implementation to see if any
* other types are supported.
* *
* @author Jan Luehe
* *
* @see java.security.PrivateKey * @see java.security.PrivateKey
* @see javax.crypto.SecretKey * @see javax.crypto.SecretKey
@ -582,9 +593,9 @@ public class KeyStore {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param type the type of keystore. * @param type the type of keystore.
* See Appendix A in the <a href= * See the KeyStore section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyStore">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard keystore types. * for information about standard keystore types.
* *
* @return a keystore object of the specified type. * @return a keystore object of the specified type.
@ -620,9 +631,9 @@ public class KeyStore {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param type the type of keystore. * @param type the type of keystore.
* See Appendix A in the <a href= * See the KeyStore section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyStore">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard keystore types. * for information about standard keystore types.
* *
* @param provider the name of the provider. * @param provider the name of the provider.
@ -663,9 +674,9 @@ public class KeyStore {
* does not have to be registered in the provider list. * does not have to be registered in the provider list.
* *
* @param type the type of keystore. * @param type the type of keystore.
* See Appendix A in the <a href= * See the KeyStore section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyStore">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard keystore types. * for information about standard keystore types.
* *
* @param provider the provider. * @param provider the provider.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2010, 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
@ -37,7 +37,7 @@ import java.nio.ByteBuffer;
/** /**
* This MessageDigest class provides applications the functionality of a * This MessageDigest class provides applications the functionality of a
* message digest algorithm, such as MD5 or SHA. * message digest algorithm, such as SHA-1 or SHA-256.
* Message digests are secure one-way hash functions that take arbitrary-sized * Message digests are secure one-way hash functions that take arbitrary-sized
* data and output a fixed-length hash value. * data and output a fixed-length hash value.
* *
@ -81,8 +81,21 @@ import java.nio.ByteBuffer;
* the superclass are intended for cryptographic service providers who wish to * the superclass are intended for cryptographic service providers who wish to
* supply their own implementations of message digest algorithms. * supply their own implementations of message digest algorithms.
* *
* @author Benjamin Renaud * <p> Every implementation of the Java platform is required to support
* the following standard <code>MessageDigest</code> algorithms:
* <ul>
* <li><tt>MD5</tt></li>
* <li><tt>SHA-1</tt></li>
* <li><tt>SHA-256</tt></li>
* </ul>
* These algorithms are described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#MessageDigest">
* MessageDigest section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
* Consult the release documentation for your implementation to see if any
* other algorithms are supported.
* *
* @author Benjamin Renaud
* *
* @see DigestInputStream * @see DigestInputStream
* @see DigestOutputStream * @see DigestOutputStream
@ -104,9 +117,9 @@ public abstract class MessageDigest extends MessageDigestSpi {
* Creates a message digest with the specified algorithm name. * Creates a message digest with the specified algorithm name.
* *
* @param algorithm the standard name of the digest algorithm. * @param algorithm the standard name of the digest algorithm.
* See Appendix A in the <a href= * See the MessageDigest section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#MessageDigest">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
*/ */
protected MessageDigest(String algorithm) { protected MessageDigest(String algorithm) {
@ -127,9 +140,9 @@ public abstract class MessageDigest extends MessageDigestSpi {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param algorithm the name of the algorithm requested. * @param algorithm the name of the algorithm requested.
* See Appendix A in the <a href= * See the MessageDigest section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#MessageDigest">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @return a Message Digest object that implements the specified algorithm. * @return a Message Digest object that implements the specified algorithm.
@ -173,9 +186,9 @@ public abstract class MessageDigest extends MessageDigestSpi {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param algorithm the name of the algorithm requested. * @param algorithm the name of the algorithm requested.
* See Appendix A in the <a href= * See the MessageDigest section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#MessageDigest">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the name of the provider. * @param provider the name of the provider.
@ -222,9 +235,9 @@ public abstract class MessageDigest extends MessageDigestSpi {
* does not have to be registered in the provider list. * does not have to be registered in the provider list.
* *
* @param algorithm the name of the algorithm requested. * @param algorithm the name of the algorithm requested.
* See Appendix A in the <a href= * See the MessageDigest section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#MessageDigest">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the provider. * @param provider the provider.
@ -439,9 +452,9 @@ public abstract class MessageDigest extends MessageDigestSpi {
* Returns a string that identifies the algorithm, independent of * Returns a string that identifies the algorithm, independent of
* implementation details. The name should be a standard * implementation details. The name should be a standard
* Java Security name (such as "SHA", "MD5", and so on). * Java Security name (such as "SHA", "MD5", and so on).
* See Appendix A in the <a href= * See the MessageDigest section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#MessageDigest">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @return the name of the algorithm * @return the name of the algorithm

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, 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
@ -67,9 +67,6 @@ import sun.security.util.SecurityConstants;
* implementation. In addition, an instance of a Policy object can be * implementation. In addition, an instance of a Policy object can be
* constructed by invoking one of the <code>getInstance</code> factory methods * constructed by invoking one of the <code>getInstance</code> factory methods
* with a standard type. The default policy type is "JavaPolicy". * with a standard type. The default policy type is "JavaPolicy".
* See Appendix A in the <a href="../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
* Java Cryptography Architecture API Specification &amp; Reference </a>
* for a list of standard Policy types.
* *
* <p> Once a Policy instance has been installed (either by default, or by * <p> Once a Policy instance has been installed (either by default, or by
* calling <code>setPolicy</code>), * calling <code>setPolicy</code>),
@ -133,7 +130,7 @@ public abstract class Policy {
* This method first calls * This method first calls
* <code>SecurityManager.checkPermission</code> with a * <code>SecurityManager.checkPermission</code> with a
* <code>SecurityPermission("getPolicy")</code> permission * <code>SecurityPermission("getPolicy")</code> permission
* to ensure it's ok to get the Policy object.. * to ensure it's ok to get the Policy object.
* *
* @return the installed Policy. * @return the installed Policy.
* *
@ -340,9 +337,10 @@ public abstract class Policy {
* <p> Note that the list of registered providers may be retrieved via * <p> Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param type the specified Policy type. See Appendix A in the * @param type the specified Policy type. See the Policy section in the
* <a href="../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * <a href=
* Java Cryptography Architecture API Specification &amp; Reference </a> * "{@docRoot}/../technotes/guides/security/StandardNames.html#Policy">
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for a list of standard Policy types. * for a list of standard Policy types.
* *
* @param params parameters for the Policy, which may be null. * @param params parameters for the Policy, which may be null.
@ -393,9 +391,10 @@ public abstract class Policy {
* <p> Note that the list of registered providers may be retrieved via * <p> Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param type the specified Policy type. See Appendix A in the * @param type the specified Policy type. See the Policy section in the
* <a href="../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * <a href=
* Java Cryptography Architecture API Specification &amp; Reference </a> * "{@docRoot}/../technotes/guides/security/StandardNames.html#Policy">
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for a list of standard Policy types. * for a list of standard Policy types.
* *
* @param params parameters for the Policy, which may be null. * @param params parameters for the Policy, which may be null.
@ -456,9 +455,10 @@ public abstract class Policy {
* object is returned. Note that the specified Provider object * object is returned. Note that the specified Provider object
* does not have to be registered in the provider list. * does not have to be registered in the provider list.
* *
* @param type the specified Policy type. See Appendix A in the * @param type the specified Policy type. See the Policy section in the
* <a href="../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * <a href=
* Java Cryptography Architecture API Specification &amp; Reference </a> * "{@docRoot}/../technotes/guides/security/StandardNames.html#Policy">
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for a list of standard Policy types. * for a list of standard Policy types.
* *
* @param params parameters for the Policy, which may be null. * @param params parameters for the Policy, which may be null.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2010, 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
@ -133,9 +133,9 @@ public class SecureRandom extends java.util.Random {
* <p> Note that the list of registered providers may be retrieved via * <p> Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* <p> See Appendix A in the <a href= * <p> See the SecureRandom section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#SecureRandom">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard RNG algorithm names. * for information about standard RNG algorithm names.
* *
* <p> The returned SecureRandom object has not been seeded. To seed the * <p> The returned SecureRandom object has not been seeded. To seed the
@ -171,9 +171,9 @@ public class SecureRandom extends java.util.Random {
* <p> Note that the list of registered providers may be retrieved via * <p> Note that the list of registered providers may be retrieved via
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* <p> See Appendix A in the <a href= * <p> See the SecureRandom section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#SecureRandom">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard RNG algorithm names. * for information about standard RNG algorithm names.
* *
* @param seed the seed. * @param seed the seed.
@ -256,9 +256,9 @@ public class SecureRandom extends java.util.Random {
* previously called. * previously called.
* *
* @param algorithm the name of the RNG algorithm. * @param algorithm the name of the RNG algorithm.
* See Appendix A in the <a href= * See the SecureRandom section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#SecureRandom">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard RNG algorithm names. * for information about standard RNG algorithm names.
* *
* @return the new SecureRandom object. * @return the new SecureRandom object.
@ -299,9 +299,9 @@ public class SecureRandom extends java.util.Random {
* previously called. * previously called.
* *
* @param algorithm the name of the RNG algorithm. * @param algorithm the name of the RNG algorithm.
* See Appendix A in the <a href= * See the SecureRandom section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#SecureRandom">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard RNG algorithm names. * for information about standard RNG algorithm names.
* *
* @param provider the name of the provider. * @param provider the name of the provider.
@ -347,9 +347,9 @@ public class SecureRandom extends java.util.Random {
* previously called. * previously called.
* *
* @param algorithm the name of the RNG algorithm. * @param algorithm the name of the RNG algorithm.
* See Appendix A in the <a href= * See the SecureRandom section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#SecureRandom">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard RNG algorithm names. * for information about standard RNG algorithm names.
* *
* @param provider the provider. * @param provider the provider.

View File

@ -277,10 +277,11 @@ public final class Security {
/** /**
* Gets a specified property for an algorithm. The algorithm name * Gets a specified property for an algorithm. The algorithm name
* should be a standard name. See Appendix A in the <a href= * should be a standard name. See the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
*
* One possible use is by specialized algorithm parsers, which may map * One possible use is by specialized algorithm parsers, which may map
* classes to algorithms which they understand (much like Key parsers * classes to algorithms which they understand (much like Key parsers
* do). * do).
@ -513,9 +514,9 @@ public final class Security {
* *
* </ul> * </ul>
* *
* <p> See Appendix A in the <a href= * <p> See the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard cryptographic service names, standard * for information about standard cryptographic service names, standard
* algorithm names and standard attribute names. * algorithm names and standard attribute names.
* *
@ -581,9 +582,9 @@ public final class Security {
* constraint expressed by the specified attribute name/value pair. * constraint expressed by the specified attribute name/value pair.
* </ul> * </ul>
* *
* <p> See Appendix A in the <a href= * <p> See the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "../../../technotes/guides/security/StandardNames.html">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard cryptographic service names, standard * for information about standard cryptographic service names, standard
* algorithm names and standard attribute names. * algorithm names and standard attribute names.
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2010, 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
@ -47,7 +47,7 @@ import sun.security.jca.*;
import sun.security.jca.GetInstance.Instance; import sun.security.jca.GetInstance.Instance;
/** /**
* This Signature class is used to provide applications the functionality * The Signature class is used to provide applications the functionality
* of a digital signature algorithm. Digital signatures are used for * of a digital signature algorithm. Digital signatures are used for
* authentication and integrity assurance of digital data. * authentication and integrity assurance of digital data.
* *
@ -98,6 +98,20 @@ import sun.security.jca.GetInstance.Instance;
* the superclass are intended for cryptographic service providers who wish to * the superclass are intended for cryptographic service providers who wish to
* supply their own implementations of digital signature algorithms. * supply their own implementations of digital signature algorithms.
* *
* <p> Every implementation of the Java platform is required to support the
* following standard <code>Signature</code> algorithms:
* <ul>
* <li><tt>SHA1withDSA</tt></li>
* <li><tt>SHA1withRSA</tt></li>
* <li><tt>SHA256withRSA</tt></li>
* </ul>
* These algorithms are described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#Signature">
* Signature section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
* Consult the release documentation for your implementation to see if any
* other algorithms are supported.
*
* @author Benjamin Renaud * @author Benjamin Renaud
* *
*/ */
@ -144,9 +158,9 @@ public abstract class Signature extends SignatureSpi {
* Creates a Signature object for the specified algorithm. * Creates a Signature object for the specified algorithm.
* *
* @param algorithm the standard string name of the algorithm. * @param algorithm the standard string name of the algorithm.
* See Appendix A in the <a href= * See the Signature section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#Signature">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
*/ */
protected Signature(String algorithm) { protected Signature(String algorithm) {
@ -184,9 +198,9 @@ public abstract class Signature extends SignatureSpi {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param algorithm the standard name of the algorithm requested. * @param algorithm the standard name of the algorithm requested.
* See Appendix A in the <a href= * See the Signature section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#Signature">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @return the new Signature object. * @return the new Signature object.
@ -303,9 +317,9 @@ public abstract class Signature extends SignatureSpi {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param algorithm the name of the algorithm requested. * @param algorithm the name of the algorithm requested.
* See Appendix A in the <a href= * See the Signature section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#Signature">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the name of the provider. * @param provider the name of the provider.
@ -353,9 +367,9 @@ public abstract class Signature extends SignatureSpi {
* does not have to be registered in the provider list. * does not have to be registered in the provider list.
* *
* @param algorithm the name of the algorithm requested. * @param algorithm the name of the algorithm requested.
* See Appendix A in the <a href= * See the Signature section in the <a href=
* "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#Signature">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the provider. * @param provider the provider.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2010, 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
@ -83,6 +83,19 @@ import java.util.List;
* may not follow these conventions. PKIX <code>CertPathValidator</code>s will * may not follow these conventions. PKIX <code>CertPathValidator</code>s will
* detect any departure from these conventions that cause the certification * detect any departure from these conventions that cause the certification
* path to be invalid and throw a <code>CertPathValidatorException</code>. * path to be invalid and throw a <code>CertPathValidatorException</code>.
*
* <p> Every implementation of the Java platform is required to support the
* following standard <code>CertPath</code> encodings:
* <ul>
* <li><tt>PKCS7</tt></li>
* <li><tt>PkiPath</tt></li>
* </ul>
* These encodings are described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathEncodings">
* CertPath Encodings section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
* Consult the release documentation for your implementation to see if any
* other encodings are supported.
* <p> * <p>
* <b>Concurrent Access</b> * <b>Concurrent Access</b>
* <p> * <p>

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2010, 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
@ -52,6 +52,19 @@ import sun.security.jca.GetInstance.Instance;
* result (including the <code>CertPath</code> that was built) is returned * result (including the <code>CertPath</code> that was built) is returned
* in an object that implements the <code>CertPathBuilderResult</code> * in an object that implements the <code>CertPathBuilderResult</code>
* interface. * interface.
*
* <p> Every implementation of the Java platform is required to support the
* following standard <code>CertPathBuilder</code> algorithm:
* <ul>
* <li><tt>PKIX</tt></li>
* </ul>
* This algorithm is described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder">
* CertPathBuilder section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
* Consult the release documentation for your implementation to see if any
* other algorithms are supported.
*
* <p> * <p>
* <b>Concurrent Access</b> * <b>Concurrent Access</b>
* <p> * <p>
@ -118,10 +131,10 @@ public class CertPathBuilder {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param algorithm the name of the requested <code>CertPathBuilder</code> * @param algorithm the name of the requested <code>CertPathBuilder</code>
* algorithm. See Appendix A in the <a href= * algorithm. See the CertPathBuilder section in the <a href=
* "../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder">
* Java Certification Path API Programmer's Guide </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @return a <code>CertPathBuilder</code> object that implements the * @return a <code>CertPathBuilder</code> object that implements the
* specified algorithm. * specified algorithm.
@ -153,10 +166,10 @@ public class CertPathBuilder {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param algorithm the name of the requested <code>CertPathBuilder</code> * @param algorithm the name of the requested <code>CertPathBuilder</code>
* algorithm. See Appendix A in the <a href= * algorithm. See the CertPathBuilder section in the <a href=
* "../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder">
* Java Certification Path API Programmer's Guide </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the name of the provider. * @param provider the name of the provider.
* *
@ -193,10 +206,10 @@ public class CertPathBuilder {
* does not have to be registered in the provider list. * does not have to be registered in the provider list.
* *
* @param algorithm the name of the requested <code>CertPathBuilder</code> * @param algorithm the name of the requested <code>CertPathBuilder</code>
* algorithm. See Appendix A in the <a href= * algorithm. See the CertPathBuilder section in the <a href=
* "../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder">
* Java Certification Path API Programmer's Guide </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the provider. * @param provider the provider.
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2010, 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,6 +53,19 @@ import sun.security.jca.GetInstance.Instance;
* and an algorithm-specific set of parameters. If successful, the result is * and an algorithm-specific set of parameters. If successful, the result is
* returned in an object that implements the * returned in an object that implements the
* <code>CertPathValidatorResult</code> interface. * <code>CertPathValidatorResult</code> interface.
*
* <p> Every implementation of the Java platform is required to support the
* following standard <code>CertPathValidator</code> algorithm:
* <ul>
* <li><tt>PKIX</tt></li>
* </ul>
* This algorithm is described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathValidator">
* CertPathValidator section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
* Consult the release documentation for your implementation to see if any
* other algorithms are supported.
*
* <p> * <p>
* <b>Concurrent Access</b> * <b>Concurrent Access</b>
* <p> * <p>
@ -118,10 +131,10 @@ public class CertPathValidator {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param algorithm the name of the requested <code>CertPathValidator</code> * @param algorithm the name of the requested <code>CertPathValidator</code>
* algorithm. See Appendix A in the <a href= * algorithm. See the CertPathValidator section in the <a href=
* "../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathValidator">
* Java Certification Path API Programmer's Guide </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @return a <code>CertPathValidator</code> object that implements the * @return a <code>CertPathValidator</code> object that implements the
* specified algorithm. * specified algorithm.
@ -153,10 +166,10 @@ public class CertPathValidator {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param algorithm the name of the requested <code>CertPathValidator</code> * @param algorithm the name of the requested <code>CertPathValidator</code>
* algorithm. See Appendix A in the <a href= * algorithm. See the CertPathValidator section in the <a href=
* "../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathValidator">
* Java Certification Path API Programmer's Guide </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names. * for information about standard algorithm names.
* *
* @param provider the name of the provider. * @param provider the name of the provider.
* *
@ -193,12 +206,11 @@ public class CertPathValidator {
* object is returned. Note that the specified Provider object * object is returned. Note that the specified Provider object
* does not have to be registered in the provider list. * does not have to be registered in the provider list.
* *
* @param algorithm the name of the requested * @param algorithm the name of the requested <code>CertPathValidator</code>
* <code>CertPathValidator</code> algorithm. * algorithm. See the CertPathValidator section in the <a href=
* See Appendix A in the <a href= * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathValidator">
* "../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* Java Certification Path API Programmer's Guide </a> * for information about standard algorithm names.
* for information about standard algorithm names.
* *
* @param provider the provider. * @param provider the provider.
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 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
@ -286,6 +286,11 @@ public class CertPathValidatorException extends GeneralSecurityException {
/** /**
* The signature is invalid. * The signature is invalid.
*/ */
INVALID_SIGNATURE INVALID_SIGNATURE,
/**
* The public key or the signature algorithm has been constrained.
*/
ALGORITHM_CONSTRAINED
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2010, 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
@ -58,10 +58,20 @@ import sun.security.jca.GetInstance.Instance;
* vast repository of untrusted certificates and CRLs. For example, an LDAP * vast repository of untrusted certificates and CRLs. For example, an LDAP
* implementation of <code>CertStore</code> provides access to certificates * implementation of <code>CertStore</code> provides access to certificates
* and CRLs stored in one or more directories using the LDAP protocol and the * and CRLs stored in one or more directories using the LDAP protocol and the
* schema as defined in the RFC service attribute. See Appendix A in the * schema as defined in the RFC service attribute.
* <a href= "../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> *
* Java Certification Path API Programmer's Guide</a> for more information about * <p> Every implementation of the Java platform is required to support the
* standard <code>CertStore</code> types. * following standard <code>CertStore</code> type:
* <ul>
* <li><tt>Collection</tt></li>
* </ul>
* This type is described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertStore">
* CertStore section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
* Consult the release documentation for your implementation to see if any
* other types are supported.
*
* <p> * <p>
* <b>Concurrent Access</b> * <b>Concurrent Access</b>
* <p> * <p>
@ -192,10 +202,10 @@ public class CertStore {
* cloned. * cloned.
* *
* @param type the name of the requested <code>CertStore</code> type. * @param type the name of the requested <code>CertStore</code> type.
* See Appendix A in the <a href= * See the CertStore section in the <a href=
* "../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertStore">
* Java Certification Path API Programmer's Guide </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard types. * for information about standard types.
* *
* @param params the initialization parameters (may be <code>null</code>). * @param params the initialization parameters (may be <code>null</code>).
* *
@ -252,10 +262,10 @@ public class CertStore {
* cloned. * cloned.
* *
* @param type the requested <code>CertStore</code> type. * @param type the requested <code>CertStore</code> type.
* See Appendix A in the <a href= * See the CertStore section in the <a href=
* "../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertStore">
* Java Certification Path API Programmer's Guide </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard types. * for information about standard types.
* *
* @param params the initialization parameters (may be <code>null</code>). * @param params the initialization parameters (may be <code>null</code>).
* *
@ -310,10 +320,10 @@ public class CertStore {
* cloned. * cloned.
* *
* @param type the requested <code>CertStore</code> type. * @param type the requested <code>CertStore</code> type.
* See Appendix A in the <a href= * See the CertStore section in the <a href=
* "../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertStore">
* Java Certification Path API Programmer's Guide </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard types. * for information about standard types.
* *
* @param params the initialization parameters (may be <code>null</code>). * @param params the initialization parameters (may be <code>null</code>).
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, 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
@ -69,9 +69,9 @@ public abstract class Certificate implements java.io.Serializable {
* Creates a certificate of the specified type. * Creates a certificate of the specified type.
* *
* @param type the standard name of the certificate type. * @param type the standard name of the certificate type.
* See Appendix A in the <a href= * See the CertificateFactory section in the <a href=
* "../../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertificateFactory">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard certificate types. * for information about standard certificate types.
*/ */
protected Certificate(String type) { protected Certificate(String type) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2010, 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
@ -91,11 +91,29 @@ import sun.security.jca.GetInstance.Instance;
* } * }
* </pre> * </pre>
* *
* <p> Every implementation of the Java platform is required to support the
* following standard <code>CertificateFactory</code> type:
* <ul>
* <li><tt>X.509</tt></li>
* </ul>
* and the following standard <code>CertPath</code> encodings:
* <ul>
* <li><tt>PKCS7</tt></li>
* <li><tt>PkiPath</tt></li>
* </ul>
* The type and encodings are described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertificateFactory">
* CertificateFactory section</a> and the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathEncodings">
* CertPath Encodings section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
* Consult the release documentation for your implementation to see if any
* other types or encodings are supported.
*
* @author Hemma Prafullchandra * @author Hemma Prafullchandra
* @author Jan Luehe * @author Jan Luehe
* @author Sean Mullan * @author Sean Mullan
* *
*
* @see Certificate * @see Certificate
* @see X509Certificate * @see X509Certificate
* @see CertPath * @see CertPath
@ -146,9 +164,9 @@ public class CertificateFactory {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param type the name of the requested certificate type. * @param type the name of the requested certificate type.
* See Appendix A in the <a href= * See the CertificateFactory section in the <a href=
* "../../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertificateFactory">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard certificate types. * for information about standard certificate types.
* *
* @return a certificate factory object for the specified type. * @return a certificate factory object for the specified type.
@ -184,9 +202,9 @@ public class CertificateFactory {
* the {@link Security#getProviders() Security.getProviders()} method. * the {@link Security#getProviders() Security.getProviders()} method.
* *
* @param type the certificate type. * @param type the certificate type.
* See Appendix A in the <a href= * See the CertificateFactory section in the <a href=
* "../../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertificateFactory">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard certificate types. * for information about standard certificate types.
* *
* @param provider the name of the provider. * @param provider the name of the provider.
@ -228,11 +246,10 @@ public class CertificateFactory {
* does not have to be registered in the provider list. * does not have to be registered in the provider list.
* *
* @param type the certificate type. * @param type the certificate type.
* See Appendix A in the <a href= * See the CertificateFactory section in the <a href=
* "../../../../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertificateFactory">
* Java Cryptography Architecture API Specification &amp; Reference </a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard certificate types. * for information about standard certificate types.
* @param provider the provider. * @param provider the provider.
* *
* @return a certificate factory object for the specified type. * @return a certificate factory object for the specified type.
@ -325,10 +342,10 @@ public class CertificateFactory {
/** /**
* Returns an iteration of the <code>CertPath</code> encodings supported * Returns an iteration of the <code>CertPath</code> encodings supported
* by this certificate factory, with the default encoding first. See * by this certificate factory, with the default encoding first. See
* Appendix A in the * the CertPath Encodings section in the <a href=
* <a href="../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathEncodings">
* Java Certification Path API Programmer's Guide</a> for information about * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* standard encoding names and their formats. * for information about standard encoding names and their formats.
* <p> * <p>
* Attempts to modify the returned <code>Iterator</code> via its * Attempts to modify the returned <code>Iterator</code> via its
* <code>remove</code> method result in an * <code>remove</code> method result in an
@ -364,9 +381,10 @@ public class CertificateFactory {
/** /**
* Generates a <code>CertPath</code> object and initializes it with * Generates a <code>CertPath</code> object and initializes it with
* the data read from the <code>InputStream</code> inStream. The data * the data read from the <code>InputStream</code> inStream. The data
* is assumed to be in the specified encoding. See Appendix A in the * is assumed to be in the specified encoding. See
* <a href="../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> * the CertPath Encodings section in the <a href=
* Java Certification Path API Programmer's Guide</a> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathEncodings">
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard encoding names and their formats. * for information about standard encoding names and their formats.
* *
* @param inStream an <code>InputStream</code> containing the data * @param inStream an <code>InputStream</code> containing the data

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2010, 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
@ -182,9 +182,9 @@ public abstract class CertificateFactorySpi {
/** /**
* Returns an iteration of the <code>CertPath</code> encodings supported * Returns an iteration of the <code>CertPath</code> encodings supported
* by this certificate factory, with the default encoding first. See * by this certificate factory, with the default encoding first. See
* Appendix A in the * the CertPath Encodings section in the <a href=
* <a href="../../../../technotes/guides/security/certpath/CertPathProgGuide.html#AppA"> * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathEncodings">
* Java Certification Path API Programmer's Guide</a> * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard encoding names. * for information about standard encoding names.
* <p> * <p>
* Attempts to modify the returned <code>Iterator</code> via its * Attempts to modify the returned <code>Iterator</code> via its

View File

@ -1,5 +1,5 @@
<!-- <!--
Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. Copyright (c) 1998, 2010, 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
@ -35,9 +35,15 @@ certificates and X.509 v2 CRLs.
<h2>Package Specification</h2> <h2>Package Specification</h2>
<ul> <ul>
<li><a href="../../../../technotes/guides/security/crypto/CryptoSpec.html"><b>Cryptography <li><a href="{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html">
Architecture</b></a> <b>Java<FONT SIZE=-2><SUP>TM</SUP></FONT>
<li>RFC 3280: Internet X.509 Public Key Infrastructure Certificate and CRL Profile Cryptography Architecture (JCA) Reference Guide</b></a>
<li>RFC 3280: Internet X.509 Public Key Infrastructure Certificate and
Certificate Revocation List (CRL) Profile
<li><a href="{@docRoot}/../technotes/guides/security/StandardNames.html">
<b>Java<FONT SIZE=-2><SUP>TM</SUP></FONT>
Cryptography Architecture Standard Algorithm Name
Documentation</b></a></li>
</ul> </ul>
<h2>Related Documentation</h2> <h2>Related Documentation</h2>
@ -45,11 +51,13 @@ certificates and X.509 v2 CRLs.
For information about X.509 certificates and CRLs, please see: For information about X.509 certificates and CRLs, please see:
<ul> <ul>
<li><a href="http://www.ietf.org/rfc/rfc3280.txt"> <li><a href="http://www.ietf.org/rfc/rfc3280.txt">
http://www.ietf.org/rfc/rfc3280.txt</a> http://www.ietf.org/rfc/rfc3280.txt</a>
<li><a href="../../../../technotes/guides/security/certpath/CertPathProgGuide.html"> <li><a href=
PKI API Programmer's Guide</a> "{@docRoot}/../technotes/guides/security/certpath/CertPathProgGuide.html">
<li><a href="../../../../technotes/guides/security/cert3.html"> <b>Java<FONT SIZE=-2><SUP>TM</SUP></FONT>
X.509 Certificates and CRLs</a> PKI Programmer's Guide</a>
<li><a href="{@docRoot}/../technotes/guides/security/cert3.html">
X.509 Certificates and Certificate Revocation Lists (CRLs)</a>
</ul> </ul>
@since 1.2 @since 1.2

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<!-- <!--
Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. Copyright (c) 1998, 2010, 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
@ -51,10 +51,17 @@ without having to add or rewrite code.
<h2>Package Specification</h2> <h2>Package Specification</h2>
<ul> <ul>
<li><a href="{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html"><b> <li><a href="{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html">
Cryptography Architecture</b></a></li> <b>Java<FONT SIZE=-2><SUP>TM</SUP></FONT>
Cryptography Architecture (JCA) Reference Guide</b></a></li>
<li>PKCS8: Private-Key Information Standard, Version 1.2, November 1993</li> <li>PKCS #8: Private-Key Information Syntax Standard, Version 1.2,
November 1993</li>
<li><a href="{@docRoot}/../technotes/guides/security/StandardNames.html">
<b>Java<FONT SIZE=-2><SUP>TM</SUP></FONT>
Cryptography Architecture Standard Algorithm Name
Documentation</b></a></li>
</ul> </ul>
<h2>Related Documentation</h2> <h2>Related Documentation</h2>
@ -62,13 +69,16 @@ without having to add or rewrite code.
For further documentation, please see: For further documentation, please see:
<ul> <ul>
<li><a href= <li><a href=
"{@docRoot}/../technotes/guides/security/spec/security-spec.doc.html"><b> "{@docRoot}/../technotes/guides/security/spec/security-spec.doc.html">
Security Architecture</b></a></li> <b>Java<FONT SIZE=-2><SUP>TM</SUP></FONT>
SE Platform Security Architecture</b></a></li>
<li><a href= <li><a href=
"{@docRoot}/../technotes/guides/security/crypto/HowToImplAProvider.html"><b> "{@docRoot}/../technotes/guides/security/crypto/HowToImplAProvider.html">
How to Implement a Provider for the Java Cryptography Architecture <b>How to Implement a Provider in the
Java<FONT SIZE=-2><SUP>TM</SUP></FONT> Cryptography Architecture
</b></a></li> </b></a></li>
<li><a href= <li><a href=
"{@docRoot}/../technotes/guides/security/PolicyFiles.html"><b> "{@docRoot}/../technotes/guides/security/PolicyFiles.html"><b>
Default Policy Implementation and Policy File Syntax Default Policy Implementation and Policy File Syntax
@ -76,12 +86,14 @@ For further documentation, please see:
<li><a href= <li><a href=
"{@docRoot}/../technotes/guides/security/permissions.html"><b> "{@docRoot}/../technotes/guides/security/permissions.html"><b>
Policy Permissions Permissions in the
Java<FONT SIZE=-2><SUP>TM</SUP></FONT> SE Development Kit (JDK)
</b></a></li> </b></a></li>
<li><a href= <li><a href=
"{@docRoot}/../technotes/guides/security/SecurityToolsSummary.html"><b> "{@docRoot}/../technotes/guides/security/SecurityToolsSummary.html"><b>
Security Tools Summary Summary of Tools for
Java<FONT SIZE=-2><SUP>TM</SUP></FONT> Platform Security
</b></a></li> </b></a></li>
<li><b>keytool</b> <li><b>keytool</b>
@ -100,6 +112,6 @@ For further documentation, please see:
</ul> </ul>
@since JDK1.1 @since 1.1
</body> </body>
</html> </html>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<!-- <!--
Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. Copyright (c) 1998, 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
@ -45,21 +45,22 @@ The reader/writer facility, available through the
use and update data from a spread sheet, flat file, or any other tabular use and update data from a spread sheet, flat file, or any other tabular
data source. data source.
<P> <P>
<h2>What the JDBC<sup><font size=-2>TM</font></sup> 4.0 API Includes</h2> <h2>What the JDBC<sup><font size=-2>TM</font></sup> 4.1 API Includes</h2>
The JDBC<sup><font size=-2>TM</font></sup> 4.0 API includes both The JDBC<sup><font size=-2>TM</font></sup> 4.1 API includes both
the <code>java.sql</code> package, referred to as the JDBC core API, the <code>java.sql</code> package, referred to as the JDBC core API,
and the <code>javax.sql</code> package, referred to as the JDBC Optional and the <code>javax.sql</code> package, referred to as the JDBC Optional
Package API. This complete JDBC API Package API. This complete JDBC API
is included in the Java<sup><font size=-2>TM</font></sup> is included in the Java<sup><font size=-2>TM</font></sup>
Standard Edition (Java SE<sup><font size=-2>TM</font></sup>), version 6. Standard Edition (Java SE<sup><font size=-2>TM</font></sup>), version 7.
The <code>javax.sql</code> package extends the functionality of the JDBC API The <code>javax.sql</code> package extends the functionality of the JDBC API
from a client-side API to a server-side API, and it is an essential part from a client-side API to a server-side API, and it is an essential part
of the Java<sup><font size=-2>TM</font></sup> Enterprise Edition of the Java<sup><font size=-2>TM</font></sup> Enterprise Edition
(Java EE<sup><font size=-2>TM</font></sup>) technology. (Java EE<sup><font size=-2>TM</font></sup>) technology.
<P> <P>
<h2>Versions</h2> <h2>Versions</h2>
The JDBC 4.0 API incorporates all of the previous JDBC API versions: The JDBC 4.1 API incorporates all of the previous JDBC API versions:
<UL> <UL>
<LI> The JDBC 4.0 API
<LI> The JDBC 3.0 API <LI> The JDBC 3.0 API
<LI> The JDBC 2.1 core API <LI> The JDBC 2.1 core API
<LI> The JDBC 2.0 Optional Package API<br> <LI> The JDBC 2.0 Optional Package API<br>
@ -75,7 +76,9 @@ into the Java platform. When these "since" tags are used in
Javadoc<sup><font size=-2>TM</font></sup> comments for the JDBC API, Javadoc<sup><font size=-2>TM</font></sup> comments for the JDBC API,
they indicate the following: they indicate the following:
<UL> <UL>
<LI>Since 1.6 -- new in the JDBC 4.0 API and part of the Java SE platform, <LI>Since 1.7 -- new in the JDBC 4.1 API and part of the Java SE platform,
version 7
<LI>Since 1.6 -- new in the JDBC 4.0 API and part of the Java SE platform,
version 6 version 6
<LI>Since 1.4 -- new in the JDBC 3.0 API and part of the J2SE platform, <LI>Since 1.4 -- new in the JDBC 3.0 API and part of the J2SE platform,
version 1.4 version 1.4
@ -176,6 +179,25 @@ The <code>java.sql</code> package contains API for the following:
</UL> </UL>
</UL> </UL>
<P> <P>
<h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.1 API</h3>
<UL>
<LI>Allow <code>Connection</code>,
<code>ResultSet</code> and <code>Statement</code> objects to be
used with the try-with-resources statement</LI>
<LI>Supported added to <code>CallableStatement</code> and
<code>ResultSet</code> to specify the Java type to convert to via the
<code>getObject</code> method</LI>
<LI><code>DatabaseMetaData</code> methods to return PseudoColumns and if a
generated key is always returned</LI>
<LI>Added support to <code>Connection</code> to specify a database schema,
abort and timeout a physical connection.</LI>
<LI>Added support to close a <code>Statement</code> object when its dependent
objects have been closed</LI>
<LI>Support for obtaining the parent logger for a <code>Driver</code>,
<code>DataSource</code>, <code>ConnectionPoolDataSource</code> and
<code>XADataSource</code></LI>
</UL>
<h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.0 API</h3> <h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.0 API</h3>
<UL> <UL>
<LI>auto java.sql.Driver discovery -- no longer need to load a <LI>auto java.sql.Driver discovery -- no longer need to load a
@ -190,7 +212,7 @@ The <code>java.sql</code> package contains API for the following:
<li>Support added to allow a JDBC application to access an instance of a JDBC resource <li>Support added to allow a JDBC application to access an instance of a JDBC resource
that has been wrapped by a vendor, usually in an application server or connection that has been wrapped by a vendor, usually in an application server or connection
pooling environment. pooling environment.
<li>Availability to be notfied when a <code>PreparedStatement</code> that is associated <li>Availability to be notified when a <code>PreparedStatement</code> that is associated
with a <code>PooledConnection</code> has been closed or the driver determines is invalid with a <code>PooledConnection</code> has been closed or the driver determines is invalid
@ -288,7 +310,7 @@ object back to its SQL type to store it in the data source.
<h2>Related Documentation</h2> <h2>Related Documentation</h2>
<ul> <ul>
<li><a href="../../../guide/jdbc/getstart/GettingStartedTOC.fm.html">Getting Started</a>--overviews of the major interfaces <li><a href="../../../technotes/guides/jdbc/getstart/GettingStartedTOC.fm.html">Getting Started</a>--overviews of the major interfaces
<P> <P>
<li><a href="http://java.sun.com/docs/books/tutorial/jdbc">Chapters on the JDBC <li><a href="http://java.sun.com/docs/books/tutorial/jdbc">Chapters on the JDBC
API</a>--from the online version of <i>The Java Tutorial Continued</i> API</a>--from the online version of <i>The Java Tutorial Continued</i>

View File

@ -2823,6 +2823,7 @@ public class Arrays {
* @param a the array by which the list will be backed * @param a the array by which the list will be backed
* @return a list view of the specified array * @return a list view of the specified array
*/ */
@SafeVarargs
public static <T> List<T> asList(T... a) { public static <T> List<T> asList(T... a) {
return new ArrayList<>(a); return new ArrayList<>(a);
} }

View File

@ -3827,6 +3827,7 @@ public class Collections {
* @see Collection#addAll(Collection) * @see Collection#addAll(Collection)
* @since 1.5 * @since 1.5
*/ */
@SafeVarargs
public static <T> boolean addAll(Collection<? super T> c, T... elements) { public static <T> boolean addAll(Collection<? super T> c, T... elements) {
boolean result = false; boolean result = false;
for (T element : elements) for (T element : elements)

File diff suppressed because it is too large Load Diff

View File

@ -317,6 +317,7 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
* or if <tt>rest</tt> is null * or if <tt>rest</tt> is null
* @return an enum set initially containing the specified elements * @return an enum set initially containing the specified elements
*/ */
@SafeVarargs
public static <E extends Enum<E>> EnumSet<E> of(E first, E... rest) { public static <E extends Enum<E>> EnumSet<E> of(E first, E... rest) {
EnumSet<E> result = noneOf(first.getDeclaringClass()); EnumSet<E> result = noneOf(first.getDeclaringClass());
result.add(first); result.add(first);

View File

@ -47,9 +47,6 @@ import java.text.DateFormatSymbols;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -1859,7 +1856,7 @@ public final class Formatter implements Closeable, Flushable {
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) {
@ -2179,7 +2176,7 @@ public final class Formatter implements Closeable, Flushable {
*/ */
public Formatter(PrintStream ps) { public Formatter(PrintStream ps) {
this(Locale.getDefault(Locale.Category.FORMAT), this(Locale.getDefault(Locale.Category.FORMAT),
(Appendable)Objects.nonNull(ps)); (Appendable)Objects.requireNonNull(ps));
} }
/** /**

View File

@ -187,7 +187,7 @@ public final class Objects {
* and constructors, as demonstrated below: * and constructors, as demonstrated below:
* <blockquote><pre> * <blockquote><pre>
* public Foo(Bar bar) { * public Foo(Bar bar) {
* this.bar = Objects.nonNull(bar); * this.bar = Objects.requireNonNull(bar);
* } * }
* </pre></blockquote> * </pre></blockquote>
* *
@ -196,7 +196,7 @@ public final class Objects {
* @return {@code obj} if not {@code null} * @return {@code obj} if not {@code null}
* @throws NullPointerException if {@code obj} is {@code null} * @throws NullPointerException if {@code obj} is {@code null}
*/ */
public static <T> T nonNull(T obj) { public static <T> T requireNonNull(T obj) {
if (obj == null) if (obj == null)
throw new NullPointerException(); throw new NullPointerException();
return obj; return obj;
@ -209,8 +209,8 @@ public final class Objects {
* constructors with multiple parameters, as demonstrated below: * constructors with multiple parameters, as demonstrated below:
* <blockquote><pre> * <blockquote><pre>
* public Foo(Bar bar, Baz baz) { * public Foo(Bar bar, Baz baz) {
* this.bar = Objects.nonNull(bar, "bar must not be null"); * this.bar = Objects.requireNonNull(bar, "bar must not be null");
* this.baz = Objects.nonNull(baz, "baz must not be null"); * this.baz = Objects.requireNonNull(baz, "baz must not be null");
* } * }
* </pre></blockquote> * </pre></blockquote>
* *
@ -221,7 +221,7 @@ public final class Objects {
* @return {@code obj} if not {@code null} * @return {@code obj} if not {@code null}
* @throws NullPointerException if {@code obj} is {@code null} * @throws NullPointerException if {@code obj} is {@code null}
*/ */
public static <T> T nonNull(T obj, String message) { public 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;

View File

@ -25,7 +25,8 @@
package java.util; package java.util;
import java.nio.file.FileRef; import java.nio.file.Path;
import java.nio.file.Files;
import java.util.regex.*; import java.util.regex.*;
import java.io.*; import java.io.*;
import java.math.*; import java.math.*;
@ -34,6 +35,7 @@ import java.nio.channels.*;
import java.nio.charset.*; import java.nio.charset.*;
import java.text.*; import java.text.*;
import java.util.Locale; import java.util.Locale;
import sun.misc.LRUCache; import sun.misc.LRUCache;
/** /**
@ -591,7 +593,7 @@ public final class Scanner implements Iterator<String>, Closeable {
* interface * interface
*/ */
public Scanner(Readable source) { public Scanner(Readable source) {
this(Objects.nonNull(source, "source"), WHITESPACE_PATTERN); this(Objects.requireNonNull(source, "source"), WHITESPACE_PATTERN);
} }
/** /**
@ -618,7 +620,7 @@ public final class Scanner implements Iterator<String>, Closeable {
* does not exist * does not exist
*/ */
public Scanner(InputStream source, String charsetName) { public Scanner(InputStream source, String charsetName) {
this(makeReadable(Objects.nonNull(source, "source"), toCharset(charsetName)), this(makeReadable(Objects.requireNonNull(source, "source"), toCharset(charsetName)),
WHITESPACE_PATTERN); WHITESPACE_PATTERN);
} }
@ -628,7 +630,7 @@ public final class Scanner implements Iterator<String>, Closeable {
* @throws IllegalArgumentException if the charset is not supported * @throws IllegalArgumentException if the charset is not supported
*/ */
private static Charset toCharset(String csn) { private static Charset toCharset(String csn) {
Objects.nonNull(csn, "charsetName"); Objects.requireNonNull(csn, "charsetName");
try { try {
return Charset.forName(csn); return Charset.forName(csn);
} catch (IllegalCharsetNameException|UnsupportedCharsetException e) { } catch (IllegalCharsetNameException|UnsupportedCharsetException e) {
@ -669,7 +671,7 @@ public final class Scanner implements Iterator<String>, Closeable {
public Scanner(File source, String charsetName) public Scanner(File source, String charsetName)
throws FileNotFoundException throws FileNotFoundException
{ {
this(Objects.nonNull(source), toDecoder(charsetName)); this(Objects.requireNonNull(source), toDecoder(charsetName));
} }
private Scanner(File source, CharsetDecoder dec) private Scanner(File source, CharsetDecoder dec)
@ -679,7 +681,7 @@ public final class Scanner implements Iterator<String>, Closeable {
} }
private static CharsetDecoder toDecoder(String charsetName) { private static CharsetDecoder toDecoder(String charsetName) {
Objects.nonNull(charsetName, "charsetName"); Objects.requireNonNull(charsetName, "charsetName");
try { try {
return Charset.forName(charsetName).newDecoder(); return Charset.forName(charsetName).newDecoder();
} catch (IllegalCharsetNameException|UnsupportedCharsetException unused) { } catch (IllegalCharsetNameException|UnsupportedCharsetException unused) {
@ -699,16 +701,16 @@ public final class Scanner implements Iterator<String>, Closeable {
* {@linkplain java.nio.charset.Charset#defaultCharset() default charset}. * {@linkplain java.nio.charset.Charset#defaultCharset() default charset}.
* *
* @param source * @param source
* A file to be scanned * the path to the file to be scanned
* @throws IOException * @throws IOException
* if an I/O error occurs opening source * if an I/O error occurs opening source
* *
* @since 1.7 * @since 1.7
*/ */
public Scanner(FileRef source) public Scanner(Path source)
throws IOException throws IOException
{ {
this(source.newInputStream()); this(Files.newInputStream(source));
} }
/** /**
@ -717,7 +719,7 @@ public final class Scanner implements Iterator<String>, Closeable {
* characters using the specified charset. * characters using the specified charset.
* *
* @param source * @param source
* A file to be scanned * the path to the file to be scanned
* @param charsetName * @param charsetName
* The encoding type used to convert bytes from the file * The encoding type used to convert bytes from the file
* into characters to be scanned * into characters to be scanned
@ -727,12 +729,12 @@ public final class Scanner implements Iterator<String>, Closeable {
* if the specified encoding is not found * if the specified encoding is not found
* @since 1.7 * @since 1.7
*/ */
public Scanner(FileRef source, String charsetName) throws IOException { public Scanner(Path source, String charsetName) throws IOException {
this(Objects.nonNull(source), toCharset(charsetName)); this(Objects.requireNonNull(source), toCharset(charsetName));
} }
private Scanner(FileRef source, Charset charset) throws IOException { private Scanner(Path source, Charset charset) throws IOException {
this(makeReadable(source.newInputStream(), charset)); this(makeReadable(Files.newInputStream(source), charset));
} }
/** /**
@ -754,7 +756,7 @@ public final class Scanner implements Iterator<String>, Closeable {
* @param source A channel to scan * @param source A channel to scan
*/ */
public Scanner(ReadableByteChannel source) { public Scanner(ReadableByteChannel source) {
this(makeReadable(Objects.nonNull(source, "source")), this(makeReadable(Objects.requireNonNull(source, "source")),
WHITESPACE_PATTERN); WHITESPACE_PATTERN);
} }
@ -774,7 +776,7 @@ public final class Scanner implements Iterator<String>, Closeable {
* does not exist * does not exist
*/ */
public Scanner(ReadableByteChannel source, String charsetName) { public Scanner(ReadableByteChannel source, String charsetName) {
this(makeReadable(Objects.nonNull(source, "source"), toDecoder(charsetName)), this(makeReadable(Objects.requireNonNull(source, "source"), toDecoder(charsetName)),
WHITESPACE_PATTERN); WHITESPACE_PATTERN);
} }

Some files were not shown because too many files have changed in this diff Show More