Mercurial > hg > icedtea10
changeset 1623:5bda1b46a64f
Make NIO2 build with 7.
2009-02-20 Andrew John Hughes <ahughes@redhat.com>
* overlays/nio2/openjdk/jdk/src/share/classes/java/io/File.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/io/FilePermission.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/net/ProtocolFamily.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/net/SocketOption.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/net/StandardProtocolFamily.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/net/StandardSocketOption.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/Channels.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/DatagramChannel.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/FileChannel.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/FileLock.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/MembershipKey.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/MulticastChannel.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/NetworkChannel.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/exceptions,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/package-info.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/spi/SelectorProvider.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/spi/package.html,
* overlays/nio2/openjdk/jdk/src/share/classes/java/util/Scanner.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java,
* overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaIODeleteOnExitAccess.java,
* overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaNetGetIndexAccess.java,
* overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaUtilConcurrentThreadPoolExecutorAccess.java,
* overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/SharedSecrets.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/ExtendedSocketOption.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipKeyImpl.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipRegistry.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/OptionKey.java: Removed
* Makefile.am: Remove moved patch.
* overlays/nio2/openjdk/jdk/src/share/classes/com/sun/nio/file/ExtendedCopyOption.java,
* overlays/nio2/openjdk/jdk/src/share/classes/com/sun/nio/file/ExtendedOpenOption.java,
* overlays/nio2/openjdk/jdk/src/share/classes/com/sun/nio/file/ExtendedWatchEventModifier.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/io/Inputs.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/io/Outputs.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousByteChannel.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousChannel.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousChannelGroup.java: Fix imports.
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousDatagramChannel.java: Fix imports,
match method naming to those used in main 7 tree.
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java: Fix imports.
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java:
Fix imports, match method named to 7 tree.
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/CompletionHandler.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/SeekableByteChannel.java: Fix imports.
(positionSBC(long)): Rename back to position.
(truncateSBC(long)): Rename back to truncate.
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/spi/AsynchronousChannelProvider.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/AccessDeniedException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/AccessMode.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/AtomicMoveNotSupportedException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ClosedDirectoryStreamException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ClosedFileSystemException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ClosedWatchServiceException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/CopyOption.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/DirectoryNotEmptyException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/DirectoryStream.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/DirectoryStreamFilters.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileAction.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileAlreadyExistsException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileRef.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileStore.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystem.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystemAlreadyExistsException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystemException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystemNotFoundException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystems.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileTreeWalker.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileVisitOption.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileVisitResult.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileVisitor.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Files.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/InvalidPathException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/LinkOption.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/LinkPermission.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/NoSuchFileException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/NotDirectoryException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/NotLinkException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/OpenOption.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Path.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/PathMatcher.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Paths.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ProviderMismatchException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ProviderNotFoundException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ReadOnlyFileSystemException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/SecureDirectoryStream.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/SimpleFileVisitor.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/StandardCopyOption.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/StandardOpenOption.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/StandardWatchEventKind.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/WatchEvent.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/WatchKey.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/WatchService.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Watchable.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntry.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntryFlag.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntryPermission.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntryType.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclFileAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/Attributes.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/BasicFileAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/BasicFileAttributes.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/DosFileAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/DosFileAttributes.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileAttribute.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileOwnerAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileStoreAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileStoreSpaceAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileStoreSpaceAttributes.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/GroupPrincipal.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/NamedAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFileAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFileAttributes.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFilePermission.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFilePermissions.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/UserPrincipal.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/UserPrincipalLookupService.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/UserPrincipalNotFoundException.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/package-info.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/package-info.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/AbstractPath.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/FileSystemProvider.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/FileTypeDetector.java,
* overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/package-info.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AbstractFuture.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousChannelGroupImpl.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousFileChannelImpl.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousFileLockImpl.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/CompletedFuture.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/FileLockTable.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/Invoker.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/PendingFuture.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousDatagramChannelImpl.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/ThreadPool.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractAclFileAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractBasicFileAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractFileStoreSpaceAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractFileTypeDetector.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractNamedAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractPoller.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchKey.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchService.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java,
* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/PollingWatchService.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/JarFileAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/JarFileAttributes.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileAttributes.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileBasicAttributeView.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileBasicAttributes.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFilePath.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileStore.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileStream.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystem.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystemProvider.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipPathParser.java,
* overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipUtils.java: Fix imports.
* overlays/nio2/openjdk/jdk/src/share/native/sun/nio/ch/genSocketOptionRegistry.c: Fix imports.
* overlays/nio2/openjdk/jdk/src/share/sample/nio/aio/EchoServer.java,
* overlays/nio2/openjdk/jdk/src/share/sample/nio/file/AclEdit.java,
* overlays/nio2/openjdk/jdk/src/share/sample/nio/file/Chmod.java,
* overlays/nio2/openjdk/jdk/src/share/sample/nio/file/Copy.java,
* overlays/nio2/openjdk/jdk/src/share/sample/nio/file/DiskUsage.java,
* overlays/nio2/openjdk/jdk/src/share/sample/nio/file/FileType.java,
* overlays/nio2/openjdk/jdk/src/share/sample/nio/file/WatchDir.java,
* overlays/nio2/openjdk/jdk/src/share/sample/nio/file/Xdd.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/LinuxAsynchronousChannelProvider.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/Port.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/SolarisAsynchronousChannelProvider.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/SolarisEventPort.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/DefaultFileTypeDetector.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxNamedAttributeView.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxWatchService.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixCopyFile.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixDirectoryStream.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixException.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileAttributeViews.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileAttributes.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileModeAttribute.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileStore.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystem.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixSecureDirectoryStream.java,
* overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixUserPrincipals.java,
* overlays/nio2/openjdk/jdk/test/demo/nio/ZipFileSystem/Sanity.java,
* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/io/Inputs/Basic.java,
* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java,
* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Basic.java:
Fix imports.
* patches/icedtea-doc-headers.patch: Remove extra '+'.
* patches/icedtea-nio2.patch: Recreated, now includes patch to java.io.File,
java.io.FilePermission, java.net.StandardProtocolFamily, java.net.StandardSocketOption,
java.nio.channels.Channels, java.nio.channels.DatagramChannel, java.nio.channels.exceptions,
java.nio.channels.FileChannel, java.nio.channels.FileLock, java.nio.channels.package-info.java,
java.util.Scanner. Remove patch to sun.nio.ch.FileChannelImpl. Fix imports. Remove 6 cruft.
line wrap: on
line diff
--- a/ChangeLog Fri Feb 13 20:38:41 2009 +0000 +++ b/ChangeLog Fri Feb 20 14:50:00 2009 +0000 @@ -1,3 +1,216 @@ +2009-02-20 Andrew John Hughes <ahughes@redhat.com> + + * overlays/nio2/openjdk/jdk/src/share/classes/java/io/File.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/io/FilePermission.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/net/ProtocolFamily.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/net/SocketOption.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/net/StandardProtocolFamily.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/net/StandardSocketOption.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/Channels.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/DatagramChannel.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/FileChannel.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/FileLock.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/MembershipKey.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/MulticastChannel.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/NetworkChannel.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/exceptions, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/package-info.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/spi/SelectorProvider.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/spi/package.html, + * overlays/nio2/openjdk/jdk/src/share/classes/java/util/Scanner.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java, + * overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaIODeleteOnExitAccess.java, + * overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaNetGetIndexAccess.java, + * overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaUtilConcurrentThreadPoolExecutorAccess.java, + * overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/SharedSecrets.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/ExtendedSocketOption.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipKeyImpl.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipRegistry.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/OptionKey.java: Removed + * Makefile.am: Remove moved patch. + * overlays/nio2/openjdk/jdk/src/share/classes/com/sun/nio/file/ExtendedCopyOption.java, + * overlays/nio2/openjdk/jdk/src/share/classes/com/sun/nio/file/ExtendedOpenOption.java, + * overlays/nio2/openjdk/jdk/src/share/classes/com/sun/nio/file/ExtendedWatchEventModifier.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/io/Inputs.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/io/Outputs.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousByteChannel.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousChannel.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousChannelGroup.java: Fix imports. + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousDatagramChannel.java: Fix imports, + match method naming to those used in main 7 tree. + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java: Fix imports. + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java: + Fix imports, match method named to 7 tree. + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/CompletionHandler.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/SeekableByteChannel.java: Fix imports. + (positionSBC(long)): Rename back to position. + (truncateSBC(long)): Rename back to truncate. + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/spi/AsynchronousChannelProvider.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/AccessDeniedException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/AccessMode.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/AtomicMoveNotSupportedException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ClosedDirectoryStreamException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ClosedFileSystemException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ClosedWatchServiceException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/CopyOption.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/DirectoryNotEmptyException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/DirectoryStream.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/DirectoryStreamFilters.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileAction.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileAlreadyExistsException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileRef.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileStore.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystem.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystemAlreadyExistsException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystemException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystemNotFoundException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystems.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileTreeWalker.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileVisitOption.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileVisitResult.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileVisitor.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Files.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/InvalidPathException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/LinkOption.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/LinkPermission.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/NoSuchFileException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/NotDirectoryException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/NotLinkException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/OpenOption.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Path.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/PathMatcher.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Paths.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ProviderMismatchException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ProviderNotFoundException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ReadOnlyFileSystemException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/SecureDirectoryStream.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/SimpleFileVisitor.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/StandardCopyOption.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/StandardOpenOption.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/StandardWatchEventKind.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/WatchEvent.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/WatchKey.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/WatchService.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Watchable.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntry.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntryFlag.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntryPermission.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntryType.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclFileAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/Attributes.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/BasicFileAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/BasicFileAttributes.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/DosFileAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/DosFileAttributes.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileAttribute.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileOwnerAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileStoreAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileStoreSpaceAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileStoreSpaceAttributes.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/GroupPrincipal.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/NamedAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFileAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFileAttributes.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFilePermission.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFilePermissions.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/UserPrincipal.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/UserPrincipalLookupService.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/UserPrincipalNotFoundException.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/package-info.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/package-info.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/AbstractPath.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/FileSystemProvider.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/FileTypeDetector.java, + * overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/package-info.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AbstractFuture.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousChannelGroupImpl.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousFileChannelImpl.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousFileLockImpl.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/CompletedFuture.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/FileLockTable.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/Invoker.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/PendingFuture.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousDatagramChannelImpl.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/ThreadPool.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractAclFileAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractBasicFileAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractFileStoreSpaceAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractFileTypeDetector.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractNamedAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractPoller.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchKey.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchService.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java, + * overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/PollingWatchService.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/JarFileAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/JarFileAttributes.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileAttributes.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileBasicAttributeView.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileBasicAttributes.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFilePath.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileStore.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileStream.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystem.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystemProvider.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipPathParser.java, + * overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipUtils.java: Fix imports. + * overlays/nio2/openjdk/jdk/src/share/native/sun/nio/ch/genSocketOptionRegistry.c: Fix imports. + * overlays/nio2/openjdk/jdk/src/share/sample/nio/aio/EchoServer.java, + * overlays/nio2/openjdk/jdk/src/share/sample/nio/file/AclEdit.java, + * overlays/nio2/openjdk/jdk/src/share/sample/nio/file/Chmod.java, + * overlays/nio2/openjdk/jdk/src/share/sample/nio/file/Copy.java, + * overlays/nio2/openjdk/jdk/src/share/sample/nio/file/DiskUsage.java, + * overlays/nio2/openjdk/jdk/src/share/sample/nio/file/FileType.java, + * overlays/nio2/openjdk/jdk/src/share/sample/nio/file/WatchDir.java, + * overlays/nio2/openjdk/jdk/src/share/sample/nio/file/Xdd.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/LinuxAsynchronousChannelProvider.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/Port.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/SolarisAsynchronousChannelProvider.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/SolarisEventPort.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/DefaultFileTypeDetector.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxNamedAttributeView.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxWatchService.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixCopyFile.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixDirectoryStream.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixException.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileAttributeViews.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileAttributes.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileModeAttribute.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileStore.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystem.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixSecureDirectoryStream.java, + * overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixUserPrincipals.java, + * overlays/nio2/openjdk/jdk/test/demo/nio/ZipFileSystem/Sanity.java, + * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/io/Inputs/Basic.java, + * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java, + * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Basic.java: + Fix imports. + * patches/icedtea-doc-headers.patch: Remove extra '+'. + * patches/icedtea-nio2.patch: Recreated, now includes patch to java.io.File, + java.io.FilePermission, java.net.StandardProtocolFamily, java.net.StandardSocketOption, + java.nio.channels.Channels, java.nio.channels.DatagramChannel, java.nio.channels.exceptions, + java.nio.channels.FileChannel, java.nio.channels.FileLock, java.nio.channels.package-info.java, + java.util.Scanner. Remove patch to sun.nio.ch.FileChannelImpl. Fix imports. Remove 6 cruft. + 2009-02-13 Andrew John Hughes <ahughes@redhat.com> * overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/java/io/File.java,
--- a/Makefile.am Fri Feb 13 20:38:41 2009 +0000 +++ b/Makefile.am Fri Feb 20 14:50:00 2009 +0000 @@ -2117,7 +2117,6 @@ patches/ecj/icedtea-hotspot-$(HSBUILD).patch \ patches/ecj/icedtea-spp.patch \ patches/ecj/icedtea-jopt.patch \ - patches/ecj/icedtea-pr261.patch \ patches/ecj/icedtea-sbcs.patch stamps/patch-ecj.stamp: stamps/clone-ecj.stamp
--- a/overlays/nio2/openjdk/jdk/src/share/classes/com/sun/nio/file/ExtendedCopyOption.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/com/sun/nio/file/ExtendedCopyOption.java Fri Feb 20 14:50:00 2009 +0000 @@ -25,7 +25,7 @@ package com.sun.nio.file; -import org.classpath.icedtea.java.nio.file.CopyOption; +import java.nio.file.CopyOption; /** * Defines <em>extended</em> copy options supported on some platforms
--- a/overlays/nio2/openjdk/jdk/src/share/classes/com/sun/nio/file/ExtendedOpenOption.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/com/sun/nio/file/ExtendedOpenOption.java Fri Feb 20 14:50:00 2009 +0000 @@ -25,7 +25,7 @@ package com.sun.nio.file; -import org.classpath.icedtea.java.nio.file.OpenOption; +import java.nio.file.OpenOption; /** * Defines <em>extended</em> open options supported on some platforms
--- a/overlays/nio2/openjdk/jdk/src/share/classes/com/sun/nio/file/ExtendedWatchEventModifier.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/com/sun/nio/file/ExtendedWatchEventModifier.java Fri Feb 20 14:50:00 2009 +0000 @@ -25,7 +25,7 @@ package com.sun.nio.file; -import org.classpath.icedtea.java.nio.file.WatchEvent.Modifier; +import java.nio.file.WatchEvent.Modifier; /** * Defines <em>extended</em> watch event modifiers supported on some platforms
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/io/File.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,450 +0,0 @@ -/* - * Copyright 1994-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.io; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.net.URL; -import java.net.MalformedURLException; -import java.net.URISyntaxException; - -import java.io.IOException; -import java.io.IOError; - -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.security.AccessController; -import java.security.PrivilegedAction; -import sun.security.action.GetPropertyAction; - -import org.classpath.icedtea.java.nio.file.FileAlreadyExistsException; -import org.classpath.icedtea.java.nio.file.FileSystem; -import org.classpath.icedtea.java.nio.file.FileSystems; -import org.classpath.icedtea.java.nio.file.InvalidPathException; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.Paths; - -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; -import org.classpath.icedtea.java.nio.file.attribute.FileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission; -import org.classpath.icedtea.java.nio.file.attribute.PosixFilePermissions; - -import org.classpath.icedtea.misc.SharedSecrets; - -/** - * An abstract representation of file and directory pathnames. - * - * <p> User interfaces and operating systems use system-dependent <em>pathname - * strings</em> to name files and directories. This class presents an - * abstract, system-independent view of hierarchical pathnames. An - * <em>abstract pathname</em> has two components: - * - * <ol> - * <li> An optional system-dependent <em>prefix</em> string, - * such as a disk-drive specifier, <code>"/"</code> for the UNIX root - * directory, or <code>"\\\\"</code> for a Microsoft Windows UNC pathname, and - * <li> A sequence of zero or more string <em>names</em>. - * </ol> - * - * The first name in an abstract pathname may be a directory name or, in the - * case of Microsoft Windows UNC pathnames, a hostname. Each subsequent name - * in an abstract pathname denotes a directory; the last name may denote - * either a directory or a file. The <em>empty</em> abstract pathname has no - * prefix and an empty name sequence. - * - * <p> The conversion of a pathname string to or from an abstract pathname is - * inherently system-dependent. When an abstract pathname is converted into a - * pathname string, each name is separated from the next by a single copy of - * the default <em>separator character</em>. The default name-separator - * character is defined by the system property <code>file.separator</code>, and - * is made available in the public static fields <code>{@link - * #separator}</code> and <code>{@link #separatorChar}</code> of this class. - * When a pathname string is converted into an abstract pathname, the names - * within it may be separated by the default name-separator character or by any - * other name-separator character that is supported by the underlying system. - * - * <p> A pathname, whether abstract or in string form, may be either - * <em>absolute</em> or <em>relative</em>. An absolute pathname is complete in - * that no other information is required in order to locate the file that it - * denotes. A relative pathname, in contrast, must be interpreted in terms of - * information taken from some other pathname. By default the classes in the - * <code>java.io</code> package always resolve relative pathnames against the - * current user directory. This directory is named by the system property - * <code>user.dir</code>, and is typically the directory in which the Java - * virtual machine was invoked. - * - * <p> The <em>parent</em> of an abstract pathname may be obtained by invoking - * the {@link #getParent} method of this class and consists of the pathname's - * prefix and each name in the pathname's name sequence except for the last. - * Each directory's absolute pathname is an ancestor of any <tt>File</tt> - * object with an absolute abstract pathname which begins with the directory's - * absolute pathname. For example, the directory denoted by the abstract - * pathname <tt>"/usr"</tt> is an ancestor of the directory denoted by the - * pathname <tt>"/usr/local/bin"</tt>. - * - * <p> The prefix concept is used to handle root directories on UNIX platforms, - * and drive specifiers, root directories and UNC pathnames on Microsoft Windows platforms, - * as follows: - * - * <ul> - * - * <li> For UNIX platforms, the prefix of an absolute pathname is always - * <code>"/"</code>. Relative pathnames have no prefix. The abstract pathname - * denoting the root directory has the prefix <code>"/"</code> and an empty - * name sequence. - * - * <li> For Microsoft Windows platforms, the prefix of a pathname that contains a drive - * specifier consists of the drive letter followed by <code>":"</code> and - * possibly followed by <code>"\\"</code> if the pathname is absolute. The - * prefix of a UNC pathname is <code>"\\\\"</code>; the hostname and the share - * name are the first two names in the name sequence. A relative pathname that - * does not specify a drive has no prefix. - * - * </ul> - * - * <p> Instances of this class may or may not denote an actual file-system - * object such as a file or a directory. If it does denote such an object - * then that object resides in a <i>partition</i>. A partition is an - * operating system-specific portion of storage for a file system. A single - * storage device (e.g. a physical disk-drive, flash memory, CD-ROM) may - * contain multiple partitions. The object, if any, will reside on the - * partition <a name="partName">named</a> by some ancestor of the absolute - * form of this pathname. - * - * <p> A file system may implement restrictions to certain operations on the - * actual file-system object, such as reading, writing, and executing. These - * restrictions are collectively known as <i>access permissions</i>. The file - * system may have multiple sets of access permissions on a single object. - * For example, one set may apply to the object's <i>owner</i>, and another - * may apply to all other users. The access permissions on an object may - * cause some methods in this class to fail. - * - * <p> Instances of the <code>File</code> class are immutable; that is, once - * created, the abstract pathname represented by a <code>File</code> object - * will never change. - * - * <h4>Interoperability with {@code java.nio.file} package</h4> - * - * <p> {@note new} - * The <a href="../../java/nio/file/package-summary.html">{@code java.nio.file}</a> - * package defines interfaces and classes for the Java virtual machine to access - * files, file attributes, and file systems. This API may be used to overcome - * many of the limitations of the {@code java.io.File} class. - * 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 - * locate a file. The resulting {@code Path} provides more efficient and - * extensive access to file attributes, additional file operations, and I/O - * exceptions to help diagnose errors when an operation on a file fails. - * - * @author unascribed - * @since JDK1.0 - */ - -public class File - extends java.io.File -{ - - /** - * Creates a new <code>File</code> instance by converting the given - * pathname string into an abstract pathname. If the given string is - * the empty string, then the result is the empty abstract pathname. - * - * @param pathname A pathname string - * @throws NullPointerException - * If the <code>pathname</code> argument is <code>null</code> - */ - @ConstructorProperties("path") - public File(String pathname) { - super(pathname); - } - - /* Note: The two-argument File constructors do not interpret an empty - parent abstract pathname as the current user directory. An empty parent - instead causes the child to be resolved against the system-dependent - directory defined by the FileSystem.getDefaultParent method. On Unix - this default is "/", while on Microsoft Windows it is "\\". This is required for - compatibility with the original behavior of this class. */ - - /** - * Creates a new <code>File</code> instance from a parent pathname string - * and a child pathname string. - * - * <p> If <code>parent</code> is <code>null</code> then the new - * <code>File</code> instance is created as if by invoking the - * single-argument <code>File</code> constructor on the given - * <code>child</code> pathname string. - * - * <p> Otherwise the <code>parent</code> pathname string is taken to denote - * a directory, and the <code>child</code> pathname string is taken to - * denote either a directory or a file. If the <code>child</code> pathname - * string is absolute then it is converted into a relative pathname in a - * system-dependent way. If <code>parent</code> is the empty string then - * the new <code>File</code> instance is created by converting - * <code>child</code> into an abstract pathname and resolving the result - * against a system-dependent default directory. Otherwise each pathname - * string is converted into an abstract pathname and the child abstract - * pathname is resolved against the parent. - * - * @param parent The parent pathname string - * @param child The child pathname string - * @throws NullPointerException - * If <code>child</code> is <code>null</code> - */ - public File(String parent, String child) { - super(parent, child); - } - - /** - * Creates a new <code>File</code> instance from a parent abstract - * pathname and a child pathname string. - * - * <p> If <code>parent</code> is <code>null</code> then the new - * <code>File</code> instance is created as if by invoking the - * single-argument <code>File</code> constructor on the given - * <code>child</code> pathname string. - * - * <p> Otherwise the <code>parent</code> abstract pathname is taken to - * denote a directory, and the <code>child</code> pathname string is taken - * to denote either a directory or a file. If the <code>child</code> - * pathname string is absolute then it is converted into a relative - * pathname in a system-dependent way. If <code>parent</code> is the empty - * abstract pathname then the new <code>File</code> instance is created by - * converting <code>child</code> into an abstract pathname and resolving - * the result against a system-dependent default directory. Otherwise each - * pathname string is converted into an abstract pathname and the child - * abstract pathname is resolved against the parent. - * - * @param parent The parent abstract pathname - * @param child The child pathname string - * @throws NullPointerException - * If <code>child</code> is <code>null</code> - */ - public File(File parent, String child) { - super(parent, child); - } - - - - /* -- Temporary files -- */ - - private static class TemporaryDirectory { - private TemporaryDirectory() { } - - static final File valueAsFile = - new File(AccessController.doPrivileged(new GetPropertyAction("java.io.tmpdir"))); - - // file name generation - private static final AtomicInteger counter = - new AtomicInteger(new Random().nextInt() & 0xffff); - static File generateFile(String prefix, String suffix, File dir) { - int n = counter.getAndIncrement(); - return new File(dir, prefix + Integer.toString(n) + suffix); - } - - // default file permissions - static final FileAttribute<Set<PosixFilePermission>> defaultPosixFilePermissions = - PosixFilePermissions.asFileAttribute(EnumSet - .of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE)); - static final boolean isPosix = isPosix(); - static boolean isPosix() { - return AccessController.doPrivileged( - new PrivilegedAction<Boolean>() { - public Boolean run() { - try { - return FileSystems.getDefault().getPath(valueAsFile.getPath()) - .getFileStore().supportsFileAttributeView("posix"); - } catch (IOException e) { - throw new IOError(e); - } - } - }); - } - } - - /** - * {@note new} - * Creates an empty file in the default temporary-file directory, using - * the given prefix and suffix to generate its name. This method is - * equivalent to invoking the {@link #createTempFile(String,String) - * createTempFile(prefix, suffix)} method with the addition that the - * resulting pathname may be requested to be deleted when the Java virtual - * machine terminates, and the initial file attributes to set atomically - * when creating the file may be specified. - * - * <p> When the value of the {@code deleteOnExit} method is {@code true} - * then the resulting file is requested to be deleted when the Java virtual - * machine terminates as if by invoking the {@link #deleteOnExit deleteOnExit} - * method. - * - * <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. - * - * @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 deleteOnExit - * {@code true} if the file denoted by resulting pathname be - * deleted when the Java virtual machine terminates - * @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</code> 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. When the {@code - * deleteOnExit} parameter has the value {@code true} then the - * security manager's {@link - * java.lang.SecurityManager#checkDelete(java.lang.String)} is - * invoked to check delete access to the file. - * @since 1.7 - */ - public static File createTempFile(String prefix, - String suffix, - boolean deleteOnExit, - FileAttribute<?>... attrs) - throws IOException - { - if (prefix.length() < 3) - throw new IllegalArgumentException("Prefix string too short"); - suffix = (suffix == null) ? ".tmp" : suffix; - - // special case POSIX environments so that 0600 is used as the file mode - if (TemporaryDirectory.isPosix) { - if (attrs.length == 0) { - // no attributes so use default permissions - attrs = new FileAttribute<?>[1]; - attrs[0] = TemporaryDirectory.defaultPosixFilePermissions; - } else { - // check if posix permissions given; if not use default - boolean hasPermissions = false; - for (int i=0; i<attrs.length; i++) { - if (attrs[i].name().equals("posix:permissions")) { - hasPermissions = true; - break; - } - } - if (!hasPermissions) { - FileAttribute<?>[] copy = new FileAttribute<?>[attrs.length+1]; - System.arraycopy(attrs, 0, copy, 0, attrs.length); - attrs = copy; - attrs[attrs.length-1] = - TemporaryDirectory.defaultPosixFilePermissions; - } - } - } - - // use Path#createFile to create file - SecurityManager sm = System.getSecurityManager(); - for (;;) { - File f = TemporaryDirectory - .generateFile(prefix, suffix, TemporaryDirectory.valueAsFile); - if (sm != null && deleteOnExit) - sm.checkDelete(f.getPath()); - try { - f.toPath().createFile(attrs); - if (deleteOnExit) - SharedSecrets.getJavaIODeleteOnExitAccess().add(f.getPath()); - return f; - } catch (InvalidPathException e) { - // don't reveal temporary directory location - if (sm != null) - throw new IllegalArgumentException("Invalid prefix or suffix"); - throw e; - } catch (SecurityException e) { - // don't reveal temporary directory location - if (sm != null) - throw new SecurityException("Unable to create temporary file"); - throw e; - } catch (FileAlreadyExistsException e) { - // ignore - } - } - } - - // -- Integration with java.nio.file -- - - private volatile transient Path filePath; - - /** - * {@note new} - * Returns a {@link Path java.nio.file.Path} object constructed from the - * this abstract path. The first invocation of this method works as if - * invoking it were equivalent to evaluating the expression: - * <blockquote><pre> - * {@link FileSystems#getDefault FileSystems.getDefault}().{@link FileSystem#getPath getPath}(this.{@link #getPath getPath}()); - * </pre></blockquote> - * Subsequent invocations of this method return the same {@code Path}. - * - * <p> If this abstract pathname is the empty abstract pathname then this - * method returns a {@code Path} that may be used to access to the current - * user directory. - * - * @return A {@code Path} constructed from this abstract path. The resulting - * {@code Path} is associated with the {@link FileSystems#getDefault - * default-filesystem}. - * - * @throws InvalidPathException - * If a {@code Path} object cannot be constructed from the abstract - * path (see {@link java.nio.file.FileSystem#getPath FileSystem.getPath}) - * - * @since 1.7 - */ - public Path toPath() { - if (filePath == null) { - synchronized (this) { - if (filePath == null) { - String path = getPath(); - if (path.length() == 0) { - // assume default file system treats "." as current directory - filePath = Paths.get("."); - } else { - filePath = Paths.get(path); - } - } - } - } - return filePath; - } -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/io/FilePermission.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,852 +0,0 @@ -/* - * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.io; - -import java.security.*; -import java.util.Enumeration; -import java.util.List; -import java.util.ArrayList; -import java.util.Vector; -import java.util.Collections; -import java.io.IOException; -import java.io.ObjectStreamField; -import java.io.ObjectOutputStream; -import java.io.ObjectInputStream; -import java.io.Serializable; -import sun.security.util.SecurityConstants; - -/** - * This class represents access to a file or directory. A FilePermission consists - * of a pathname and a set of actions valid for that pathname. - * <P> - * Pathname is the pathname of the file or directory granted the specified - * actions. A pathname that ends in "/*" (where "/" is - * the file separator character, <code>File.separatorChar</code>) indicates - * all the files and directories contained in that directory. A pathname - * that ends with "/-" indicates (recursively) all files - * and subdirectories contained in that directory. A pathname consisting of - * the special token "<<ALL FILES>>" matches <b>any</b> file. - * <P> - * Note: A pathname consisting of a single "*" indicates all the files - * in the current directory, while a pathname consisting of a single "-" - * indicates all the files in the current directory and - * (recursively) all files and subdirectories contained in the current - * directory. - * <P> - * {@note revised} - * The actions to be granted are passed to the constructor in a string containing - * a list of one or more comma-separated keywords. The possible keywords are - * "read", "write", "execute", "delete", and "readlink". Their meaning is - * defined as follows: - * <P> - * <DL> - * <DT> read <DD> read permission - * <DT> write <DD> write permission - * <DT> execute - * <DD> execute permission. Allows <code>Runtime.exec</code> to - * be called. Corresponds to <code>SecurityManager.checkExec</code>. - * <DT> delete - * <DD> delete permission. Allows <code>File.delete</code> to - * be called. Corresponds to <code>SecurityManager.checkDelete</code>. - * <DT> readlink - * <DD> read link permission. Allows the target of a - * <a href="../nio/file/package-summary.html#links">symbolic link</a> - * to be read by invoking the {@link java.nio.file.Path#readSymbolicLink - * readSymbolicLink } method. - * </DL> - * <P> - * The actions string is converted to lowercase before processing. - * <P> - * Be careful when granting FilePermissions. Think about the implications - * of granting read and especially write access to various files and - * directories. The "<<ALL FILES>>" permission with write action is - * especially dangerous. This grants permission to write to the entire - * file system. One thing this effectively allows is replacement of the - * system binary, including the JVM runtime environment. - * - * <p>Please note: Code can always read a file from the same - * directory it's in (or a subdirectory of that directory); it does not - * need explicit permission to do so. - * - * @see java.security.Permission - * @see java.security.Permissions - * @see java.security.PermissionCollection - * - * - * @author Marianne Mueller - * @author Roland Schemers - * @since 1.2 - * - * @serial exclude - */ - -public final class FilePermission extends Permission implements Serializable { - - /** - * Execute action. - */ - private final static int EXECUTE = 0x1; - /** - * Write action. - */ - private final static int WRITE = 0x2; - /** - * Read action. - */ - private final static int READ = 0x4; - /** - * Delete action. - */ - private final static int DELETE = 0x8; - /** - * Read link action. - */ - private final static int READLINK = 0x10; - - /** - * All actions (read,write,execute,delete,readlink) - */ - private final static int ALL = READ|WRITE|EXECUTE|DELETE|READLINK; - /** - * No actions. - */ - private final static int NONE = 0x0; - - // the actions mask - private transient int mask; - - // does path indicate a directory? (wildcard or recursive) - private transient boolean directory; - - // is it a recursive directory specification? - private transient boolean recursive; - - /** - * the actions string. - * - * @serial - */ - private String actions; // Left null as long as possible, then - // created and re-used in the getAction function. - - // canonicalized dir path. In the case of - // directories, it is the name "/blah/*" or "/blah/-" without - // the last character (the "*" or "-"). - - private transient String cpath; - - // static Strings used by init(int mask) - private static final char RECURSIVE_CHAR = '-'; - private static final char WILD_CHAR = '*'; - -/* - public String toString() - { - StringBuffer sb = new StringBuffer(); - sb.append("***\n"); - sb.append("cpath = "+cpath+"\n"); - sb.append("mask = "+mask+"\n"); - sb.append("actions = "+getActions()+"\n"); - sb.append("directory = "+directory+"\n"); - sb.append("recursive = "+recursive+"\n"); - sb.append("***\n"); - return sb.toString(); - } -*/ - - private static final long serialVersionUID = 7930732926638008763L; - - /** - * initialize a FilePermission object. Common to all constructors. - * Also called during de-serialization. - * - * @param mask the actions mask to use. - * - */ - private void init(int mask) - { - - if ((mask & ALL) != mask) - throw new IllegalArgumentException("invalid actions mask"); - - if (mask == NONE) - throw new IllegalArgumentException("invalid actions mask"); - - if ((cpath = getName()) == null) - throw new NullPointerException("name can't be null"); - - this.mask = mask; - - if (cpath.equals("<<ALL FILES>>")) { - directory = true; - recursive = true; - cpath = ""; - return; - } - - // store only the canonical cpath if possible - cpath = AccessController.doPrivileged(new PrivilegedAction<String>() { - public String run() { - try { - return sun.security.provider.PolicyFile.canonPath(cpath); - } catch (IOException ioe) { - return cpath; - } - } - }); - - int len = cpath.length(); - char last = ((len > 0) ? cpath.charAt(len - 1) : 0); - - if (last == RECURSIVE_CHAR && - cpath.charAt(len - 2) == File.separatorChar) { - directory = true; - recursive = true; - cpath = cpath.substring(0, --len); - } else if (last == WILD_CHAR && - cpath.charAt(len - 2) == File.separatorChar) { - directory = true; - //recursive = false; - cpath = cpath.substring(0, --len); - } else { - // overkill since they are initialized to false, but - // commented out here to remind us... - //directory = false; - //recursive = false; - } - - // XXX: at this point the path should be absolute. die if it isn't? - } - - /** - * Creates a new FilePermission object with the specified actions. - * <i>path</i> is the pathname of a file or directory, and <i>actions</i> - * contains a comma-separated list of the desired actions granted on the - * file or directory. Possible actions are - * "read", "write", "execute", "delete", and "readlink". - * - * <p>A pathname that ends in "/*" (where "/" is - * the file separator character, <code>File.separatorChar</code>) - * indicates all the files and directories contained in that directory. - * A pathname that ends with "/-" indicates (recursively) all files and - * subdirectories contained in that directory. The special pathname - * "<<ALL FILES>>" matches any file. - * - * <p>A pathname consisting of a single "*" indicates all the files - * in the current directory, while a pathname consisting of a single "-" - * indicates all the files in the current directory and - * (recursively) all files and subdirectories contained in the current - * directory. - * - * <p>A pathname containing an empty string represents an empty path. - * - * @param path the pathname of the file/directory. - * @param actions the action string. - * - * @throws IllegalArgumentException - * If actions is <code>null</code>, empty or contains an action - * other than the specified possible actions. - */ - - public FilePermission(String path, String actions) - { - super(path); - init(getMask(actions)); - } - - /** - * Creates a new FilePermission object using an action mask. - * More efficient than the FilePermission(String, String) constructor. - * Can be used from within - * code that needs to create a FilePermission object to pass into the - * <code>implies</code> method. - * - * @param path the pathname of the file/directory. - * @param mask the action mask to use. - */ - - // package private for use by the FilePermissionCollection add method - FilePermission(String path, int mask) - { - super(path); - init(mask); - } - - /** - * Checks if this FilePermission object "implies" the specified permission. - * <P> - * More specifically, this method returns true if:<p> - * <ul> - * <li> <i>p</i> is an instanceof FilePermission,<p> - * <li> <i>p</i>'s actions are a proper subset of this - * object's actions, and <p> - * <li> <i>p</i>'s pathname is implied by this object's - * pathname. For example, "/tmp/*" implies "/tmp/foo", since - * "/tmp/*" encompasses all files in the "/tmp" directory, - * including the one named "foo". - * </ul> - * - * @param p the permission to check against. - * - * @return <code>true</code> if the specified permission is not - * <code>null</code> and is implied by this object, - * <code>false</code> otherwise. - */ - public boolean implies(Permission p) { - if (!(p instanceof FilePermission)) - return false; - - FilePermission that = (FilePermission) p; - - // we get the effective mask. i.e., the "and" of this and that. - // They must be equal to that.mask for implies to return true. - - return ((this.mask & that.mask) == that.mask) && impliesIgnoreMask(that); - } - - /** - * Checks if the Permission's actions are a proper subset of the - * this object's actions. Returns the effective mask iff the - * this FilePermission's path also implies that FilePermission's path. - * - * @param that the FilePermission to check against. - * @param exact return immediately if the masks are not equal - * @return the effective mask - */ - boolean impliesIgnoreMask(FilePermission that) { - if (this.directory) { - if (this.recursive) { - // make sure that.path is longer then path so - // something like /foo/- does not imply /foo - if (that.directory) { - return (that.cpath.length() >= this.cpath.length()) && - that.cpath.startsWith(this.cpath); - } else { - return ((that.cpath.length() > this.cpath.length()) && - that.cpath.startsWith(this.cpath)); - } - } else { - if (that.directory) { - // if the permission passed in is a directory - // specification, make sure that a non-recursive - // permission (i.e., this object) can't imply a recursive - // permission. - if (that.recursive) - return false; - else - return (this.cpath.equals(that.cpath)); - } else { - int last = that.cpath.lastIndexOf(File.separatorChar); - if (last == -1) - return false; - else { - // this.cpath.equals(that.cpath.substring(0, last+1)); - // Use regionMatches to avoid creating new string - return (this.cpath.length() == (last + 1)) && - this.cpath.regionMatches(0, that.cpath, 0, last+1); - } - } - } - } else if (that.directory) { - // if this is NOT recursive/wildcarded, - // do not let it imply a recursive/wildcarded permission - return false; - } else { - return (this.cpath.equals(that.cpath)); - } - } - - /** - * Checks two FilePermission objects for equality. Checks that <i>obj</i> is - * a FilePermission, and has the same pathname and actions as this object. - * <P> - * @param obj the object we are testing for equality with this object. - * @return <code>true</code> if obj is a FilePermission, and has the same - * pathname and actions as this FilePermission object, - * <code>false</code> otherwise. - */ - public boolean equals(Object obj) { - if (obj == this) - return true; - - if (! (obj instanceof FilePermission)) - return false; - - FilePermission that = (FilePermission) obj; - - return (this.mask == that.mask) && - this.cpath.equals(that.cpath) && - (this.directory == that.directory) && - (this.recursive == that.recursive); - } - - /** - * Returns the hash code value for this object. - * - * @return a hash code value for this object. - */ - - public int hashCode() { - return this.cpath.hashCode(); - } - - /** - * Converts an actions String to an actions mask. - * - * @param action the action string. - * @return the actions mask. - */ - private static int getMask(String actions) { - - int mask = NONE; - - // Null action valid? - if (actions == null) { - return mask; - } - // Check against use of constants (used heavily within the JDK) - if (actions == SecurityConstants.FILE_READ_ACTION) { - return READ; - } else if (actions == SecurityConstants.FILE_WRITE_ACTION) { - return WRITE; - } else if (actions == SecurityConstants.FILE_EXECUTE_ACTION) { - return EXECUTE; - } else if (actions == SecurityConstants.FILE_DELETE_ACTION) { - return DELETE; - } else if (actions == SecurityConstants.FILE_READLINK_ACTION) { - return READLINK; - } - - char[] a = actions.toCharArray(); - - int i = a.length - 1; - if (i < 0) - return mask; - - while (i != -1) { - char c; - - // skip whitespace - while ((i!=-1) && ((c = a[i]) == ' ' || - c == '\r' || - c == '\n' || - c == '\f' || - c == '\t')) - i--; - - // check for the known strings - int matchlen; - - if (i >= 3 && (a[i-3] == 'r' || a[i-3] == 'R') && - (a[i-2] == 'e' || a[i-2] == 'E') && - (a[i-1] == 'a' || a[i-1] == 'A') && - (a[i] == 'd' || a[i] == 'D')) - { - matchlen = 4; - mask |= READ; - - } else if (i >= 4 && (a[i-4] == 'w' || a[i-4] == 'W') && - (a[i-3] == 'r' || a[i-3] == 'R') && - (a[i-2] == 'i' || a[i-2] == 'I') && - (a[i-1] == 't' || a[i-1] == 'T') && - (a[i] == 'e' || a[i] == 'E')) - { - matchlen = 5; - mask |= WRITE; - - } else if (i >= 6 && (a[i-6] == 'e' || a[i-6] == 'E') && - (a[i-5] == 'x' || a[i-5] == 'X') && - (a[i-4] == 'e' || a[i-4] == 'E') && - (a[i-3] == 'c' || a[i-3] == 'C') && - (a[i-2] == 'u' || a[i-2] == 'U') && - (a[i-1] == 't' || a[i-1] == 'T') && - (a[i] == 'e' || a[i] == 'E')) - { - matchlen = 7; - mask |= EXECUTE; - - } else if (i >= 5 && (a[i-5] == 'd' || a[i-5] == 'D') && - (a[i-4] == 'e' || a[i-4] == 'E') && - (a[i-3] == 'l' || a[i-3] == 'L') && - (a[i-2] == 'e' || a[i-2] == 'E') && - (a[i-1] == 't' || a[i-1] == 'T') && - (a[i] == 'e' || a[i] == 'E')) - { - matchlen = 6; - mask |= DELETE; - - } else if (i >= 7 && (a[i-7] == 'r' || a[i-7] == 'R') && - (a[i-6] == 'e' || a[i-6] == 'E') && - (a[i-5] == 'a' || a[i-5] == 'A') && - (a[i-4] == 'd' || a[i-4] == 'D') && - (a[i-3] == 'l' || a[i-3] == 'L') && - (a[i-2] == 'i' || a[i-2] == 'I') && - (a[i-1] == 'n' || a[i-1] == 'N') && - (a[i] == 'k' || a[i] == 'K')) - { - matchlen = 8; - mask |= READLINK; - - } else { - // parse error - throw new IllegalArgumentException( - "invalid permission: " + actions); - } - - // make sure we didn't just match the tail of a word - // like "ackbarfaccept". Also, skip to the comma. - boolean seencomma = false; - while (i >= matchlen && !seencomma) { - switch(a[i-matchlen]) { - case ',': - seencomma = true; - /*FALLTHROUGH*/ - case ' ': case '\r': case '\n': - case '\f': case '\t': - break; - default: - throw new IllegalArgumentException( - "invalid permission: " + actions); - } - i--; - } - - // point i at the location of the comma minus one (or -1). - i -= matchlen; - } - - return mask; - } - - /** - * Return the current action mask. Used by the FilePermissionCollection. - * - * @return the actions mask. - */ - - int getMask() { - return mask; - } - - /** - * Return the canonical string representation of the actions. - * Always returns present actions in the following order: - * read, write, execute, delete, readlink. - * - * @return the canonical string representation of the actions. - */ - private static String getActions(int mask) - { - StringBuilder sb = new StringBuilder(); - boolean comma = false; - - if ((mask & READ) == READ) { - comma = true; - sb.append("read"); - } - - if ((mask & WRITE) == WRITE) { - if (comma) sb.append(','); - else comma = true; - sb.append("write"); - } - - if ((mask & EXECUTE) == EXECUTE) { - if (comma) sb.append(','); - else comma = true; - sb.append("execute"); - } - - if ((mask & DELETE) == DELETE) { - if (comma) sb.append(','); - else comma = true; - sb.append("delete"); - } - - if ((mask & READLINK) == READLINK) { - if (comma) sb.append(','); - else comma = true; - sb.append("readlink"); - } - - return sb.toString(); - } - - /** - * Returns the "canonical string representation" of the actions. - * That is, this method always returns present actions in the following order: - * read, write, execute, delete, readlink. For example, if this FilePermission - * object allows both write and read actions, a call to <code>getActions</code> - * will return the string "read,write". - * - * @return the canonical string representation of the actions. - */ - public String getActions() - { - if (actions == null) - actions = getActions(this.mask); - - return actions; - } - - - /** - * Returns a new PermissionCollection object for storing FilePermission - * objects. - * <p> - * FilePermission objects must be stored in a manner that allows them - * to be inserted into the collection in any order, but that also enables the - * PermissionCollection <code>implies</code> - * method to be implemented in an efficient (and consistent) manner. - * - * <p>For example, if you have two FilePermissions: - * <OL> - * <LI> <code>"/tmp/-", "read"</code> - * <LI> <code>"/tmp/scratch/foo", "write"</code> - * </OL> - * - * <p>and you are calling the <code>implies</code> method with the FilePermission: - * - * <pre> - * "/tmp/scratch/foo", "read,write", - * </pre> - * - * then the <code>implies</code> function must - * take into account both the "/tmp/-" and "/tmp/scratch/foo" - * permissions, so the effective permission is "read,write", - * and <code>implies</code> returns true. The "implies" semantics for - * FilePermissions are handled properly by the PermissionCollection object - * returned by this <code>newPermissionCollection</code> method. - * - * @return a new PermissionCollection object suitable for storing - * FilePermissions. - */ - - public PermissionCollection newPermissionCollection() { - return new FilePermissionCollection(); - } - - /** - * WriteObject is called to save the state of the FilePermission - * to a stream. The actions are serialized, and the superclass - * takes care of the name. - */ - private void writeObject(ObjectOutputStream s) - throws IOException - { - // Write out the actions. The superclass takes care of the name - // call getActions to make sure actions field is initialized - if (actions == null) - getActions(); - s.defaultWriteObject(); - } - - /** - * readObject is called to restore the state of the FilePermission from - * a stream. - */ - private void readObject(ObjectInputStream s) - throws IOException, ClassNotFoundException - { - // Read in the actions, then restore everything else by calling init. - s.defaultReadObject(); - init(getMask(actions)); - } -} - -/** - * A FilePermissionCollection stores a set of FilePermission permissions. - * FilePermission objects - * must be stored in a manner that allows them to be inserted in any - * order, but enable the implies function to evaluate the implies - * method. - * For example, if you have two FilePermissions: - * <OL> - * <LI> "/tmp/-", "read" - * <LI> "/tmp/scratch/foo", "write" - * </OL> - * And you are calling the implies function with the FilePermission: - * "/tmp/scratch/foo", "read,write", then the implies function must - * take into account both the /tmp/- and /tmp/scratch/foo - * permissions, so the effective permission is "read,write". - * - * @see java.security.Permission - * @see java.security.Permissions - * @see java.security.PermissionCollection - * - * - * @author Marianne Mueller - * @author Roland Schemers - * - * @serial include - * - */ - -final class FilePermissionCollection extends PermissionCollection -implements Serializable { - - // Not serialized; see serialization section at end of class - private transient List<Permission> perms; - - /** - * Create an empty FilePermissions object. - * - */ - - public FilePermissionCollection() { - perms = new ArrayList<Permission>(); - } - - /** - * Adds a permission to the FilePermissions. The key for the hash is - * permission.path. - * - * @param permission the Permission object to add. - * - * @exception IllegalArgumentException - if the permission is not a - * FilePermission - * - * @exception SecurityException - if this FilePermissionCollection object - * has been marked readonly - */ - - public void add(Permission permission) - { - if (! (permission instanceof FilePermission)) - throw new IllegalArgumentException("invalid permission: "+ - permission); - if (isReadOnly()) - throw new SecurityException( - "attempt to add a Permission to a readonly PermissionCollection"); - - synchronized (this) { - perms.add(permission); - } - } - - /** - * Check and see if this set of permissions implies the permissions - * expressed in "permission". - * - * @param p the Permission object to compare - * - * @return true if "permission" is a proper subset of a permission in - * the set, false if not. - */ - - public boolean implies(Permission permission) - { - if (! (permission instanceof FilePermission)) - return false; - - FilePermission fp = (FilePermission) permission; - - int desired = fp.getMask(); - int effective = 0; - int needed = desired; - - synchronized (this) { - int len = perms.size(); - for (int i = 0; i < len; i++) { - FilePermission x = (FilePermission) perms.get(i); - if (((needed & x.getMask()) != 0) && x.impliesIgnoreMask(fp)) { - effective |= x.getMask(); - if ((effective & desired) == desired) - return true; - needed = (desired ^ effective); - } - } - } - return false; - } - - /** - * Returns an enumeration of all the FilePermission objects in the - * container. - * - * @return an enumeration of all the FilePermission objects. - */ - - public Enumeration elements() { - // Convert Iterator into Enumeration - synchronized (this) { - return Collections.enumeration(perms); - } - } - - private static final long serialVersionUID = 2202956749081564585L; - - // Need to maintain serialization interoperability with earlier releases, - // which had the serializable field: - // private Vector permissions; - - /** - * @serialField permissions java.util.Vector - * A list of FilePermission objects. - */ - private static final ObjectStreamField[] serialPersistentFields = { - new ObjectStreamField("permissions", Vector.class), - }; - - /** - * @serialData "permissions" field (a Vector containing the FilePermissions). - */ - /* - * Writes the contents of the perms field out as a Vector for - * serialization compatibility with earlier releases. - */ - private void writeObject(ObjectOutputStream out) throws IOException { - // Don't call out.defaultWriteObject() - - // Write out Vector - Vector<Permission> permissions = new Vector<Permission>(perms.size()); - synchronized (this) { - permissions.addAll(perms); - } - - ObjectOutputStream.PutField pfields = out.putFields(); - pfields.put("permissions", permissions); - out.writeFields(); - } - - /* - * Reads in a Vector of FilePermissions and saves them in the perms field. - */ - @SuppressWarnings("unchecked") - private void readObject(ObjectInputStream in) throws IOException, - ClassNotFoundException { - // Don't call defaultReadObject() - - // Read in serialized fields - ObjectInputStream.GetField gfields = in.readFields(); - - // Get the one we want - Vector<Permission> permissions = (Vector<Permission>)gfields.get("permissions", null); - perms = new ArrayList<Permission>(permissions.size()); - perms.addAll(permissions); - } -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/io/Inputs.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/io/Inputs.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,5 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +23,7 @@ * have any questions. */ -package org.classpath.icedtea.java.io; +package java.io; import java.io.Closeable; import java.io.FileInputStream; @@ -41,11 +40,11 @@ import java.util.List; -import org.classpath.icedtea.java.nio.file.FileRef; +import java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.attribute.Attributes; +import java.nio.file.attribute.Attributes; -import org.classpath.icedtea.java.util.Scanner; +import java.util.Scanner; /** * {@note experimental}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/io/Outputs.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/io/Outputs.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,5 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +23,7 @@ * have any questions. */ -package org.classpath.icedtea.java.io; +package java.io; import java.io.BufferedWriter; import java.io.FileOutputStream; @@ -40,11 +39,11 @@ import java.util.Arrays; import java.util.List; -import org.classpath.icedtea.java.nio.file.FileRef; +import java.nio.file.FileRef; -import static org.classpath.icedtea.java.nio.file.StandardOpenOption.CREATE; -import static org.classpath.icedtea.java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; -import static org.classpath.icedtea.java.nio.file.StandardOpenOption.WRITE; +import static java.nio.file.StandardOpenOption.CREATE; +import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; +import static java.nio.file.StandardOpenOption.WRITE; /** * {@note experimental}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/net/ProtocolFamily.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.net; - -/** - * Represents a family of communication protocols. - * - * @since 1.7 - */ - -public interface ProtocolFamily { - /** - * Returns the name of the protocol family. - */ - String name(); -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/net/SocketOption.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.net; - -/** - * A socket option associated with a socket. - * - * <p> In the {@link java.nio.channels channels} package, the {@link - * java.nio.channels.NetworkChannel} interface defines the {@link - * java.nio.channels.NetworkChannel#setOption(SocketOption,Object) setOption} - * and {@link java.nio.channels.NetworkChannel#getOption(SocketOption) getOption} - * methods to set and query the channel's socket options. - * - * @param <T> The type of the socket option value. - * - * @since 1.7 - * - * @see StandardSocketOption - */ - -public interface SocketOption<T> { - - /** - * Returns the name of the socket option. - */ - String name(); - - /** - * Returns the type of the socket option value. - */ - Class<T> type(); -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/net/StandardProtocolFamily.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.net; - -/** - * Defines the standard families of communication protocols. - * - * @since 1.7 - */ - -public enum StandardProtocolFamily implements ProtocolFamily { - - /** - * Internet Protocol Version 4 (IPv4) - */ - INET, - - /** - * Internet Protocol Version 6 (IPv6) - */ - INET6 -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/net/StandardSocketOption.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,370 +0,0 @@ -/* - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.net; - -import java.net.NetworkInterface; - -/** - * Defines the <em>standard</em> socket options. - * - * <p> The {@link SocketOption#name name} of each socket option defined by this - * class is its field name. - * - * <p> In this release, the socket options defined here are used by {@link - * java.nio.channels.NetworkChannel network} channels in the {@link - * java.nio.channels channels} package. - * - * @since 1.7 - */ - -public final class StandardSocketOption { - private StandardSocketOption() { } - - // -- SOL_SOCKET -- - - /** - * Allow transmission of broadcast datagrams. - * - * <p> The value of this socket option is a {@code Boolean} that represents - * whether the option is enabled or disabled. The option is specific to - * datagram-oriented sockets sending to {@link java.net.Inet4Address IPv4} - * broadcast addresses. When the socket option is enabled then the socket - * can be used to send <em>broadcast datagrams</em>. - * - * <p> The initial value of this socket option is {@code FALSE}. The socket - * option may be enabled or disabled at any time. Some operating systems may - * require that the Java virtual machine be started with implementation - * specific privileges to enable this option or send broadcast datagrams. - * - * @see <a href="http://www.ietf.org/rfc/rfc919.txt">RFC 929: - * Broadcasting Internet Datagrams</a> - * @see DatagramSocket#setBroadcast - */ - public static final SocketOption<Boolean> SO_BROADCAST = - new StdSocketOption<Boolean>("SO_BROADCAST", Boolean.class); - - /** - * Keep connection alive. - * - * <p> The value of this socket option is a {@code Boolean} that represents - * whether the option is enabled or disabled. When the {@code SO_KEEPALIVE} - * option is enabled the operating system may use a <em>keep-alive</em> - * mechanism to periodically probe the other end of a connection when the - * connection is otherwise idle. The exact semantics of the keep alive - * mechanism is system dependent and therefore unspecified. - * - * <p> The initial value of this socket option is {@code FALSE}. The socket - * option may be enabled or disabled at any time. - * - * @see <a href="http://www.ietf.org/rfc/rfc1122.txt">RFC 1122 - * Requirements for Internet Hosts -- Communication Layers</a> - * @see Socket#setKeepAlive - */ - public static final SocketOption<Boolean> SO_KEEPALIVE = - new StdSocketOption<Boolean>("SO_KEEPALIVE", Boolean.class); - - /** - * The size of the socket send buffer. - * - * <p> The value of this socket option is an {@code Integer} that is the - * size of the socket send buffer in bytes. The socket send buffer is an - * output buffer used by the networking implementation. It may need to be - * increased for high-volume connections. The value of the socket option is - * a <em>hint</em> to the implementation to size the buffer and the actual - * size may differ. The socket option can be queried to retrieve the actual - * size. - * - * <p> For datagram-oriented sockets, the size of the send buffer may limit - * the size of the datagrams that may be sent by the socket. Whether - * datagrams larger than the buffer size are sent or discarded is system - * dependent. - * - * <p> The initial/default size of the socket send buffer and the range of - * allowable values is system dependent although a negative size is not - * allowed. An attempt to set the socket send buffer to larger than its - * maximum size causes it to be set to its maximum size. - * - * <p> An implementation allows this socket option to be set before the - * socket is bound or connected. Whether an implementation allows the - * socket send buffer to be changed after the socket is bound is system - * dependent. - * - * @see Socket#setSendBufferSize - */ - public static final SocketOption<Integer> SO_SNDBUF = - new StdSocketOption<Integer>("SO_SNDBUF", Integer.class); - - - /** - * The size of the socket receive buffer. - * - * <p> The value of this socket option is an {@code Integer} that is the - * size of the socket receive buffer in bytes. The socket receive buffer is - * an input buffer used by the networking implementation. It may need to be - * increased for high-volume connections or decreased to limit the possible - * backlog of incoming data. The value of the socket option is a - * <em>hint</em> to the implementation to size the buffer and the actual - * size may differ. - * - * <p> For datagram-oriented sockets, the size of the receive buffer may - * limit the size of the datagrams that can be received. Whether datagrams - * larger than the buffer size can be received is system dependent. - * Increasing the socket receive buffer may be important for cases where - * datagrams arrive in bursts faster than they can be processed. - * - * <p> In the case of stream-oriented sockets and the TCP/IP protocol, the - * size of the socket receive buffer may be used when advertising the size - * of the TCP receive window to the remote peer. - * - * <p> The initial/default size of the socket receive buffer and the range - * of allowable values is system dependent although a negative size is not - * allowed. An attempt to set the socket receive buffer to larger than its - * maximum size causes it to be set to its maximum size. - * - * <p> An implementation allows this socket option to be set before the - * socket is bound or connected. Whether an implementation allows the - * socket receive buffer to be changed after the socket is bound is system - * dependent. - * - * @see <a href="http://www.ietf.org/rfc/rfc1323.txt">RFC 1323: TCP - * Extensions for High Performance</a> - * @see Socket#setReceiveBufferSize - * @see ServerSocket#setReceiveBufferSize - */ - public static final SocketOption<Integer> SO_RCVBUF = - new StdSocketOption<Integer>("SO_RCVBUF", Integer.class); - - /** - * Re-use address. - * - * <p> The value of this socket option is a {@code Boolean} that represents - * whether the option is enabled or disabled. The exact semantics of this - * socket option are socket type and system dependent. - * - * <p> In the case of stream-oriented sockets, this socket option will - * usually determine whether the socket can be bound to a socket address - * when a previous connection involving that socket address is in the - * <em>TIME_WAIT</em> state. On implementations where the semantics differ, - * and the socket option is not required to be enabled in order to bind the - * socket when a previous connection is in this state, then the - * implementation may choose to ignore this option. - * - * <p> For datagram-oriented sockets the socket option is used to allow - * multiple programs bind to the same address. This option should be enabled - * when the socket is to be used for Internet Protocol (IP) multicasting. - * - * <p> An implementation allows this socket option to be set before the - * socket is bound or connected. Changing the value of this socket option - * after the socket is bound has no effect. The default value of this - * socket option is system dependent. - * - * @see <a href="http://www.ietf.org/rfc/rfc793.txt">RFC 793: Transmission - * Control Protocol</a> - * @see ServerSocket#setReuseAddress - */ - public static final SocketOption<Boolean> SO_REUSEADDR = - new StdSocketOption<Boolean>("SO_REUSEADDR", Boolean.class); - - /** - * Linger on close if data is present. - * - * <p> The value of this socket option is an {@code Integer} that controls - * the action taken when unsent data is queued on the socket and a method - * to close the socket is invoked. If the value of the socket option is zero - * or greater, then it represents a timeout value, in seconds, known as the - * <em>linger interval</em>. The linger interval is the timeout for the - * {@code close} method to block while the operating system attempts to - * transmit the unsent data or it decides that it is unable to transmit the - * data. If the value of the socket option is less than zero then the option - * is disabled. In that case the {@code close} method does not wait until - * unsent data is transmitted; if possible the operating system will transmit - * any unsent data before the connection is closed. - * - * <p> This socket option is intended for use with sockets that are configured - * in {@link java.nio.channels.SelectableChannel#isBlocking() blocking} mode - * only. The behavior of the {@code close} method when this option is - * enabled on a non-blocking socket is not defined. - * - * <p> The initial value of this socket option is a negative value, meaning - * that the option is disabled. The option may be enabled, or the linger - * interval changed, at any time. The maximum value of the linger interval - * is system dependent. Setting the linger interval to a value that is - * greater than its maximum value causes the linger interval to be set to - * its maximum value. - * - * @see Socket#setSoLinger - */ - public static final SocketOption<Integer> SO_LINGER = - new StdSocketOption<Integer>("SO_LINGER", Integer.class); - - - // -- IPPROTO_IP -- - - /** - * The Type of Service (ToS) octet in the Internet Protocol (IP) header. - * - * <p> The value of this socket option is an {@code Integer} representing - * the value of the ToS octet in IP packets sent by sockets to an {@link - * StandardProtocolFamily#INET IPv4} socket. The interpretation of the ToS - * octet is network specific and is not defined by this class. Further - * information on the ToS octet can be found in <a - * href="http://www.ietf.org/rfc/rfc1349.txt">RFC 1349</a> and <a - * href="http://www.ietf.org/rfc/rfc2474.txt">RFC 2474</a>. The value - * of the socket option is a <em>hint</em>. An implementation may ignore the - * value, or ignore specific values. - * - * <p> The initial/default value of the TOS field in the ToS octet is - * implementation specific but will typically be {@code 0}. For - * datagram-oriented sockets the option may be configured at any time after - * the socket has been bound. The new value of the octet is used when sending - * subsequent datagrams. It is system dependent whether this option can be - * queried or changed prior to binding the socket. - * - * <p> The behavior of this socket option on a stream-oriented socket, or an - * {@link StandardProtocolFamily#INET6 IPv6} socket, is not defined in this - * release. - * - * @see DatagramSocket#setTrafficClass - */ - public static final SocketOption<Integer> IP_TOS = - new StdSocketOption<Integer>("IP_TOS", Integer.class); - - /** - * The network interface for Internet Protocol (IP) multicast datagrams. - * - * <p> The value of this socket option is a {@link NetworkInterface} that - * represents the outgoing interface for multicast datagrams sent by the - * datagram-oriented socket. For {@link StandardProtocolFamily#INET6 IPv6} - * sockets then it is system dependent whether setting this option also - * sets the outgoing interface for multlicast datagrams sent to IPv4 - * addresses. - * - * <p> The initial/default value of this socket option may be {@code null} - * to indicate that outgoing interface will be selected by the operating - * system, typically based on the network routing tables. An implementation - * allows this socket option to be set after the socket is bound. Whether - * the socket option can be queried or changed prior to binding the socket - * is system dependent. - * - * @see java.nio.channels.MulticastChannel - * @see MulticastSocket#setInterface - */ - public static final SocketOption<NetworkInterface> IP_MULTICAST_IF = - new StdSocketOption<NetworkInterface>("IP_MULTICAST_IF", NetworkInterface.class); - - /** - * The <em>time-to-live</em> for Internet Protocol (IP) multicast datagrams. - * - * <p> The value of this socket option is an {@code Integer} in the range - * <tt>0 <= value <= 255</tt>. It is used to control - * the scope of multicast datagrams sent by the datagram-oriented socket. - * In the case of an {@link StandardProtocolFamily#INET IPv4} socket - * the option is the time-to-live (TTL) on multicast datagrams sent by the - * socket. Datagrams with a TTL of zero are not transmitted on the network - * but may be delivered locally. In the case of an {@link - * StandardProtocolFamily#INET6 IPv6} socket the option is the - * <em>hop limit</em> which is number of <em>hops</em> that the datagram can - * pass through before expiring on the network. For IPv6 sockets it is - * system dependent whether the option also sets the <em>time-to-live</em> - * on multicast datagrams sent to IPv4 addresses. - * - * <p> The initial/default value of the time-to-live setting is typically - * {@code 1}. An implementation allows this socket option to be set after - * the socket is bound. Whether the socket option can be queried or changed - * prior to binding the socket is system dependent. - * - * @see java.nio.channels.MulticastChannel - * @see MulticastSocket#setTimeToLive - */ - public static final SocketOption<Integer> IP_MULTICAST_TTL = - new StdSocketOption<Integer>("IP_MULTICAST_TTL", Integer.class); - - /** - * Loopback for Internet Protocol (IP) multicast datagrams. - * - * <p> The value of this socket option is a {@code Boolean} that controls - * the <em>loopback</em> of multicast datagrams. The value of the socket - * option represents if the option is enabled or disabled. - * - * <p> The exact semantics of this socket options are system dependent. - * In particular, it is system dependent whether the loopback applies to - * multicast datagrams sent from the socket or received by the socket. - * For {@link StandardProtocolFamily#INET6 IPv6} sockets then it is - * system dependent whether the option also applies to multicast datagrams - * sent to IPv4 addresses. - * - * <p> The initial/default value of this socket option is {@code TRUE}. An - * implementation allows this socket option to be set after the socket is - * bound. Whether the socket option can be queried or changed prior to - * binding the socket is system dependent. - * - * @see java.nio.channels.MulticastChannel - * @see MulticastSocket#setLoopbackMode - */ - public static final SocketOption<Boolean> IP_MULTICAST_LOOP = - new StdSocketOption<Boolean>("IP_MULTICAST_LOOP", Boolean.class); - - - // -- IPPROTO_TCP -- - - /** - * Disable the Nagle algorithm. - * - * <p> The value of this socket option is a {@code Boolean} that represents - * whether the option is enabled or disabled. The socket option is specific to - * stream-oriented sockets using the TCP/IP protocol. TCP/IP uses an algorithm - * known as <em>The Nagle Algorithm</em> to coalesce short segments and - * improve network efficiency. - * - * <p> The default value of this socket option is {@code FALSE}. The - * socket option should only be enabled in cases where it is known that the - * coalescing impacts performance. The socket option may be enabled at any - * time. In other words, the Nagle Algorithm can be disabled. Once the option - * is enabled, it is system dependent whether it can be subsequently - * disabled. If it cannot, then invoking the {@code setOption} method to - * disable the option has no effect. - * - * @see <a href="http://www.ietf.org/rfc/rfc1122.txt">RFC 1122: - * Requirements for Internet Hosts -- Communication Layers</a> - * @see Socket#setTcpNoDelay - */ - public static final SocketOption<Boolean> TCP_NODELAY = - new StdSocketOption<Boolean>("TCP_NODELAY", Boolean.class); - - - private static class StdSocketOption<T> implements SocketOption<T> { - private final String name; - private final Class<T> type; - StdSocketOption(String name, Class<T> type) { - this.name = name; - this.type = type; - } - public String name() { return name; } - public Class<T> type() { return type; } - public String toString() { return name; } - } -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousByteChannel.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousByteChannel.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.channels; +package java.nio.channels; import java.nio.ByteBuffer; import java.util.concurrent.Future;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousChannel.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousChannel.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.channels; +package java.nio.channels; import java.io.IOException; import java.nio.channels.Channel;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousChannelGroup.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousChannelGroup.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,12 +24,12 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.channels; +package java.nio.channels; import java.io.IOException; import java.util.concurrent.*; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider; +import java.nio.channels.spi.AsynchronousChannelProvider; /** * A grouping of asynchronous channels for the purpose of resource sharing.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousDatagramChannel.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousDatagramChannel.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.channels; +package java.nio.channels; import java.util.concurrent.TimeUnit; import java.util.concurrent.Future; @@ -32,10 +32,10 @@ import java.net.SocketAddress; import java.nio.ByteBuffer; -import org.classpath.icedtea.java.net.ProtocolFamily; -import org.classpath.icedtea.java.net.SocketOption; +import java.net.ProtocolFamily; +import java.net.SocketOption; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider; +import java.nio.channels.spi.AsynchronousChannelProvider; /** * An asynchronous channel for datagram-oriented sockets.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.channels; +package java.nio.channels; import java.nio.ByteBuffer; import java.io.IOException; @@ -34,10 +34,10 @@ import java.util.HashSet; import java.util.Collections; -import org.classpath.icedtea.java.nio.file.OpenOption; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; -import org.classpath.icedtea.java.nio.file.spi.FileSystemProvider; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.attribute.FileAttribute; +import java.nio.file.spi.FileSystemProvider; /** * An asynchronous channel for reading, writing, and manipulating a file.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,14 +24,14 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.channels; +package java.nio.channels; import java.net.SocketAddress; import java.util.concurrent.Future; import java.io.IOException; -import org.classpath.icedtea.java.net.SocketOption; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider; +import java.net.SocketOption; +import java.nio.channels.spi.AsynchronousChannelProvider; /** * An asynchronous channel for stream-oriented listening sockets.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.channels; +package java.nio.channels; import java.util.concurrent.TimeUnit; import java.util.concurrent.Future; @@ -32,8 +32,8 @@ import java.net.SocketAddress; import java.nio.ByteBuffer; -import org.classpath.icedtea.java.net.SocketOption; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider; +import java.net.SocketOption; +import java.nio.channels.spi.AsynchronousChannelProvider; /** * An asynchronous channel for stream-oriented connecting sockets.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/Channels.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,214 +0,0 @@ -/* - * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.nio.channels; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.UnsupportedCharsetException; -import java.nio.channels.spi.AbstractInterruptibleChannel; -import java.util.concurrent.ExecutionException; -import sun.nio.ch.ChannelInputStream; -import sun.nio.cs.StreamDecoder; -import sun.nio.cs.StreamEncoder; - - -/** - * Utility methods for channels and streams. - * - * <p> This class defines static methods that support the interoperation of the - * stream classes of the <tt>{@link java.io}</tt> package with the channel - * classes of this package. </p> - * - * - * @author Mark Reinhold - * @author Mike McCloskey - * @author JSR-51 Expert Group - * @since 1.4 - */ - -public final class Channels { - - private Channels() { } // No instantiation - - /** - * {@note new} - * Constructs a stream that reads bytes from the given channel. - * - * <p> The stream will not be buffered, and it will not support the {@link - * InputStream#mark mark} or {@link InputStream#reset reset} methods. The - * stream will be safe for access by multiple concurrent threads. Closing - * the stream will in turn cause the channel to be closed. </p> - * - * @param ch - * The channel from which bytes will be read - * - * @return A new input stream - * - * @since 1.7 - */ - public static InputStream newInputStream(final AsynchronousByteChannel ch) { - return new InputStream() { - - private ByteBuffer bb = null; - private byte[] bs = null; // Invoker's previous array - private byte[] b1 = null; - - - public synchronized int read() throws IOException { - if (b1 == null) - b1 = new byte[1]; - int n = this.read(b1); - if (n == 1) - return b1[0] & 0xff; - return -1; - } - - - public synchronized int read(byte[] bs, int off, int len) - throws IOException - { - if ((off < 0) || (off > bs.length) || (len < 0) || - ((off + len) > bs.length) || ((off + len) < 0)) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) - return 0; - - ByteBuffer bb = ((this.bs == bs) - ? this.bb - : ByteBuffer.wrap(bs)); - bb.position(off); - bb.limit(Math.min(off + len, bb.capacity())); - this.bb = bb; - this.bs = bs; - - boolean interrupted = false; - try { - for (;;) { - try { - return ch.read(bb).get(); - } catch (ExecutionException ee) { - throw new IOException(ee.getCause()); - } catch (InterruptedException ie) { - interrupted = true; - } - } - } finally { - if (interrupted) - Thread.currentThread().interrupt(); - } - } - - - public void close() throws IOException { - ch.close(); - } - }; - } - - /** - * {@note new} - * Constructs a stream that writes bytes to the given channel. - * - * <p> The stream will not be buffered. The stream will be safe for access - * by multiple concurrent threads. Closing the stream will in turn cause - * the channel to be closed. </p> - * - * @param ch - * The channel to which bytes will be written - * - * @return A new output stream - * - * @since 1.7 - */ - public static OutputStream newOutputStream(final AsynchronousByteChannel ch) { - return new OutputStream() { - - private ByteBuffer bb = null; - private byte[] bs = null; // Invoker's previous array - private byte[] b1 = null; - - - public synchronized void write(int b) throws IOException { - if (b1 == null) - b1 = new byte[1]; - b1[0] = (byte)b; - this.write(b1); - } - - - public synchronized void write(byte[] bs, int off, int len) - throws IOException - { - if ((off < 0) || (off > bs.length) || (len < 0) || - ((off + len) > bs.length) || ((off + len) < 0)) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) { - return; - } - ByteBuffer bb = ((this.bs == bs) - ? this.bb - : ByteBuffer.wrap(bs)); - bb.limit(Math.min(off + len, bb.capacity())); - bb.position(off); - this.bb = bb; - this.bs = bs; - - boolean interrupted = false; - try { - while (bb.remaining() > 0) { - try { - ch.write(bb).get(); - } catch (ExecutionException ee) { - throw new IOException(ee.getCause()); - } catch (InterruptedException ie) { - interrupted = true; - } - } - } finally { - if (interrupted) - Thread.currentThread().interrupt(); - } - } - - - public void close() throws IOException { - ch.close(); - } - }; - } - - -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/CompletionHandler.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/CompletionHandler.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.channels; +package java.nio.channels; /** * A handler for consuming the result of an asynchronous I/O operation.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/DatagramChannel.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,223 +0,0 @@ -/* - * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.nio.channels; - -import java.io.IOException; -import java.net.DatagramSocket; -import java.net.SocketAddress; -import java.nio.ByteBuffer; - -import org.classpath.icedtea.java.net.ProtocolFamily; -import org.classpath.icedtea.java.net.SocketOption; - -import org.classpath.icedtea.java.nio.channels.spi.SelectorProvider; - -/** - * A selectable channel for datagram-oriented sockets. - * - * <p> {@note revised} A datagram channel is created by invoking one of the {@link #open open} methods - * of this class. It is not possible to create a channel for an arbitrary, - * pre-existing datagram socket. A newly-created datagram channel is open but not - * connected. A datagram channel need not be connected in order for the {@link #send - * send} and {@link #receive receive} methods to be used. A datagram channel may be - * connected, by invoking its {@link #connect connect} method, in order to - * avoid the overhead of the security checks are otherwise performed as part of - * every send and receive operation. A datagram channel must be connected in - * order to use the {@link #read(java.nio.ByteBuffer) read} and {@link - * #write(java.nio.ByteBuffer) write} methods, since those methods do not - * accept or return socket addresses. - * - * <p> Once connected, a datagram channel remains connected until it is - * disconnected or closed. Whether or not a datagram channel is connected may - * be determined by invoking its {@link #isConnected isConnected} method. - * - * <p> Socket options are configured using the {@link #setOption(SocketOption,Object) - * setOption} method. A datagram channel to an Internet Protocol socket supports - * the following options: - * <blockquote> - * <table border> - * <tr> - * <th>Option Name</th> - * <th>Description</th> - * </tr> - * <tr> - * <td> {@link java.net.StandardSocketOption#SO_SNDBUF SO_SNDBUF} </td> - * <td> The size of the socket send buffer </td> - * </tr> - * <tr> - * <td> {@link java.net.StandardSocketOption#SO_RCVBUF SO_RCVBUF} </td> - * <td> The size of the socket receive buffer </td> - * </tr> - * <tr> - * <td> {@link java.net.StandardSocketOption#SO_REUSEADDR SO_REUSEADDR} </td> - * <td> Re-use address </td> - * </tr> - * <tr> - * <td> {@link java.net.StandardSocketOption#SO_BROADCAST SO_BROADCAST} </td> - * <td> Allow transmission of broadcast datagrams </td> - * </tr> - * <tr> - * <td> {@link java.net.StandardSocketOption#IP_TOS IP_TOS} </td> - * <td> The Type of Service (ToS) octet in the Internet Protocol (IP) header </td> - * </tr> - * <tr> - * <td> {@link java.net.StandardSocketOption#IP_MULTICAST_IF IP_MULTICAST_IF} </td> - * <td> The network interface for Internet Protocol (IP) multicast datagrams </td> - * </tr> - * <tr> - * <td> {@link java.net.StandardSocketOption#IP_MULTICAST_TTL - * IP_MULTICAST_TTL} </td> - * <td> The <em>time-to-live</em> for Internet Protocol (IP) multicast - * datagrams </td> - * </tr> - * <tr> - * <td> {@link java.net.StandardSocketOption#IP_MULTICAST_LOOP - * IP_MULTICAST_LOOP} </td> - * <td> Loopback for Internet Protocol (IP) multicast datagrams </td> - * </tr> - * </table> - * </blockquote> - * Additional (implementation specific) options may also be supported. - * - * <p> Datagram channels are safe for use by multiple concurrent threads. They - * support concurrent reading and writing, though at most one thread may be - * reading and at most one thread may be writing at any given time. </p> - * - * @author Mark Reinhold - * @author JSR-51 Expert Group - * @since 1.4 - * @updated 1.7 - */ - -public abstract class DatagramChannel - extends java.nio.channels.DatagramChannel - implements MulticastChannel -{ - - /** - * Initializes a new instance of this class. - */ - protected DatagramChannel(SelectorProvider provider) { - super(provider); - } - - /** - * Opens a datagram channel. - * - * <p> The new channel is created by invoking the {@link - * java.nio.channels.spi.SelectorProvider#openDatagramChannel() - * openDatagramChannel} method of the system-wide default {@link - * java.nio.channels.spi.SelectorProvider} object. The channel will not be - * connected. </p> - * - * @return A new datagram channel - * - * @throws IOException - * If an I/O error occurs - */ - public static DatagramChannel open() throws IOException { - return SelectorProvider.provider().openDatagramChannel(); - } - - /** - * Opens a datagram channel. - * - * <p> The {@code family} parameter is used to specify the {@link - * ProtocolFamily}. If the datagram channel is to be used for IP multicasing - * then this should correspond to the address type of the multicast groups - * that this channel will join. - * - * <p> The new channel is created by invoking the {@link - * java.nio.channels.spi.SelectorProvider#openDatagramChannel(ProtocolFamily) - * openDatagramChannel} method of the system-wide default {@link - * java.nio.channels.spi.SelectorProvider} object. The channel will not be - * connected. - * - * @param family - * The protocol family - * - * @return A new datagram channel - * - * @throws UnsupportedOperationException - * If the specified protocol family is not supported. For example, - * suppose the parameter is specified as {@link - * java.net.StandardProtocolFamily#INET6 StandardProtocolFamily.INET6} - * but IPv6 is not enabled on the platform. - * @throws IOException - * If an I/O error occurs - * - * @since 1.7 - */ - public static DatagramChannel open(ProtocolFamily family) throws IOException { - return SelectorProvider.provider().openDatagramChannel(family); - } - - - // -- Socket-specific operations -- - - /** - * @throws AlreadyBoundException {@inheritDoc} - * @throws UnsupportedAddressTypeException {@inheritDoc} - * @throws ClosedChannelException {@inheritDoc} - * @throws IOException {@inheritDoc} - * @throws SecurityException - * If a security manager has been installed and its {@link - * SecurityManager#checkListen checkListen} method denies the - * operation - * - * @since 1.7 - */ - public abstract DatagramChannel bind(SocketAddress local) - throws IOException; - - /** - * @throws IllegalArgumentException {@inheritDoc} - * @throws ClosedChannelException {@inheritDoc} - * @throws IOException {@inheritDoc} - * - * @since 1.7 - */ - public abstract <T> DatagramChannel setOption(SocketOption<T> name, T value) - throws IOException; - - /** - * {@note new} - * Returns the remote address to which this channel's socket is connected. - * - * @return The remote address; {@code null} if the channel's socket is not - * connected - * - * @throws ClosedChannelException - * If the channel is closed - * @throws IOException - * If an I/O error occurs - * - * @since 1.7 - */ - public abstract SocketAddress getRemoteAddress() throws IOException; - -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/FileChannel.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,404 +0,0 @@ -/* - * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.nio.channels; - -import java.io.*; -import java.nio.ByteBuffer; -import java.nio.MappedByteBuffer; -import java.nio.channels.GatheringByteChannel; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.ScatteringByteChannel; -import java.nio.channels.WritableByteChannel; -import java.nio.channels.spi.AbstractInterruptibleChannel; -import java.util.Set; -import java.util.HashSet; -import java.util.Collections; - -import org.classpath.icedtea.java.nio.file.OpenOption; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; -import org.classpath.icedtea.java.nio.file.spi.FileSystemProvider; - -/** - * A channel for reading, writing, mapping, and manipulating a file. - * - * <p> {@note revised} - * A file channel is a {@link SeekableByteChannel} that is connected to - * a file. It has a current <i>position</i> within its file which can - * be both {@link #position() <i>queried</i>} and {@link #position(long) - * <i>modified</i>}. The file itself contains a variable-length sequence - * of bytes that can be read and written and whose current {@link #size - * <i>size</i>} can be queried. The size of the file increases - * when bytes are written beyond its current size; the size of the file - * decreases when it is {@link #truncate </code><i>truncated</i><code>}. The - * file may also have some associated <i>metadata</i> such as access - * permissions, content type, and last-modification time; this class does not - * define methods for metadata access. - * - * <p> In addition to the familiar read, write, and close operations of byte - * channels, this class defines the following file-specific operations: </p> - * - * <ul> - * - * <li><p> Bytes may be {@link #read(ByteBuffer, long) read} or - * {@link #write(ByteBuffer, long) <i>written</i>} at an absolute - * position in a file in a way that does not affect the channel's current - * position. </p></li> - * - * <li><p> A region of a file may be {@link #map <i>mapped</i>} - * directly into memory; for large files this is often much more efficient - * than invoking the usual <tt>read</tt> or <tt>write</tt> methods. - * </p></li> - * - * <li><p> Updates made to a file may be {@link #force <i>forced - * out</i>} to the underlying storage device, ensuring that data are not - * lost in the event of a system crash. </p></li> - * - * <li><p> Bytes can be transferred from a file {@link #transferTo <i>to - * some other channel</i>}, and {@link #transferFrom <i>vice - * versa</i>}, in a way that can be optimized by many operating systems - * into a very fast transfer directly to or from the filesystem cache. - * </p></li> - * - * <li><p> A region of a file may be {@link FileLock <i>locked</i>} - * against access by other programs. </p></li> - * - * </ul> - * - * <p> File channels are safe for use by multiple concurrent threads. The - * {@link Channel#close close} method may be invoked at any time, as specified - * by the {@link Channel} interface. Only one operation that involves the - * channel's position or can change its file's size may be in progress at any - * given time; attempts to initiate a second such operation while the first is - * still in progress will block until the first operation completes. Other - * operations, in particular those that take an explicit position, may proceed - * concurrently; whether they in fact do so is dependent upon the underlying - * implementation and is therefore unspecified. - * - * <p> The view of a file provided by an instance of this class is guaranteed - * to be consistent with other views of the same file provided by other - * instances in the same program. The view provided by an instance of this - * class may or may not, however, be consistent with the views seen by other - * concurrently-running programs due to caching performed by the underlying - * operating system and delays induced by 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 or on some other - * machine. The exact nature of any such inconsistencies are system-dependent - * and are therefore unspecified. - * - * <p> A file channel is created by invoking one of the {@link #open open} - * methods defined by this class. A file channel can also be obtained from an - * existing {@link java.io.FileInputStream#getChannel FileInputStream}, {@link - * java.io.FileOutputStream#getChannel FileOutputStream}, or {@link - * java.io.RandomAccessFile#getChannel RandomAccessFile} object by invoking - * that object's <tt>getChannel</tt> method, which returns a file channel that - * is connected to the same underlying file. Where the file channel is obtained - * from an existing stream or random access file then the state of the file - * channel is intimately connected to that of the object whose <tt>getChannel</tt> - * method returned the channel. Changing the channel's position, whether - * explicitly or by reading or writing bytes, will change the file position of - * the originating object, and vice versa. Changing the file's length via the - * file channel will change the length seen via the originating object, and vice - * versa. Changing the file's content by writing bytes will change the content - * seen by the originating object, and vice versa. - * - * <a name="open-mode"></a> <p> At various points this class specifies that an - * instance that is "open for reading," "open for writing," or "open for - * reading and writing" is required. A channel obtained via the {@link - * java.io.FileInputStream#getChannel getChannel} method of a {@link - * java.io.FileInputStream} instance will be open for reading. A channel - * obtained via the {@link java.io.FileOutputStream#getChannel getChannel} - * method of a {@link java.io.FileOutputStream} instance will be open for - * writing. Finally, a channel obtained via the {@link - * java.io.RandomAccessFile#getChannel getChannel} method of a {@link - * java.io.RandomAccessFile} instance will be open for reading if the instance - * was created with mode <tt>"r"</tt> and will be open for reading and writing - * if the instance was created with mode <tt>"rw"</tt>. - * - * <a name="append-mode"></a><p> A file channel that is open for writing may be in - * <i>append mode</i>, for example if it was obtained from a file-output stream - * that was created by invoking the {@link - * java.io.FileOutputStream#FileOutputStream(java.io.File,boolean) - * FileOutputStream(File,boolean)} constructor and passing <tt>true</tt> for - * the second parameter. In this mode each invocation of a relative write - * operation first advances the position to the end of the file and then writes - * the requested data. Whether the advancement of the position and the writing - * of the data are done in a single atomic operation is system-dependent and - * therefore unspecified. - * - * @see java.io.FileInputStream#getChannel() - * @see java.io.FileOutputStream#getChannel() - * @see java.io.RandomAccessFile#getChannel() - * - * @author Mark Reinhold - * @author Mike McCloskey - * @author JSR-51 Expert Group - * @since 1.4 - * @updated 1.7 - */ - -public abstract class FileChannel - extends java.nio.channels.FileChannel - implements SeekableByteChannel -{ - /** - * Initializes a new instance of this class. - */ - protected FileChannel() { } - - /** - * {@note new} - * Opens or creates a file, returning a file channel to access the file. - * - * <p> The {@code options} parameter determines how the file is opened. - * The {@link StandardOpenOption#READ READ} and {@link StandardOpenOption#WRITE - * WRITE} options determine if the file should be opened for reading and/or - * writing. If neither option (or the {@link StandardOpenOption#APPEND APPEND} - * option) is contained in the array then the file is opened for reading. - * By default reading or writing commences at the beginning of the file. - * - * <p> In the addition to {@code READ} and {@code WRITE}, the following - * options may be present: - * - * <table border=1 cellpadding=5 summary=""> - * <tr> <th>Option</th> <th>Description</th> </tr> - * <tr> - * <td> {@link StandardOpenOption#APPEND APPEND} </td> - * <td> If this option is present then the file is opened for writing and - * each invocation of the channel's {@code write} method first advances - * the position to the end of the file and then writes the requested - * data. Whether the advancement of the position and the writing of the - * data are done in a single atomic operation is system-dependent and - * therefore unspecified. This option may not be used in conjunction - * with the {@code READ} or {@code TRUNCATE_EXISTING} options. </td> - * </tr> - * <tr> - * <td> {@link StandardOpenOption#TRUNCATE_EXISTING TRUNCATE_EXISTING} </td> - * <td> If this option is present then the existing file is truncated to - * a size of 0 bytes. This option is ignored when the file is opened only - * for reading. </td> - * </tr> - * <tr> - * <td> {@link StandardOpenOption#CREATE_NEW CREATE_NEW} </td> - * <td> If this option is present then a new file is created, failing if - * the file already exists. When creating a file the check for the - * existence of the file and the creation of the file if it does not exist - * is atomic with respect to other file system operations. This option is - * ignored when the file is opened only for reading. </td> - * </tr> - * <tr> - * <td > {@link StandardOpenOption#CREATE CREATE} </td> - * <td> If this option is present then an existing file is opened if it - * exists, otherwise a new file is created. When creating a file the check - * for the existence of the file and the creation of the file if it does - * not exist is atomic with respect to other file system operations. This - * option is ignored if the {@code CREATE_NEW} option is also present or - * the file is opened only for reading. </td> - * </tr> - * <tr> - * <td > {@link StandardOpenOption#DELETE_ON_CLOSE DELETE_ON_CLOSE} </td> - * <td> When this option is present then the implementation makes a - * <em>best effort</em> attempt to delete the file when closed by the - * the {@link #close close} method. If the {@code close} method is not - * invoked then a <em>best effort</em> attempt is made to delete the file - * when the Java virtual machine terminates. </td> - * </tr> - * <tr> - * <td>{@link StandardOpenOption#SPARSE SPARSE} </td> - * <td> When creating a new file this option is a <em>hint</em> that the - * new file will be sparse. This option is ignored when not creating - * a new file. </td> - * </tr> - * <tr> - * <td> {@link StandardOpenOption#SYNC SYNC} </td> - * <td> Requires that every update to the file's content or metadata be - * written synchronously to the underlying storage device. (see <a - * href="../file/package-summary.html#integrity"> Synchronized I/O file - * integrity</a>). </td> - * <tr> - * <tr> - * <td> {@link StandardOpenOption#DSYNC DSYNC} </td> - * <td> Requires that every update to the file's content be written - * synchronously to the underlying storage device. (see <a - * href="../file/package-summary.html#integrity"> Synchronized I/O file - * integrity</a>). </td> - * </tr> - * </table> - * - * <p> An implementation may also support additional options. - * - * <p> The {@code attrs} parameter is an optional array of file {@link - * FileAttribute file-attributes} to set atomically when creating the file. - * - * <p> The new channel is created by invoking the {@link - * FileSystemProvider#newFileChannel newFileChannel} method on the - * provider that created the {@code Path}. - * - * @param file - * The path of 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 file channel - * - * @throws IllegalArgumentException - * If the set contains an invalid combination of options - * @throws UnsupportedOperationException - * If the {@code file} is associated with a provider that does not - * support creating file channels, or an unsupported open option is - * specified, or the array contains an attribute that cannot be set - * atomically when creating the file - * @throws IOException - * If an I/O error occurs - * @throws SecurityException - * If a security manager is installed and it denies an - * unspecified permission required by the implementation. - * In the case of the default provider, the {@link - * SecurityManager#checkRead(String)} method is invoked to check - * read access if the file is opened for reading. The {@link - * SecurityManager#checkWrite(String)} method is invoked to check - * write access if the file is opened for writing - * - * @since 1.7 - */ - public static FileChannel open(Path file, - Set<? extends OpenOption> options, - FileAttribute<?>... attrs) - throws IOException - { - FileSystemProvider provider = file.getFileSystem().provider(); - return provider.newFileChannel(file, options, attrs); - } - - private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0]; - - /** - * {@note new} - * Opens or creates a file, returning a file channel to access the file. - * - * <p> An invocation of this method behaves in exactly the same way as the - * invocation - * <pre> - * fc.{@link #open(Path,Set,FileAttribute[]) open}(file, options, new FileAttribute<?>[0]); - * </pre> - * - * @param file - * The path of the file to open or create - * @param options - * Options specifying how the file is opened - * - * @return A new file channel - * - * @throws IllegalArgumentException - * If the set contains an invalid combination of options - * @throws UnsupportedOperationException - * If the {@code file} is associated with a provider that does not - * support creating file channels, or an unsupported open option is - * specified - * @throws IOException - * If an I/O error occurs - * @throws SecurityException - * If a security manager is installed and it denies an - * unspecified permission required by the implementation. - * In the case of the default provider, the {@link - * SecurityManager#checkRead(String)} method is invoked to check - * read access if the file is opened for reading. The {@link - * SecurityManager#checkWrite(String)} method is invoked to check - * write access if the file is opened for writing - * - * @since 1.7 - */ - public static FileChannel open(Path file, OpenOption... options) - throws IOException - { - Set<OpenOption> set = new HashSet<OpenOption>(options.length); - Collections.addAll(set, options); - return open(file, set, NO_ATTRIBUTES); - } - - /** - * Sets this channel's file position. - * - * <p> Setting the position to a value that is greater than the file's - * current size is legal but does not change the size of the file. A later - * attempt to read bytes at such a position will immediately return an - * end-of-file indication. A later attempt to write bytes at such a - * position will cause the file to be grown to accommodate the new bytes; - * the values of any bytes between the previous end-of-file and the - * newly-written bytes are unspecified. </p> - * - * @param newPosition - * The new position, a non-negative integer counting - * the number of bytes from the beginning of the file - * - * @return This file channel - * - * @throws ClosedChannelException - * If this channel is closed - * - * @throws IllegalArgumentException - * If the new position is negative - * - * @throws IOException - * If some other I/O error occurs - */ - public abstract FileChannel positionSBC(long newPosition) throws IOException; - - /** - * Truncates this channel's file to the given size. - * - * <p> If the given size is less than the file's current size then the file - * is truncated, discarding any bytes beyond the new end of the file. If - * the given size is greater than or equal to the file's current size then - * the file is not modified. In either case, if this channel's file - * position is greater than the given size then it is set to that size. - * </p> - * - * @param size - * The new size, a non-negative byte count - * - * @return This file channel - * - * @throws NonWritableChannelException - * If this channel was not opened for writing - * - * @throws ClosedChannelException - * If this channel is closed - * - * @throws IllegalArgumentException - * If the new size is negative - * - * @throws IOException - * If some other I/O error occurs - */ - public abstract FileChannel truncateSBC(long size) throws IOException; - - -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/FileLock.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,321 +0,0 @@ -/* - * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.nio.channels; - -import java.io.IOException; - -import java.nio.channels.Channel; - -/** - * A token representing a lock on a region of a file. - * - * <p> A file-lock object is created each time a lock is acquired on a file via - * one of the {@link FileChannel#lock(long,long,boolean) lock} or {@link - * FileChannel#tryLock(long,long,boolean) tryLock} methods of the - * {@link FileChannel} class, or the {@link - * AsynchronousFileChannel#lock(long,long,boolean,Object,CompletionHandler) lock} - * or {@link AsynchronousFileChannel#tryLock(long,long,boolean) tryLock} - * methods of the {@link AsynchronousFileChannel} class. - * - * <p> A file-lock object is initially valid. It remains valid until the lock - * is released by invoking the {@link #release release} method, by closing the - * channel that was used to acquire it, or by the termination of the Java - * virtual machine, whichever comes first. The validity of a lock may be - * tested by invoking its {@link #isValid isValid} method. - * - * <p> A file lock is either <i>exclusive</i> or <i>shared</i>. A shared lock - * prevents other concurrently-running programs from acquiring an overlapping - * exclusive lock, but does allow them to acquire overlapping shared locks. An - * exclusive lock prevents other programs from acquiring an overlapping lock of - * either type. Once it is released, a lock has no further effect on the locks - * that may be acquired by other programs. - * - * <p> Whether a lock is exclusive or shared may be determined by invoking its - * {@link #isShared isShared} method. Some platforms do not support shared - * locks, in which case a request for a shared lock is automatically converted - * into a request for an exclusive lock. - * - * <p> The locks held on a particular file by a single Java virtual machine do - * not overlap. The {@link #overlaps overlaps} method may be used to test - * whether a candidate lock range overlaps an existing lock. - * - * <p> A file-lock object records the file channel upon whose file the lock is - * held, the type and validity of the lock, and the position and size of the - * locked region. Only the validity of a lock is subject to change over time; - * all other aspects of a lock's state are immutable. - * - * <p> File locks are held on behalf of the entire Java virtual machine. - * They are not suitable for controlling access to a file by multiple - * threads within the same virtual machine. - * - * <p> File-lock objects are safe for use by multiple concurrent threads. - * - * - * <a name="pdep"><h4> Platform dependencies </h4></a> - * - * <p> This file-locking API is intended to map directly to the native locking - * facility of the underlying operating system. Thus the locks held on a file - * should be visible to all programs that have access to the file, regardless - * of the language in which those programs are written. - * - * <p> Whether or not a lock actually prevents another program from accessing - * the content of the locked region is system-dependent and therefore - * unspecified. The native file-locking facilities of some systems are merely - * <i>advisory</i>, meaning that programs must cooperatively observe a known - * locking protocol in order to guarantee data integrity. On other systems - * native file locks are <i>mandatory</i>, meaning that if one program locks a - * region of a file then other programs are actually prevented from accessing - * that region in a way that would violate the lock. On yet other systems, - * whether native file locks are advisory or mandatory is configurable on a - * per-file basis. To ensure consistent and correct behavior across platforms, - * it is strongly recommended that the locks provided by this API be used as if - * they were advisory locks. - * - * <p> On some systems, acquiring a mandatory lock on a region of a file - * prevents that region from being {@link java.nio.channels.FileChannel#map - * <i>mapped into memory</i>}, and vice versa. Programs that combine - * locking and mapping should be prepared for this combination to fail. - * - * <p> On some systems, closing a channel releases all locks held by the Java - * virtual machine on the underlying file regardless of whether the locks were - * acquired via that channel or via another channel open on the same file. It - * is strongly recommended that, within a program, a unique channel be used to - * acquire all locks on any given file. - * - * <p> Some network filesystems permit file locking to be used with - * memory-mapped files only when the locked regions are page-aligned and a - * whole multiple of the underlying hardware's page size. Some network - * filesystems do not implement file locks on regions that extend past a - * certain position, often 2<sup>30</sup> or 2<sup>31</sup>. In general, great - * care should be taken when locking files that reside on network filesystems. - * - * - * @author Mark Reinhold - * @author JSR-51 Expert Group - * @since 1.4 - * @updated 1.7 - */ - -public abstract class FileLock { - - private final Channel channel; - private final long position; - private final long size; - private final boolean shared; - - /** - * Initializes a new instance of this class. </p> - * - * @param channel - * The file channel upon whose file this lock is held - * - * @param position - * The position within the file at which the locked region starts; - * must be non-negative - * - * @param size - * The size of the locked region; must be non-negative, and the sum - * <tt>position</tt> + <tt>size</tt> must be non-negative - * - * @param shared - * <tt>true</tt> if this lock is shared, - * <tt>false</tt> if it is exclusive - * - * @throws IllegalArgumentException - * If the preconditions on the parameters do not hold - */ - protected FileLock(FileChannel channel, - long position, long size, boolean shared) - { - if (position < 0) - throw new IllegalArgumentException("Negative position"); - if (size < 0) - throw new IllegalArgumentException("Negative size"); - if (position + size < 0) - throw new IllegalArgumentException("Negative position + size"); - this.channel = channel; - this.position = position; - this.size = size; - this.shared = shared; - } - - /** - * {@note new} Initializes a new instance of this class. - * - * @param channel - * The channel upon whose file this lock is held - * - * @param position - * The position within the file at which the locked region starts; - * must be non-negative - * - * @param size - * The size of the locked region; must be non-negative, and the sum - * <tt>position</tt> + <tt>size</tt> must be non-negative - * - * @param shared - * <tt>true</tt> if this lock is shared, - * <tt>false</tt> if it is exclusive - * - * @throws IllegalArgumentException - * If the preconditions on the parameters do not hold - * - * @since 1.7 - */ - protected FileLock(AsynchronousFileChannel channel, - long position, long size, boolean shared) - { - if (position < 0) - throw new IllegalArgumentException("Negative position"); - if (size < 0) - throw new IllegalArgumentException("Negative size"); - if (position + size < 0) - throw new IllegalArgumentException("Negative position + size"); - this.channel = channel; - this.position = position; - this.size = size; - this.shared = shared; - } - - /** - * {@note revised} - * Returns the file channel upon whose file this lock was acquired. - * - * <p> This method has been superseded by the {@link #acquiredBy acquiredBy} - * method. - * - * @return The file channel, or {@code null} if the file lock was not - * acquired by a file channel. - */ - public final FileChannel channel() { - return (channel instanceof FileChannel) ? (FileChannel)channel : null; - } - - /** - * {@note new} - * Returns the channel upon whose file this lock was acquired. - * - * @return The channel upon whose file this lock was acquired. - * - * @since 1.7 - */ - public Channel acquiredBy() { - return channel; - } - - /** - * Returns the position within the file of the first byte of the locked - * region. - * - * <p> A locked region need not be contained within, or even overlap, the - * actual underlying file, so the value returned by this method may exceed - * the file's current size. </p> - * - * @return The position - */ - public final long position() { - return position; - } - - /** - * Returns the size of the locked region in bytes. - * - * <p> A locked region need not be contained within, or even overlap, the - * actual underlying file, so the value returned by this method may exceed - * the file's current size. </p> - * - * @return The size of the locked region - */ - public final long size() { - return size; - } - - /** - * Tells whether this lock is shared. </p> - * - * @return <tt>true</tt> if lock is shared, - * <tt>false</tt> if it is exclusive - */ - public final boolean isShared() { - return shared; - } - - /** - * Tells whether or not this lock overlaps the given lock range. </p> - * - * @return <tt>true</tt> if, and only if, this lock and the given lock - * range overlap by at least one byte - */ - public final boolean overlaps(long position, long size) { - if (position + size <= this.position) - return false; // That is below this - if (this.position + this.size <= position) - return false; // This is below that - return true; - } - - /** - * Tells whether or not this lock is valid. - * - * <p> A lock object remains valid until it is released or the associated - * file channel is closed, whichever comes first. </p> - * - * @return <tt>true</tt> if, and only if, this lock is valid - */ - public abstract boolean isValid(); - - /** - * Releases this lock. - * - * <p> If this lock object is valid then invoking this method releases the - * lock and renders the object invalid. If this lock object is invalid - * then invoking this method has no effect. </p> - * - * @throws ClosedChannelException - * If the channel that was used to acquire this lock - * is no longer open - * - * @throws IOException - * If an I/O error occurs - */ - public abstract void release() throws IOException; - - /** - * Returns a string describing the range, type, and validity of this lock. - * - * @return A descriptive string - */ - public final String toString() { - return (this.getClass().getName() - + "[" + position - + ":" + size - + " " + (shared ? "shared" : "exclusive") - + " " + (isValid() ? "valid" : "invalid") - + "]"); - } - -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/MembershipKey.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,183 +0,0 @@ -/* - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.nio.channels; - -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.io.IOException; - -/** - * A token representing the membership of an Internet Protocol (IP) multicast - * group. - * - * <p> A membership key may represent a membership to receive all datagrams sent - * to the group, or it may be <em>source-specific</em>, meaning that it - * represents a membership that receives only datagrams from a specific source - * address. Whether or not a membership key is source-specific may be determined - * by invoking its {@link #sourceAddress() sourceAddress} method. - * - * <p> A membership key is valid upon creation and remains valid until the - * membership is dropped by invoking the {@link #drop() drop} method, or - * the channel is closed. The validity of the membership key may be tested - * by invoking its {@link #isValid() isValid} method. - * - * <p> Where a membership key is not source-specific and the underlying operation - * system supports source filtering, then the {@link #block block} and {@link - * #unblock unblock} methods can be used to block or unblock multicast datagrams - * from particular source addresses. - * - * @see MulticastChannel - * - * @since 1.7 - */ -public abstract class MembershipKey { - - /** - * Initializes a new instance of this class. - */ - protected MembershipKey() { - } - - /** - * Tells whether or not this membership is valid. - * - * <p> A multicast group membership is valid upon creation and remains - * valid until the membership is dropped by invoking the {@link #drop() drop} - * method, or the channel is closed. - * - * @return {@code true} if this membership key is valid, {@code false} - * otherwise - */ - public abstract boolean isValid(); - - /** - * Drop membership. - * - * <p> If the membership key represents a membership to receive all datagrams - * then the membership is dropped and the channel will no longer receive any - * datagrams sent to the group. If the membership key is source-specific - * then the channel will no longer receive datagrams sent to the group from - * that source address. - * - * <p> After membership is dropped it may still be possible to receive - * datagrams sent to the group. This can arise when datagrams are waiting to - * be received in the socket's receive buffer. After membership is dropped - * then the channel may {@link MulticastChannel#join join} the group again - * in which case a new membership key is returned. - * - * <p> Upon return, this membership object will be {@link #isValid() invalid}. - * If the multicast group membership is already invalid then invoking this - * method has no effect. Once a multicast group membership is invalid, - * it remains invalid forever. - * - * @throws IOException - * If an I/O error occurs - */ - public abstract void drop() throws IOException; - - /** - * Block multicast datagrams from the given source address. - * - * <p> If this membership key is not source-specific, and the underlying - * operating system supports source filtering, then this method blocks - * multicast datagrams from the given source address. If the given source - * address is already blocked then this method has no effect. - * After a source address is blocked it may still be possible to receive - * datagams from that source. This can arise when datagrams are waiting to - * be received in the socket's receive buffer. - * - * @param source - * The source address to block - * - * @return This membership key - * - * @throws IllegalArgumentException - * If the {@code source} parameter is not a unicast address or - * is not the same address type as the multicast group - * @throws IllegalStateException - * If this membership key is source-specific or is no longer valid - * @throws UnsupportedOperationException - * If the underlying operating system does not support source - * filtering - * @throws IOException - * If an I/O error occurs - */ - public abstract MembershipKey block(InetAddress source) throws IOException; - - /** - * Unblock multicast datagrams from the given source address that was - * previously blocked using the {@link #block(InetAddress) block} method. - * - * @param source - * The source address to unblock - * - * @return This membership key - * - * @throws IllegalStateException - * If the given source address is not currently blocked or the - * membership key is no longer valid - * @throws IOException - * If an I/O error occurs - */ - public abstract MembershipKey unblock(InetAddress source) throws IOException; - - /** - * Returns the channel for which this membership key was created. This - * method will continue to return the channel even after the membership - * becomes {@link #isValid invalid}. - * - * @return the channel - */ - public abstract MulticastChannel channel(); - - /** - * Returns the multicast group for which this membership key was created. - * This method will continue to return the group even after the membership - * becomes {@link #isValid invalid}. - * - * @return the multicast group - */ - public abstract InetAddress group(); - - /** - * Returns the network interface for which this membership key was created. - * This method will continue to return the network interface even after the - * membership becomes {@link #isValid invalid}. - * - * @return the network interface - */ - public abstract NetworkInterface networkInterface(); - - /** - * Returns the source address if this membership key is source-specific, - * or {@code null} if this membership is not source-specific. - * - * @return The source address if this membership key is source-specific, - * otherwise {@code null} - */ - public abstract InetAddress sourceAddress(); -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/MulticastChannel.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,216 +0,0 @@ -/* - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.nio.channels; - -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.io.IOException; - -import org.classpath.icedtea.java.net.ProtocolFamily; // javadoc -import org.classpath.icedtea.java.net.StandardProtocolFamily; // javadoc -import org.classpath.icedtea.java.net.StandardSocketOption; // javadoc - -/** - * A network channel that supports Internet Protocol (IP) multicasting. - * - * <p> IP multicasting is the transmission of IP datagrams to members of - * a <em>group</em> that is zero or more hosts identified by a single destination - * address. - * - * <p> In the case of a channel to an {@link StandardProtocolFamily#INET IPv4} socket, - * the underlying operating system supports <a href="http://www.ietf.org/rfc/rfc2236.txt"> - * <i>RFC 2236: Internet Group Management Protocol, Version 2 (IGMPv2)</i></a>. - * It may optionally support source filtering as specified by <a - * href="http://www.ietf.org/rfc/rfc3376.txt"> <i>RFC 3376: Internet Group - * Management Protocol, Version 3 (IGMPv3)</i></a>. - * For channels to an {@link StandardProtocolFamily#INET6 IPv6} socket, the equivalent - * standards are <a href="http://www.ietf.org/rfc/rfc2710.txt"> <i>RFC 2710: - * Multicast Listener Discovery (MLD) for IPv6</i></a> and <a - * href="http://www.ietf.org/rfc/rfc3810.txt"> <i>RFC 3810: Multicast Listener - * Discovery Version 2 (MLDv2) for IPv6</i></a>. - * - * <p> The {@link #join(InetAddress,NetworkInterface)} method is used to - * join a group and receive all multicast datagrams sent to the group. A channel - * may join several multicast groups and may join the same group on several - * {@link NetworkInterface interfaces}. Membership is dropped by invoking the {@link - * MembershipKey#drop drop} method on the returned {@link MembershipKey}. If the - * underlying platform supports source filtering then the {@link MembershipKey#block - * block} and {@link MembershipKey#unblock unblock} methods can be used to block or - * unblock multicast datagrams from particular source addresses. - * - * <p> The {@link #join(InetAddress,NetworkInterface,InetAddress)} method - * is used to begin receiving datagrams sent to a group whose source address matches - * a given source address. This method throws {@link UnsupportedOperationException} - * if the underlying platform does not support source filtering. Membership is - * <em>cumulative</em> and this method may be invoked again with the same group - * and interface to allow receiving datagrams from other source addresses. The - * method returns a {@link MembershipKey} that represents membership to receive - * datagrams from the given source address. Invoking the key's {@link - * MembershipKey#drop drop} method drops membership so that datagrams from the - * source address can no longer be received. - * - * <h4>Platform dependencies</h4> - * - * The multicast implementation is intended to map directly to the native - * multicasting facility. Consequently, the following items should be considered - * when developing an application that receives IP multicast datagrams: - * - * <ol> - * - * <li><p> The creation of the channel should specify the {@link ProtocolFamily} - * that corresponds to the address type of the multicast groups that the channel - * will join. There is no guarantee that a channel to a socket in one protocol - * family can join and receive multicast datagrams when the address of the - * multicast group corresponds to another protocol family. For example, it is - * implementation specific if a channel to an {@link StandardProtocolFamily#INET6 IPv6} - * socket can join an {@link StandardProtocolFamily#INET IPv4} multicast group and receive - * multicast datagrams sent to the group. </p></li> - * - * <li><p> The channel's socket should be bound to the {@link - * InetAddress#isAnyLocalAddress wildcard} address. If the socket is bound to - * a specific address, rather than the wildcard address then it is implementation - * specific if multicast datagrams are received by the socket. </p></li> - * - * <li><p> The {@link StandardSocketOption#SO_REUSEADDR SO_REUSEADDR} option should be - * enabled prior to {@link NetworkChannel#bind binding} the socket. This is - * required to allow multiple members of the group to bind to the same - * address. </p></li> - * - * </ol> - * - * <p> <b>Usage Example:</b> - * <pre> - * // join multicast group on this interface, and also use this - * // interface for outgoing multicast datagrams - * NetworkInterface ni = NetworkInterface.getByName("hme0"); - * - * DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET) - * .setOption(StandardSocketOption.SO_REUSEADDR, true) - * .bind(new InetSocketAddress(5000)) - * .setOption(StandardSocketOption.IP_MULTICAST_IF, ni); - * - * InetAddress group = InetAddress.getByName("225.4.5.6"); - * - * MembershipKey key = dc.join(group, ni); - * </pre> - * - * @since 1.7 - */ - -public interface MulticastChannel - extends NetworkChannel -{ - /** - * Joins a multicast group to begin receiving all datagrams sent to the group, - * returning a membership key. - * - * <p> If this channel is currently a member of the group on the given - * interface to receive all datagrams then the membership key, representing - * that membership, is returned. Otherwise this channel joins the group and - * the resulting new membership key is returned. The resulting membership key - * is not {@link MembershipKey#sourceAddress source-specific}. - * - * <p> A multicast channel may join several multicast groups, including - * the same group on more than one interface. An implementation may impose a - * limit on the number of groups that may be joined at the same time. - * - * @param group - * The multicast address to join - * @param interf - * The network interface on which to join the group - * - * @return The membership key - * - * @throws IllegalArgumentException - * If the group parameter is not a {@link InetAddress#isMulticastAddress - * multicast} address, or the group parameter is an address type - * that is not supported by this channel - * @throws IllegalStateException - * If the channel already has source-specific membership of the - * group on the interface - * @throws UnsupportedOperationException - * If the channel's socket is not an Internet Protocol socket - * @throws ClosedChannelException - * If this channel is closed - * @throws IOException - * If an I/O error occurs - * @throws SecurityException - * If a security manager is set, and its - * {@link SecurityManager#checkMulticast(InetAddress) checkMulticast} - * method denies access to the multiast group - */ - MembershipKey join(InetAddress group, NetworkInterface interf) - throws IOException; - - /** - * Joins a multicast group to begin receiving datagrams sent to the group - * from a given source address. - * - * <p> If this channel is currently a member of the group on the given - * interface to receive datagrams from the given source address then the - * membership key, representing that membership, is returned. Otherwise this - * channel joins the group and the resulting new membership key is returned. - * The resulting membership key is {@link MembershipKey#sourceAddress - * source-specific}. - * - * <p> Membership is <em>cumulative</em> and this method may be invoked - * again with the same group and interface to allow receiving datagrams sent - * by other source addresses to the group. - * - * @param group - * The multicast address to join - * @param interf - * The network interface on which to join the group - * @param source - * The source address - * - * @return The membership key - * - * @throws IllegalArgumentException - * If the group parameter is not a {@link - * InetAddress#isMulticastAddress multicast} address, the - * source parameter is not a unicast address, the group - * parameter is an address type that is not supported by this channel, - * or the source parameter is not the same address type as the group - * @throws IllegalStateException - * If the channel is currently a member of the group on the given - * interface to receive all datagrams - * @throws UnsupportedOperationException - * If the channel's socket is not an Internet Protocol socket or - * source filtering is not supported - * @throws ClosedChannelException - * If this channel is closed - * @throws IOException - * If an I/O error occurs - * @throws SecurityException - * If a security manager is set, and its - * {@link SecurityManager#checkMulticast(InetAddress) checkMulticast} - * method denies access to the multiast group - */ - MembershipKey join(InetAddress group, NetworkInterface interf, InetAddress source) - throws IOException; -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/NetworkChannel.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,165 +0,0 @@ -/* - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.nio.channels; - -import java.net.SocketAddress; - -import java.nio.channels.Channel; - -import java.util.Set; -import java.io.IOException; - -import org.classpath.icedtea.java.net.SocketOption; - -/** - * A channel to a network socket. - * - * <p> A channel that implements this interface is a channel to a network - * socket. The {@link #bind(SocketAddress) bind} method is used to bind the - * socket to a local {@link SocketAddress address}, the {@link #getLocalAddress() - * getLocalAddress} method returns the address that the socket is bound to, and - * the {@link #setOption(SocketOption,Object) setOption} and {@link - * #getOption(SocketOption) getOption} methods are used to set and query socket - * options. An implementation of this interface should specify the socket options - * that it supports. - * - * <p> The {@link #bind bind} and {@link #setOption setOption} methods that do - * not otherwise have a value to return are specified to return the network - * channel upon which they are invoked. This allows method invocations to be - * chained. Implementations of this interface should specialize the return type - * so that method invocations on the implementation class can be chained. - * - * @since 1.7 - */ - -public interface NetworkChannel - extends Channel -{ - /** - * Binds the channel's socket to a local address. - * - * <p> This method is used to establish an association between the socket and - * a local address. Once an association is established then the socket remains - * bound until the channel is closed. If the {@code local} parameter has the - * value {@code null} then the socket will be bound to an address that is - * assigned automatically. - * - * @param local - * The address to bind the socket, or {@code null} to bind the socket - * to an automatically assigned socket address - * - * @return This channel - * - * @throws AlreadyBoundException - * If the socket is already bound - * @throws UnsupportedAddressTypeException - * If the type of the given address is not supported - * @throws ClosedChannelException - * If the channel is closed - * @throws IOException - * If some other I/O error occurs - * @throws SecurityException - * If a security manager is installed and it denies an unspecified - * permission. An implementation of this interface should specify - * any required permissions. - * - * @see #getLocalAddress - */ - NetworkChannel bind(SocketAddress local) throws IOException; - - /** - * Returns the socket address that this channel's socket is bound to, or - * {@code null} if the socket is not bound. - * - * <p> Where the channel is {@link #bind bound} to an Internet Protocol - * socket address then the return value from this method is of type {@link - * java.net.InetSocketAddress}. - * - * @return The socket address that the socket is bound to, or {@code null} - * if the channel's socket is not bound - * - * @throws ClosedChannelException - * If the channel is closed - * @throws IOException - * If an I/O error occurs - */ - SocketAddress getLocalAddress() throws IOException; - - /** - * Sets the value of a socket option. - * - * @param name - * The socket option - * @param value - * The value of the socket option. A value of {@code null} may be - * a valid value for some socket options. - * - * @return This channel - * - * @throws UnsupportedOperationException - * If the socket option is not supported by this channel - * @throws IllegalArgumentException - * If the value is not a valid value for this socket option - * @throws ClosedChannelException - * If this channel is closed - * @throws IOException - * If an I/O error occurs - * - * @see java.net.StandardSocketOption - */ - <T> NetworkChannel setOption(SocketOption<T> name, T value) throws IOException; - - /** - * Returns the value of a socket option. - * - * @param name - * The socket option - * - * @return The value of the socket option. A value of {@code null} may be - * a valid value for some socket options. - * - * @throws UnsupportedOperationException - * If the socket option is not supported by this channel - * @throws ClosedChannelException - * If this channel is closed - * @throws IOException - * If an I/O error occurs - * - * @see java.net.StandardSocketOption - */ - <T> T getOption(SocketOption<T> name) throws IOException; - - /** - * Returns a set of the socket options supported by this channel. - * - * <p> This method will continue to return the set of options even after the - * channel has been closed. - * - * @return A set of the socket options supported by this channel - */ - Set<SocketOption<?>> supportedOptions(); -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/SeekableByteChannel.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/SeekableByteChannel.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.channels; +package java.nio.channels; import java.nio.ByteBuffer; import java.nio.channels.ByteChannel; @@ -124,7 +124,7 @@ * @throws IOException * If some other I/O error occurs */ - SeekableByteChannel positionSBC(long newPosition) throws IOException; + SeekableByteChannel position(long newPosition) throws IOException; /** * Returns the current size of entity to which this channel is connected. @@ -166,5 +166,5 @@ * @throws IOException * If some other I/O error occurs */ - SeekableByteChannel truncateSBC(long size) throws IOException; + SeekableByteChannel truncate(long size) throws IOException; }
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/exceptions Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -# -# Copyright 2000-2008 Sun Microsystems, Inc. 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. Sun designates this -# particular file as subject to the "Classpath" exception as provided -# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -# CA 95054 USA or visit www.sun.com if you need additional information or -# have any questions. -# - -# Generated exception classes for java.nio.channels - -PACKAGE=org.classpath.icedtea.java.nio.channels -# This year should only change if the generated source is modified. -COPYRIGHT_YEARS=2000-2007 -SINCE=1.7 - -SUPER=java.io.IOException - -gen InterruptedByTimeoutException " - * Checked exception received by a thread when a timeout elapses before an - * asynchronous operation completes." \ - -4268008601014042947L - -SUPER=IllegalArgumentException - -gen IllegalChannelGroupException " - * Unchecked exception thrown when an attempt is made to open a channel - * in a group that was not created by the same provider. " \ - -2495041211157744253L - -SUPER=IllegalStateException - -gen AcceptPendingException " - * Unchecked exception thrown when an attempt is made to initiate an accept - * operation on a channel and a previous accept operation has not completed." \ - 2721339977965416421L - -gen ReadPendingException " - * Unchecked exception thrown when an attempt is made to read from an - * asynchronous socket channel and a previous read has not completed." \ - 1986315242191227217L - -gen WritePendingException " - * Unchecked exception thrown when an attempt is made to write to an - * asynchronous socket channel and a previous write has not completed." \ - 7031871839266032276L - -gen ShutdownChannelGroupException " - * Unchecked exception thrown when an attempt is made to construct a channel in - * a group that is shutdown or the completion handler for an I/O operation - * cannot be invoked because the channel group is shutdown." \ - -3903801676350154157L
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/package-info.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,293 +0,0 @@ -/* - * Copyright 2001-2008 Sun Microsystems, Inc. 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -/** - * Defines channels, which represent connections to entities that are capable of - * performing I/O operations, such as files and sockets; defines selectors, for - * multiplexed, non-blocking I/O operations. - * - * <a name="channels"></a> - * - * <blockquote><table cellspacing=1 cellpadding=0 summary="Lists channels and their descriptions"> - * <tr><th><p align="left">Channels</p></th><th><p align="left">Description</p></th></tr> - * <tr><td valign=top><tt><i>{@link java.nio.channels.Channel}</i></tt></td> - * <td>A nexus for I/O operations</td></tr> - * <tr><td valign=top><tt> <i>{@link java.nio.channels.ReadableByteChannel}</i></tt></td> - * <td>Can read into a buffer</td></tr> - * <tr><td valign=top><tt> <i>{@link java.nio.channels.ScatteringByteChannel} </i></tt></td> - * <td>Can read into a sequence of buffers</td></tr> - * <tr><td valign=top><tt> <i>{@link java.nio.channels.WritableByteChannel}</i></tt></td> - * <td>Can write from a buffer</td></tr> - * <tr><td valign=top><tt> <i>{@link java.nio.channels.GatheringByteChannel}</i></tt></td> - * <td>Can write from a sequence of buffers</td></tr> - * <tr><td valign=top><tt> <i>{@link java.nio.channels.ByteChannel}</i></tt></td> - * <td>Can read/write to/from a buffer</td></tr> - * <tr><td valign=top><tt> <i>{@link java.nio.channels.SeekableByteChannel}</i></tt></td> - * <td>A {@code ByteChannel} connected to an entity that contains a variable-length sequence of bytes</td></tr> - * <tr><td valign=top><tt> <i>{@link java.nio.channels.AsynchronousChannel}</i></tt></td> - * <td>Supports asynchronous I/O operations.</td></tr> - * <tr><td valign=top><tt> <i>{@link java.nio.channels.AsynchronousByteChannel}</i></tt></td> - * <td>Can read and write bytes asynchronously</td></tr> - * <tr><td valign=top><tt> <i>{@link java.nio.channels.NetworkChannel}</i></tt></td> - * <td>A channel to a network socket</td></tr> - * <tr><td valign=top><tt> <i>{@link java.nio.channels.MulticastChannel}</i></tt></td> - * <td>Can join Internet Protocol (IP) multicast groups</td></tr> - * <tr><td valign=top><tt>{@link org.classpath.icedtea.java.nio.channels.Channels}</tt></td> - * <td>Utility methods for channel/stream interoperation</td></tr> - * </table></blockquote> - * - * <p> A <i>channel</i> represents an open connection to an entity such as a - * hardware device, a file, a network socket, or a program component that is - * capable of performing one or more distinct I/O operations, for example reading - * or writing. As specified in the {@link java.nio.channels.Channel} interface, - * channels are either open or closed, and they are both <i>asynchronously - * closeable</i> and <i>interruptible</i>. - * - * <p> The {@link java.nio.channels.Channel} interface is extended by several - * other interfaces. - * - * <p> The {@link java.nio.channels.ReadableByteChannel} interface specifies a - * {@link java.nio.channels.ReadableByteChannel#read read} method that reads bytes - * from the channel into a buffer; similarly, the {@link - * java.nio.channels.WritableByteChannel} interface specifies a {@link - * java.nio.channels.WritableByteChannel#write write} method that writes bytes - * from a buffer to the channel. The {@link java.nio.channels.ByteChannel} - * interface unifies these two interfaces for the common case of channels that can - * both read and write bytes. The {@link java.nio.channels.SeekableByteChannel} - * interface extends the {@code ByteChannel} interface with methods to {@link - * java.nio.channels.SeekableByteChannel#position() query} and {@link - * java.nio.channels.SeekableByteChannel#position(long) modify} the channel's - * current position, and its {@link java.nio.channels.SeekableByteChannel#size - * size}. - * - * <p> The {@link java.nio.channels.ScatteringByteChannel} and {@link - * java.nio.channels.GatheringByteChannel} interfaces extend the {@link - * java.nio.channels.ReadableByteChannel} and {@link - * java.nio.channels.WritableByteChannel} interfaces, respectively, adding {@link - * java.nio.channels.ScatteringByteChannel#read read} and {@link - * java.nio.channels.GatheringByteChannel#write write} methods that take a - * sequence of buffers rather than a single buffer. - * - * <p> The {@link java.nio.channels.NetworkChannel} interface specifies methods - * to {@link java.nio.channels.NetworkChannel#bind bind} the channel's socket, - * obtain the address to which the socket is bound, and methods to {@link - * java.nio.channels.NetworkChannel#getOption get} and {@link - * java.nio.channels.NetworkChannel#setOption set} socket options. The {@link - * java.nio.channels.MulticastChannel} interface specifies methods to join - * Internet Protocol (IP) multicast groups. - * - * <p> The {@link org.classpath.icedtea.java.nio.channels.Channels} utility class defines static methods - * that support the interoperation of the stream classes of the <tt>{@link - * java.io}</tt> package with the channel classes of this package. An appropriate - * channel can be constructed from an {@link java.io.InputStream} or an {@link - * java.io.OutputStream}, and conversely an {@link java.io.InputStream} or an - * {@link java.io.OutputStream} can be constructed from a channel. A {@link - * java.io.Reader} can be constructed that uses a given charset to decode bytes - * from a given readable byte channel, and conversely a {@link java.io.Writer} can - * be constructed that uses a given charset to encode characters into bytes and - * write them to a given writable byte channel. - * - * <blockquote><table cellspacing=1 cellpadding=0 summary="Lists file channels and their descriptions"> - * <tr><th><p align="left">File channels</p></th><th><p align="left">Description</p></th></tr> - * <tr><td valign=top><tt>{@link org.classpath.icedtea.java.nio.channels.FileChannel}</tt></td> - * <td>Reads, writes, maps, and manipulates files</td></tr> - * <tr><td valign=top><tt>{@link org.classpath.icedtea.java.nio.channels.FileLock}</tt></td> - * <td>A lock on a (region of a) file</td></tr> - * <tr><td valign=top><tt>{@link java.nio.MappedByteBuffer}/{@link java.nio.MappedBigByteBuffer} </tt></td> - * <td>A direct byte buffer or big byte buffer mapped to a region of a file</td></tr> - * </table></blockquote> - * - * <p> The {@link org.classpath.icedtea.java.nio.channels.FileChannel} class supports the usual - * operations of reading bytes from, and writing bytes to, a channel connected to - * a file, as well as those of querying and modifying the current file position - * and truncating the file to a specific size. It defines methods for acquiring - * locks on the whole file or on a specific region of a file; these methods return - * instances of the {@link org.classpath.icedtea.java.nio.channels.FileLock} class. Finally, it defines - * methods for forcing updates to the file to be written to the storage device that - * contains it, for efficiently transferring bytes between the file and other - * channels, and for mapping a region of the file directly into memory. - * - * <p> A {@code FileChannel} is created by invoking one of its static {@link - * java.nio.channels.FileChannel#open open} methods, or by invoking the {@code - * getChannel} method of a {@link java.io.FileInputStream}, {@link - * java.io.FileOutputStream}, or {@link java.io.RandomAccessFile} to return a - * file channel connected to the same underlying file as the <tt>{@link java.io}</tt> - * class. - * - * <a name="multiplex"></a> - * <blockquote><table cellspacing=1 cellpadding=0 summary="Lists multiplexed, non-blocking channels and their descriptions"> - * <tr><th><p align="left">Multiplexed, non-blocking I/O</p></th><th><p align="left">Description</p></th></tr> - * <tr><td valign=top><tt>{@link java.nio.channels.SelectableChannel}</tt></td> - * <td>A channel that can be multiplexed</td></tr> - * <tr><td valign=top><tt> {@link java.nio.channels.DatagramChannel}</tt></td> - * <td>A channel to a datagram-oriented socket</td></tr> - * <tr><td valign=top><tt> {@link java.nio.channels.Pipe.SinkChannel}</tt></td> - * <td>The write end of a pipe</td></tr> - * <tr><td valign=top><tt> {@link java.nio.channels.Pipe.SourceChannel}</tt></td> - * <td>The read end of a pipe</td></tr> - * <tr><td valign=top><tt> {@link java.nio.channels.ServerSocketChannel} </tt></td> - * <td>A channel to a stream-oriented listening socket</td></tr> - * <tr><td valign=top><tt> {@link java.nio.channels.SocketChannel}</tt></td> - * <td>A channel for a stream-oriented connecting socket</td></tr> - * <tr><td valign=top><tt>{@link java.nio.channels.Selector}</tt></td> - * <td>A multiplexor of selectable channels</td></tr> - * <tr><td valign=top><tt>{@link java.nio.channels.SelectionKey}</tt></td> - * <td>A token representing the registration <br> of a channel - * with a selector</td></tr> - * <tr><td valign=top><tt>{@link java.nio.channels.Pipe}</tt></td> - * <td>Two channels that form a unidirectional pipe</td></tr> - * </table></blockquote> - * - * <p> Multiplexed, non-blocking I/O, which is much more scalable than - * thread-oriented, blocking I/O, is provided by <i>selectors</i>, <i>selectable - * channels</i>, and <i>selection keys</i>. - * - * <p> A <a href="Selector.html"><i>selector</i></a> is a multiplexor of <a - * href="SelectableChannel.html"><i>selectable channels</i></a>, which in turn are - * a special type of channel that can be put into <a - * href="SelectableChannel.html#bm"><i>non-blocking mode</i></a>. To perform - * multiplexed I/O operations, one or more selectable channels are first created, - * put into non-blocking mode, and {@link - * java.nio.channels.SelectableChannel#register <i>registered</i>} - * with a selector. Registering a channel specifies the set of I/O operations - * that will be tested for readiness by the selector, and returns a <a - * href="SelectionKey.html"><i>selection key</i></a> that represents the - * registration. - * - * <p> Once some channels have been registered with a selector, a <a - * href="Selector.html#selop"><i>selection operation</i></a> can be performed in - * order to discover which channels, if any, have become ready to perform one or - * more of the operations in which interest was previously declared. If a channel - * is ready then the key returned when it was registered will be added to the - * selector's <i>selected-key set</i>. The key set, and the keys within it, can - * be examined in order to determine the operations for which each channel is - * ready. From each key one can retrieve the corresponding channel in order to - * perform whatever I/O operations are required. - * - * <p> That a selection key indicates that its channel is ready for some operation - * is a hint, but not a guarantee, that such an operation can be performed by a - * thread without causing the thread to block. It is imperative that code that - * performs multiplexed I/O be written so as to ignore these hints when they prove - * to be incorrect. - * - * <p> This package defines selectable-channel classes corresponding to the {@link - * java.net.DatagramSocket}, {@link java.net.ServerSocket}, and {@link - * java.net.Socket} classes defined in the <tt>{@link java.net}</tt> package. - * Minor changes to these classes have been made in order to support sockets that - * are associated with channels. This package also defines a simple class that - * implements unidirectional pipes. In all cases, a new selectable channel is - * created by invoking the static <tt>open</tt> method of the corresponding class. - * If a channel needs an associated socket then a socket will be created as a side - * effect of this operation. - * - * <p> The implementation of selectors, selectable channels, and selection keys - * can be replaced by "plugging in" an alternative definition or instance of the - * {@link java.nio.channels.spi.SelectorProvider} class defined in the <tt>{@link - * java.nio.channels.spi}</tt> package. It is not expected that many developers - * will actually make use of this facility; it is provided primarily so that - * sophisticated users can take advantage of operating-system-specific - * I/O-multiplexing mechanisms when very high performance is required. - * - * <p> Much of the bookkeeping and synchronization required to implement the - * multiplexed-I/O abstractions is performed by the {@link - * java.nio.channels.spi.AbstractInterruptibleChannel}, {@link - * java.nio.channels.spi.AbstractSelectableChannel}, {@link - * java.nio.channels.spi.AbstractSelectionKey}, and {@link - * java.nio.channels.spi.AbstractSelector} classes in the <tt>{@link - * java.nio.channels.spi}</tt> package. When defining a custom selector provider, - * only the {@link java.nio.channels.spi.AbstractSelector} and {@link - * java.nio.channels.spi.AbstractSelectionKey} classes should be subclassed - * directly; custom channel classes should extend the appropriate {@link - * java.nio.channels.SelectableChannel} subclasses defined in this package. - * - * <a name="async"></a> - * - * <blockquote><table cellspacing=1 cellpadding=0 summary="Lists asynchronous channels and their descriptions"> - * <tr><th><p align="left">Asynchronous I/O</p></th><th><p align="left">Description</p></th></tr> - * <tr><td valign=top><tt>{@link org.classpath.icedtea.java.nio.channels.AsynchronousFileChannel}</tt></td> - * <td>An asynchronous channel for reading, writing, and manipulating a file</td></tr> - * <tr><td valign=top><tt>{@link org.classpath.icedtea.java.nio.channels.AsynchronousSocketChannel}</tt></td> - * <td>An asynchronous channel to a stream-oriented connecting socket</td></tr> - * <tr><td valign=top><tt>{@link org.classpath.icedtea.java.nio.channels.AsynchronousServerSocketChannel} </tt></td> - * <td>An asynchronous channel to a stream-oriented listening socket</td></tr> - * <tr><td valign=top><tt>{@link org.classpath.icedtea.java.nio.channels.AsynchronousDatagramChannel}</tt></td> - * <td>An asynchronous channel to a datagram-oriented socket</td></tr> - * <tr><td valign=top><tt>{@link org.classpath.icedtea.java.nio.channels.CompletionHandler}</tt></td> - * <td>A handler for consuming the result of an asynchronous operation</td></tr> - * <tr><td valign=top><tt>{@link org.classpath.icedtea.java.nio.channels.AsynchronousChannelGroup}</tt></td> - * <td>A grouping of asynchronous channels for the purpose of resource sharing</td></tr> - * </table></blockquote> - * - * <p> {@link org.classpath.icedtea.java.nio.channels.AsynchronousChannel Asynchronous channels} are a - * special type of channel capable of asynchronous I/O operations. Asynchronous - * channels are non-blocking and define methods to initiate asynchronous - * operations, returning a {@link java.util.concurrent.Future} representing the - * pending result of each operation. The {@code Future} can be used to poll or - * wait for the result of the operation. Asynchronous I/O operations can also - * specify a {@link org.classpath.icedtea.java.nio.channels.CompletionHandler} to invoke when the - * operation completes. A completion handler is user provided code that is executed - * to consume the result of I/O operation. - * - * <p> This package defines asynchronous-channel classes that are connected to - * a stream-oriented connecting or listening socket, or a datagram-oriented socket. - * It also defines the {@link org.classpath.icedtea.java.nio.channels.AsynchronousFileChannel} class - * for asynchronous reading, writing, and manipulating a file. As with the {@link - * org.classpath.icedtea.java.nio.channels.FileChannel} it supports operations to truncate the file - * to a specific size, force updates to the file to be written to the storage - * device, or acquire locks on the whole file or on a specific region of the file. - * Unlike the {@code FileChannel} it does not define methods for mapping a - * region of the file directly into memory. Where memory mapped I/O is required, - * then a {@code FileChannel} can be used. - * - * <p> Asynchronous channels are bound to an asynchronous channel group for the - * purpose of resource sharing. A group has an associated {@link - * java.util.concurrent.ExecutorService} to which tasks are submitted to handle - * I/O events and dispatch to completion handlers that consume the result of - * asynchronous operations performed on channels in the group. The group can - * optionally be specified when creating the channel or the channel can be bound - * to a <em>default group</em>. Sophisticated users may wish to create their - * own asynchronous channel groups or configure the {@code ExecutorService} - * that will be used for the default group. - * - * <p> As with selectors, the implementatin of asynchronous channels can be - * replaced by "plugging in" an alternative definition or instance of the {@link - * java.nio.channels.spi.AsynchronousChannelProvider} class defined in the - * <tt>{@link java.nio.channels.spi}</tt> package. It is not expected that many - * developers will actually make use of this facility; it is provided primarily - * so that sophisticated users can take advantage of operating-system-specific - * asynchronous I/O mechanisms when very high performance is required. - * - * <hr width="80%"> - * <p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor - * or method in any class or interface in this package will cause a {@link - * java.lang.NullPointerException NullPointerException} to be thrown. - * - * @since 1.4 - * @updated 1.7 - * @author Mark Reinhold - * @author JSR-51 Expert Group - */ - -package org.classpath.icedtea.java.nio.channels;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/spi/AsynchronousChannelProvider.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/spi/AsynchronousChannelProvider.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.channels.spi; +package java.nio.channels.spi; import java.nio.channels.*; import java.io.IOException; @@ -35,12 +35,12 @@ import java.security.AccessController; import java.security.PrivilegedAction; -import org.classpath.icedtea.java.net.ProtocolFamily; +import java.net.ProtocolFamily; -import org.classpath.icedtea.java.nio.channels.AsynchronousChannelGroup; -import org.classpath.icedtea.java.nio.channels.AsynchronousDatagramChannel; -import org.classpath.icedtea.java.nio.channels.AsynchronousServerSocketChannel; -import org.classpath.icedtea.java.nio.channels.AsynchronousSocketChannel; +import java.nio.channels.AsynchronousChannelGroup; +import java.nio.channels.AsynchronousDatagramChannel; +import java.nio.channels.AsynchronousServerSocketChannel; +import java.nio.channels.AsynchronousSocketChannel; /** * Service-provider class for asynchronous channels. @@ -83,7 +83,7 @@ } private static boolean loadProviderFromProperty() { - String cn = System.getProperty("org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider"); + String cn = System.getProperty("java.nio.channels.spi.AsynchronousChannelProvider"); if (cn == null) return false; try {
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/spi/SelectorProvider.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,199 +0,0 @@ -/* - * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.nio.channels.spi; - -import java.io.IOException; - -import java.security.AccessController; -import java.security.PrivilegedAction; - -import java.util.Iterator; -import java.util.ServiceLoader; -import java.util.ServiceConfigurationError; - -import org.classpath.icedtea.java.net.ProtocolFamily; - -import org.classpath.icedtea.java.nio.channels.DatagramChannel; - -/** - * Service-provider class for selectors and selectable channels. - * - * <p> A selector provider is a concrete subclass of this class that has a - * zero-argument constructor and implements the abstract methods specified - * below. A given invocation of the Java virtual machine maintains a single - * system-wide default provider instance, which is returned by the {@link - * #provider() provider} method. The first invocation of that method will locate - * the default provider as specified below. - * - * <p> The system-wide default provider is used by the static <tt>open</tt> - * methods of the {@link java.nio.channels.DatagramChannel#open - * DatagramChannel}, {@link java.nio.channels.Pipe#open Pipe}, {@link - * java.nio.channels.Selector#open Selector}, {@link - * java.nio.channels.ServerSocketChannel#open ServerSocketChannel}, and {@link - * java.nio.channels.SocketChannel#open SocketChannel} classes. It is also - * used by the {@link java.lang.System#inheritedChannel System.inheritedChannel()} - * method. A program may make use of a provider other than the default provider - * by instantiating that provider and then directly invoking the <tt>open</tt> - * methods defined in this class. - * - * <p> All of the methods in this class are safe for use by multiple concurrent - * threads. </p> - * - * - * @author Mark Reinhold - * @author JSR-51 Expert Group - * @since 1.4 - */ - -public abstract class SelectorProvider - extends java.nio.channels.spi.SelectorProvider { - - private static final Object lock = new Object(); - private static SelectorProvider provider = null; - - /** - * Opens a datagram channel. </p> - * - * @return The new channel - */ - public abstract DatagramChannel openDatagramChannel() - throws IOException; - - /** - * {@note new} - * Opens a datagram channel. - * - * @param family - * The protocol family - * - * @return A new datagram channel - * - * @throws UnsupportedOperationException - * If the specified protocol family is not supported - * @throws IOException - * If an I/O error occurs - * - * @since 1.7 - */ - public abstract DatagramChannel openDatagramChannel(ProtocolFamily family) - throws IOException; - - /** - * Returns the system-wide default selector provider for this invocation of - * the Java virtual machine. - * - * <p> The first invocation of this method locates the default provider - * object as follows: </p> - * - * <ol> - * - * <li><p> If the system property - * <tt>java.nio.channels.spi.SelectorProvider</tt> is defined then it is - * taken to be the fully-qualified name of a concrete provider class. - * The class is loaded and instantiated; if this process fails then an - * unspecified error is thrown. </p></li> - * - * <li><p> If a provider class has been installed in a jar file that is - * visible to the system class loader, and that jar file contains a - * provider-configuration file named - * <tt>java.nio.channels.spi.SelectorProvider</tt> in the resource - * directory <tt>META-INF/services</tt>, then the first class name - * specified in that file is taken. The class is loaded and - * instantiated; if this process fails then an unspecified error is - * thrown. </p></li> - * - * <li><p> Finally, if no provider has been specified by any of the above - * means then the system-default provider class is instantiated and the - * result is returned. </p></li> - * - * </ol> - * - * <p> Subsequent invocations of this method return the provider that was - * returned by the first invocation. </p> - * - * @return The system-wide default selector provider - */ - public static SelectorProvider provider() { - synchronized (lock) { - if (provider != null) - return provider; - return AccessController - .doPrivileged(new PrivilegedAction<SelectorProvider>() { - public SelectorProvider run() { - if (loadProviderFromProperty()) - return provider; - if (loadProviderAsService()) - return provider; - provider = sun.nio.ch.DefaultSelectorProvider.create(); - return provider; - } - }); - } - } - - private static boolean loadProviderFromProperty() { - String cn = System.getProperty("org.classpath.icedtea.java.nio.channels.spi.SelectorProvider"); - if (cn == null) - return false; - try { - Class<?> c = Class.forName(cn, true, - ClassLoader.getSystemClassLoader()); - provider = (SelectorProvider)c.newInstance(); - return true; - } catch (ClassNotFoundException x) { - throw new ServiceConfigurationError(null, x); - } catch (IllegalAccessException x) { - throw new ServiceConfigurationError(null, x); - } catch (InstantiationException x) { - throw new ServiceConfigurationError(null, x); - } catch (SecurityException x) { - throw new ServiceConfigurationError(null, x); - } - } - - private static boolean loadProviderAsService() { - - ServiceLoader<SelectorProvider> sl = - ServiceLoader.load(SelectorProvider.class, - ClassLoader.getSystemClassLoader()); - Iterator<SelectorProvider> i = sl.iterator(); - for (;;) { - try { - if (!i.hasNext()) - return false; - provider = i.next(); - return true; - } catch (ServiceConfigurationError sce) { - if (sce.getCause() instanceof SecurityException) { - // Ignore the security exception, try the next provider - continue; - } - throw sce; - } - } - } -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/channels/spi/package.html Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -<!-- - Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. - Copyright 2009 Red Hat, Inc. - 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. Sun designates this - particular file as subject to the "Classpath" exception as provided - by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - CA 95054 USA or visit www.sun.com if you need additional information or - have any questions. ---> - -<!doctype html public "-//IETF//DTD HTML//EN"> -<html> -<body bgcolor="white"> - -Service-provider classes for the <tt>{@link org.classpath.icedtea.java.nio.channels}</tt> package. - -<p> Only developers who are defining new asynchronous channel providers should need -to make direct use of this package. </p> - -<p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor -or method in any class or interface in this package will cause a {@link -java.lang.NullPointerException NullPointerException} to be thrown. - - -@since 1.7 -@author Mark Reinhold -@author JSR-51 Expert Group - -</body> -</html>
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/AccessDeniedException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/AccessDeniedException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Checked exception thrown when a file system operation is denied, typically
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/AccessMode.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/AccessMode.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Defines access modes used to test the accessibility of a file.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/AtomicMoveNotSupportedException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/AtomicMoveNotSupportedException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Checked exception thrown when a file cannot be moved as an atomic file system
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ClosedDirectoryStreamException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ClosedDirectoryStreamException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Unchecked exception thrown when an attempt is made to invoke an operation on
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ClosedFileSystemException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ClosedFileSystemException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Unchecked exception thrown when an attempt is made to invoke an operation on
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ClosedWatchServiceException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ClosedWatchServiceException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Unchecked exception thrown when an attempt is made to invoke an operation on
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/CopyOption.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/CopyOption.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * An object that configures how to copy or move a file.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/DirectoryNotEmptyException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/DirectoryNotEmptyException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Checked exception thrown when a file system operation fails because a
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/DirectoryStream.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/DirectoryStream.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.util.Iterator; import java.io.Closeable;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/DirectoryStreamFilters.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/DirectoryStreamFilters.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.io.IOException; import java.io.IOError;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileAction.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileAction.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileAlreadyExistsException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileAlreadyExistsException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Checked exception thrown when an attempt is made to create a file or
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileRef.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileRef.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,13 +24,13 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.io.IOException; -import org.classpath.icedtea.java.nio.channels.SeekableByteChannel; +import java.nio.channels.SeekableByteChannel; -import org.classpath.icedtea.java.nio.file.attribute.FileAttributeView; +import java.nio.file.attribute.FileAttributeView; /** * A reference to a file.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileStore.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileStore.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,12 +24,12 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.util.Set; -import org.classpath.icedtea.java.nio.file.attribute.FileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileStoreAttributeView; +import java.nio.file.attribute.FileAttributeView; +import java.nio.file.attribute.FileStoreAttributeView; /** * Storage for files. A {@code FileStore} represents a storage pool, device,
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystem.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystem.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,15 +24,15 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.util.Set; import java.io.Closeable; import java.io.IOException; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipalLookupService; +import java.nio.file.attribute.UserPrincipalLookupService; -import org.classpath.icedtea.java.nio.file.spi.FileSystemProvider; +import java.nio.file.spi.FileSystemProvider; /** * Provides an interface to a file system and is the factory for objects to
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystemAlreadyExistsException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystemAlreadyExistsException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Runtime exception thrown an attempt is made to create a file system that
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystemException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystemException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystemNotFoundException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystemNotFoundException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Runtime exception thrown when a file system cannot be found.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystems.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileSystems.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.net.URI; import java.io.IOException; @@ -33,7 +33,7 @@ import java.util.*; import java.lang.reflect.Constructor; -import org.classpath.icedtea.java.nio.file.spi.FileSystemProvider; +import java.nio.file.spi.FileSystemProvider; /** * Factory methods for file systems. This class defines the {@link #getDefault
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileTreeWalker.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileTreeWalker.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,13 +24,13 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.io.IOException; import java.util.*; -import org.classpath.icedtea.java.nio.file.attribute.Attributes; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.Attributes; +import java.nio.file.attribute.BasicFileAttributes; /** * Simple file tree walker that works in a similar manner to nftw(3C).
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileVisitOption.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileVisitOption.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Defines the file tree traversal options.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileVisitResult.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileVisitResult.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * The result type of a {@link FileVisitor FileVisitor}.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileVisitor.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/FileVisitor.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,11 +24,11 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.io.IOException; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.BasicFileAttributes; /** * A visitor of files. An implementation of this interface is provided to the
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Files.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Files.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,14 +24,14 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.io.IOException; import java.util.*; import java.security.AccessController; import java.security.PrivilegedAction; -import org.classpath.icedtea.java.nio.file.spi.FileTypeDetector; +import java.nio.file.spi.FileTypeDetector; /** * Utility methods for files and directories.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/InvalidPathException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/InvalidPathException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Unchecked exception thrown when path string cannot be converted into a
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/LinkOption.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/LinkOption.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Defines the options as to how symbolic links are handled.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/LinkPermission.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/LinkPermission.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.security.BasicPermission;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/NoSuchFileException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/NoSuchFileException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Checked exception thrown when an attempt is made to access a file that does
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/NotDirectoryException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/NotDirectoryException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Checked exception thrown when a file system operation, intended for a
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/NotLinkException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/NotLinkException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Checked exception thrown when a file system operation fails because a file
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/OpenOption.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/OpenOption.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * An object that configures how to open or create a file.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Path.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Path.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,16 +24,16 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.nio.channels.*; import java.io.*; import java.net.URI; import java.util.*; -import org.classpath.icedtea.java.nio.channels.SeekableByteChannel; +import java.nio.channels.SeekableByteChannel; -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.FileAttribute; /** * A file reference that locates a file using a system dependent path. The file
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/PathMatcher.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/PathMatcher.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * An interface that is implemented by objects that perform match operations on
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Paths.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Paths.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,12 +24,12 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.net.URI; import java.util.Iterator; -import org.classpath.icedtea.java.nio.file.spi.FileSystemProvider; +import java.nio.file.spi.FileSystemProvider; /** * This class consists exclusively of static methods that return a {@link Path}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ProviderMismatchException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ProviderMismatchException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Unchecked exception thrown when an attempt is made to invoke a method on an
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ProviderNotFoundException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ProviderNotFoundException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Runtime exception thrown a provider of the required type cannot be found.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ReadOnlyFileSystemException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/ReadOnlyFileSystemException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Unchecked exception thrown when an attempt is made to update an object in a
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/SecureDirectoryStream.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/SecureDirectoryStream.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,14 +23,14 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.util.Set; import java.io.IOException; -import org.classpath.icedtea.java.nio.channels.SeekableByteChannel; -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; -import org.classpath.icedtea.java.nio.file.attribute.FileAttributeView; +import java.nio.channels.SeekableByteChannel; +import java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.FileAttributeView; /** * A {@code DirectoryStream} that defines operations on files that are located
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/SimpleFileVisitor.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/SimpleFileVisitor.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,12 +24,12 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.io.IOException; import java.io.IOError; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.BasicFileAttributes; /** * A simple visitor of files with default behavior to visit all files and to
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/StandardCopyOption.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/StandardCopyOption.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Defines the standard copy options.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/StandardOpenOption.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/StandardOpenOption.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Defines the standard open options.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/StandardWatchEventKind.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/StandardWatchEventKind.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * Defines the <em>standard</em> event kinds.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/WatchEvent.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/WatchEvent.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; /** * An event or a repeated event for an object that is registered with a {@link
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/WatchKey.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/WatchKey.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.util.List;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/WatchService.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/WatchService.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.io.Closeable; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Watchable.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/Watchable.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntry.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntry.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.util.*;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntryFlag.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntryFlag.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; /** * Defines the flags for used by the flags component of an ACL {@link AclEntry
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntryPermission.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntryPermission.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; /** * Defines the permissions for use with the permissions component of an ACL
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntryType.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclEntryType.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; /** * A typesafe enumeration of the access control entry types.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclFileAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AclFileAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.util.List; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/AttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.util.*; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/Attributes.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/Attributes.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,15 +24,15 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.io.IOException; import java.util.*; import java.util.concurrent.TimeUnit; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.FileStore; -import org.classpath.icedtea.java.nio.file.LinkOption; +import java.nio.file.FileRef; +import java.nio.file.FileStore; +import java.nio.file.LinkOption; /** * This class consists exclusively of static methods that operate on or return
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/BasicFileAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/BasicFileAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.util.concurrent.TimeUnit; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/BasicFileAttributes.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/BasicFileAttributes.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.util.concurrent.TimeUnit;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/DosFileAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/DosFileAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/DosFileAttributes.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/DosFileAttributes.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; /** * File attributes associated with a file in a file system that supports
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileAttribute.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileAttribute.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; /** * An object that encapsulates the value of a file attribute that can be set
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; /** * An attribute view that is a read-only or updatable view of non-opaque
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileOwnerAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileOwnerAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileStoreAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileStoreAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; /** * An attribute view that is a read-only or updatable view of the attributes of
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileStoreSpaceAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileStoreSpaceAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.util.Map; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileStoreSpaceAttributes.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/FileStoreSpaceAttributes.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; /** * Space related attributes of a file store.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/GroupPrincipal.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/GroupPrincipal.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; /** * A {@code UserPrincipal} representing a <em>group identity</em>, used to
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/NamedAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/NamedAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.nio.ByteBuffer; import java.util.List;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFileAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFileAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.util.Set; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFileAttributes.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFileAttributes.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.util.Set;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFilePermission.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFilePermission.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.util.*;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFilePermissions.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/PosixFilePermissions.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,19 +24,19 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.util.*; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.OWNER_READ; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.OWNER_WRITE; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.GROUP_READ; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.GROUP_WRITE; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.OTHERS_READ; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.OTHERS_WRITE; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.OTHERS_EXECUTE; +import static java.nio.file.attribute.PosixFilePermission.OWNER_READ; +import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE; +import static java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE; +import static java.nio.file.attribute.PosixFilePermission.GROUP_READ; +import static java.nio.file.attribute.PosixFilePermission.GROUP_WRITE; +import static java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE; +import static java.nio.file.attribute.PosixFilePermission.OTHERS_READ; +import static java.nio.file.attribute.PosixFilePermission.OTHERS_WRITE; +import static java.nio.file.attribute.PosixFilePermission.OTHERS_EXECUTE; /** * This class consists exclusively of static methods that operate on sets of
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/UserPrincipal.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/UserPrincipal.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.security.Principal;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/UserPrincipalLookupService.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/UserPrincipalLookupService.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/UserPrincipalNotFoundException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/UserPrincipalNotFoundException.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute; import java.io.IOException;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/package-info.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/attribute/package-info.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,65 +29,65 @@ * * <blockquote><table cellspacing=1 cellpadding=0 summary="Attribute views"> * <tr><th><p align="left">Attribute views</p></th><th><p align="left">Description</p></th></tr> - * <tr><td valign=top><tt><i>{@link org.classpath.icedtea.java.nio.file.attribute.AttributeView}</i></tt></td> + * <tr><td valign=top><tt><i>{@link java.nio.file.attribute.AttributeView}</i></tt></td> * <td>Can read or update non-opaque values associated with objects in a file system</td></tr> - * <tr><td valign=top><tt> <i>{@link org.classpath.icedtea.java.nio.file.attribute.FileAttributeView}</i></tt></td> + * <tr><td valign=top><tt> <i>{@link java.nio.file.attribute.FileAttributeView}</i></tt></td> * <td>Can read or update file attributes</td></tr> - * <tr><td valign=top><tt> <i>{@link org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributeView} </i></tt></td> + * <tr><td valign=top><tt> <i>{@link java.nio.file.attribute.BasicFileAttributeView} </i></tt></td> * <td>Can read or update a basic set of file attributes</td></tr> - * <tr><td valign=top><tt> <i>{@link org.classpath.icedtea.java.nio.file.attribute.PosixFileAttributeView} </i></tt></td> + * <tr><td valign=top><tt> <i>{@link java.nio.file.attribute.PosixFileAttributeView} </i></tt></td> * <td>Can read or update POSIX defined file attributes</td></tr> - * <tr><td valign=top><tt> <i>{@link org.classpath.icedtea.java.nio.file.attribute.DosFileAttributeView} </i></tt></td> + * <tr><td valign=top><tt> <i>{@link java.nio.file.attribute.DosFileAttributeView} </i></tt></td> * <td>Can read or update FAT file attributes</td></tr> - * <tr><td valign=top><tt>  <i>{@link org.classpath.icedtea.java.nio.file.attribute.FileOwnerAttributeView} </i></tt></td> + * <tr><td valign=top><tt>  <i>{@link java.nio.file.attribute.FileOwnerAttributeView} </i></tt></td> * <td>Can read or update the owner of a file</td></tr> - * <tr><td valign=top><tt> <i>{@link org.classpath.icedtea.java.nio.file.attribute.AclFileAttributeView} </i></tt></td> + * <tr><td valign=top><tt> <i>{@link java.nio.file.attribute.AclFileAttributeView} </i></tt></td> * <td>Can read or update Access Control Lists</td></tr> - * <tr><td valign=top><tt> <i>{@link org.classpath.icedtea.java.nio.file.attribute.NamedAttributeView} </i></tt></td> + * <tr><td valign=top><tt> <i>{@link java.nio.file.attribute.NamedAttributeView} </i></tt></td> * <td>Can read or update Named Attributes</td></tr> - * <tr><td valign=top><tt> <i>{@link org.classpath.icedtea.java.nio.file.attribute.FileStoreAttributeView}</i></tt></td> + * <tr><td valign=top><tt> <i>{@link java.nio.file.attribute.FileStoreAttributeView}</i></tt></td> * <td>Can read or update file system attributes</td></tr> - * <tr><td valign=top><tt> <i>{@link org.classpath.icedtea.java.nio.file.attribute.FileStoreSpaceAttributeView} </i></tt></td> + * <tr><td valign=top><tt> <i>{@link java.nio.file.attribute.FileStoreSpaceAttributeView} </i></tt></td> * <td>Can read file system <em>space usage</em> related attributes</td></tr> * </table></blockquote> * * <p> An attribute view provides a read-only or updatable view of the non-opaque * values, or <em>metadata</em>, associated with objects in a file system. - * The {@link org.classpath.icedtea.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 * attributes. {@code FileAttributeViews} are selected by invoking the {@link - * org.classpath.icedtea.java.nio.file.FileRef#getFileAttributeView} method with a + * java.nio.file.FileRef#getFileAttributeView} method with a * <em>type-token</em> to identify the required view. Views can also be identified - * by name. The {@link org.classpath.icedtea.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 * a given type is obtained by invoking the {@link - * org.classpath.icedtea.java.nio.file.FileStore#getFileStoreAttributeView} method. + * java.nio.file.FileStore#getFileStoreAttributeView} method. * - * <p> The {@link org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributeView} + * <p> The {@link java.nio.file.attribute.BasicFileAttributeView} * class defines methods to read and update a <em>basic</em> set of file * attributes that are common to many file systems. * - * <p> The {@link org.classpath.icedtea.java.nio.file.attribute.PosixFileAttributeView} + * <p> The {@link java.nio.file.attribute.PosixFileAttributeView} * interface extends {@code BasicFileAttributeView} by defining methods * to access the file attributes commonly used by file systems and operating systems * that implement the Portable Operating System Interface (POSIX) family of * standards. * - * <p> The {@link org.classpath.icedtea.java.nio.file.attribute.DosFileAttributeView} + * <p> The {@link java.nio.file.attribute.DosFileAttributeView} * class extends {@code BasicFileAttributeView} by defining methods to * access the legacy "DOS" file attributes supported on file systems such as File * Allocation Tabl (FAT), commonly used in consumer devices. * - * <p> The {@link org.classpath.icedtea.java.nio.file.attribute.AclFileAttributeView} + * <p> The {@link java.nio.file.attribute.AclFileAttributeView} * class defines methods to read and write the Access Control List (ACL) * file attribute. The ACL model used by this file attribute view is based * on the model defined by <a href="http://www.ietf.org/rfc/rfc3530.txt"> * <i>RFC 3530: Network File System (NFS) version 4 Protocol</i></a>. * - * <p> The {@link org.classpath.icedtea.java.nio.file.attribute.FileStoreSpaceAttributeView} class + * <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 org.classpath.icedtea.java.nio.file.attribute.Attributes} utility class defines + * <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. * @@ -96,14 +96,14 @@ * * <ul> * - * <p><li> The {@link org.classpath.icedtea.java.nio.file.attribute.UserPrincipal} and - * {@link org.classpath.icedtea.java.nio.file.attribute.GroupPrincipal} interfaces represent an + * <p><li> The {@link java.nio.file.attribute.UserPrincipal} and + * {@link java.nio.file.attribute.GroupPrincipal} interfaces represent an * identity or group identity. </li> * - * <p><li> The {@link org.classpath.icedtea.java.nio.file.attribute.UserPrincipalLookupService} + * <p><li> The {@link java.nio.file.attribute.UserPrincipalLookupService} * interface defines methods to lookup user or group principals. </li> * - * <p><li> The {@link org.classpath.icedtea.java.nio.file.attribute.Attribute} interface + * <p><li> The {@link java.nio.file.attribute.Attribute} interface * represents the value of an attribute for cases where the attribute value is * require to be set atomically when creating an object in the file system. </li> * @@ -117,4 +117,4 @@ * @since 1.7 */ -package org.classpath.icedtea.java.nio.file.attribute; +package java.nio.file.attribute;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/package-info.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/package-info.java Fri Feb 20 14:50:00 2009 +0000 @@ -27,9 +27,9 @@ * Define interfaces and classes for the Java virtual machine to access files, * file attributes, and file systems. * - * <p> The org.classpath.icedtea.java.nio.file package defines classes to access files and file + * <p> The java.nio.file package defines classes to access files and file * systems. The API to access file and file system attributes is defined in the - * {@link org.classpath.icedtea.java.nio.file.attribute} package. The {@link org.classpath.icedtea.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 * platform default provider, or to construct other provider implementations. * @@ -46,13 +46,13 @@ * not included in this package. * * <a name="interop"><h3>Interoperability</h3></a> - * The {@link org.classpath.icedtea.java.io.File} class defines the {@link org.classpath.icedtea.java.io.File#toPath - * toPath} method to construct a {@link org.classpath.icedtea.java.nio.file.Path} by converting - * the abstract path represented by the {@code org.classpath.icedtea.java.io.File} object. The resulting + * The {@link java.io.File} class defines the {@link java.io.File#toPath + * toPath} method to construct a {@link java.nio.file.Path} by converting + * the abstract path represented by the {@code java.io.File} object. The resulting * {@code Path} can be used to operate on the same file as the {@code File} * object. The {@code Path} specification provides further information * on the <a href="Path.html#interop">interoperability</a> between {@code Path} - * and {@code org.classpath.icedtea.java.io.File} objects. + * and {@code java.io.File} objects. * * <h3>Visibility</h3> * The view of the files and file system provided by classes in this package are @@ -66,8 +66,8 @@ * system-dependent and are therefore unspecified. * * <a name="integrity"><h3>Synchronized I/O File Integrity</h3></a> - * The {@link org.classpath.icedtea.java.nio.file.StandardOpenOption#SYNC SYNC} and {@link - * org.classpath.icedtea.java.nio.file.StandardOpenOption#DSYNC DSYNC} options are used when opening a file + * The {@link java.nio.file.StandardOpenOption#SYNC SYNC} and {@link + * java.nio.file.StandardOpenOption#DSYNC DSYNC} options are used when opening a file * to require that updates to the file are written synchronously to the underlying * storage device. In the case of the default provider, and the file resides on * a local storage device, and the {@link java.nio.channels.SeekableByteChannel @@ -79,7 +79,7 @@ * for ensuring that critical information is not lost in the event of a system * 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 - * org.classpath.icedtea.java.nio.file.spi.FileSystemProvider provider} implementations is provider + * java.nio.file.spi.FileSystemProvider provider} implementations is provider * specific. * * <h3>General Exceptions</h3> @@ -90,17 +90,17 @@ * cause a {@code NullPointerException}, unless otherwise specified. * * <p> Unless otherwise noted, methods that attempt to access the file system - * will throw {@link org.classpath.icedtea.java.nio.file.ClosedFileSystemException} when invoked on - * objects associated with a {@link org.classpath.icedtea.java.nio.file.FileSystem} that has been - * {@link org.classpath.icedtea.java.nio.file.FileSystem#close closed}. Additionally, any methods + * will throw {@link java.nio.file.ClosedFileSystemException} when invoked on + * objects associated with a {@link java.nio.file.FileSystem} that has been + * {@link java.nio.file.FileSystem#close closed}. Additionally, any methods * that attempt write access to a file system will throw {@link - * org.classpath.icedtea.java.nio.file.ReadOnlyFileSystemException} when invoked on an object associated - * with a {@link org.classpath.icedtea.java.nio.file.FileSystem} that only provides read-only access. + * java.nio.file.ReadOnlyFileSystemException} when invoked on an object associated + * with a {@link java.nio.file.FileSystem} that only provides read-only access. * * <p> Unless otherwise noted, invoking a method of any class or interface in - * this package created by one {@link org.classpath.icedtea.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, - * will throw {@link org.classpath.icedtea.java.nio.file.ProviderMismatchException}. + * will throw {@link java.nio.file.ProviderMismatchException}. * * <h3>Optional Specific Exceptions</h3> * Most of the methods defined by classes in this package that access the @@ -113,4 +113,4 @@ * * @since 1.7 */ -package org.classpath.icedtea.java.nio.file; +package java.nio.file;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/AbstractPath.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/AbstractPath.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,34 +24,34 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.spi; +package java.nio.file.spi; import java.nio.channels.*; import java.nio.ByteBuffer; import java.io.*; import java.util.*; -import org.classpath.icedtea.java.nio.channels.SeekableByteChannel; +import java.nio.channels.SeekableByteChannel; -import org.classpath.icedtea.java.nio.file.AtomicMoveNotSupportedException; -import org.classpath.icedtea.java.nio.file.CopyOption; -import org.classpath.icedtea.java.nio.file.DirectoryStream; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.LinkOption; -import org.classpath.icedtea.java.nio.file.NoSuchFileException; -import org.classpath.icedtea.java.nio.file.OpenOption; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.PathMatcher; -import org.classpath.icedtea.java.nio.file.StandardOpenOption; -import org.classpath.icedtea.java.nio.file.StandardCopyOption; -import org.classpath.icedtea.java.nio.file.WatchEvent; -import org.classpath.icedtea.java.nio.file.WatchKey; -import org.classpath.icedtea.java.nio.file.WatchService; +import java.nio.file.AtomicMoveNotSupportedException; +import java.nio.file.CopyOption; +import java.nio.file.DirectoryStream; +import java.nio.file.FileRef; +import java.nio.file.LinkOption; +import java.nio.file.NoSuchFileException; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.PathMatcher; +import java.nio.file.StandardOpenOption; +import java.nio.file.StandardCopyOption; +import java.nio.file.WatchEvent; +import java.nio.file.WatchKey; +import java.nio.file.WatchService; -import org.classpath.icedtea.java.nio.file.attribute.Attributes; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.Attributes; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.BasicFileAttributeView; +import java.nio.file.attribute.FileAttribute; /** * Base implementation class for a {@code Path}.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/FileSystemProvider.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/FileSystemProvider.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.spi; +package java.nio.file.spi; import java.net.URI; import java.util.*; @@ -33,14 +33,14 @@ import java.security.PrivilegedAction; import java.io.IOException; -import org.classpath.icedtea.java.nio.channels.AsynchronousFileChannel; -import org.classpath.icedtea.java.nio.channels.FileChannel; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.FileSystem; -import org.classpath.icedtea.java.nio.file.FileSystems; -import org.classpath.icedtea.java.nio.file.OpenOption; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; +import java.nio.channels.AsynchronousFileChannel; +import java.nio.channels.FileChannel; +import java.nio.file.FileRef; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.attribute.FileAttribute; /** * Service-provider class for file systems.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/FileTypeDetector.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/FileTypeDetector.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,11 +24,11 @@ * have any questions. */ -package org.classpath.icedtea.java.nio.file.spi; +package java.nio.file.spi; import java.io.IOException; -import org.classpath.icedtea.java.nio.file.FileRef; +import java.nio.file.FileRef; /** * A file type detector for probing a file to guess its file type.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/package-info.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/java/nio/file/spi/package-info.java Fri Feb 20 14:50:00 2009 +0000 @@ -24,7 +24,7 @@ */ /** - * Service-provider classes for the <tt>{@link org.classpath.icedtea.java.nio.file}</tt> package. + * Service-provider classes for the <tt>{@link java.nio.file}</tt> package. * * <p> Only developers who are defining new file system providers or file type * detectors should need to make direct use of this package. </p> @@ -36,4 +36,4 @@ * @since 1.7 */ -package org.classpath.icedtea.java.nio.file.spi; +package java.nio.file.spi;
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/util/Scanner.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2657 +0,0 @@ -/* - * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package org.classpath.icedtea.java.util; - -import java.util.regex.*; -import java.io.*; -import java.math.*; -import java.nio.*; -import java.nio.channels.*; -import java.nio.charset.*; -import java.text.*; -import java.util.InputMismatchException; -import java.util.Iterator; -import java.util.Locale; -import java.util.NoSuchElementException; -import sun.misc.LRUCache; - -import org.classpath.icedtea.java.nio.file.FileRef; - -/** - * A simple text scanner which can parse primitive types and strings using - * regular expressions. - * - * <p>A <code>Scanner</code> breaks its input into tokens using a - * delimiter pattern, which by default matches whitespace. The resulting - * tokens may then be converted into values of different types using the - * various <tt>next</tt> methods. - * - * <p>For example, this code allows a user to read a number from - * <tt>System.in</tt>: - * <blockquote><pre> - * Scanner sc = new Scanner(System.in); - * int i = sc.nextInt(); - * </pre></blockquote> - * - * <p>As another example, this code allows <code>long</code> types to be - * assigned from entries in a file <code>myNumbers</code>: - * <blockquote><pre> - * Scanner sc = new Scanner(new File("myNumbers")); - * while (sc.hasNextLong()) { - * long aLong = sc.nextLong(); - * }</pre></blockquote> - * - * <p>The scanner can also use delimiters other than whitespace. This - * example reads several items in from a string: - *<blockquote><pre> - * String input = "1 fish 2 fish red fish blue fish"; - * Scanner s = new Scanner(input).useDelimiter("\\s*fish\\s*"); - * System.out.println(s.nextInt()); - * System.out.println(s.nextInt()); - * System.out.println(s.next()); - * System.out.println(s.next()); - * s.close(); </pre></blockquote> - * <p> - * prints the following output: - * <blockquote><pre> - * 1 - * 2 - * red - * blue </pre></blockquote> - * - * <p>The same output can be generated with this code, which uses a regular - * expression to parse all four tokens at once: - *<blockquote><pre> - * String input = "1 fish 2 fish red fish blue fish"; - * Scanner s = new Scanner(input); - * s.findInLine("(\\d+) fish (\\d+) fish (\\w+) fish (\\w+)"); - * MatchResult result = s.match(); - * for (int i=1; i<=result.groupCount(); i++) - * System.out.println(result.group(i)); - * s.close(); </pre></blockquote> - * - * <p>The <a name="default-delimiter">default whitespace delimiter</a> used - * by a scanner is as recognized by {@link java.lang.Character}.{@link - * java.lang.Character#isWhitespace(char) isWhitespace}. The {@link #reset} - * method will reset the value of the scanner's delimiter to the default - * whitespace delimiter regardless of whether it was previously changed. - * - * <p>A scanning operation may block waiting for input. - * - * <p>The {@link #next} and {@link #hasNext} methods and their - * primitive-type companion methods (such as {@link #nextInt} and - * {@link #hasNextInt}) first skip any input that matches the delimiter - * pattern, and then attempt to return the next token. Both <tt>hasNext</tt> - * and <tt>next</tt> methods may block waiting for further input. Whether a - * <tt>hasNext</tt> method blocks has no connection to whether or not its - * associated <tt>next</tt> method will block. - * - * <p> The {@link #findInLine}, {@link #findWithinHorizon}, and {@link #skip} - * methods operate independently of the delimiter pattern. These methods will - * attempt to match the specified pattern with no regard to delimiters in the - * input and thus can be used in special circumstances where delimiters are - * not relevant. These methods may block waiting for more input. - * - * <p>When a scanner throws an {@link InputMismatchException}, the scanner - * will not pass the token that caused the exception, so that it may be - * retrieved or skipped via some other method. - * - * <p>Depending upon the type of delimiting pattern, empty tokens may be - * returned. For example, the pattern <tt>"\\s+"</tt> will return no empty - * tokens since it matches multiple instances of the delimiter. The delimiting - * pattern <tt>"\\s"</tt> could return empty tokens since it only passes one - * space at a time. - * - * <p> A scanner can read text from any object which implements the {@link - * java.lang.Readable} interface. If an invocation of the underlying - * readable's {@link java.lang.Readable#read} method throws an {@link - * java.io.IOException} then the scanner assumes that the end of the input - * has been reached. The most recent <tt>IOException</tt> thrown by the - * underlying readable can be retrieved via the {@link #ioException} method. - * - * <p>When a <code>Scanner</code> is closed, it will close its input source - * if the source implements the {@link java.io.Closeable} interface. - * - * <p>A <code>Scanner</code> is not safe for multithreaded use without - * external synchronization. - * - * <p>Unless otherwise mentioned, passing a <code>null</code> parameter into - * any method of a <code>Scanner</code> will cause a - * <code>NullPointerException</code> to be thrown. - * - * <p>A scanner will default to interpreting numbers as decimal unless a - * different radix has been set by using the {@link #useRadix} method. The - * {@link #reset} method will reset the value of the scanner's radix to - * <code>10</code> regardless of whether it was previously changed. - * - * <a name="localized-numbers"> - * <h4> Localized numbers </h4> - * - * <p> An instance of this class is capable of scanning numbers in the standard - * formats as well as in the formats of the scanner's locale. A scanner's - * <a name="initial-locale">initial locale </a>is the value returned by the {@link - * java.util.Locale#getDefault} method; it may be changed via the {@link - * #useLocale} method. The {@link #reset} method will reset the value of the - * scanner's locale to the initial locale regardless of whether it was - * previously changed. - * - * <p>The localized formats are defined in terms of the following parameters, - * which for a particular locale are taken from that locale's {@link - * java.text.DecimalFormat DecimalFormat} object, <tt>df</tt>, and its and - * {@link java.text.DecimalFormatSymbols DecimalFormatSymbols} object, - * <tt>dfs</tt>. - * - * <blockquote><table> - * <tr><td valign="top"><i>LocalGroupSeparator </i></td> - * <td valign="top">The character used to separate thousands groups, - * <i>i.e.,</i> <tt>dfs.</tt>{@link - * java.text.DecimalFormatSymbols#getGroupingSeparator - * getGroupingSeparator()}</td></tr> - * <tr><td valign="top"><i>LocalDecimalSeparator </i></td> - * <td valign="top">The character used for the decimal point, - * <i>i.e.,</i> <tt>dfs.</tt>{@link - * java.text.DecimalFormatSymbols#getDecimalSeparator - * getDecimalSeparator()}</td></tr> - * <tr><td valign="top"><i>LocalPositivePrefix </i></td> - * <td valign="top">The string that appears before a positive number (may - * be empty), <i>i.e.,</i> <tt>df.</tt>{@link - * java.text.DecimalFormat#getPositivePrefix - * getPositivePrefix()}</td></tr> - * <tr><td valign="top"><i>LocalPositiveSuffix </i></td> - * <td valign="top">The string that appears after a positive number (may be - * empty), <i>i.e.,</i> <tt>df.</tt>{@link - * java.text.DecimalFormat#getPositiveSuffix - * getPositiveSuffix()}</td></tr> - * <tr><td valign="top"><i>LocalNegativePrefix </i></td> - * <td valign="top">The string that appears before a negative number (may - * be empty), <i>i.e.,</i> <tt>df.</tt>{@link - * java.text.DecimalFormat#getNegativePrefix - * getNegativePrefix()}</td></tr> - * <tr><td valign="top"><i>LocalNegativeSuffix </i></td> - * <td valign="top">The string that appears after a negative number (may be - * empty), <i>i.e.,</i> <tt>df.</tt>{@link - * java.text.DecimalFormat#getNegativeSuffix - * getNegativeSuffix()}</td></tr> - * <tr><td valign="top"><i>LocalNaN </i></td> - * <td valign="top">The string that represents not-a-number for - * floating-point values, - * <i>i.e.,</i> <tt>dfs.</tt>{@link - * java.text.DecimalFormatSymbols#getNaN - * getNaN()}</td></tr> - * <tr><td valign="top"><i>LocalInfinity </i></td> - * <td valign="top">The string that represents infinity for floating-point - * values, <i>i.e.,</i> <tt>dfs.</tt>{@link - * java.text.DecimalFormatSymbols#getInfinity - * getInfinity()}</td></tr> - * </table></blockquote> - * - * <a name="number-syntax"> - * <h4> Number syntax </h4> - * - * <p> The strings that can be parsed as numbers by an instance of this class - * are specified in terms of the following regular-expression grammar, where - * Rmax is the highest digit in the radix being used (for example, Rmax is 9 - * in base 10). - * - * <p> - * <table cellspacing=0 cellpadding=0 align=center> - * - * <tr><td valign=top align=right><i>NonASCIIDigit</i> ::</td> - * <td valign=top>= A non-ASCII character c for which - * {@link java.lang.Character#isDigit Character.isDigit}<tt>(c)</tt> - * returns true</td></tr> - * - * <tr><td> </td></tr> - * - * <tr><td align=right><i>Non0Digit</i> ::</td> - * <td><tt>= [1-</tt><i>Rmax</i><tt>] | </tt><i>NonASCIIDigit</i></td></tr> - * - * <tr><td> </td></tr> - * - * <tr><td align=right><i>Digit</i> ::</td> - * <td><tt>= [0-</tt><i>Rmax</i><tt>] | </tt><i>NonASCIIDigit</i></td></tr> - * - * <tr><td> </td></tr> - * - * <tr><td valign=top align=right><i>GroupedNumeral</i> ::</td> - * <td valign=top> - * <table cellpadding=0 cellspacing=0> - * <tr><td><tt>= ( </tt></td> - * <td><i>Non0Digit</i><tt> - * </tt><i>Digit</i><tt>? - * </tt><i>Digit</i><tt>?</tt></td></tr> - * <tr><td></td> - * <td><tt>( </tt><i>LocalGroupSeparator</i><tt> - * </tt><i>Digit</i><tt> - * </tt><i>Digit</i><tt> - * </tt><i>Digit</i><tt> )+ )</tt></td></tr> - * </table></td></tr> - * - * <tr><td> </td></tr> - * - * <tr><td align=right><i>Numeral</i> ::</td> - * <td><tt>= ( ( </tt><i>Digit</i><tt>+ ) - * | </tt><i>GroupedNumeral</i><tt> )</tt></td></tr> - * - * <tr><td> </td></tr> - * - * <tr><td valign=top align=right> - * <a name="Integer-regex"><i>Integer</i> ::</td> - * <td valign=top><tt>= ( [-+]? ( </tt><i>Numeral</i><tt> - * ) )</tt></td></tr> - * <tr><td></td> - * <td><tt>| </tt><i>LocalPositivePrefix</i><tt> </tt><i>Numeral</i><tt> - * </tt><i>LocalPositiveSuffix</i></td></tr> - * <tr><td></td> - * <td><tt>| </tt><i>LocalNegativePrefix</i><tt> </tt><i>Numeral</i><tt> - * </tt><i>LocalNegativeSuffix</i></td></tr> - * - * <tr><td> </td></tr> - * - * <tr><td align=right><i>DecimalNumeral</i> ::</td> - * <td><tt>= </tt><i>Numeral</i></td></tr> - * <tr><td></td> - * <td><tt>| </tt><i>Numeral</i><tt> - * </tt><i>LocalDecimalSeparator</i><tt> - * </tt><i>Digit</i><tt>*</tt></td></tr> - * <tr><td></td> - * <td><tt>| </tt><i>LocalDecimalSeparator</i><tt> - * </tt><i>Digit</i><tt>+</tt></td></tr> - * - * <tr><td> </td></tr> - * - * <tr><td align=right><i>Exponent</i> ::</td> - * <td><tt>= ( [eE] [+-]? </tt><i>Digit</i><tt>+ )</tt></td></tr> - * - * <tr><td> </td></tr> - * - * <tr><td align=right> - * <a name="Decimal-regex"><i>Decimal</i> ::</td> - * <td><tt>= ( [-+]? </tt><i>DecimalNumeral</i><tt> - * </tt><i>Exponent</i><tt>? )</tt></td></tr> - * <tr><td></td> - * <td><tt>| </tt><i>LocalPositivePrefix</i><tt> - * </tt><i>DecimalNumeral</i><tt> - * </tt><i>LocalPositiveSuffix</i> - * </tt><i>Exponent</i><tt>?</td></tr> - * <tr><td></td> - * <td><tt>| </tt><i>LocalNegativePrefix</i><tt> - * </tt><i>DecimalNumeral</i><tt> - * </tt><i>LocalNegativeSuffix</i> - * </tt><i>Exponent</i><tt>?</td></tr> - * - * <tr><td> </td></tr> - * - * <tr><td align=right><i>HexFloat</i> ::</td> - * <td><tt>= [-+]? 0[xX][0-9a-fA-F]*\.[0-9a-fA-F]+ - * ([pP][-+]?[0-9]+)?</tt></td></tr> - * - * <tr><td> </td></tr> - * - * <tr><td align=right><i>NonNumber</i> ::</td> - * <td valign=top><tt>= NaN - * | </tt><i>LocalNan</i><tt> - * | Infinity - * | </tt><i>LocalInfinity</i></td></tr> - * - * <tr><td> </td></tr> - * - * <tr><td align=right><i>SignedNonNumber</i> ::</td> - * <td><tt>= ( [-+]? </tt><i>NonNumber</i><tt> )</tt></td></tr> - * <tr><td></td> - * <td><tt>| </tt><i>LocalPositivePrefix</i><tt> - * </tt><i>NonNumber</i><tt> - * </tt><i>LocalPositiveSuffix</i></td></tr> - * <tr><td></td> - * <td><tt>| </tt><i>LocalNegativePrefix</i><tt> - * </tt><i>NonNumber</i><tt> - * </tt><i>LocalNegativeSuffix</i></td></tr> - * - * <tr><td> </td></tr> - * - * <tr><td valign=top align=right> - * <a name="Float-regex"><i>Float</i> ::</td> - * <td valign=top><tt>= </tt><i>Decimal</i><tt></td></tr> - * <tr><td></td> - * <td><tt>| </tt><i>HexFloat</i><tt></td></tr> - * <tr><td></td> - * <td><tt>| </tt><i>SignedNonNumber</i><tt></td></tr> - * - * </table> - * </center> - * - * <p> Whitespace is not significant in the above regular expressions. - * - * @since 1.5 - */ -public final class Scanner implements Iterator<String> { - - // Internal buffer used to hold input - private CharBuffer buf; - - // Size of internal character buffer - private static final int BUFFER_SIZE = 1024; // change to 1024; - - // The index into the buffer currently held by the Scanner - private int position; - - // Internal matcher used for finding delimiters - private Matcher matcher; - - // Pattern used to delimit tokens - private Pattern delimPattern; - - // Pattern found in last hasNext operation - private Pattern hasNextPattern; - - // Position after last hasNext operation - private int hasNextPosition; - - // Result after last hasNext operation - private String hasNextResult; - - // The input source - private Readable source; - - // Boolean is true if source is done - private boolean sourceClosed = false; - - // Boolean indicating more input is required - private boolean needInput = false; - - // Boolean indicating if a delim has been skipped this operation - private boolean skipped = false; - - // A store of a position that the scanner may fall back to - private int savedScannerPosition = -1; - - // A cache of the last primitive type scanned - private Object typeCache = null; - - // Boolean indicating if a match result is available - private boolean matchValid = false; - - // Boolean indicating if this scanner has been closed - private boolean closed = false; - - // The current radix used by this scanner - private int radix = 10; - - // The default radix for this scanner - private int defaultRadix = 10; - - // The locale used by this scanner - private Locale locale = null; - - // A cache of the last few recently used Patterns - private LRUCache<String,Pattern> patternCache = - new LRUCache<String,Pattern>(7) { - protected Pattern create(String s) { - return Pattern.compile(s); - } - protected boolean hasName(Pattern p, String s) { - return p.pattern().equals(s); - } - }; - - // A holder of the last IOException encountered - private IOException lastException; - - // A pattern for java whitespace - private static Pattern WHITESPACE_PATTERN = Pattern.compile( - "\\p{javaWhitespace}+"); - - // A pattern for any token - private static Pattern FIND_ANY_PATTERN = Pattern.compile("(?s).*"); - - // A pattern for non-ASCII digits - private static Pattern NON_ASCII_DIGIT = Pattern.compile( - "[\\p{javaDigit}&&[^0-9]]"); - - // Fields and methods to support scanning primitive types - - /** - * Locale dependent values used to scan numbers - */ - private String groupSeparator = "\\,"; - private String decimalSeparator = "\\."; - private String nanString = "NaN"; - private String infinityString = "Infinity"; - private String positivePrefix = ""; - private String negativePrefix = "\\-"; - private String positiveSuffix = ""; - private String negativeSuffix = ""; - - /** - * Fields and an accessor method to match booleans - */ - private static volatile Pattern boolPattern; - private static final String BOOLEAN_PATTERN = "true|false"; - private static Pattern boolPattern() { - Pattern bp = boolPattern; - if (bp == null) - boolPattern = bp = Pattern.compile(BOOLEAN_PATTERN, - Pattern.CASE_INSENSITIVE); - return bp; - } - - /** - * Fields and methods to match bytes, shorts, ints, and longs - */ - private Pattern integerPattern; - private String digits = "0123456789abcdefghijklmnopqrstuvwxyz"; - private String non0Digit = "[\\p{javaDigit}&&[^0]]"; - private int SIMPLE_GROUP_INDEX = 5; - private String buildIntegerPatternString() { - String radixDigits = digits.substring(0, radix); - // \\p{javaDigit} is not guaranteed to be appropriate - // here but what can we do? The final authority will be - // whatever parse method is invoked, so ultimately the - // Scanner will do the right thing - String digit = "((?i)["+radixDigits+"]|\\p{javaDigit})"; - String groupedNumeral = "("+non0Digit+digit+"?"+digit+"?("+ - groupSeparator+digit+digit+digit+")+)"; - // digit++ is the possessive form which is necessary for reducing - // backtracking that would otherwise cause unacceptable performance - String numeral = "(("+ digit+"++)|"+groupedNumeral+")"; - String javaStyleInteger = "([-+]?(" + numeral + "))"; - String negativeInteger = negativePrefix + numeral + negativeSuffix; - String positiveInteger = positivePrefix + numeral + positiveSuffix; - return "("+ javaStyleInteger + ")|(" + - positiveInteger + ")|(" + - negativeInteger + ")"; - } - private Pattern integerPattern() { - if (integerPattern == null) { - integerPattern = patternCache.forName(buildIntegerPatternString()); - } - return integerPattern; - } - - /** - * Fields and an accessor method to match line separators - */ - private static volatile Pattern separatorPattern; - private static volatile Pattern linePattern; - private static final String LINE_SEPARATOR_PATTERN = - "\r\n|[\n\r\u2028\u2029\u0085]"; - private static final String LINE_PATTERN = ".*("+LINE_SEPARATOR_PATTERN+")|.+$"; - - private static Pattern separatorPattern() { - Pattern sp = separatorPattern; - if (sp == null) - separatorPattern = sp = Pattern.compile(LINE_SEPARATOR_PATTERN); - return sp; - } - - private static Pattern linePattern() { - Pattern lp = linePattern; - if (lp == null) - linePattern = lp = Pattern.compile(LINE_PATTERN); - return lp; - } - - /** - * Fields and methods to match floats and doubles - */ - private Pattern floatPattern; - private Pattern decimalPattern; - private void buildFloatAndDecimalPattern() { - // \\p{javaDigit} may not be perfect, see above - String digit = "([0-9]|(\\p{javaDigit}))"; - String exponent = "([eE][+-]?"+digit+"+)?"; - String groupedNumeral = "("+non0Digit+digit+"?"+digit+"?("+ - groupSeparator+digit+digit+digit+")+)"; - // Once again digit++ is used for performance, as above - String numeral = "(("+digit+"++)|"+groupedNumeral+")"; - String decimalNumeral = "("+numeral+"|"+numeral + - decimalSeparator + digit + "*+|"+ decimalSeparator + - digit + "++)"; - String nonNumber = "(NaN|"+nanString+"|Infinity|"+ - infinityString+")"; - String positiveFloat = "(" + positivePrefix + decimalNumeral + - positiveSuffix + exponent + ")"; - String negativeFloat = "(" + negativePrefix + decimalNumeral + - negativeSuffix + exponent + ")"; - String decimal = "(([-+]?" + decimalNumeral + exponent + ")|"+ - positiveFloat + "|" + negativeFloat + ")"; - String hexFloat = - "[-+]?0[xX][0-9a-fA-F]*\\.[0-9a-fA-F]+([pP][-+]?[0-9]+)?"; - String positiveNonNumber = "(" + positivePrefix + nonNumber + - positiveSuffix + ")"; - String negativeNonNumber = "(" + negativePrefix + nonNumber + - negativeSuffix + ")"; - String signedNonNumber = "(([-+]?"+nonNumber+")|" + - positiveNonNumber + "|" + - negativeNonNumber + ")"; - floatPattern = Pattern.compile(decimal + "|" + hexFloat + "|" + - signedNonNumber); - decimalPattern = Pattern.compile(decimal); - } - private Pattern floatPattern() { - if (floatPattern == null) { - buildFloatAndDecimalPattern(); - } - return floatPattern; - } - private Pattern decimalPattern() { - if (decimalPattern == null) { - buildFloatAndDecimalPattern(); - } - return decimalPattern; - } - - // Constructors - - /** - * Constructs a <code>Scanner</code> that returns values scanned - * from the specified source delimited by the specified pattern. - * - * @param source A character source implementing the Readable interface - * @param pattern A delimiting pattern - * @return A scanner with the specified source and pattern - */ - private Scanner(Readable source, Pattern pattern) { - if (source == null) - throw new NullPointerException("source"); - if (pattern == null) - throw new NullPointerException("pattern"); - this.source = source; - delimPattern = pattern; - buf = CharBuffer.allocate(BUFFER_SIZE); - buf.limit(0); - matcher = delimPattern.matcher(buf); - matcher.useTransparentBounds(true); - matcher.useAnchoringBounds(false); - useLocale(Locale.getDefault()); - } - - /** - * Constructs a new <code>Scanner</code> that produces values scanned - * from the specified source. - * - * @param source A character source implementing the {@link Readable} - * interface - */ - public Scanner(Readable source) { - this(source, WHITESPACE_PATTERN); - } - - /** - * Constructs a new <code>Scanner</code> that produces values scanned - * from the specified input stream. Bytes from the stream are converted - * into characters using the underlying platform's - * {@linkplain java.nio.charset.Charset#defaultCharset() default charset}. - * - * @param source An input stream to be scanned - */ - public Scanner(InputStream source) { - this(new InputStreamReader(source), WHITESPACE_PATTERN); - } - - /** - * Constructs a new <code>Scanner</code> that produces values scanned - * from the specified input stream. Bytes from the stream are converted - * into characters using the specified charset. - * - * @param source An input stream to be scanned - * @param charsetName The encoding type used to convert bytes from the - * stream into characters to be scanned - * @throws IllegalArgumentException if the specified character set - * does not exist - */ - public Scanner(InputStream source, String charsetName) { - this(makeReadable(source, charsetName), WHITESPACE_PATTERN); - } - - private static Readable makeReadable(InputStream source, - String charsetName) - { - if (source == null) - throw new NullPointerException("source"); - InputStreamReader isr = null; - try { - isr = new InputStreamReader(source, charsetName); - } catch (UnsupportedEncodingException uee) { - IllegalArgumentException iae = new IllegalArgumentException(); - iae.initCause(uee); - throw iae; - } - return isr; - } - - /** - * Constructs a new <code>Scanner</code> that produces values scanned - * from the specified file. Bytes from the file are converted into - * characters using the underlying platform's - * {@linkplain java.nio.charset.Charset#defaultCharset() default charset}. - * - * @param source A file to be scanned - * @throws FileNotFoundException if source is not found - */ - public Scanner(File source) - throws FileNotFoundException - { - this((ReadableByteChannel)(new FileInputStream(source).getChannel())); - } - - /** - * Constructs a new <code>Scanner</code> that produces values scanned - * from the specified file. Bytes from the file are converted into - * characters using the specified charset. - * - * @param source A file to be scanned - * @param charsetName The encoding type used to convert bytes from the file - * into characters to be scanned - * @throws FileNotFoundException if source is not found - * @throws IllegalArgumentException if the specified encoding is - * not found - */ - public Scanner(File source, String charsetName) - throws FileNotFoundException - { - this((ReadableByteChannel)(new FileInputStream(source).getChannel()), - charsetName); - } - - /** - * {@note new} - * Constructs a new <code>Scanner</code> that produces values scanned - * from the specified file. Bytes from the file are converted into - * characters using the underlying platform's - * {@linkplain java.nio.charset.Charset#defaultCharset() default charset}. - * - * @param source - * A file to be scanned - * @throws IOException - * if an I/O error occurs opening source - * - * @since 1.7 - */ - public Scanner(FileRef source) - throws IOException - { - this(source.newByteChannel()); - } - - /** - * {@note new} - * Constructs a new <code>Scanner</code> that produces values scanned - * from the specified file. Bytes from the file are converted into - * characters using the specified charset. - * - * @param source - * A file to be scanned - * @param charsetName - * The encoding type used to convert bytes from the file - * into characters to be scanned - * @throws IOException - * if an I/O error occurs opening source - * @throws IllegalArgumentException - * if the specified encoding is not found - * @since 1.7 - */ - public Scanner(FileRef source, String charsetName) - throws IOException - { - this(source.newByteChannel(), charsetName); - } - - /** - * Constructs a new <code>Scanner</code> that produces values scanned - * from the specified string. - * - * @param source A string to scan - */ - public Scanner(String source) { - this(new StringReader(source), WHITESPACE_PATTERN); - } - - /** - * Constructs a new <code>Scanner</code> that produces values scanned - * from the specified channel. Bytes from the source are converted into - * characters using the underlying platform's - * {@linkplain java.nio.charset.Charset#defaultCharset() default charset}. - * - * @param source A channel to scan - */ - public Scanner(ReadableByteChannel source) { - this(makeReadable(source), WHITESPACE_PATTERN); - } - - private static Readable makeReadable(ReadableByteChannel source) { - if (source == null) - throw new NullPointerException("source"); - String defaultCharsetName = - java.nio.charset.Charset.defaultCharset().name(); - return Channels.newReader(source, - java.nio.charset.Charset.defaultCharset().name()); - } - - /** - * Constructs a new <code>Scanner</code> that produces values scanned - * from the specified channel. Bytes from the source are converted into - * characters using the specified charset. - * - * @param source A channel to scan - * @param charsetName The encoding type used to convert bytes from the - * channel into characters to be scanned - * @throws IllegalArgumentException if the specified character set - * does not exist - */ - public Scanner(ReadableByteChannel source, String charsetName) { - this(makeReadable(source, charsetName), WHITESPACE_PATTERN); - } - - private static Readable makeReadable(ReadableByteChannel source, - String charsetName) - { - if (source == null) - throw new NullPointerException("source"); - if (!Charset.isSupported(charsetName)) - throw new IllegalArgumentException(charsetName); - return Channels.newReader(source, charsetName); - } - - // Private primitives used to support scanning - - private void saveState() { - savedScannerPosition = position; - } - - private void revertState() { - this.position = savedScannerPosition; - savedScannerPosition = -1; - skipped = false; - } - - private boolean revertState(boolean b) { - this.position = savedScannerPosition; - savedScannerPosition = -1; - skipped = false; - return b; - } - - private void cacheResult() { - hasNextResult = matcher.group(); - hasNextPosition = matcher.end(); - hasNextPattern = matcher.pattern(); - } - - private void cacheResult(String result) { - hasNextResult = result; - hasNextPosition = matcher.end(); - hasNextPattern = matcher.pattern(); - } - - // Clears both regular cache and type cache - private void clearCaches() { - hasNextPattern = null; - typeCache = null; - } - - // Also clears both the regular cache and the type cache - private String getCachedResult() { - position = hasNextPosition; - hasNextPattern = null; - typeCache = null; - return hasNextResult; - } - - // Also clears both the regular cache and the type cache - private void useTypeCache() { - if (closed) - throw new IllegalStateException("Scanner closed"); - position = hasNextPosition; - hasNextPattern = null; - typeCache = null; - } - - // Tries to read more input. May block. - private void readInput() { - if (buf.limit() == buf.capacity()) - makeSpace(); - - // Prepare to receive data - int p = buf.position(); - buf.position(buf.limit()); - buf.limit(buf.capacity()); - - int n = 0; - try { - n = source.read(buf); - } catch (IOException ioe) { - lastException = ioe; - n = -1; - } - - if (n == -1) { - sourceClosed = true; - needInput = false; - } - - if (n > 0) - needInput = false; - - // Restore current position and limit for reading - buf.limit(buf.position()); - buf.position(p); - } - - // After this method is called there will either be an exception - // or else there will be space in the buffer - private boolean makeSpace() { - clearCaches(); - int offset = savedScannerPosition == -1 ? - position : savedScannerPosition; - buf.position(offset); - // Gain space by compacting buffer - if (offset > 0) { - buf.compact(); - translateSavedIndexes(offset); - position -= offset; - buf.flip(); - return true; - } - // Gain space by growing buffer - int newSize = buf.capacity() * 2; - CharBuffer newBuf = CharBuffer.allocate(newSize); - newBuf.put(buf); - newBuf.flip(); - translateSavedIndexes(offset); - position -= offset; - buf = newBuf; - matcher.reset(buf); - return true; - } - - // When a buffer compaction/reallocation occurs the saved indexes must - // be modified appropriately - private void translateSavedIndexes(int offset) { - if (savedScannerPosition != -1) - savedScannerPosition -= offset; - } - - // If we are at the end of input then NoSuchElement; - // If there is still input left then InputMismatch - private void throwFor() { - skipped = false; - if ((sourceClosed) && (position == buf.limit())) - throw new NoSuchElementException(); - else - throw new InputMismatchException(); - } - - // Returns true if a complete token or partial token is in the buffer. - // It is not necessary to find a complete token since a partial token - // means that there will be another token with or without more input. - private boolean hasTokenInBuffer() { - matchValid = false; - matcher.usePattern(delimPattern); - matcher.region(position, buf.limit()); - - // Skip delims first - if (matcher.lookingAt()) - position = matcher.end(); - - // If we are sitting at the end, no more tokens in buffer - if (position == buf.limit()) - return false; - - return true; - } - - /* - * Returns a "complete token" that matches the specified pattern - * - * A token is complete if surrounded by delims; a partial token - * is prefixed by delims but not postfixed by them - * - * The position is advanced to the end of that complete token - * - * Pattern == null means accept any token at all - * - * Triple return: - * 1. valid string means it was found - * 2. null with needInput=false means we won't ever find it - * 3. null with needInput=true means try again after readInput - */ - private String getCompleteTokenInBuffer(Pattern pattern) { - matchValid = false; - - // Skip delims first - matcher.usePattern(delimPattern); - if (!skipped) { // Enforcing only one skip of leading delims - matcher.region(position, buf.limit()); - if (matcher.lookingAt()) { - // If more input could extend the delimiters then we must wait - // for more input - if (matcher.hitEnd() && !sourceClosed) { - needInput = true; - return null; - } - // The delims were whole and the matcher should skip them - skipped = true; - position = matcher.end(); - } - } - - // If we are sitting at the end, no more tokens in buffer - if (position == buf.limit()) { - if (sourceClosed) - return null; - needInput = true; - return null; - } - - // Must look for next delims. Simply attempting to match the - // pattern at this point may find a match but it might not be - // the first longest match because of missing input, or it might - // match a partial token instead of the whole thing. - - // Then look for next delims - matcher.region(position, buf.limit()); - boolean foundNextDelim = matcher.find(); - if (foundNextDelim && (matcher.end() == position)) { - // Zero length delimiter match; we should find the next one - // using the automatic advance past a zero length match; - // Otherwise we have just found the same one we just skipped - foundNextDelim = matcher.find(); - } - if (foundNextDelim) { - // In the rare case that more input could cause the match - // to be lost and there is more input coming we must wait - // for more input. Note that hitting the end is okay as long - // as the match cannot go away. It is the beginning of the - // next delims we want to be sure about, we don't care if - // they potentially extend further. - if (matcher.requireEnd() && !sourceClosed) { - needInput = true; - return null; - } - int tokenEnd = matcher.start(); - // There is a complete token. - if (pattern == null) { - // Must continue with match to provide valid MatchResult - pattern = FIND_ANY_PATTERN; - } - // Attempt to match against the desired pattern - matcher.usePattern(pattern); - matcher.region(position, tokenEnd); - if (matcher.matches()) { - String s = matcher.group(); - position = matcher.end(); - return s; - } else { // Complete token but it does not match - return null; - } - } - - // If we can't find the next delims but no more input is coming, - // then we can treat the remainder as a whole token - if (sourceClosed) { - if (pattern == null) { - // Must continue with match to provide valid MatchResult - pattern = FIND_ANY_PATTERN; - } - // Last token; Match the pattern here or throw - matcher.usePattern(pattern); - matcher.region(position, buf.limit()); - if (matcher.matches()) { - String s = matcher.group(); - position = matcher.end(); - return s; - } - // Last piece does not match - return null; - } - - // There is a partial token in the buffer; must read more - // to complete it - needInput = true; - return null; - } - - // Finds the specified pattern in the buffer up to horizon. - // Returns a match for the specified input pattern. - private String findPatternInBuffer(Pattern pattern, int horizon) { - matchValid = false; - matcher.usePattern(pattern); - int bufferLimit = buf.limit(); - int horizonLimit = -1; - int searchLimit = bufferLimit; - if (horizon > 0) { - horizonLimit = position + horizon; - if (horizonLimit < bufferLimit) - searchLimit = horizonLimit; - } - matcher.region(position, searchLimit); - if (matcher.find()) { - if (matcher.hitEnd() && (!sourceClosed)) { - // The match may be longer if didn't hit horizon or real end - if (searchLimit != horizonLimit) { - // Hit an artificial end; try to extend the match - needInput = true; - return null; - } - // The match could go away depending on what is next - if ((searchLimit == horizonLimit) && matcher.requireEnd()) { - // Rare case: we hit the end of input and it happens - // that it is at the horizon and the end of input is - // required for the match. - needInput = true; - return null; - } - } - // Did not hit end, or hit real end, or hit horizon - position = matcher.end(); - return matcher.group(); - } - - if (sourceClosed) - return null; - - // If there is no specified horizon, or if we have not searched - // to the specified horizon yet, get more input - if ((horizon == 0) || (searchLimit != horizonLimit)) - needInput = true; - return null; - } - - // Returns a match for the specified input pattern anchored at - // the current position - private String matchPatternInBuffer(Pattern pattern) { - matchValid = false; - matcher.usePattern(pattern); - matcher.region(position, buf.limit()); - if (matcher.lookingAt()) { - if (matcher.hitEnd() && (!sourceClosed)) { - // Get more input and try again - needInput = true; - return null; - } - position = matcher.end(); - return matcher.group(); - } - - if (sourceClosed) - return null; - - // Read more to find pattern - needInput = true; - return null; - } - - // Throws if the scanner is closed - private void ensureOpen() { - if (closed) - throw new IllegalStateException("Scanner closed"); - } - - // Public methods - - /** - * Closes this scanner. - * - * <p> If this scanner has not yet been closed then if its underlying - * {@linkplain java.lang.Readable readable} also implements the {@link - * java.io.Closeable} interface then the readable's <tt>close</tt> method - * will be invoked. If this scanner is already closed then invoking this - * method will have no effect. - * - * <p>Attempting to perform search operations after a scanner has - * been closed will result in an {@link IllegalStateException}. - * - */ - public void close() { - if (closed) - return; - if (source instanceof Closeable) { - try { - ((Closeable)source).close(); - } catch (IOException ioe) { - lastException = ioe; - } - } - sourceClosed = true; - source = null; - closed = true; - } - - /** - * Returns the <code>IOException</code> last thrown by this - * <code>Scanner</code>'s underlying <code>Readable</code>. This method - * returns <code>null</code> if no such exception exists. - * - * @return the last exception thrown by this scanner's readable - */ - public IOException ioException() { - return lastException; - } - - /** - * Returns the <code>Pattern</code> this <code>Scanner</code> is currently - * using to match delimiters. - * - * @return this scanner's delimiting pattern. - */ - public Pattern delimiter() { - return delimPattern; - } - - /** - * Sets this scanner's delimiting pattern to the specified pattern. - * - * @param pattern A delimiting pattern - * @return this scanner - */ - public Scanner useDelimiter(Pattern pattern) { - delimPattern = pattern; - return this; - } - - /** - * Sets this scanner's delimiting pattern to a pattern constructed from - * the specified <code>String</code>. - * - * <p> An invocation of this method of the form - * <tt>useDelimiter(pattern)</tt> behaves in exactly the same way as the - * invocation <tt>useDelimiter(Pattern.compile(pattern))</tt>. - * - * <p> Invoking the {@link #reset} method will set the scanner's delimiter - * to the <a href= "#default-delimiter">default</a>. - * - * @param pattern A string specifying a delimiting pattern - * @return this scanner - */ - public Scanner useDelimiter(String pattern) { - delimPattern = patternCache.forName(pattern); - return this; - } - - /** - * Returns this scanner's locale. - * - * <p>A scanner's locale affects many elements of its default - * primitive matching regular expressions; see - * <a href= "#localized-numbers">localized numbers</a> above. - * - * @return this scanner's locale - */ - public Locale locale() { - return this.locale; - } - - /** - * Sets this scanner's locale to the specified locale. - * - * <p>A scanner's locale affects many elements of its default - * primitive matching regular expressions; see - * <a href= "#localized-numbers">localized numbers</a> above. - * - * <p>Invoking the {@link #reset} method will set the scanner's locale to - * the <a href= "#initial-locale">initial locale</a>. - * - * @param locale A string specifying the locale to use - * @return this scanner - */ - public Scanner useLocale(Locale locale) { - if (locale.equals(this.locale)) - return this; - - this.locale = locale; - DecimalFormat df = - (DecimalFormat)NumberFormat.getNumberInstance(locale); - DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(locale); - - // These must be literalized to avoid collision with regex - // metacharacters such as dot or parenthesis - groupSeparator = "\\" + dfs.getGroupingSeparator(); - decimalSeparator = "\\" + dfs.getDecimalSeparator(); - - // Quoting the nonzero length locale-specific things - // to avoid potential conflict with metacharacters - nanString = "\\Q" + dfs.getNaN() + "\\E"; - infinityString = "\\Q" + dfs.getInfinity() + "\\E"; - positivePrefix = df.getPositivePrefix(); - if (positivePrefix.length() > 0) - positivePrefix = "\\Q" + positivePrefix + "\\E"; - negativePrefix = df.getNegativePrefix(); - if (negativePrefix.length() > 0) - negativePrefix = "\\Q" + negativePrefix + "\\E"; - positiveSuffix = df.getPositiveSuffix(); - if (positiveSuffix.length() > 0) - positiveSuffix = "\\Q" + positiveSuffix + "\\E"; - negativeSuffix = df.getNegativeSuffix(); - if (negativeSuffix.length() > 0) - negativeSuffix = "\\Q" + negativeSuffix + "\\E"; - - // Force rebuilding and recompilation of locale dependent - // primitive patterns - integerPattern = null; - floatPattern = null; - - return this; - } - - /** - * Returns this scanner's default radix. - * - * <p>A scanner's radix affects elements of its default - * number matching regular expressions; see - * <a href= "#localized-numbers">localized numbers</a> above. - * - * @return the default radix of this scanner - */ - public int radix() { - return this.defaultRadix; - } - - /** - * Sets this scanner's default radix to the specified radix. - * - * <p>A scanner's radix affects elements of its default - * number matching regular expressions; see - * <a href= "#localized-numbers">localized numbers</a> above. - * - * <p>If the radix is less than <code>Character.MIN_RADIX</code> - * or greater than <code>Character.MAX_RADIX</code>, then an - * <code>IllegalArgumentException</code> is thrown. - * - * <p>Invoking the {@link #reset} method will set the scanner's radix to - * <code>10</code>. - * - * @param radix The radix to use when scanning numbers - * @return this scanner - * @throws IllegalArgumentException if radix is out of range - */ - public Scanner useRadix(int radix) { - if ((radix < Character.MIN_RADIX) || (radix > Character.MAX_RADIX)) - throw new IllegalArgumentException("radix:"+radix); - - if (this.defaultRadix == radix) - return this; - this.defaultRadix = radix; - // Force rebuilding and recompilation of radix dependent patterns - integerPattern = null; - return this; - } - - // The next operation should occur in the specified radix but - // the default is left untouched. - private void setRadix(int radix) { - if (this.radix != radix) { - // Force rebuilding and recompilation of radix dependent patterns - integerPattern = null; - this.radix = radix; - } - } - - /** - * Returns the match result of the last scanning operation performed - * by this scanner. This method throws <code>IllegalStateException</code> - * if no match has been performed, or if the last match was - * not successful. - * - * <p>The various <code>next</code>methods of <code>Scanner</code> - * make a match result available if they complete without throwing an - * exception. For instance, after an invocation of the {@link #nextInt} - * method that returned an int, this method returns a - * <code>MatchResult</code> for the search of the - * <a href="#Integer-regex"><i>Integer</i></a> regular expression - * defined above. Similarly the {@link #findInLine}, - * {@link #findWithinHorizon}, and {@link #skip} methods will make a - * match available if they succeed. - * - * @return a match result for the last match operation - * @throws IllegalStateException If no match result is available - */ - public MatchResult match() { - if (!matchValid) - throw new IllegalStateException("No match result available"); - return matcher.toMatchResult(); - } - - /** - * <p>Returns the string representation of this <code>Scanner</code>. The - * string representation of a <code>Scanner</code> contains information - * that may be useful for debugging. The exact format is unspecified. - * - * @return The string representation of this scanner - */ - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("java.util.Scanner"); - sb.append("[delimiters=" + delimPattern + "]"); - sb.append("[position=" + position + "]"); - sb.append("[match valid=" + matchValid + "]"); - sb.append("[need input=" + needInput + "]"); - sb.append("[source closed=" + sourceClosed + "]"); - sb.append("[skipped=" + skipped + "]"); - sb.append("[group separator=" + groupSeparator + "]"); - sb.append("[decimal separator=" + decimalSeparator + "]"); - sb.append("[positive prefix=" + positivePrefix + "]"); - sb.append("[negative prefix=" + negativePrefix + "]"); - sb.append("[positive suffix=" + positiveSuffix + "]"); - sb.append("[negative suffix=" + negativeSuffix + "]"); - sb.append("[NaN string=" + nanString + "]"); - sb.append("[infinity string=" + infinityString + "]"); - return sb.toString(); - } - - /** - * Returns true if this scanner has another token in its input. - * This method may block while waiting for input to scan. - * The scanner does not advance past any input. - * - * @return true if and only if this scanner has another token - * @throws IllegalStateException if this scanner is closed - * @see java.util.Iterator - */ - public boolean hasNext() { - ensureOpen(); - saveState(); - while (!sourceClosed) { - if (hasTokenInBuffer()) - return revertState(true); - readInput(); - } - boolean result = hasTokenInBuffer(); - return revertState(result); - } - - /** - * Finds and returns the next complete token from this scanner. - * A complete token is preceded and followed by input that matches - * the delimiter pattern. This method may block while waiting for input - * to scan, even if a previous invocation of {@link #hasNext} returned - * <code>true</code>. - * - * @return the next token - * @throws NoSuchElementException if no more tokens are available - * @throws IllegalStateException if this scanner is closed - * @see java.util.Iterator - */ - public String next() { - ensureOpen(); - clearCaches(); - - while (true) { - String token = getCompleteTokenInBuffer(null); - if (token != null) { - matchValid = true; - skipped = false; - return token; - } - if (needInput) - readInput(); - else - throwFor(); - } - } - - /** - * The remove operation is not supported by this implementation of - * <code>Iterator</code>. - * - * @throws UnsupportedOperationException if this method is invoked. - * @see java.util.Iterator - */ - public void remove() { - throw new UnsupportedOperationException(); - } - - /** - * Returns true if the next token matches the pattern constructed from the - * specified string. The scanner does not advance past any input. - * - * <p> An invocation of this method of the form <tt>hasNext(pattern)</tt> - * behaves in exactly the same way as the invocation - * <tt>hasNext(Pattern.compile(pattern))</tt>. - * - * @param pattern a string specifying the pattern to scan - * @return true if and only if this scanner has another token matching - * the specified pattern - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNext(String pattern) { - return hasNext(patternCache.forName(pattern)); - } - - /** - * Returns the next token if it matches the pattern constructed from the - * specified string. If the match is successful, the scanner advances - * past the input that matched the pattern. - * - * <p> An invocation of this method of the form <tt>next(pattern)</tt> - * behaves in exactly the same way as the invocation - * <tt>next(Pattern.compile(pattern))</tt>. - * - * @param pattern a string specifying the pattern to scan - * @return the next token - * @throws NoSuchElementException if no such tokens are available - * @throws IllegalStateException if this scanner is closed - */ - public String next(String pattern) { - return next(patternCache.forName(pattern)); - } - - /** - * Returns true if the next complete token matches the specified pattern. - * A complete token is prefixed and postfixed by input that matches - * the delimiter pattern. This method may block while waiting for input. - * The scanner does not advance past any input. - * - * @param pattern the pattern to scan for - * @return true if and only if this scanner has another token matching - * the specified pattern - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNext(Pattern pattern) { - ensureOpen(); - if (pattern == null) - throw new NullPointerException(); - hasNextPattern = null; - saveState(); - - while (true) { - if (getCompleteTokenInBuffer(pattern) != null) { - matchValid = true; - cacheResult(); - return revertState(true); - } - if (needInput) - readInput(); - else - return revertState(false); - } - } - - /** - * Returns the next token if it matches the specified pattern. This - * method may block while waiting for input to scan, even if a previous - * invocation of {@link #hasNext(Pattern)} returned <code>true</code>. - * If the match is successful, the scanner advances past the input that - * matched the pattern. - * - * @param pattern the pattern to scan for - * @return the next token - * @throws NoSuchElementException if no more tokens are available - * @throws IllegalStateException if this scanner is closed - */ - public String next(Pattern pattern) { - ensureOpen(); - if (pattern == null) - throw new NullPointerException(); - - // Did we already find this pattern? - if (hasNextPattern == pattern) - return getCachedResult(); - clearCaches(); - - // Search for the pattern - while (true) { - String token = getCompleteTokenInBuffer(pattern); - if (token != null) { - matchValid = true; - skipped = false; - return token; - } - if (needInput) - readInput(); - else - throwFor(); - } - } - - /** - * Returns true if there is another line in the input of this scanner. - * This method may block while waiting for input. The scanner does not - * advance past any input. - * - * @return true if and only if this scanner has another line of input - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextLine() { - saveState(); - - String result = findWithinHorizon(linePattern(), 0); - if (result != null) { - MatchResult mr = this.match(); - String lineSep = mr.group(1); - if (lineSep != null) { - result = result.substring(0, result.length() - - lineSep.length()); - cacheResult(result); - - } else { - cacheResult(); - } - } - revertState(); - return (result != null); - } - - /** - * Advances this scanner past the current line and returns the input - * that was skipped. - * - * This method returns the rest of the current line, excluding any line - * separator at the end. The position is set to the beginning of the next - * line. - * - * <p>Since this method continues to search through the input looking - * for a line separator, it may buffer all of the input searching for - * the line to skip if no line separators are present. - * - * @return the line that was skipped - * @throws NoSuchElementException if no line was found - * @throws IllegalStateException if this scanner is closed - */ - public String nextLine() { - if (hasNextPattern == linePattern()) - return getCachedResult(); - clearCaches(); - - String result = findWithinHorizon(linePattern, 0); - if (result == null) - throw new NoSuchElementException("No line found"); - MatchResult mr = this.match(); - String lineSep = mr.group(1); - if (lineSep != null) - result = result.substring(0, result.length() - lineSep.length()); - if (result == null) - throw new NoSuchElementException(); - else - return result; - } - - // Public methods that ignore delimiters - - /** - * Attempts to find the next occurrence of a pattern constructed from the - * specified string, ignoring delimiters. - * - * <p>An invocation of this method of the form <tt>findInLine(pattern)</tt> - * behaves in exactly the same way as the invocation - * <tt>findInLine(Pattern.compile(pattern))</tt>. - * - * @param pattern a string specifying the pattern to search for - * @return the text that matched the specified pattern - * @throws IllegalStateException if this scanner is closed - */ - public String findInLine(String pattern) { - return findInLine(patternCache.forName(pattern)); - } - - /** - * Attempts to find the next occurrence of the specified pattern ignoring - * delimiters. If the pattern is found before the next line separator, the - * scanner advances past the input that matched and returns the string that - * matched the pattern. - * If no such pattern is detected in the input up to the next line - * separator, then <code>null</code> is returned and the scanner's - * position is unchanged. This method may block waiting for input that - * matches the pattern. - * - * <p>Since this method continues to search through the input looking - * for the specified pattern, it may buffer all of the input searching for - * the desired token if no line separators are present. - * - * @param pattern the pattern to scan for - * @return the text that matched the specified pattern - * @throws IllegalStateException if this scanner is closed - */ - public String findInLine(Pattern pattern) { - ensureOpen(); - if (pattern == null) - throw new NullPointerException(); - clearCaches(); - // Expand buffer to include the next newline or end of input - int endPosition = 0; - saveState(); - while (true) { - String token = findPatternInBuffer(separatorPattern(), 0); - if (token != null) { - endPosition = matcher.start(); - break; // up to next newline - } - if (needInput) { - readInput(); - } else { - endPosition = buf.limit(); - break; // up to end of input - } - } - revertState(); - int horizonForLine = endPosition - position; - // If there is nothing between the current pos and the next - // newline simply return null, invoking findWithinHorizon - // with "horizon=0" will scan beyond the line bound. - if (horizonForLine == 0) - return null; - // Search for the pattern - return findWithinHorizon(pattern, horizonForLine); - } - - /** - * Attempts to find the next occurrence of a pattern constructed from the - * specified string, ignoring delimiters. - * - * <p>An invocation of this method of the form - * <tt>findWithinHorizon(pattern)</tt> behaves in exactly the same way as - * the invocation - * <tt>findWithinHorizon(Pattern.compile(pattern, horizon))</tt>. - * - * @param pattern a string specifying the pattern to search for - * @return the text that matched the specified pattern - * @throws IllegalStateException if this scanner is closed - * @throws IllegalArgumentException if horizon is negative - */ - public String findWithinHorizon(String pattern, int horizon) { - return findWithinHorizon(patternCache.forName(pattern), horizon); - } - - /** - * Attempts to find the next occurrence of the specified pattern. - * - * <p>This method searches through the input up to the specified - * search horizon, ignoring delimiters. If the pattern is found the - * scanner advances past the input that matched and returns the string - * that matched the pattern. If no such pattern is detected then the - * null is returned and the scanner's position remains unchanged. This - * method may block waiting for input that matches the pattern. - * - * <p>A scanner will never search more than <code>horizon</code> code - * points beyond its current position. Note that a match may be clipped - * by the horizon; that is, an arbitrary match result may have been - * different if the horizon had been larger. The scanner treats the - * horizon as a transparent, non-anchoring bound (see {@link - * Matcher#useTransparentBounds} and {@link Matcher#useAnchoringBounds}). - * - * <p>If horizon is <code>0</code>, then the horizon is ignored and - * this method continues to search through the input looking for the - * specified pattern without bound. In this case it may buffer all of - * the input searching for the pattern. - * - * <p>If horizon is negative, then an IllegalArgumentException is - * thrown. - * - * @param pattern the pattern to scan for - * @return the text that matched the specified pattern - * @throws IllegalStateException if this scanner is closed - * @throws IllegalArgumentException if horizon is negative - */ - public String findWithinHorizon(Pattern pattern, int horizon) { - ensureOpen(); - if (pattern == null) - throw new NullPointerException(); - if (horizon < 0) - throw new IllegalArgumentException("horizon < 0"); - clearCaches(); - - // Search for the pattern - while (true) { - String token = findPatternInBuffer(pattern, horizon); - if (token != null) { - matchValid = true; - return token; - } - if (needInput) - readInput(); - else - break; // up to end of input - } - return null; - } - - /** - * Skips input that matches the specified pattern, ignoring delimiters. - * This method will skip input if an anchored match of the specified - * pattern succeeds. - * - * <p>If a match to the specified pattern is not found at the - * current position, then no input is skipped and a - * <tt>NoSuchElementException</tt> is thrown. - * - * <p>Since this method seeks to match the specified pattern starting at - * the scanner's current position, patterns that can match a lot of - * input (".*", for example) may cause the scanner to buffer a large - * amount of input. - * - * <p>Note that it is possible to skip something without risking a - * <code>NoSuchElementException</code> by using a pattern that can - * match nothing, e.g., <code>sc.skip("[ \t]*")</code>. - * - * @param pattern a string specifying the pattern to skip over - * @return this scanner - * @throws NoSuchElementException if the specified pattern is not found - * @throws IllegalStateException if this scanner is closed - */ - public Scanner skip(Pattern pattern) { - ensureOpen(); - if (pattern == null) - throw new NullPointerException(); - clearCaches(); - - // Search for the pattern - while (true) { - String token = matchPatternInBuffer(pattern); - if (token != null) { - matchValid = true; - position = matcher.end(); - return this; - } - if (needInput) - readInput(); - else - throw new NoSuchElementException(); - } - } - - /** - * Skips input that matches a pattern constructed from the specified - * string. - * - * <p> An invocation of this method of the form <tt>skip(pattern)</tt> - * behaves in exactly the same way as the invocation - * <tt>skip(Pattern.compile(pattern))</tt>. - * - * @param pattern a string specifying the pattern to skip over - * @return this scanner - * @throws IllegalStateException if this scanner is closed - */ - public Scanner skip(String pattern) { - return skip(patternCache.forName(pattern)); - } - - // Convenience methods for scanning primitives - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as a boolean value using a case insensitive pattern - * created from the string "true|false". The scanner does not - * advance past the input that matched. - * - * @return true if and only if this scanner's next token is a valid - * boolean value - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextBoolean() { - return hasNext(boolPattern()); - } - - /** - * Scans the next token of the input into a boolean value and returns - * that value. This method will throw <code>InputMismatchException</code> - * if the next token cannot be translated into a valid boolean value. - * If the match is successful, the scanner advances past the input that - * matched. - * - * @return the boolean scanned from the input - * @throws InputMismatchException if the next token is not a valid boolean - * @throws NoSuchElementException if input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public boolean nextBoolean() { - clearCaches(); - return Boolean.parseBoolean(next(boolPattern())); - } - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as a byte value in the default radix using the - * {@link #nextByte} method. The scanner does not advance past any input. - * - * @return true if and only if this scanner's next token is a valid - * byte value - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextByte() { - return hasNextByte(defaultRadix); - } - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as a byte value in the specified radix using the - * {@link #nextByte} method. The scanner does not advance past any input. - * - * @param radix the radix used to interpret the token as a byte value - * @return true if and only if this scanner's next token is a valid - * byte value - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextByte(int radix) { - setRadix(radix); - boolean result = hasNext(integerPattern()); - if (result) { // Cache it - try { - String s = (matcher.group(SIMPLE_GROUP_INDEX) == null) ? - processIntegerToken(hasNextResult) : - hasNextResult; - typeCache = Byte.parseByte(s, radix); - } catch (NumberFormatException nfe) { - result = false; - } - } - return result; - } - - /** - * Scans the next token of the input as a <tt>byte</tt>. - * - * <p> An invocation of this method of the form - * <tt>nextByte()</tt> behaves in exactly the same way as the - * invocation <tt>nextByte(radix)</tt>, where <code>radix</code> - * is the default radix of this scanner. - * - * @return the <tt>byte</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Integer</i> - * regular expression, or is out of range - * @throws NoSuchElementException if input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public byte nextByte() { - return nextByte(defaultRadix); - } - - /** - * Scans the next token of the input as a <tt>byte</tt>. - * This method will throw <code>InputMismatchException</code> - * if the next token cannot be translated into a valid byte value as - * described below. If the translation is successful, the scanner advances - * past the input that matched. - * - * <p> If the next token matches the <a - * href="#Integer-regex"><i>Integer</i></a> regular expression defined - * above then the token is converted into a <tt>byte</tt> value as if by - * removing all locale specific prefixes, group separators, and locale - * specific suffixes, then mapping non-ASCII digits into ASCII - * digits via {@link Character#digit Character.digit}, prepending a - * negative sign (-) if the locale specific negative prefixes and suffixes - * were present, and passing the resulting string to - * {@link Byte#parseByte(String, int) Byte.parseByte} with the - * specified radix. - * - * @param radix the radix used to interpret the token as a byte value - * @return the <tt>byte</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Integer</i> - * regular expression, or is out of range - * @throws NoSuchElementException if input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public byte nextByte(int radix) { - // Check cached result - if ((typeCache != null) && (typeCache instanceof Byte) - && this.radix == radix) { - byte val = ((Byte)typeCache).byteValue(); - useTypeCache(); - return val; - } - setRadix(radix); - clearCaches(); - // Search for next byte - try { - String s = next(integerPattern()); - if (matcher.group(SIMPLE_GROUP_INDEX) == null) - s = processIntegerToken(s); - return Byte.parseByte(s, radix); - } catch (NumberFormatException nfe) { - position = matcher.start(); // don't skip bad token - throw new InputMismatchException(nfe.getMessage()); - } - } - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as a short value in the default radix using the - * {@link #nextShort} method. The scanner does not advance past any input. - * - * @return true if and only if this scanner's next token is a valid - * short value in the default radix - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextShort() { - return hasNextShort(defaultRadix); - } - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as a short value in the specified radix using the - * {@link #nextShort} method. The scanner does not advance past any input. - * - * @param radix the radix used to interpret the token as a short value - * @return true if and only if this scanner's next token is a valid - * short value in the specified radix - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextShort(int radix) { - setRadix(radix); - boolean result = hasNext(integerPattern()); - if (result) { // Cache it - try { - String s = (matcher.group(SIMPLE_GROUP_INDEX) == null) ? - processIntegerToken(hasNextResult) : - hasNextResult; - typeCache = Short.parseShort(s, radix); - } catch (NumberFormatException nfe) { - result = false; - } - } - return result; - } - - /** - * Scans the next token of the input as a <tt>short</tt>. - * - * <p> An invocation of this method of the form - * <tt>nextShort()</tt> behaves in exactly the same way as the - * invocation <tt>nextShort(radix)</tt>, where <code>radix</code> - * is the default radix of this scanner. - * - * @return the <tt>short</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Integer</i> - * regular expression, or is out of range - * @throws NoSuchElementException if input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public short nextShort() { - return nextShort(defaultRadix); - } - - /** - * Scans the next token of the input as a <tt>short</tt>. - * This method will throw <code>InputMismatchException</code> - * if the next token cannot be translated into a valid short value as - * described below. If the translation is successful, the scanner advances - * past the input that matched. - * - * <p> If the next token matches the <a - * href="#Integer-regex"><i>Integer</i></a> regular expression defined - * above then the token is converted into a <tt>short</tt> value as if by - * removing all locale specific prefixes, group separators, and locale - * specific suffixes, then mapping non-ASCII digits into ASCII - * digits via {@link Character#digit Character.digit}, prepending a - * negative sign (-) if the locale specific negative prefixes and suffixes - * were present, and passing the resulting string to - * {@link Short#parseShort(String, int) Short.parseShort} with the - * specified radix. - * - * @param radix the radix used to interpret the token as a short value - * @return the <tt>short</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Integer</i> - * regular expression, or is out of range - * @throws NoSuchElementException if input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public short nextShort(int radix) { - // Check cached result - if ((typeCache != null) && (typeCache instanceof Short) - && this.radix == radix) { - short val = ((Short)typeCache).shortValue(); - useTypeCache(); - return val; - } - setRadix(radix); - clearCaches(); - // Search for next short - try { - String s = next(integerPattern()); - if (matcher.group(SIMPLE_GROUP_INDEX) == null) - s = processIntegerToken(s); - return Short.parseShort(s, radix); - } catch (NumberFormatException nfe) { - position = matcher.start(); // don't skip bad token - throw new InputMismatchException(nfe.getMessage()); - } - } - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as an int value in the default radix using the - * {@link #nextInt} method. The scanner does not advance past any input. - * - * @return true if and only if this scanner's next token is a valid - * int value - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextInt() { - return hasNextInt(defaultRadix); - } - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as an int value in the specified radix using the - * {@link #nextInt} method. The scanner does not advance past any input. - * - * @param radix the radix used to interpret the token as an int value - * @return true if and only if this scanner's next token is a valid - * int value - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextInt(int radix) { - setRadix(radix); - boolean result = hasNext(integerPattern()); - if (result) { // Cache it - try { - String s = (matcher.group(SIMPLE_GROUP_INDEX) == null) ? - processIntegerToken(hasNextResult) : - hasNextResult; - typeCache = Integer.parseInt(s, radix); - } catch (NumberFormatException nfe) { - result = false; - } - } - return result; - } - - /** - * The integer token must be stripped of prefixes, group separators, - * and suffixes, non ascii digits must be converted into ascii digits - * before parse will accept it. - */ - private String processIntegerToken(String token) { - String result = token.replaceAll(""+groupSeparator, ""); - boolean isNegative = false; - int preLen = negativePrefix.length(); - if ((preLen > 0) && result.startsWith(negativePrefix)) { - isNegative = true; - result = result.substring(preLen); - } - int sufLen = negativeSuffix.length(); - if ((sufLen > 0) && result.endsWith(negativeSuffix)) { - isNegative = true; - result = result.substring(result.length() - sufLen, - result.length()); - } - if (isNegative) - result = "-" + result; - return result; - } - - /** - * Scans the next token of the input as an <tt>int</tt>. - * - * <p> An invocation of this method of the form - * <tt>nextInt()</tt> behaves in exactly the same way as the - * invocation <tt>nextInt(radix)</tt>, where <code>radix</code> - * is the default radix of this scanner. - * - * @return the <tt>int</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Integer</i> - * regular expression, or is out of range - * @throws NoSuchElementException if input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public int nextInt() { - return nextInt(defaultRadix); - } - - /** - * Scans the next token of the input as an <tt>int</tt>. - * This method will throw <code>InputMismatchException</code> - * if the next token cannot be translated into a valid int value as - * described below. If the translation is successful, the scanner advances - * past the input that matched. - * - * <p> If the next token matches the <a - * href="#Integer-regex"><i>Integer</i></a> regular expression defined - * above then the token is converted into an <tt>int</tt> value as if by - * removing all locale specific prefixes, group separators, and locale - * specific suffixes, then mapping non-ASCII digits into ASCII - * digits via {@link Character#digit Character.digit}, prepending a - * negative sign (-) if the locale specific negative prefixes and suffixes - * were present, and passing the resulting string to - * {@link Integer#parseInt(String, int) Integer.parseInt} with the - * specified radix. - * - * @param radix the radix used to interpret the token as an int value - * @return the <tt>int</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Integer</i> - * regular expression, or is out of range - * @throws NoSuchElementException if input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public int nextInt(int radix) { - // Check cached result - if ((typeCache != null) && (typeCache instanceof Integer) - && this.radix == radix) { - int val = ((Integer)typeCache).intValue(); - useTypeCache(); - return val; - } - setRadix(radix); - clearCaches(); - // Search for next int - try { - String s = next(integerPattern()); - if (matcher.group(SIMPLE_GROUP_INDEX) == null) - s = processIntegerToken(s); - return Integer.parseInt(s, radix); - } catch (NumberFormatException nfe) { - position = matcher.start(); // don't skip bad token - throw new InputMismatchException(nfe.getMessage()); - } - } - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as a long value in the default radix using the - * {@link #nextLong} method. The scanner does not advance past any input. - * - * @return true if and only if this scanner's next token is a valid - * long value - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextLong() { - return hasNextLong(defaultRadix); - } - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as a long value in the specified radix using the - * {@link #nextLong} method. The scanner does not advance past any input. - * - * @param radix the radix used to interpret the token as a long value - * @return true if and only if this scanner's next token is a valid - * long value - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextLong(int radix) { - setRadix(radix); - boolean result = hasNext(integerPattern()); - if (result) { // Cache it - try { - String s = (matcher.group(SIMPLE_GROUP_INDEX) == null) ? - processIntegerToken(hasNextResult) : - hasNextResult; - typeCache = Long.parseLong(s, radix); - } catch (NumberFormatException nfe) { - result = false; - } - } - return result; - } - - /** - * Scans the next token of the input as a <tt>long</tt>. - * - * <p> An invocation of this method of the form - * <tt>nextLong()</tt> behaves in exactly the same way as the - * invocation <tt>nextLong(radix)</tt>, where <code>radix</code> - * is the default radix of this scanner. - * - * @return the <tt>long</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Integer</i> - * regular expression, or is out of range - * @throws NoSuchElementException if input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public long nextLong() { - return nextLong(defaultRadix); - } - - /** - * Scans the next token of the input as a <tt>long</tt>. - * This method will throw <code>InputMismatchException</code> - * if the next token cannot be translated into a valid long value as - * described below. If the translation is successful, the scanner advances - * past the input that matched. - * - * <p> If the next token matches the <a - * href="#Integer-regex"><i>Integer</i></a> regular expression defined - * above then the token is converted into a <tt>long</tt> value as if by - * removing all locale specific prefixes, group separators, and locale - * specific suffixes, then mapping non-ASCII digits into ASCII - * digits via {@link Character#digit Character.digit}, prepending a - * negative sign (-) if the locale specific negative prefixes and suffixes - * were present, and passing the resulting string to - * {@link Long#parseLong(String, int) Long.parseLong} with the - * specified radix. - * - * @param radix the radix used to interpret the token as an int value - * @return the <tt>long</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Integer</i> - * regular expression, or is out of range - * @throws NoSuchElementException if input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public long nextLong(int radix) { - // Check cached result - if ((typeCache != null) && (typeCache instanceof Long) - && this.radix == radix) { - long val = ((Long)typeCache).longValue(); - useTypeCache(); - return val; - } - setRadix(radix); - clearCaches(); - try { - String s = next(integerPattern()); - if (matcher.group(SIMPLE_GROUP_INDEX) == null) - s = processIntegerToken(s); - return Long.parseLong(s, radix); - } catch (NumberFormatException nfe) { - position = matcher.start(); // don't skip bad token - throw new InputMismatchException(nfe.getMessage()); - } - } - - /** - * The float token must be stripped of prefixes, group separators, - * and suffixes, non ascii digits must be converted into ascii digits - * before parseFloat will accept it. - * - * If there are non-ascii digits in the token these digits must - * be processed before the token is passed to parseFloat. - */ - private String processFloatToken(String token) { - String result = token.replaceAll(groupSeparator, ""); - if (!decimalSeparator.equals("\\.")) - result = result.replaceAll(decimalSeparator, "."); - boolean isNegative = false; - int preLen = negativePrefix.length(); - if ((preLen > 0) && result.startsWith(negativePrefix)) { - isNegative = true; - result = result.substring(preLen); - } - int sufLen = negativeSuffix.length(); - if ((sufLen > 0) && result.endsWith(negativeSuffix)) { - isNegative = true; - result = result.substring(result.length() - sufLen, - result.length()); - } - if (result.equals(nanString)) - result = "NaN"; - if (result.equals(infinityString)) - result = "Infinity"; - if (isNegative) - result = "-" + result; - - // Translate non-ASCII digits - Matcher m = NON_ASCII_DIGIT.matcher(result); - if (m.find()) { - StringBuilder inASCII = new StringBuilder(); - for (int i=0; i<result.length(); i++) { - char nextChar = result.charAt(i); - if (Character.isDigit(nextChar)) { - int d = Character.digit(nextChar, 10); - if (d != -1) - inASCII.append(d); - else - inASCII.append(nextChar); - } else { - inASCII.append(nextChar); - } - } - result = inASCII.toString(); - } - - return result; - } - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as a float value using the {@link #nextFloat} - * method. The scanner does not advance past any input. - * - * @return true if and only if this scanner's next token is a valid - * float value - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextFloat() { - setRadix(10); - boolean result = hasNext(floatPattern()); - if (result) { // Cache it - try { - String s = processFloatToken(hasNextResult); - typeCache = Float.valueOf(Float.parseFloat(s)); - } catch (NumberFormatException nfe) { - result = false; - } - } - return result; - } - - /** - * Scans the next token of the input as a <tt>float</tt>. - * This method will throw <code>InputMismatchException</code> - * if the next token cannot be translated into a valid float value as - * described below. If the translation is successful, the scanner advances - * past the input that matched. - * - * <p> If the next token matches the <a - * href="#Float-regex"><i>Float</i></a> regular expression defined above - * then the token is converted into a <tt>float</tt> value as if by - * removing all locale specific prefixes, group separators, and locale - * specific suffixes, then mapping non-ASCII digits into ASCII - * digits via {@link Character#digit Character.digit}, prepending a - * negative sign (-) if the locale specific negative prefixes and suffixes - * were present, and passing the resulting string to - * {@link Float#parseFloat Float.parseFloat}. If the token matches - * the localized NaN or infinity strings, then either "Nan" or "Infinity" - * is passed to {@link Float#parseFloat(String) Float.parseFloat} as - * appropriate. - * - * @return the <tt>float</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Float</i> - * regular expression, or is out of range - * @throws NoSuchElementException if input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public float nextFloat() { - // Check cached result - if ((typeCache != null) && (typeCache instanceof Float)) { - float val = ((Float)typeCache).floatValue(); - useTypeCache(); - return val; - } - setRadix(10); - clearCaches(); - try { - return Float.parseFloat(processFloatToken(next(floatPattern()))); - } catch (NumberFormatException nfe) { - position = matcher.start(); // don't skip bad token - throw new InputMismatchException(nfe.getMessage()); - } - } - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as a double value using the {@link #nextDouble} - * method. The scanner does not advance past any input. - * - * @return true if and only if this scanner's next token is a valid - * double value - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextDouble() { - setRadix(10); - boolean result = hasNext(floatPattern()); - if (result) { // Cache it - try { - String s = processFloatToken(hasNextResult); - typeCache = Double.valueOf(Double.parseDouble(s)); - } catch (NumberFormatException nfe) { - result = false; - } - } - return result; - } - - /** - * Scans the next token of the input as a <tt>double</tt>. - * This method will throw <code>InputMismatchException</code> - * if the next token cannot be translated into a valid double value. - * If the translation is successful, the scanner advances past the input - * that matched. - * - * <p> If the next token matches the <a - * href="#Float-regex"><i>Float</i></a> regular expression defined above - * then the token is converted into a <tt>double</tt> value as if by - * removing all locale specific prefixes, group separators, and locale - * specific suffixes, then mapping non-ASCII digits into ASCII - * digits via {@link Character#digit Character.digit}, prepending a - * negative sign (-) if the locale specific negative prefixes and suffixes - * were present, and passing the resulting string to - * {@link Double#parseDouble Double.parseDouble}. If the token matches - * the localized NaN or infinity strings, then either "Nan" or "Infinity" - * is passed to {@link Double#parseDouble(String) Double.parseDouble} as - * appropriate. - * - * @return the <tt>double</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Float</i> - * regular expression, or is out of range - * @throws NoSuchElementException if the input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public double nextDouble() { - // Check cached result - if ((typeCache != null) && (typeCache instanceof Double)) { - double val = ((Double)typeCache).doubleValue(); - useTypeCache(); - return val; - } - setRadix(10); - clearCaches(); - // Search for next float - try { - return Double.parseDouble(processFloatToken(next(floatPattern()))); - } catch (NumberFormatException nfe) { - position = matcher.start(); // don't skip bad token - throw new InputMismatchException(nfe.getMessage()); - } - } - - // Convenience methods for scanning multi precision numbers - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as a <code>BigInteger</code> in the default radix using the - * {@link #nextBigInteger} method. The scanner does not advance past any - * input. - * - * @return true if and only if this scanner's next token is a valid - * <code>BigInteger</code> - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextBigInteger() { - return hasNextBigInteger(defaultRadix); - } - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as a <code>BigInteger</code> in the specified radix using - * the {@link #nextBigInteger} method. The scanner does not advance past - * any input. - * - * @param radix the radix used to interpret the token as an integer - * @return true if and only if this scanner's next token is a valid - * <code>BigInteger</code> - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextBigInteger(int radix) { - setRadix(radix); - boolean result = hasNext(integerPattern()); - if (result) { // Cache it - try { - String s = (matcher.group(SIMPLE_GROUP_INDEX) == null) ? - processIntegerToken(hasNextResult) : - hasNextResult; - typeCache = new BigInteger(s, radix); - } catch (NumberFormatException nfe) { - result = false; - } - } - return result; - } - - /** - * Scans the next token of the input as a {@link java.math.BigInteger - * BigInteger}. - * - * <p> An invocation of this method of the form - * <tt>nextBigInteger()</tt> behaves in exactly the same way as the - * invocation <tt>nextBigInteger(radix)</tt>, where <code>radix</code> - * is the default radix of this scanner. - * - * @return the <tt>BigInteger</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Integer</i> - * regular expression, or is out of range - * @throws NoSuchElementException if the input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public BigInteger nextBigInteger() { - return nextBigInteger(defaultRadix); - } - - /** - * Scans the next token of the input as a {@link java.math.BigInteger - * BigInteger}. - * - * <p> If the next token matches the <a - * href="#Integer-regex"><i>Integer</i></a> regular expression defined - * above then the token is converted into a <tt>BigInteger</tt> value as if - * by removing all group separators, mapping non-ASCII digits into ASCII - * digits via the {@link Character#digit Character.digit}, and passing the - * resulting string to the {@link - * java.math.BigInteger#BigInteger(java.lang.String) - * BigInteger(String, int)} constructor with the specified radix. - * - * @param radix the radix used to interpret the token - * @return the <tt>BigInteger</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Integer</i> - * regular expression, or is out of range - * @throws NoSuchElementException if the input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public BigInteger nextBigInteger(int radix) { - // Check cached result - if ((typeCache != null) && (typeCache instanceof BigInteger) - && this.radix == radix) { - BigInteger val = (BigInteger)typeCache; - useTypeCache(); - return val; - } - setRadix(radix); - clearCaches(); - // Search for next int - try { - String s = next(integerPattern()); - if (matcher.group(SIMPLE_GROUP_INDEX) == null) - s = processIntegerToken(s); - return new BigInteger(s, radix); - } catch (NumberFormatException nfe) { - position = matcher.start(); // don't skip bad token - throw new InputMismatchException(nfe.getMessage()); - } - } - - /** - * Returns true if the next token in this scanner's input can be - * interpreted as a <code>BigDecimal</code> using the - * {@link #nextBigDecimal} method. The scanner does not advance past any - * input. - * - * @return true if and only if this scanner's next token is a valid - * <code>BigDecimal</code> - * @throws IllegalStateException if this scanner is closed - */ - public boolean hasNextBigDecimal() { - setRadix(10); - boolean result = hasNext(decimalPattern()); - if (result) { // Cache it - try { - String s = processFloatToken(hasNextResult); - typeCache = new BigDecimal(s); - } catch (NumberFormatException nfe) { - result = false; - } - } - return result; - } - - /** - * Scans the next token of the input as a {@link java.math.BigDecimal - * BigDecimal}. - * - * <p> If the next token matches the <a - * href="#Decimal-regex"><i>Decimal</i></a> regular expression defined - * above then the token is converted into a <tt>BigDecimal</tt> value as if - * by removing all group separators, mapping non-ASCII digits into ASCII - * digits via the {@link Character#digit Character.digit}, and passing the - * resulting string to the {@link - * java.math.BigDecimal#BigDecimal(java.lang.String) BigDecimal(String)} - * constructor. - * - * @return the <tt>BigDecimal</tt> scanned from the input - * @throws InputMismatchException - * if the next token does not match the <i>Decimal</i> - * regular expression, or is out of range - * @throws NoSuchElementException if the input is exhausted - * @throws IllegalStateException if this scanner is closed - */ - public BigDecimal nextBigDecimal() { - // Check cached result - if ((typeCache != null) && (typeCache instanceof BigDecimal)) { - BigDecimal val = (BigDecimal)typeCache; - useTypeCache(); - return val; - } - setRadix(10); - clearCaches(); - // Search for next float - try { - String s = processFloatToken(next(decimalPattern())); - return new BigDecimal(s); - } catch (NumberFormatException nfe) { - position = matcher.start(); // don't skip bad token - throw new InputMismatchException(nfe.getMessage()); - } - } - - /** - * Resets this scanner. - * - * <p> Resetting a scanner discards all of its explicit state - * information which may have been changed by invocations of {@link - * #useDelimiter}, {@link #useLocale}, or {@link #useRadix}. - * - * <p> An invocation of this method of the form - * <tt>scanner.reset()</tt> behaves in exactly the same way as the - * invocation - * - * <blockquote><pre> - * scanner.useDelimiter("\\p{javaWhitespace}+") - * .useLocale(Locale.getDefault()) - * .useRadix(10); - * </pre></blockquote> - * - * @return this scanner - * - * @since 1.6 - */ - public Scanner reset() { - delimPattern = WHITESPACE_PATTERN; - useLocale(Locale.getDefault()); - useRadix(10); - clearCaches(); - return this; - } -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1371 +0,0 @@ -/* - * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package org.classpath.icedtea.java.util.concurrent; - -import java.util.*; - -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.Callable; -import java.util.concurrent.Delayed; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.FutureTask; -import java.util.concurrent.RejectedExecutionHandler; -import java.util.concurrent.RunnableScheduledFuture; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; - -import java.util.concurrent.atomic.*; -import java.util.concurrent.locks.*; - -import org.classpath.icedtea.misc.JavaUtilConcurrentThreadPoolExecutorAccess; -import org.classpath.icedtea.misc.SharedSecrets; - -/** - * A {@link ThreadPoolExecutor} that can additionally schedule - * commands to run after a given delay, or to execute - * periodically. This class is preferable to {@link java.util.Timer} - * when multiple worker threads are needed, or when the additional - * flexibility or capabilities of {@link ThreadPoolExecutor} (which - * this class extends) are required. - * - * <p>Delayed tasks execute no sooner than they are enabled, but - * without any real-time guarantees about when, after they are - * enabled, they will commence. Tasks scheduled for exactly the same - * execution time are enabled in first-in-first-out (FIFO) order of - * submission. - * - * <p>When a submitted task is cancelled before it is run, execution - * is suppressed. By default, such a cancelled task is not - * automatically removed from the work queue until its delay - * elapses. While this enables further inspection and monitoring, it - * may also cause unbounded retention of cancelled tasks. To avoid - * this, set {@link #setRemoveOnCancelPolicy} to {@code true}, which - * causes tasks to be immediately removed from the work queue at - * time of cancellation. - * - * <p>While this class inherits from {@link ThreadPoolExecutor}, a few - * of the inherited tuning methods are not useful for it. In - * particular, because it acts as a fixed-sized pool using - * {@code corePoolSize} threads and an unbounded queue, adjustments - * to {@code maximumPoolSize} have no useful effect. Additionally, it - * is almost never a good idea to set {@code corePoolSize} to zero or - * use {@code allowCoreThreadTimeOut} because this may leave the pool - * without threads to handle tasks once they become eligible to run. - * - * <p><b>Extension notes:</b> This class overrides the - * {@link ThreadPoolExecutor#execute execute} and - * {@link AbstractExecutorService#submit(Runnable) submit} - * methods to generate internal {@link ScheduledFuture} objects to - * control per-task delays and scheduling. To preserve - * functionality, any further overrides of these methods in - * subclasses must invoke superclass versions, which effectively - * disables additional task customization. However, this class - * provides alternative protected extension method - * {@code decorateTask} (one version each for {@code Runnable} and - * {@code Callable}) that can be used to customize the concrete task - * types used to execute commands entered via {@code execute}, - * {@code submit}, {@code schedule}, {@code scheduleAtFixedRate}, - * and {@code scheduleWithFixedDelay}. By default, a - * {@code ScheduledThreadPoolExecutor} uses a task type extending - * {@link FutureTask}. However, this may be modified or replaced using - * subclasses of the form: - * - * <pre> {@code - * public class CustomScheduledExecutor extends ScheduledThreadPoolExecutor { - * - * static class CustomTask<V> implements RunnableScheduledFuture<V> { ... } - * - * protected <V> RunnableScheduledFuture<V> decorateTask( - * Runnable r, RunnableScheduledFuture<V> task) { - * return new CustomTask<V>(r, task); - * } - * - * protected <V> RunnableScheduledFuture<V> decorateTask( - * Callable<V> c, RunnableScheduledFuture<V> task) { - * return new CustomTask<V>(c, task); - * } - * // ... add constructors, etc. - * }}</pre> - * - * @since 1.5 - * @author Doug Lea - */ -public class ScheduledThreadPoolExecutor - extends ThreadPoolExecutor - implements ScheduledExecutorService { - - /* - * This class specializes ThreadPoolExecutor implementation by - * - * 1. Using a custom task type, ScheduledFutureTask for - * tasks, even those that don't require scheduling (i.e., - * those submitted using ExecutorService execute, not - * ScheduledExecutorService methods) which are treated as - * delayed tasks with a delay of zero. - * - * 2. Using a custom queue (DelayedWorkQueue), a variant of - * unbounded DelayQueue. The lack of capacity constraint and - * the fact that corePoolSize and maximumPoolSize are - * effectively identical simplifies some execution mechanics - * (see delayedExecute) compared to ThreadPoolExecutor. - * - * 3. Supporting optional run-after-shutdown parameters, which - * leads to overrides of shutdown methods to remove and cancel - * tasks that should NOT be run after shutdown, as well as - * different recheck logic when task (re)submission overlaps - * with a shutdown. - * - * 4. Task decoration methods to allow interception and - * instrumentation, which are needed because subclasses cannot - * otherwise override submit methods to get this effect. These - * don't have any impact on pool control logic though. - */ - - /** - * False if should cancel/suppress periodic tasks on shutdown. - */ - private volatile boolean continueExistingPeriodicTasksAfterShutdown; - - /** - * False if should cancel non-periodic tasks on shutdown. - */ - private volatile boolean executeExistingDelayedTasksAfterShutdown = true; - - /** - * True if ScheduledFutureTask.cancel should remove from queue - */ - private volatile boolean removeOnCancel = false; - - /** - * Sequence number to break scheduling ties, and in turn to - * guarantee FIFO order among tied entries. - */ - private static final AtomicLong sequencer = new AtomicLong(0); - - /** - * Returns current nanosecond time. - */ - final long now() { - return System.nanoTime(); - } - - private class ScheduledFutureTask<V> - extends FutureTask<V> implements RunnableScheduledFuture<V> { - - /** Sequence number to break ties FIFO */ - private final long sequenceNumber; - - /** The time the task is enabled to execute in nanoTime units */ - private long time; - - /** - * Period in nanoseconds for repeating tasks. A positive - * value indicates fixed-rate execution. A negative value - * indicates fixed-delay execution. A value of 0 indicates a - * non-repeating task. - */ - private final long period; - - /** The actual task to be re-enqueued by reExecutePeriodic */ - RunnableScheduledFuture<V> outerTask = this; - - /** - * Index into delay queue, to support faster cancellation. - */ - int heapIndex; - - /** - * Creates a one-shot action with given nanoTime-based trigger time. - */ - ScheduledFutureTask(Runnable r, V result, long ns) { - super(r, result); - this.time = ns; - this.period = 0; - this.sequenceNumber = sequencer.getAndIncrement(); - } - - /** - * Creates a periodic action with given nano time and period. - */ - ScheduledFutureTask(Runnable r, V result, long ns, long period) { - super(r, result); - this.time = ns; - this.period = period; - this.sequenceNumber = sequencer.getAndIncrement(); - } - - /** - * Creates a one-shot action with given nanoTime-based trigger. - */ - ScheduledFutureTask(Callable<V> callable, long ns) { - super(callable); - this.time = ns; - this.period = 0; - this.sequenceNumber = sequencer.getAndIncrement(); - } - - public long getDelay(TimeUnit unit) { - return unit.convert(time - now(), TimeUnit.NANOSECONDS); - } - - public int compareTo(Delayed other) { - if (other == this) // compare zero ONLY if same object - return 0; - if (other instanceof ScheduledFutureTask) { - ScheduledFutureTask<?> x = (ScheduledFutureTask<?>)other; - long diff = time - x.time; - if (diff < 0) - return -1; - else if (diff > 0) - return 1; - else if (sequenceNumber < x.sequenceNumber) - return -1; - else - return 1; - } - long d = (getDelay(TimeUnit.NANOSECONDS) - - other.getDelay(TimeUnit.NANOSECONDS)); - return (d == 0) ? 0 : ((d < 0) ? -1 : 1); - } - - /** - * Returns true if this is a periodic (not a one-shot) action. - * - * @return true if periodic - */ - public boolean isPeriodic() { - return period != 0; - } - - /** - * Sets the next time to run for a periodic task. - */ - private void setNextRunTime() { - long p = period; - if (p > 0) - time += p; - else - time = triggerTime(-p); - } - - public boolean cancel(boolean mayInterruptIfRunning) { - boolean cancelled = super.cancel(mayInterruptIfRunning); - if (cancelled && removeOnCancel && heapIndex >= 0) - remove(this); - return cancelled; - } - - /** - * Overrides FutureTask version so as to reset/requeue if periodic. - */ - public void run() { - boolean periodic = isPeriodic(); - if (!canRunInCurrentRunState(periodic)) - cancel(false); - else if (!periodic) - ScheduledFutureTask.super.run(); - else if (ScheduledFutureTask.super.runAndReset()) { - setNextRunTime(); - reExecutePeriodic(outerTask); - } - } - } - - /** - * Returns true if can run a task given current run state - * and run-after-shutdown parameters. - * - * @param periodic true if this task periodic, false if delayed - */ - boolean canRunInCurrentRunState(boolean periodic) { - return isRunningOrShutdownSTPE(periodic ? - continueExistingPeriodicTasksAfterShutdown : - executeExistingDelayedTasksAfterShutdown); - } - - /** - * Main execution method for delayed or periodic tasks. If pool - * is shut down, rejects the task. Otherwise adds task to queue - * and starts a thread, if necessary, to run it. (We cannot - * prestart the thread to run the task because the task (probably) - * shouldn't be run yet,) If the pool is shut down while the task - * is being added, cancel and remove it if required by state and - * run-after-shutdown parameters. - * - * @param task the task - */ - private void delayedExecute(RunnableScheduledFuture<?> task) { - if (isShutdown()) - rejectSTPE(task); - else { - super.getQueue().add(task); - if (isShutdown() && - !canRunInCurrentRunState(task.isPeriodic()) && - remove(task)) - task.cancel(false); - else - prestartCoreThread(); - } - } - - /** - * Requeues a periodic task unless current run state precludes it. - * Same idea as delayedExecute except drops task rather than rejecting. - * - * @param task the task - */ - void reExecutePeriodic(RunnableScheduledFuture<?> task) { - if (canRunInCurrentRunState(true)) { - super.getQueue().add(task); - if (!canRunInCurrentRunState(true) && remove(task)) - task.cancel(false); - else - prestartCoreThread(); - } - } - - /** - * Cancels and clears the queue of all tasks that should not be run - * due to shutdown policy. Invoked within super.shutdown. - */ - void onShutdown() { - BlockingQueue<Runnable> q = super.getQueue(); - boolean keepDelayed = - getExecuteExistingDelayedTasksAfterShutdownPolicy(); - boolean keepPeriodic = - getContinueExistingPeriodicTasksAfterShutdownPolicy(); - if (!keepDelayed && !keepPeriodic) - q.clear(); - else { - // Traverse snapshot to avoid iterator exceptions - for (Object e : q.toArray()) { - if (e instanceof RunnableScheduledFuture) { - RunnableScheduledFuture<?> t = - (RunnableScheduledFuture<?>)e; - if ((t.isPeriodic() ? !keepPeriodic : !keepDelayed) || - t.isCancelled()) { // also remove if already cancelled - if (q.remove(t)) - t.cancel(false); - } - } - } - } - tryTerminateSTPE(); - } - - /** - * Modifies or replaces the task used to execute a runnable. - * This method can be used to override the concrete - * class used for managing internal tasks. - * The default implementation simply returns the given task. - * - * @param runnable the submitted Runnable - * @param task the task created to execute the runnable - * @return a task that can execute the runnable - * @since 1.6 - */ - protected <V> RunnableScheduledFuture<V> decorateTask( - Runnable runnable, RunnableScheduledFuture<V> task) { - return task; - } - - /** - * Modifies or replaces the task used to execute a callable. - * This method can be used to override the concrete - * class used for managing internal tasks. - * The default implementation simply returns the given task. - * - * @param callable the submitted Callable - * @param task the task created to execute the callable - * @return a task that can execute the callable - * @since 1.6 - */ - protected <V> RunnableScheduledFuture<V> decorateTask( - Callable<V> callable, RunnableScheduledFuture<V> task) { - return task; - } - - /** - * Creates a new {@code ScheduledThreadPoolExecutor} with the - * given core pool size. - * - * @param corePoolSize the number of threads to keep in the pool, even - * if they are idle, unless {@code allowCoreThreadTimeOut} is set - * @throws IllegalArgumentException if {@code corePoolSize < 0} - */ - public ScheduledThreadPoolExecutor(int corePoolSize) { - super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, - new DelayedWorkQueue()); - } - - /** - * Creates a new {@code ScheduledThreadPoolExecutor} with the - * given initial parameters. - * - * @param corePoolSize the number of threads to keep in the pool, even - * if they are idle, unless {@code allowCoreThreadTimeOut} is set - * @param threadFactory the factory to use when the executor - * creates a new thread - * @throws IllegalArgumentException if {@code corePoolSize < 0} - * @throws NullPointerException if {@code threadFactory} is null - */ - public ScheduledThreadPoolExecutor(int corePoolSize, - ThreadFactory threadFactory) { - super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, - new DelayedWorkQueue(), threadFactory); - } - - /** - * Creates a new ScheduledThreadPoolExecutor with the given - * initial parameters. - * - * @param corePoolSize the number of threads to keep in the pool, even - * if they are idle, unless {@code allowCoreThreadTimeOut} is set - * @param handler the handler to use when execution is blocked - * because the thread bounds and queue capacities are reached - * @throws IllegalArgumentException if {@code corePoolSize < 0} - * @throws NullPointerException if {@code handler} is null - */ - public ScheduledThreadPoolExecutor(int corePoolSize, - RejectedExecutionHandler handler) { - super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, - new DelayedWorkQueue(), handler); - } - - /** - * Creates a new ScheduledThreadPoolExecutor with the given - * initial parameters. - * - * @param corePoolSize the number of threads to keep in the pool, even - * if they are idle, unless {@code allowCoreThreadTimeOut} is set - * @param threadFactory the factory to use when the executor - * creates a new thread - * @param handler the handler to use when execution is blocked - * because the thread bounds and queue capacities are reached - * @throws IllegalArgumentException if {@code corePoolSize < 0} - * @throws NullPointerException if {@code threadFactory} or - * {@code handler} is null - */ - public ScheduledThreadPoolExecutor(int corePoolSize, - ThreadFactory threadFactory, - RejectedExecutionHandler handler) { - super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, - new DelayedWorkQueue(), threadFactory, handler); - } - - /** - * Returns the trigger time of a delayed action. - */ - private long triggerTime(long delay, TimeUnit unit) { - return triggerTime(unit.toNanos((delay < 0) ? 0 : delay)); - } - - /** - * Returns the trigger time of a delayed action. - */ - long triggerTime(long delay) { - return now() + - ((delay < (Long.MAX_VALUE >> 1)) ? delay : overflowFree(delay)); - } - - /** - * Constrains the values of all delays in the queue to be within - * Long.MAX_VALUE of each other, to avoid overflow in compareTo. - * This may occur if a task is eligible to be dequeued, but has - * not yet been, while some other task is added with a delay of - * Long.MAX_VALUE. - */ - private long overflowFree(long delay) { - Delayed head = (Delayed) super.getQueue().peek(); - if (head != null) { - long headDelay = head.getDelay(TimeUnit.NANOSECONDS); - if (headDelay < 0 && (delay - headDelay < 0)) - delay = Long.MAX_VALUE + headDelay; - } - return delay; - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public ScheduledFuture<?> schedule(Runnable command, - long delay, - TimeUnit unit) { - if (command == null || unit == null) - throw new NullPointerException(); - RunnableScheduledFuture<?> t = decorateTask(command, - new ScheduledFutureTask<Void>(command, null, - triggerTime(delay, unit))); - delayedExecute(t); - return t; - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public <V> ScheduledFuture<V> schedule(Callable<V> callable, - long delay, - TimeUnit unit) { - if (callable == null || unit == null) - throw new NullPointerException(); - RunnableScheduledFuture<V> t = decorateTask(callable, - new ScheduledFutureTask<V>(callable, - triggerTime(delay, unit))); - delayedExecute(t); - return t; - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, - long initialDelay, - long period, - TimeUnit unit) { - if (command == null || unit == null) - throw new NullPointerException(); - if (period <= 0) - throw new IllegalArgumentException(); - ScheduledFutureTask<Void> sft = - new ScheduledFutureTask<Void>(command, - null, - triggerTime(initialDelay, unit), - unit.toNanos(period)); - RunnableScheduledFuture<Void> t = decorateTask(command, sft); - sft.outerTask = t; - delayedExecute(t); - return t; - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - * @throws IllegalArgumentException {@inheritDoc} - */ - public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, - long initialDelay, - long delay, - TimeUnit unit) { - if (command == null || unit == null) - throw new NullPointerException(); - if (delay <= 0) - throw new IllegalArgumentException(); - ScheduledFutureTask<Void> sft = - new ScheduledFutureTask<Void>(command, - null, - triggerTime(initialDelay, unit), - unit.toNanos(-delay)); - RunnableScheduledFuture<Void> t = decorateTask(command, sft); - sft.outerTask = t; - delayedExecute(t); - return t; - } - - /** - * Executes {@code command} with zero required delay. - * This has effect equivalent to - * {@link #schedule(Runnable,long,TimeUnit) schedule(command, 0, anyUnit)}. - * Note that inspections of the queue and of the list returned by - * {@code shutdownNow} will access the zero-delayed - * {@link ScheduledFuture}, not the {@code command} itself. - * - * <p>A consequence of the use of {@code ScheduledFuture} objects is - * that {@link ThreadPoolExecutor#afterExecute afterExecute} is always - * called with a null second {@code Throwable} argument, even if the - * {@code command} terminated abruptly. Instead, the {@code Throwable} - * thrown by such a task can be obtained via {@link Future#get}. - * - * @throws RejectedExecutionException at discretion of - * {@code RejectedExecutionHandler}, if the task - * cannot be accepted for execution because the - * executor has been shut down - * @throws NullPointerException {@inheritDoc} - */ - public void execute(Runnable command) { - schedule(command, 0, TimeUnit.NANOSECONDS); - } - - // Override AbstractExecutorService methods - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public Future<?> submit(Runnable task) { - return schedule(task, 0, TimeUnit.NANOSECONDS); - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public <T> Future<T> submit(Runnable task, T result) { - return schedule(Executors.callable(task, result), - 0, TimeUnit.NANOSECONDS); - } - - /** - * @throws RejectedExecutionException {@inheritDoc} - * @throws NullPointerException {@inheritDoc} - */ - public <T> Future<T> submit(Callable<T> task) { - return schedule(task, 0, TimeUnit.NANOSECONDS); - } - - /** - * Sets the policy on whether to continue executing existing - * periodic tasks even when this executor has been {@code shutdown}. - * In this case, these tasks will only terminate upon - * {@code shutdownNow} or after setting the policy to - * {@code false} when already shutdown. - * This value is by default {@code false}. - * - * @param value if {@code true}, continue after shutdown, else don't. - * @see #getContinueExistingPeriodicTasksAfterShutdownPolicy - */ - public void setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean value) { - continueExistingPeriodicTasksAfterShutdown = value; - if (!value && isShutdown()) - onShutdown(); - } - - /** - * Gets the policy on whether to continue executing existing - * periodic tasks even when this executor has been {@code shutdown}. - * In this case, these tasks will only terminate upon - * {@code shutdownNow} or after setting the policy to - * {@code false} when already shutdown. - * This value is by default {@code false}. - * - * @return {@code true} if will continue after shutdown - * @see #setContinueExistingPeriodicTasksAfterShutdownPolicy - */ - public boolean getContinueExistingPeriodicTasksAfterShutdownPolicy() { - return continueExistingPeriodicTasksAfterShutdown; - } - - /** - * Sets the policy on whether to execute existing delayed - * tasks even when this executor has been {@code shutdown}. - * In this case, these tasks will only terminate upon - * {@code shutdownNow}, or after setting the policy to - * {@code false} when already shutdown. - * This value is by default {@code true}. - * - * @param value if {@code true}, execute after shutdown, else don't. - * @see #getExecuteExistingDelayedTasksAfterShutdownPolicy - */ - public void setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean value) { - executeExistingDelayedTasksAfterShutdown = value; - if (!value && isShutdown()) - onShutdown(); - } - - /** - * Gets the policy on whether to execute existing delayed - * tasks even when this executor has been {@code shutdown}. - * In this case, these tasks will only terminate upon - * {@code shutdownNow}, or after setting the policy to - * {@code false} when already shutdown. - * This value is by default {@code true}. - * - * @return {@code true} if will execute after shutdown - * @see #setExecuteExistingDelayedTasksAfterShutdownPolicy - */ - public boolean getExecuteExistingDelayedTasksAfterShutdownPolicy() { - return executeExistingDelayedTasksAfterShutdown; - } - - /** - * Sets the policy on whether cancelled tasks should be immediately - * removed from the work queue at time of cancellation. This value is - * by default {@code false}. - * - * @param value if {@code true}, remove on cancellation, else don't - * @see #getRemoveOnCancelPolicy - * @since 1.7 - */ - public void setRemoveOnCancelPolicy(boolean value) { - removeOnCancel = value; - } - - /** - * Gets the policy on whether cancelled tasks should be immediately - * removed from the work queue at time of cancellation. This value is - * by default {@code false}. - * - * @return {@code true} if cancelled tasks are immediately removed - * from the queue - * @see #setRemoveOnCancelPolicy - * @since 1.7 - */ - public boolean getRemoveOnCancelPolicy() { - return removeOnCancel; - } - - /** - * Initiates an orderly shutdown in which previously submitted - * tasks are executed, but no new tasks will be accepted. - * Invocation has no additional effect if already shut down. - * - * <p>This method does not wait for previously submitted tasks to - * complete execution. Use {@link #awaitTermination awaitTermination} - * to do that. - * - * <p>If the {@code ExecuteExistingDelayedTasksAfterShutdownPolicy} - * has been set {@code false}, existing delayed tasks whose delays - * have not yet elapsed are cancelled. And unless the {@code - * ContinueExistingPeriodicTasksAfterShutdownPolicy} has been set - * {@code true}, future executions of existing periodic tasks will - * be cancelled. - * - * @throws SecurityException {@inheritDoc} - */ - public void shutdown() { - super.shutdown(); - } - - /** - * Attempts to stop all actively executing tasks, halts the - * processing of waiting tasks, and returns a list of the tasks - * that were awaiting execution. - * - * <p>This method does not wait for actively executing tasks to - * terminate. Use {@link #awaitTermination awaitTermination} to - * do that. - * - * <p>There are no guarantees beyond best-effort attempts to stop - * processing actively executing tasks. This implementation - * cancels tasks via {@link Thread#interrupt}, so any task that - * fails to respond to interrupts may never terminate. - * - * @return list of tasks that never commenced execution. - * Each element of this list is a {@link ScheduledFuture}, - * including those tasks submitted using {@code execute}, - * which are for scheduling purposes used as the basis of a - * zero-delay {@code ScheduledFuture}. - * @throws SecurityException {@inheritDoc} - */ - public List<Runnable> shutdownNow() { - return super.shutdownNow(); - } - - /** - * Returns the task queue used by this executor. Each element of - * this queue is a {@link ScheduledFuture}, including those - * tasks submitted using {@code execute} which are for scheduling - * purposes used as the basis of a zero-delay - * {@code ScheduledFuture}. Iteration over this queue is - * <em>not</em> guaranteed to traverse tasks in the order in - * which they will execute. - * - * @return the task queue - */ - public BlockingQueue<Runnable> getQueue() { - return super.getQueue(); - } - - /** - * Specialized delay queue. To mesh with TPE declarations, this - * class must be declared as a BlockingQueue<Runnable> even though - * it can only hold RunnableScheduledFutures. - */ - static class DelayedWorkQueue extends AbstractQueue<Runnable> - implements BlockingQueue<Runnable> { - - /* - * A DelayedWorkQueue is based on a heap-based data structure - * like those in DelayQueue and PriorityQueue, except that - * every ScheduledFutureTask also records its index into the - * heap array. This eliminates the need to find a task upon - * cancellation, greatly speeding up removal (down from O(n) - * to O(log n)), and reducing garbage retention that would - * otherwise occur by waiting for the element to rise to top - * before clearing. But because the queue may also hold - * RunnableScheduledFutures that are not ScheduledFutureTasks, - * we are not guaranteed to have such indices available, in - * which case we fall back to linear search. (We expect that - * most tasks will not be decorated, and that the faster cases - * will be much more common.) - * - * All heap operations must record index changes -- mainly - * within siftUp and siftDown. Upon removal, a task's - * heapIndex is set to -1. Note that ScheduledFutureTasks can - * appear at most once in the queue (this need not be true for - * other kinds of tasks or work queues), so are uniquely - * identified by heapIndex. - */ - - private static final int INITIAL_CAPACITY = 16; - private RunnableScheduledFuture[] queue = - new RunnableScheduledFuture[INITIAL_CAPACITY]; - private final ReentrantLock lock = new ReentrantLock(); - private int size = 0; - - /** - * Thread designated to wait for the task at the head of the - * queue. This variant of the Leader-Follower pattern - * (http://www.cs.wustl.edu/~schmidt/POSA/POSA2/) serves to - * minimize unnecessary timed waiting. When a thread becomes - * the leader, it waits only for the next delay to elapse, but - * other threads await indefinitely. The leader thread must - * signal some other thread before returning from take() or - * poll(...), unless some other thread becomes leader in the - * interim. Whenever the head of the queue is replaced with a - * task with an earlier expiration time, the leader field is - * invalidated by being reset to null, and some waiting - * thread, but not necessarily the current leader, is - * signalled. So waiting threads must be prepared to acquire - * and lose leadership while waiting. - */ - private Thread leader = null; - - /** - * Condition signalled when a newer task becomes available at the - * head of the queue or a new thread may need to become leader. - */ - private final Condition available = lock.newCondition(); - - /** - * Set f's heapIndex if it is a ScheduledFutureTask. - */ - private void setIndex(RunnableScheduledFuture f, int idx) { - if (f instanceof ScheduledFutureTask) - ((ScheduledFutureTask)f).heapIndex = idx; - } - - /** - * Sift element added at bottom up to its heap-ordered spot. - * Call only when holding lock. - */ - private void siftUp(int k, RunnableScheduledFuture key) { - while (k > 0) { - int parent = (k - 1) >>> 1; - RunnableScheduledFuture e = queue[parent]; - if (key.compareTo(e) >= 0) - break; - queue[k] = e; - setIndex(e, k); - k = parent; - } - queue[k] = key; - setIndex(key, k); - } - - /** - * Sift element added at top down to its heap-ordered spot. - * Call only when holding lock. - */ - private void siftDown(int k, RunnableScheduledFuture key) { - int half = size >>> 1; - while (k < half) { - int child = (k << 1) + 1; - RunnableScheduledFuture c = queue[child]; - int right = child + 1; - if (right < size && c.compareTo(queue[right]) > 0) - c = queue[child = right]; - if (key.compareTo(c) <= 0) - break; - queue[k] = c; - setIndex(c, k); - k = child; - } - queue[k] = key; - setIndex(key, k); - } - - /** - * Resize the heap array. Call only when holding lock. - */ - private void grow() { - int oldCapacity = queue.length; - int newCapacity = oldCapacity + (oldCapacity >> 1); // grow 50% - if (newCapacity < 0) // overflow - newCapacity = Integer.MAX_VALUE; - queue = Arrays.copyOf(queue, newCapacity); - } - - /** - * Find index of given object, or -1 if absent - */ - private int indexOf(Object x) { - if (x != null) { - if (x instanceof ScheduledFutureTask) { - int i = ((ScheduledFutureTask) x).heapIndex; - // Sanity check; x could conceivably be a - // ScheduledFutureTask from some other pool. - if (i >= 0 && i < size && queue[i] == x) - return i; - } else { - for (int i = 0; i < size; i++) - if (x.equals(queue[i])) - return i; - } - } - return -1; - } - - public boolean contains(Object x) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return indexOf(x) != -1; - } finally { - lock.unlock(); - } - } - - public boolean remove(Object x) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int i = indexOf(x); - if (i < 0) - return false; - - setIndex(queue[i], -1); - int s = --size; - RunnableScheduledFuture replacement = queue[s]; - queue[s] = null; - if (s != i) { - siftDown(i, replacement); - if (queue[i] == replacement) - siftUp(i, replacement); - } - return true; - } finally { - lock.unlock(); - } - } - - public int size() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return size; - } finally { - lock.unlock(); - } - } - - public boolean isEmpty() { - return size() == 0; - } - - public int remainingCapacity() { - return Integer.MAX_VALUE; - } - - public RunnableScheduledFuture peek() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return queue[0]; - } finally { - lock.unlock(); - } - } - - public boolean offer(Runnable x) { - if (x == null) - throw new NullPointerException(); - RunnableScheduledFuture e = (RunnableScheduledFuture)x; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - int i = size; - if (i >= queue.length) - grow(); - size = i + 1; - if (i == 0) { - queue[0] = e; - setIndex(e, 0); - } else { - siftUp(i, e); - } - if (queue[0] == e) { - leader = null; - available.signal(); - } - } finally { - lock.unlock(); - } - return true; - } - - public void put(Runnable e) { - offer(e); - } - - public boolean add(Runnable e) { - return offer(e); - } - - public boolean offer(Runnable e, long timeout, TimeUnit unit) { - return offer(e); - } - - /** - * Performs common bookkeeping for poll and take: Replaces - * first element with last and sifts it down. Call only when - * holding lock. - * @param f the task to remove and return - */ - private RunnableScheduledFuture finishPoll(RunnableScheduledFuture f) { - int s = --size; - RunnableScheduledFuture x = queue[s]; - queue[s] = null; - if (s != 0) - siftDown(0, x); - setIndex(f, -1); - return f; - } - - public RunnableScheduledFuture poll() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - RunnableScheduledFuture first = queue[0]; - if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0) - return null; - else - return finishPoll(first); - } finally { - lock.unlock(); - } - } - - public RunnableScheduledFuture take() throws InterruptedException { - final ReentrantLock lock = this.lock; - lock.lockInterruptibly(); - try { - for (;;) { - RunnableScheduledFuture first = queue[0]; - if (first == null) - available.await(); - else { - long delay = first.getDelay(TimeUnit.NANOSECONDS); - if (delay <= 0) - return finishPoll(first); - else if (leader != null) - available.await(); - else { - Thread thisThread = Thread.currentThread(); - leader = thisThread; - try { - available.awaitNanos(delay); - } finally { - if (leader == thisThread) - leader = null; - } - } - } - } - } finally { - if (leader == null && queue[0] != null) - available.signal(); - lock.unlock(); - } - } - - public RunnableScheduledFuture poll(long timeout, TimeUnit unit) - throws InterruptedException { - long nanos = unit.toNanos(timeout); - final ReentrantLock lock = this.lock; - lock.lockInterruptibly(); - try { - for (;;) { - RunnableScheduledFuture first = queue[0]; - if (first == null) { - if (nanos <= 0) - return null; - else - nanos = available.awaitNanos(nanos); - } else { - long delay = first.getDelay(TimeUnit.NANOSECONDS); - if (delay <= 0) - return finishPoll(first); - if (nanos <= 0) - return null; - if (nanos < delay || leader != null) - nanos = available.awaitNanos(nanos); - else { - Thread thisThread = Thread.currentThread(); - leader = thisThread; - try { - long timeLeft = available.awaitNanos(delay); - nanos -= delay - timeLeft; - } finally { - if (leader == thisThread) - leader = null; - } - } - } - } - } finally { - if (leader == null && queue[0] != null) - available.signal(); - lock.unlock(); - } - } - - public void clear() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - for (int i = 0; i < size; i++) { - RunnableScheduledFuture t = queue[i]; - if (t != null) { - queue[i] = null; - setIndex(t, -1); - } - } - size = 0; - } finally { - lock.unlock(); - } - } - - /** - * Return and remove first element only if it is expired. - * Used only by drainTo. Call only when holding lock. - */ - private RunnableScheduledFuture pollExpired() { - RunnableScheduledFuture first = queue[0]; - if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0) - return null; - return finishPoll(first); - } - - public int drainTo(Collection<? super Runnable> c) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - final ReentrantLock lock = this.lock; - lock.lock(); - try { - RunnableScheduledFuture first; - int n = 0; - while ((first = pollExpired()) != null) { - c.add(first); - ++n; - } - return n; - } finally { - lock.unlock(); - } - } - - public int drainTo(Collection<? super Runnable> c, int maxElements) { - if (c == null) - throw new NullPointerException(); - if (c == this) - throw new IllegalArgumentException(); - if (maxElements <= 0) - return 0; - final ReentrantLock lock = this.lock; - lock.lock(); - try { - RunnableScheduledFuture first; - int n = 0; - while (n < maxElements && (first = pollExpired()) != null) { - c.add(first); - ++n; - } - return n; - } finally { - lock.unlock(); - } - } - - public Object[] toArray() { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - return Arrays.copyOf(queue, size, Object[].class); - } finally { - lock.unlock(); - } - } - - @SuppressWarnings("unchecked") - public <T> T[] toArray(T[] a) { - final ReentrantLock lock = this.lock; - lock.lock(); - try { - if (a.length < size) - return (T[]) Arrays.copyOf(queue, size, a.getClass()); - System.arraycopy(queue, 0, a, 0, size); - if (a.length > size) - a[size] = null; - return a; - } finally { - lock.unlock(); - } - } - - public Iterator<Runnable> iterator() { - return new Itr(Arrays.copyOf(queue, size)); - } - - /** - * Snapshot iterator that works off copy of underlying q array. - */ - private class Itr implements Iterator<Runnable> { - final RunnableScheduledFuture[] array; - int cursor = 0; // index of next element to return - int lastRet = -1; // index of last element, or -1 if no such - - Itr(RunnableScheduledFuture[] array) { - this.array = array; - } - - public boolean hasNext() { - return cursor < array.length; - } - - public Runnable next() { - if (cursor >= array.length) - throw new NoSuchElementException(); - lastRet = cursor; - return array[cursor++]; - } - - public void remove() { - if (lastRet < 0) - throw new IllegalStateException(); - DelayedWorkQueue.this.remove(array[lastRet]); - lastRet = -1; - } - } - } - - // Duplicated package-private methods from ThreadPoolExecutor - - private static final int COUNT_BITS = Integer.SIZE - 3; - private static final int CAPACITY = (1 << COUNT_BITS) - 1; - private static final int RUNNING = -1 << COUNT_BITS; - private static final int SHUTDOWN = 0 << COUNT_BITS; - private static final int TIDYING = 2 << COUNT_BITS; - private static final int TERMINATED = 3 << COUNT_BITS; - - // Packing and unpacking ctl - private static int runStateOf(int c) { return c & ~CAPACITY; } - private static int workerCountOf(int c) { return c & CAPACITY; } - private static int ctlOf(int rs, int wc) { return rs | wc; } - - private static final boolean ONLY_ONE = true; - - /** - * Transitions to TERMINATED state if either (SHUTDOWN and pool - * and queue empty) or (STOP and pool empty). If otherwise - * eligible to terminate but workerCount is nonzero, interrupts an - * idle worker to ensure that shutdown signals propagate. This - * method must be called following any action that might make - * termination possible -- reducing worker count or removing tasks - * from the queue during shutdown. The method is non-private to - * allow access from ScheduledThreadPoolExecutor. - */ - private final void tryTerminateSTPE() { - final JavaUtilConcurrentThreadPoolExecutorAccess juctpea = - SharedSecrets.getJavaUtilConcurrentThreadPoolExecutorAccess(); - final AtomicInteger ctl = juctpea.getCtl(this); - for (;;) { - int c = ctl.get(); - if (isRunning(c) || - runStateAtLeast(c, TIDYING) || - (runStateOf(c) == SHUTDOWN && ! juctpea.isWorkQueueEmpty(this))) - return; - if (workerCountOf(c) != 0) { // Eligible to terminate - juctpea.interruptIdleWorkers(this, ONLY_ONE); - return; - } - - juctpea.lockMainLock(this); - try { - if (ctl.compareAndSet(c, ctlOf(TIDYING, 0))) { - try { - terminated(); - } finally { - ctl.set(ctlOf(TERMINATED, 0)); - juctpea.signalAll(this); - } - return; - } - } finally { - juctpea.unlockMainLock(this); - } - // else retry on failed CAS - } - } - - /** - * State check needed by ScheduledThreadPoolExecutor to - * enable running tasks during shutdown. - * - * @param shutdownOK true if should return true if SHUTDOWN - */ - private final boolean isRunningOrShutdownSTPE(boolean shutdownOK) { - int rs = runStateOf(SharedSecrets.getJavaUtilConcurrentThreadPoolExecutorAccess().getCtl(this).get()); - return rs == RUNNING || (rs == SHUTDOWN && shutdownOK); - } - - /** - * Invokes the rejected execution handler for the given command. - * Package-protected for use by ScheduledThreadPoolExecutor. - */ - private final void rejectSTPE(Runnable command) { - SharedSecrets.getJavaUtilConcurrentThreadPoolExecutorAccess().rejectedExecution(command, this); - } - - private static boolean isRunning(int c) { - return c < SHUTDOWN; - } - - private static boolean runStateAtLeast(int c, int s) { - return c >= s; - } - -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaIODeleteOnExitAccess.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* JavaIODeleteOnExitAccess.java - Copyright (C) 2009 Red Hat, Inc. - -This file is part of IcedTea. - -IcedTea is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 2. - -IcedTea 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 for more details. - -You should have received a copy of the GNU General Public License -along with IcedTea; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. - */ - -package org.classpath.icedtea.misc; - -public interface JavaIODeleteOnExitAccess -{ - void add(String path); -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaNetGetIndexAccess.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* JavaNetGetIndex.java - Copyright (C) 2009 Red Hat, Inc. - -This file is part of IcedTea. - -IcedTea is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 2. - -IcedTea 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 for more details. - -You should have received a copy of the GNU General Public License -along with IcedTea; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. - */ - -package org.classpath.icedtea.misc; - -import java.net.NetworkInterface; - -public interface JavaNetGetIndexAccess -{ - int getIndex(NetworkInterface nf); - NetworkInterface getByIndex(int i); -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/JavaUtilConcurrentThreadPoolExecutorAccess.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* JavaUtilConcurrentThreadPoolExecutorAccess.java - Copyright (C) 2009 Red Hat, Inc. - -This file is part of IcedTea. - -IcedTea is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 2. - -IcedTea 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 for more details. - -You should have received a copy of the GNU General Public License -along with IcedTea; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. - */ - -package org.classpath.icedtea.misc; - -import java.util.concurrent.RejectedExecutionHandler; -import java.util.concurrent.ThreadPoolExecutor; - -import java.util.concurrent.atomic.AtomicInteger; - -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.ReentrantLock; - -public interface JavaUtilConcurrentThreadPoolExecutorAccess -{ - AtomicInteger getCtl(ThreadPoolExecutor e); - void lockMainLock(ThreadPoolExecutor e); - void unlockMainLock(ThreadPoolExecutor e); - void signalAll(ThreadPoolExecutor e); - void rejectedExecution(Runnable command, ThreadPoolExecutor e); - boolean isWorkQueueEmpty(ThreadPoolExecutor e); - void interruptIdleWorkers(ThreadPoolExecutor e, boolean onlyOne); -} -
--- a/overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/misc/SharedSecrets.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* SharedSecrets.java - Copyright (C) 2009 Red Hat, Inc. - -This file is part of IcedTea. - -IcedTea is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 2. - -IcedTea 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 for more details. - -You should have received a copy of the GNU General Public License -along with IcedTea; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. - */ - -/** Based on sun.misc.SharedSecrets */ -package org.classpath.icedtea.misc; - -import sun.misc.Unsafe; - -/** A repository of "shared secrets", which are a mechanism for - calling implementation-private methods in another package without - using reflection. A package-private class implements a public - interface and provides the ability to call package-private methods - within that package; the object implementing that interface is - provided through a third package to which access is restricted. - This framework avoids the primary disadvantage of using reflection - for this purpose, namely the loss of compile-time checking. */ - -public class SharedSecrets -{ - private static final Unsafe unsafe = Unsafe.getUnsafe(); - private static JavaIODeleteOnExitAccess javaIODeleteOnExitAccess; - private static JavaUtilConcurrentThreadPoolExecutorAccess javaUtilConcurrentThreadPoolExecutorAccess; - private static JavaNetGetIndexAccess javaNetGetIndexAccess; - - public static void setJavaIODeleteOnExitAccess(JavaIODeleteOnExitAccess jida) - { - javaIODeleteOnExitAccess = jida; - } - - public static JavaIODeleteOnExitAccess getJavaIODeleteOnExitAccess() - { - if (javaIODeleteOnExitAccess == null) - { - unsafe.ensureClassInitialized(java.io.File.class); - } - return javaIODeleteOnExitAccess; - } - - public static void setJavaUtilConcurrentThreadPoolExecutorAccess(JavaUtilConcurrentThreadPoolExecutorAccess juctpea) - { - javaUtilConcurrentThreadPoolExecutorAccess = juctpea; - } - - public static JavaUtilConcurrentThreadPoolExecutorAccess getJavaUtilConcurrentThreadPoolExecutorAccess() - { - if (javaUtilConcurrentThreadPoolExecutorAccess == null) - { - unsafe.ensureClassInitialized(java.util.concurrent.ThreadPoolExecutor.class); - } - return javaUtilConcurrentThreadPoolExecutorAccess; - } - - public static void setJavaNetGetIndexAccess(JavaNetGetIndexAccess jngia) - { - javaNetGetIndexAccess = jngia; - } - - public static JavaNetGetIndexAccess getJavaNetGetIndexAccess() - { - if (javaNetGetIndexAccess == null) - { - unsafe.ensureClassInitialized(java.net.NetworkInterface.class); - } - return javaNetGetIndexAccess; - } - - -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AbstractFuture.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AbstractFuture.java Fri Feb 20 14:50:00 2009 +0000 @@ -27,7 +27,7 @@ import java.util.concurrent.Future; -import org.classpath.icedtea.java.nio.channels.AsynchronousChannel; +import java.nio.channels.AsynchronousChannel; /** * Base implementation of Future used for asynchronous I/O
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousChannelGroupImpl.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousChannelGroupImpl.java Fri Feb 20 14:50:00 2009 +0000 @@ -44,10 +44,10 @@ import java.security.AccessControlContext; import sun.security.action.GetPropertyAction; -import org.classpath.icedtea.java.nio.channels.AsynchronousChannelGroup; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider; +import java.nio.channels.AsynchronousChannelGroup; +import java.nio.channels.spi.AsynchronousChannelProvider; -import org.classpath.icedtea.java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ScheduledThreadPoolExecutor; /** * Base implementation of AsynchronousChannelGroup
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousFileChannelImpl.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousFileChannelImpl.java Fri Feb 20 14:50:00 2009 +0000 @@ -33,8 +33,8 @@ import java.io.FileDescriptor; import java.io.IOException; -import org.classpath.icedtea.java.nio.channels.AsynchronousFileChannel; -import org.classpath.icedtea.java.nio.channels.FileLock; +import java.nio.channels.AsynchronousFileChannel; +import java.nio.channels.FileLock; /** * Base implementation of AsynchronousFileChannel.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousFileLockImpl.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousFileLockImpl.java Fri Feb 20 14:50:00 2009 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2001-2003 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,8 +31,8 @@ import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; -import org.classpath.icedtea.java.nio.channels.AsynchronousFileChannel; -import org.classpath.icedtea.java.nio.channels.FileLock; +import java.nio.channels.AsynchronousFileChannel; +import java.nio.channels.FileLock; public class AsynchronousFileLockImpl extends FileLock
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,6 +29,7 @@ import java.net.InetSocketAddress; import java.io.FileDescriptor; import java.io.IOException; +import java.nio.channels.AlreadyBoundException; import java.nio.channels.ClosedChannelException; import java.util.Set; import java.util.HashSet; @@ -36,10 +37,10 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import org.classpath.icedtea.java.net.SocketOption; -import org.classpath.icedtea.java.net.StandardSocketOption; +import java.net.SocketOption; +import java.net.StandardSocketOption; -import org.classpath.icedtea.java.nio.channels.AsynchronousServerSocketChannel; +import java.nio.channels.AsynchronousServerSocketChannel; /** * Base implementation of AsynchronousServerSocketChannel. @@ -158,7 +159,7 @@ { if (name == null) throw new NullPointerException(); - if (!supportedOptions().contains(name)) + if (!options().contains(name)) throw new UnsupportedOperationException("'" + name + "' not supported"); try { @@ -175,7 +176,7 @@ public final <T> T getOption(SocketOption<T> name) throws IOException { if (name == null) throw new NullPointerException(); - if (!supportedOptions().contains(name)) + if (!options().contains(name)) throw new UnsupportedOperationException("'" + name + "' not supported"); try { @@ -198,7 +199,7 @@ } - public final Set<SocketOption<?>> supportedOptions() { + public final Set<SocketOption<?>> options() { return LazyInitialization.defaultOptions; }
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java Fri Feb 20 14:50:00 2009 +0000 @@ -37,13 +37,13 @@ import java.util.concurrent.*; import java.util.concurrent.locks.*; -import org.classpath.icedtea.java.net.SocketOption; -import org.classpath.icedtea.java.net.StandardSocketOption; +import java.net.SocketOption; +import java.net.StandardSocketOption; -import org.classpath.icedtea.java.nio.channels.AsynchronousSocketChannel; -import org.classpath.icedtea.java.nio.channels.CompletionHandler; -import org.classpath.icedtea.java.nio.channels.ReadPendingException; -import org.classpath.icedtea.java.nio.channels.WritePendingException; +import java.nio.channels.AsynchronousSocketChannel; +import java.nio.channels.CompletionHandler; +import java.nio.channels.ReadPendingException; +import java.nio.channels.WritePendingException; /** * Base implementation of AsynchronousSocketChannel @@ -415,7 +415,7 @@ { if (name == null) throw new NullPointerException(); - if (!supportedOptions().contains(name)) + if (!options().contains(name)) throw new UnsupportedOperationException("'" + name + "' not supported"); try { @@ -432,7 +432,7 @@ public final <T> T getOption(SocketOption<T> name) throws IOException { if (name == null) throw new NullPointerException(); - if (!supportedOptions().contains(name)) + if (!options().contains(name)) throw new UnsupportedOperationException("'" + name + "' not supported"); try { @@ -458,7 +458,7 @@ } - public final Set<SocketOption<?>> supportedOptions() { + public final Set<SocketOption<?>> options() { return LazyInitialization.defaultOptions; }
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/CompletedFuture.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/CompletedFuture.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,7 +29,7 @@ import java.util.concurrent.ExecutionException; import java.io.IOException; -import org.classpath.icedtea.java.nio.channels.AsynchronousChannel; +import java.nio.channels.AsynchronousChannel; /** * A Future representing the result of an I/O operation that has already
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/ExtendedSocketOption.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package sun.nio.ch; - -import org.classpath.icedtea.java.net.SocketOption; - -/** - * Defines socket options that are supported by the implementation - * but not defined in StandardSocketOption. - */ - -class ExtendedSocketOption { - private ExtendedSocketOption() { } - - static final SocketOption<Boolean> SO_OOBINLINE = - new SocketOption<Boolean>() { - public String name() { return "SO_OOBINLINE"; } - public Class<Boolean> type() { return Boolean.class; } - public String toString() { return name(); } - }; -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/FileLockTable.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/FileLockTable.java Fri Feb 20 14:50:00 2009 +0000 @@ -34,7 +34,7 @@ import java.io.FileDescriptor; import java.io.IOException; -import org.classpath.icedtea.java.nio.channels.FileLock; +import java.nio.channels.FileLock; abstract class FileLockTable { protected FileLockTable() {
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/Invoker.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/Invoker.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,9 +29,9 @@ import java.security.AccessController; import sun.security.action.GetPropertyAction; -import org.classpath.icedtea.java.nio.channels.AsynchronousChannel; -import org.classpath.icedtea.java.nio.channels.CompletionHandler; -import org.classpath.icedtea.java.nio.channels.ShutdownChannelGroupException; +import java.nio.channels.AsynchronousChannel; +import java.nio.channels.CompletionHandler; +import java.nio.channels.ShutdownChannelGroupException; /** * Defines static methods to invoke a completion handler or arbitrary task.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipKeyImpl.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,224 +0,0 @@ -/* - * Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package sun.nio.ch; - -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.io.IOException; -import java.util.HashSet; - -import org.classpath.icedtea.java.nio.channels.MembershipKey; -import org.classpath.icedtea.java.nio.channels.MulticastChannel; - -/** - * MembershipKey implementation. - */ - -class MembershipKeyImpl - extends MembershipKey -{ - private final MulticastChannel ch; - private final InetAddress group; - private final NetworkInterface interf; - private final InetAddress source; - - // true when key is valid - private volatile boolean valid = true; - - // lock used when creating or accessing blockedSet - private Object stateLock = new Object(); - - // set of source addresses that are blocked - private HashSet<InetAddress> blockedSet; - - private MembershipKeyImpl(MulticastChannel ch, - InetAddress group, - NetworkInterface interf, - InetAddress source) - { - this.ch = ch; - this.group = group; - this.interf = interf; - this.source = source; - } - - /** - * MembershipKey will additional context for IPv4 membership - */ - static class Type4 extends MembershipKeyImpl { - private final int groupAddress; - private final int interfAddress; - private final int sourceAddress; - - Type4(MulticastChannel ch, - InetAddress group, - NetworkInterface interf, - InetAddress source, - int groupAddress, - int interfAddress, - int sourceAddress) - { - super(ch, group, interf, source); - this.groupAddress = groupAddress; - this.interfAddress = interfAddress; - this.sourceAddress = sourceAddress; - } - - int groupAddress() { - return groupAddress; - } - - int interfaceAddress() { - return interfAddress; - } - - int source() { - return sourceAddress; - } - } - - /** - * MembershipKey will additional context for IPv6 membership - */ - static class Type6 extends MembershipKeyImpl { - private final byte[] groupAddress; - private final int index; - private final byte[] sourceAddress; - - Type6(MulticastChannel ch, - InetAddress group, - NetworkInterface interf, - InetAddress source, - byte[] groupAddress, - int index, - byte[] sourceAddress) - { - super(ch, group, interf, source); - this.groupAddress = groupAddress; - this.index = index; - this.sourceAddress = sourceAddress; - } - - byte[] groupAddress() { - return groupAddress; - } - - int index() { - return index; - } - - byte[] source() { - return sourceAddress; - } - } - - public boolean isValid() { - return valid; - } - - // package-private - void invalidate() { - valid = false; - } - - public void drop() throws IOException { - // delegate to channel - ((DatagramChannelImpl)ch).drop(this); - } - - - public MulticastChannel channel() { - return ch; - } - - - public InetAddress group() { - return group; - } - - - public NetworkInterface networkInterface() { - return interf; - } - - - public InetAddress sourceAddress() { - return source; - } - - - public MembershipKey block(InetAddress toBlock) - throws IOException - { - if (source != null) - throw new IllegalStateException("key is source-specific"); - - synchronized (stateLock) { - if ((blockedSet != null) && blockedSet.contains(toBlock)) { - // already blocked, nothing to do - return this; - } - - ((DatagramChannelImpl)ch).block(this, toBlock); - - // created blocked set if required and add source address - if (blockedSet == null) - blockedSet = new HashSet<InetAddress>(); - blockedSet.add(toBlock); - } - return this; - } - - - public MembershipKey unblock(InetAddress toUnblock) - throws IOException - { - synchronized (stateLock) { - if ((blockedSet == null) || !blockedSet.contains(toUnblock)) - throw new IllegalStateException("not blocked"); - - ((DatagramChannelImpl)ch).unblock(this, toUnblock); - - blockedSet.remove(toUnblock); - } - return this; - } - - - public String toString() { - StringBuilder sb = new StringBuilder(64); - sb.append('<'); - sb.append(group.getHostAddress()); - sb.append(','); - sb.append(interf.getName()); - if (source != null) { - sb.append(','); - sb.append(source.getHostAddress()); - } - sb.append('>'); - return sb.toString(); - } -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/MembershipRegistry.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,132 +0,0 @@ -/* - * Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package sun.nio.ch; - -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.util.*; - -import org.classpath.icedtea.java.nio.channels.MembershipKey; - -/** - * Simple registry of membership keys for a MulticastChannel. - * - * Instances of this object are not safe by multiple concurrent threads. - */ - -class MembershipRegistry { - - // map multicast group to keys - private Map<InetAddress,List<MembershipKeyImpl>> groups = null; - - MembershipRegistry() { - } - - /** - * Checks registry for membership of the group on the given - * network interface. - */ - MembershipKey checkMembership(InetAddress group, NetworkInterface interf, - InetAddress source) - { - if (groups != null) { - List<MembershipKeyImpl> keys = groups.get(group); - if (keys != null) { - for (MembershipKeyImpl key: keys) { - if (key.networkInterface().equals(interf)) { - // already a member to receive all packets so return - // existing key or detect conflict - if (source == null) { - if (key.sourceAddress() == null) - return key; - throw new IllegalStateException("Already a member to receive all packets"); - } - - // already have source-specific membership so return key - // or detect conflict - if (key.sourceAddress() == null) - throw new IllegalStateException("Already have source-specific membership"); - if (source.equals(key.sourceAddress())) - return key; - } - } - } - } - return null; - } - - /** - * Add membership to the registry, returning a new membership key. - */ - void add(MembershipKeyImpl key) { - InetAddress group = key.group(); - List<MembershipKeyImpl> keys; - if (groups == null) { - groups = new HashMap<InetAddress,List<MembershipKeyImpl>>(); - keys = null; - } else { - keys = groups.get(group); - } - if (keys == null) { - keys = new LinkedList<MembershipKeyImpl>(); - groups.put(group, keys); - } - keys.add(key); - } - - /** - * Remove a key from the registry - */ - void remove(MembershipKeyImpl key) { - InetAddress group = key.group(); - List<MembershipKeyImpl> keys = groups.get(group); - if (keys != null) { - Iterator<MembershipKeyImpl> i = keys.iterator(); - while (i.hasNext()) { - if (i.next() == key) { - i.remove(); - break; - } - } - if (keys.isEmpty()) { - groups.remove(group); - } - } - } - - /** - * Invalidate all keys in the registry - */ - void invalidateAll() { - if (groups != null) { - for (InetAddress group: groups.keySet()) { - for (MembershipKeyImpl key: groups.get(group)) { - key.invalidate(); - } - } - } - } -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/OptionKey.java Fri Feb 13 20:38:41 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package sun.nio.ch; - -/** - * Represents the level/name of a socket option - */ - -class OptionKey { - private int level; - private int name; - - OptionKey(int level, int name) { - this.level = level; - this.name = name; - } - - int level() { - return level; - } - - int name() { - return name; - } -}
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/PendingFuture.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/PendingFuture.java Fri Feb 20 14:50:00 2009 +0000 @@ -28,8 +28,8 @@ import java.util.concurrent.*; import java.io.IOException; -import org.classpath.icedtea.java.nio.channels.AsynchronousChannel; -import org.classpath.icedtea.java.nio.channels.CompletionHandler; +import java.nio.channels.AsynchronousChannel; +import java.nio.channels.CompletionHandler; /** * A Future for a pending I/O operation. A PendingFuture allows for the
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousDatagramChannelImpl.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousDatagramChannelImpl.java Fri Feb 20 14:50:00 2009 +0000 @@ -40,16 +40,16 @@ import java.security.PrivilegedExceptionAction; import java.security.PrivilegedActionException; -import org.classpath.icedtea.java.net.ProtocolFamily; -import org.classpath.icedtea.java.net.SocketOption; +import java.net.ProtocolFamily; +import java.net.SocketOption; -import org.classpath.icedtea.java.nio.channels.AsynchronousDatagramChannel; -import org.classpath.icedtea.java.nio.channels.CompletionHandler; -import org.classpath.icedtea.java.nio.channels.DatagramChannel; -import org.classpath.icedtea.java.nio.channels.InterruptedByTimeoutException; -import org.classpath.icedtea.java.nio.channels.MembershipKey; -import org.classpath.icedtea.java.nio.channels.MulticastChannel; -import org.classpath.icedtea.java.nio.channels.ShutdownChannelGroupException; +import java.nio.channels.AsynchronousDatagramChannel; +import java.nio.channels.CompletionHandler; +import java.nio.channels.DatagramChannel; +import java.nio.channels.InterruptedByTimeoutException; +import java.nio.channels.MembershipKey; +import java.nio.channels.MulticastChannel; +import java.nio.channels.ShutdownChannelGroupException; /** * A prototype implementation of AsynchronousDatagramChannel, used to aid @@ -141,23 +141,23 @@ } - public MulticastChannel channel() { + public MulticastChannel getChannel() { return channel; } - public InetAddress group() { - return key.group(); + public InetAddress getGroup() { + return key.getGroup(); } - public NetworkInterface networkInterface() { - return key.networkInterface(); + public NetworkInterface getNetworkInterface() { + return key.getNetworkInterface(); } - public InetAddress sourceAddress() { - return key.sourceAddress(); + public InetAddress getSourceAddress() { + return key.getSourceAddress(); } @@ -414,12 +414,12 @@ } - public Set<SocketOption<?>> supportedOptions() { - return dc.supportedOptions(); + public Set<SocketOption<?>> options() { + return dc.options(); } public SocketAddress getRemoteAddress() throws IOException { - return dc.getRemoteAddress(); + return dc.getConnectedAddress(); } }
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java Fri Feb 20 14:50:00 2009 +0000 @@ -36,10 +36,10 @@ import java.io.FileDescriptor; import java.io.IOException; -import org.classpath.icedtea.java.nio.channels.AsynchronousFileChannel; -import org.classpath.icedtea.java.nio.channels.CompletionHandler; -import org.classpath.icedtea.java.nio.channels.FileLock; -import org.classpath.icedtea.java.nio.channels.ShutdownChannelGroupException; +import java.nio.channels.AsynchronousFileChannel; +import java.nio.channels.CompletionHandler; +import java.nio.channels.FileLock; +import java.nio.channels.ShutdownChannelGroupException; /** * "Portable" implementation of AsynchronousFileChannel for use on operating
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/ThreadPool.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/ch/ThreadPool.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,7 +29,7 @@ import java.security.AccessController; import sun.security.action.GetPropertyAction; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider.ThreadPoolType; +import java.nio.channels.spi.AsynchronousChannelProvider.ThreadPoolType; /** * Defines static methods to create thread pools that are configured by
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractAclFileAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractAclFileAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -28,9 +28,9 @@ import java.io.IOException; import java.util.*; -import org.classpath.icedtea.java.nio.file.attribute.AclEntry; -import org.classpath.icedtea.java.nio.file.attribute.AclFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipal; +import java.nio.file.attribute.AclEntry; +import java.nio.file.attribute.AclFileAttributeView; +import java.nio.file.attribute.UserPrincipal; /** * Base implementation of AclFileAttributeView
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractBasicFileAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractBasicFileAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,8 +29,8 @@ import java.util.*; import java.util.concurrent.TimeUnit; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributeView; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.BasicFileAttributeView; /** * Base implementation of BasicFileAttributeView
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractFileStoreSpaceAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractFileStoreSpaceAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -28,8 +28,8 @@ import java.io.IOException; import java.util.*; -import org.classpath.icedtea.java.nio.file.attribute.FileStoreSpaceAttributes; -import org.classpath.icedtea.java.nio.file.attribute.FileStoreSpaceAttributeView; +import java.nio.file.attribute.FileStoreSpaceAttributes; +import java.nio.file.attribute.FileStoreSpaceAttributeView; /** * Base implementation of FileStoreSpaceAttributeView
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractFileTypeDetector.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractFileTypeDetector.java Fri Feb 20 14:50:00 2009 +0000 @@ -28,8 +28,8 @@ import java.io.IOException; import sun.nio.fs.MimeType; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.spi.FileTypeDetector; +import java.nio.file.FileRef; +import java.nio.file.spi.FileTypeDetector; /** * Base implementation of FileTypeDetector
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractNamedAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractNamedAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,7 +29,7 @@ import java.io.IOException; import java.util.*; -import org.classpath.icedtea.java.nio.file.attribute.NamedAttributeView; +import java.nio.file.attribute.NamedAttributeView; /** * Base implementation of NamedAttributeView
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractPoller.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractPoller.java Fri Feb 20 14:50:00 2009 +0000 @@ -30,12 +30,12 @@ import java.io.IOException; import java.util.*; -import org.classpath.icedtea.java.nio.file.ClosedWatchServiceException; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.StandardWatchEventKind; -import org.classpath.icedtea.java.nio.file.WatchEvent; -import org.classpath.icedtea.java.nio.file.WatchKey; +import java.nio.file.ClosedWatchServiceException; +import java.nio.file.FileRef; +import java.nio.file.Path; +import java.nio.file.StandardWatchEventKind; +import java.nio.file.WatchEvent; +import java.nio.file.WatchKey; /** * Base implementation of background poller thread used in watch service
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchKey.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchKey.java Fri Feb 20 14:50:00 2009 +0000 @@ -27,9 +27,9 @@ import java.util.*; -import org.classpath.icedtea.java.nio.file.StandardWatchEventKind; -import org.classpath.icedtea.java.nio.file.WatchEvent; -import org.classpath.icedtea.java.nio.file.WatchKey; +import java.nio.file.StandardWatchEventKind; +import java.nio.file.WatchEvent; +import java.nio.file.WatchKey; /** * Base implementation class for watch keys.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchService.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractWatchService.java Fri Feb 20 14:50:00 2009 +0000 @@ -28,11 +28,11 @@ import java.util.concurrent.*; import java.io.IOException; -import org.classpath.icedtea.java.nio.file.ClosedWatchServiceException; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.WatchEvent; -import org.classpath.icedtea.java.nio.file.WatchKey; -import org.classpath.icedtea.java.nio.file.WatchService; +import java.nio.file.ClosedWatchServiceException; +import java.nio.file.Path; +import java.nio.file.WatchEvent; +import java.nio.file.WatchKey; +import java.nio.file.WatchService; /** * Base implementation class for watch services.
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java Fri Feb 20 14:50:00 2009 +0000 @@ -28,11 +28,11 @@ import java.util.*; import java.io.IOException; -import org.classpath.icedtea.java.nio.file.attribute.AclFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileOwnerAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.PosixFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipal; +import java.nio.file.attribute.AclFileAttributeView; +import java.nio.file.attribute.FileAttributeView; +import java.nio.file.attribute.FileOwnerAttributeView; +import java.nio.file.attribute.PosixFileAttributeView; +import java.nio.file.attribute.UserPrincipal; /** * An implementation of FileOwnerAttributeView that delegates to a given
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/PollingWatchService.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/PollingWatchService.java Fri Feb 20 14:50:00 2009 +0000 @@ -32,18 +32,18 @@ import java.io.IOException; import java.util.*; -import org.classpath.icedtea.java.nio.file.ClosedWatchServiceException; -import org.classpath.icedtea.java.nio.file.DirectoryStream; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.LinkOption; -import org.classpath.icedtea.java.nio.file.NotDirectoryException; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.StandardWatchEventKind; -import org.classpath.icedtea.java.nio.file.WatchEvent; -import org.classpath.icedtea.java.nio.file.WatchKey; +import java.nio.file.ClosedWatchServiceException; +import java.nio.file.DirectoryStream; +import java.nio.file.FileRef; +import java.nio.file.LinkOption; +import java.nio.file.NotDirectoryException; +import java.nio.file.Path; +import java.nio.file.StandardWatchEventKind; +import java.nio.file.WatchEvent; +import java.nio.file.WatchKey; -import org.classpath.icedtea.java.nio.file.attribute.Attributes; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.Attributes; +import java.nio.file.attribute.BasicFileAttributes; /** * Simple WatchService implementation that uses background thread to poll
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/JarFileAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/JarFileAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -33,7 +33,7 @@ import java.io.IOException; import java.util.*; -import org.classpath.icedtea.java.nio.file.FileRef; +import java.nio.file.FileRef; public class JarFileAttributeView extends ZipFileAttributeView {
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/JarFileAttributes.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/JarFileAttributes.java Fri Feb 20 14:50:00 2009 +0000 @@ -36,7 +36,7 @@ import java.util.Map; import java.util.Set; -import org.classpath.icedtea.java.nio.file.FileRef; +import java.nio.file.FileRef; public class JarFileAttributes extends ZipFileAttributes {
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -33,7 +33,7 @@ import java.io.IOException; import java.util.*; -import org.classpath.icedtea.java.nio.file.FileRef; +import java.nio.file.FileRef; public class ZipFileAttributeView extends ZipFileBasicAttributeView {
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileAttributes.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileAttributes.java Fri Feb 20 14:50:00 2009 +0000 @@ -34,7 +34,7 @@ import java.util.concurrent.*; import java.io.*; -import org.classpath.icedtea.java.nio.file.FileRef; +import java.nio.file.FileRef; public class ZipFileAttributes extends ZipFileBasicAttributes {
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileBasicAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileBasicAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -34,11 +34,11 @@ import java.util.concurrent.*; import java.io.IOException; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.ReadOnlyFileSystemException; +import java.nio.file.FileRef; +import java.nio.file.ReadOnlyFileSystemException; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributeView; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.BasicFileAttributeView; public class ZipFileBasicAttributeView implements BasicFileAttributeView {
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileBasicAttributes.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileBasicAttributes.java Fri Feb 20 14:50:00 2009 +0000 @@ -35,11 +35,11 @@ import java.io.IOException; import java.util.Calendar; -import org.classpath.icedtea.java.nio.file.ClosedFileSystemException; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.ReadOnlyFileSystemException; +import java.nio.file.ClosedFileSystemException; +import java.nio.file.FileRef; +import java.nio.file.ReadOnlyFileSystemException; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.BasicFileAttributes; public class ZipFileBasicAttributes implements BasicFileAttributes {
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFilePath.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFilePath.java Fri Feb 20 14:50:00 2009 +0000 @@ -43,37 +43,37 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import org.classpath.icedtea.java.nio.channels.FileChannel; -import org.classpath.icedtea.java.nio.channels.SeekableByteChannel; +import java.nio.channels.FileChannel; +import java.nio.channels.SeekableByteChannel; -import org.classpath.icedtea.java.nio.file.AccessDeniedException; -import org.classpath.icedtea.java.nio.file.AccessMode; -import org.classpath.icedtea.java.nio.file.ClosedFileSystemException; -import org.classpath.icedtea.java.nio.file.CopyOption; -import org.classpath.icedtea.java.nio.file.DirectoryStream; -import org.classpath.icedtea.java.nio.file.DirectoryStream.Filter; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.FileStore; -import org.classpath.icedtea.java.nio.file.LinkOption; -import org.classpath.icedtea.java.nio.file.NoSuchFileException; -import org.classpath.icedtea.java.nio.file.OpenOption; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.Paths; -import org.classpath.icedtea.java.nio.file.PathMatcher; -import org.classpath.icedtea.java.nio.file.ProviderMismatchException; -import org.classpath.icedtea.java.nio.file.ReadOnlyFileSystemException; -import org.classpath.icedtea.java.nio.file.StandardOpenOption; -import org.classpath.icedtea.java.nio.file.WatchEvent; -import org.classpath.icedtea.java.nio.file.WatchKey; -import org.classpath.icedtea.java.nio.file.WatchService; +import java.nio.file.AccessDeniedException; +import java.nio.file.AccessMode; +import java.nio.file.ClosedFileSystemException; +import java.nio.file.CopyOption; +import java.nio.file.DirectoryStream; +import java.nio.file.DirectoryStream.Filter; +import java.nio.file.FileRef; +import java.nio.file.FileStore; +import java.nio.file.LinkOption; +import java.nio.file.NoSuchFileException; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.PathMatcher; +import java.nio.file.ProviderMismatchException; +import java.nio.file.ReadOnlyFileSystemException; +import java.nio.file.StandardOpenOption; +import java.nio.file.WatchEvent; +import java.nio.file.WatchKey; +import java.nio.file.WatchService; -import org.classpath.icedtea.java.nio.file.attribute.Attributes; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; -import org.classpath.icedtea.java.nio.file.attribute.FileAttributeView; +import java.nio.file.attribute.Attributes; +import java.nio.file.attribute.BasicFileAttributeView; +import java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.FileAttributeView; -import org.classpath.icedtea.java.nio.file.spi.AbstractPath; -import org.classpath.icedtea.java.nio.file.spi.FileSystemProvider; +import java.nio.file.spi.AbstractPath; +import java.nio.file.spi.FileSystemProvider; /** * Jar/Zip path implementation of Path
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileStore.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileStore.java Fri Feb 20 14:50:00 2009 +0000 @@ -36,17 +36,17 @@ import java.util.HashSet; import java.util.Map; -import org.classpath.icedtea.java.nio.file.FileStore; -import org.classpath.icedtea.java.nio.file.FileSystems; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.ProviderMismatchException; -import org.classpath.icedtea.java.nio.file.attribute.FileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileStoreAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileStoreAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileStoreSpaceAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileStoreSpaceAttributes; -import org.classpath.icedtea.java.nio.file.attribute.Attributes; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributeView; +import java.nio.file.FileStore; +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.nio.file.ProviderMismatchException; +import java.nio.file.attribute.FileAttributeView; +import java.nio.file.attribute.FileStoreAttributeView; +import java.nio.file.attribute.FileStoreAttributeView; +import java.nio.file.attribute.FileStoreSpaceAttributeView; +import java.nio.file.attribute.FileStoreSpaceAttributes; +import java.nio.file.attribute.Attributes; +import java.nio.file.attribute.BasicFileAttributeView; public class ZipFileStore extends FileStore {
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileStream.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileStream.java Fri Feb 20 14:50:00 2009 +0000 @@ -37,10 +37,10 @@ import java.io.IOException; import java.util.HashSet; -import org.classpath.icedtea.java.nio.file.DirectoryStream; -import org.classpath.icedtea.java.nio.file.NotDirectoryException; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.ReadOnlyFileSystemException; +import java.nio.file.DirectoryStream; +import java.nio.file.NotDirectoryException; +import java.nio.file.Path; +import java.nio.file.ReadOnlyFileSystemException; public class ZipFileStream implements DirectoryStream<Path> {
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystem.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystem.java Fri Feb 20 14:50:00 2009 +0000 @@ -38,19 +38,19 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.regex.Pattern; -import org.classpath.icedtea.java.nio.file.ClosedFileSystemException; -import org.classpath.icedtea.java.nio.file.DirectoryStream; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.FileStore; -import org.classpath.icedtea.java.nio.file.FileSystem; -import org.classpath.icedtea.java.nio.file.InvalidPathException; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.PathMatcher; -import org.classpath.icedtea.java.nio.file.WatchService; +import java.nio.file.ClosedFileSystemException; +import java.nio.file.DirectoryStream; +import java.nio.file.FileRef; +import java.nio.file.FileStore; +import java.nio.file.FileSystem; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.nio.file.PathMatcher; +import java.nio.file.WatchService; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipalLookupService; +import java.nio.file.attribute.UserPrincipalLookupService; -import org.classpath.icedtea.java.nio.file.spi.FileSystemProvider; +import java.nio.file.spi.FileSystemProvider; public class ZipFileSystem extends FileSystem {
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystemProvider.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipFileSystemProvider.java Fri Feb 20 14:50:00 2009 +0000 @@ -37,20 +37,20 @@ import java.util.Map; import java.util.Set; -import org.classpath.icedtea.java.nio.channels.FileChannel; +import java.nio.channels.FileChannel; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.FileSystem; -import org.classpath.icedtea.java.nio.file.FileSystems; -import org.classpath.icedtea.java.nio.file.FileSystemNotFoundException; -import org.classpath.icedtea.java.nio.file.InvalidPathException; -import org.classpath.icedtea.java.nio.file.OpenOption; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.Paths; +import java.nio.file.FileRef; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.FileSystemNotFoundException; +import java.nio.file.InvalidPathException; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.Paths; -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.FileAttribute; -import org.classpath.icedtea.java.nio.file.spi.FileSystemProvider; +import java.nio.file.spi.FileSystemProvider; public class ZipFileSystemProvider extends FileSystemProvider {
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipPathParser.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipPathParser.java Fri Feb 20 14:50:00 2009 +0000 @@ -35,9 +35,9 @@ import java.util.Stack; import java.util.regex.*; -import org.classpath.icedtea.java.nio.file.InvalidPathException; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.Paths; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.nio.file.Paths; public class ZipPathParser {
--- a/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipUtils.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/demo/nio/ZipFileSystem/com/sun/nio/zipfs/ZipUtils.java Fri Feb 20 14:50:00 2009 +0000 @@ -43,16 +43,16 @@ import java.util.jar.Manifest; import java.util.zip.*; -import org.classpath.icedtea.java.nio.channels.FileChannel; -import org.classpath.icedtea.java.nio.channels.SeekableByteChannel; +import java.nio.channels.FileChannel; +import java.nio.channels.SeekableByteChannel; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.FileSystem; -import org.classpath.icedtea.java.nio.file.FileSystems; -import org.classpath.icedtea.java.nio.file.NoSuchFileException; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.Paths; -import org.classpath.icedtea.java.nio.file.StandardOpenOption; +import java.nio.file.FileRef; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; /** * This class implements static methods for reading the zip file contents @@ -86,7 +86,7 @@ throws IOException { ByteBuffer buf = ByteBuffer.allocate(nBytes); buf = buf.order(ByteOrder.LITTLE_ENDIAN); - ch.positionSBC(offset); + ch.position(offset); int read = ch.read(buf); if (read <= 0) { return null; @@ -362,7 +362,7 @@ Path p = Paths.get(zfp.getFileSystem().getZipFileSystemFile()); try { long time = - org.classpath.icedtea.java.nio.file.attribute.Attributes.readBasicFileAttributes(p).lastModifiedTime(); + java.nio.file.attribute.Attributes.readBasicFileAttributes(p).lastModifiedTime(); zei.lastModifiedTime = javaTimeToDosTime(time); } catch (IOException e) { throw e;
--- a/overlays/nio2/openjdk/jdk/src/share/native/sun/nio/ch/genSocketOptionRegistry.c Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/native/sun/nio/ch/genSocketOptionRegistry.c Fri Feb 20 14:50:00 2009 +0000 @@ -64,10 +64,10 @@ out("package sun.nio.ch; "); out("import java.util.Map; "); out("import java.util.HashMap; "); - out("import org.classpath.icedtea.java.net.ProtocolFamily; "); - out("import org.classpath.icedtea.java.net.StandardProtocolFamily; "); - out("import org.classpath.icedtea.java.net.SocketOption; "); - out("import org.classpath.icedtea.java.net.StandardSocketOption; "); + out("import java.net.ProtocolFamily; "); + out("import java.net.StandardProtocolFamily; "); + out("import java.net.SocketOption; "); + out("import java.net.StandardSocketOption; "); out("class SocketOptionRegistry { "); out(" private SocketOptionRegistry() { } "); out(" private static class RegistryKey { ");
--- a/overlays/nio2/openjdk/jdk/src/share/sample/nio/aio/EchoServer.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/sample/nio/aio/EchoServer.java Fri Feb 20 14:50:00 2009 +0000 @@ -38,8 +38,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.classpath.icedtea.java.nio.channels.AsynchronousServerSocketChannel; -import org.classpath.icedtea.java.nio.channels.AsynchronousSocketChannel; +import java.nio.channels.AsynchronousServerSocketChannel; +import java.nio.channels.AsynchronousSocketChannel; public class EchoServer {
--- a/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/AclEdit.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/AclEdit.java Fri Feb 20 14:50:00 2009 +0000 @@ -33,12 +33,12 @@ import java.util.*; import java.util.regex.Pattern; -import org.classpath.icedtea.java.nio.file.AclEntryFlag; -import org.classpath.icedtea.java.nio.file.AclEntryPermission; -import org.classpath.icedtea.java.nio.file.AclEntryType; +import java.nio.file.AclEntryFlag; +import java.nio.file.AclEntryPermission; +import java.nio.file.AclEntryType; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipalLookupService; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipalNotFoundException; +import java.nio.file.attribute.UserPrincipalLookupService; +import java.nio.file.attribute.UserPrincipalNotFoundException; /** * Sample utility for editing a file's ACL.
--- a/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/Chmod.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/Chmod.java Fri Feb 20 14:50:00 2009 +0000 @@ -32,25 +32,25 @@ import java.io.IOException; import java.util.*; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.FileVisitor; -import org.classpath.icedtea.java.nio.file.FileVisitOption; -import org.classpath.icedtea.java.nio.file.FileVisitResult; +import java.nio.file.FileRef; +import java.nio.file.FileVisitor; +import java.nio.file.FileVisitOption; +import java.nio.file.FileVisitResult; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; -import org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.PosixFilePermission; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.OWNER_READ; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.OWNER_WRITE; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.GROUP_READ; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.GROUP_WRITE; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.OTHERS_READ; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.OTHERS_WRITE; -import static org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission.OTHERS_EXECUTE; +import static java.nio.file.attribute.PosixFilePermission.OWNER_READ; +import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE; +import static java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE; +import static java.nio.file.attribute.PosixFilePermission.GROUP_READ; +import static java.nio.file.attribute.PosixFilePermission.GROUP_WRITE; +import static java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE; +import static java.nio.file.attribute.PosixFilePermission.OTHERS_READ; +import static java.nio.file.attribute.PosixFilePermission.OTHERS_WRITE; +import static java.nio.file.attribute.PosixFilePermission.OTHERS_EXECUTE; -import static org.classpath.icedtea.java.nio.file.FileVisitResult.CONTINUE; +import static java.nio.file.FileVisitResult.CONTINUE; /** * Sample code that changes the permissions of files in a similar manner to the
--- a/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/Copy.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/Copy.java Fri Feb 20 14:50:00 2009 +0000 @@ -32,19 +32,19 @@ import java.io.IOException; import java.util.*; -import org.classpath.icedtea.java.nio.file.CopyOption; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.FileVisitor; -import org.classpath.icedtea.java.nio.file.FileVisitResult; -import org.classpath.icedtea.java.nio.file.Path; +import java.nio.file.CopyOption; +import java.nio.file.FileRef; +import java.nio.file.FileVisitor; +import java.nio.file.FileVisitResult; +import java.nio.file.Path; -import static org.classpath.icedtea.java.nio.file.StandardCopyOption.COPY_ATTRIBUTES; -import static org.classpath.icedtea.java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.BasicFileAttributes; -import static org.classpath.icedtea.java.nio.file.FileVisitResult.CONTINUE; -import static org.classpath.icedtea.java.nio.file.FileVisitResult.SKIP_SUBTREE; +import static java.nio.file.FileVisitResult.CONTINUE; +import static java.nio.file.FileVisitResult.SKIP_SUBTREE; /** * Sample code that copies files in a similar manner to the cp(1) program.
--- a/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/DiskUsage.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/DiskUsage.java Fri Feb 20 14:50:00 2009 +0000 @@ -31,11 +31,11 @@ import java.io.IOException; -import org.classpath.icedtea.java.nio.file.FileStore; -import org.classpath.icedtea.java.nio.file.FileSystem; +import java.nio.file.FileStore; +import java.nio.file.FileSystem; -import org.classpath.icedtea.java.nio.file.attribute.Attributes; -import org.classpath.icedtea.java.nio.file.attribute.FileStoreSpaceAttributes; +import java.nio.file.attribute.Attributes; +import java.nio.file.attribute.FileStoreSpaceAttributes; /** * Example utility that works like the df(1M) program to print out disk space
--- a/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/FileType.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/FileType.java Fri Feb 20 14:50:00 2009 +0000 @@ -31,12 +31,12 @@ import java.io.IOException; -import org.classpath.icedtea.java.nio.file.Files; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.Paths; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; -import org.classpath.icedtea.java.nio.file.attribute.Attributes; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.Attributes; +import java.nio.file.attribute.BasicFileAttributes; public class FileType { public static void main(String[] args) throws IOException {
--- a/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/WatchDir.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/WatchDir.java Fri Feb 20 14:50:00 2009 +0000 @@ -32,23 +32,23 @@ import java.io.*; import java.util.*; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.FileSystems; -import org.classpath.icedtea.java.nio.file.FileVisitResult; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.SimpleFileVisitor; -import org.classpath.icedtea.java.nio.file.WatchDir; -import org.classpath.icedtea.java.nio.file.WatchEvent; -import org.classpath.icedtea.java.nio.file.WatchKey; -import org.classpath.icedtea.java.nio.file.WatchService; +import java.nio.file.FileRef; +import java.nio.file.FileSystems; +import java.nio.file.FileVisitResult; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.WatchDir; +import java.nio.file.WatchEvent; +import java.nio.file.WatchKey; +import java.nio.file.WatchService; -import static org.classpath.icedtea.java.nio.file.StandardWatchEventKind.ENTRY_CREATE; -import static org.classpath.icedtea.java.nio.file.StandardWatchEventKind.ENTRY_DELETE; -import static org.classpath.icedtea.java.nio.file.StandardWatchEventKind.ENTRY_MODIFY; +import static java.nio.file.StandardWatchEventKind.ENTRY_CREATE; +import static java.nio.file.StandardWatchEventKind.ENTRY_DELETE; +import static java.nio.file.StandardWatchEventKind.ENTRY_MODIFY; -import static org.classpath.icedtea.java.nio.file.LinkOption.NOFOLLOW_LINKS; +import static java.nio.file.LinkOption.NOFOLLOW_LINKS; -import org.classpath.icedtea.java.nio.file.attribute.Attributes; +import java.nio.file.attribute.Attributes; /** * Example to watch a directory (or tree) for changes to files.
--- a/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/Xdd.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/share/sample/nio/file/Xdd.java Fri Feb 20 14:50:00 2009 +0000 @@ -36,10 +36,10 @@ import java.nio.charset.Charset; -import org.classpath.icedtea.java.nio.file.FileStore; -import org.classpath.icedtea.java.nio.file.Path; +import java.nio.file.FileStore; +import java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.attribute.NamedAttributeView; +import java.nio.file.attribute.NamedAttributeView; /** * Example code to list/set/get/delete the named attributes of a file.
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java Fri Feb 20 14:50:00 2009 +0000 @@ -28,7 +28,7 @@ import java.security.AccessController; import sun.security.action.GetPropertyAction; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider; +import java.nio.channels.spi.AsynchronousChannelProvider; /** * Creates this platform's default asynchronous channel provider
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,7 +29,7 @@ import java.security.PrivilegedAction; import sun.security.action.GetPropertyAction; -import org.classpath.icedtea.java.nio.channels.spi.SelectorProvider; +import java.nio.channels.spi.SelectorProvider; /** * Creates this platform's default SelectorProvider
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/EPollPort.java Fri Feb 20 14:50:00 2009 +0000 @@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; import sun.misc.Unsafe; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider; +import java.nio.channels.spi.AsynchronousChannelProvider; /** * AsynchronousChannelGroup implementation based on the Linux epoll facility.
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/LinuxAsynchronousChannelProvider.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/LinuxAsynchronousChannelProvider.java Fri Feb 20 14:50:00 2009 +0000 @@ -28,15 +28,15 @@ import java.util.concurrent.ExecutorService; import java.io.IOException; -import org.classpath.icedtea.java.net.ProtocolFamily; +import java.net.ProtocolFamily; -import org.classpath.icedtea.java.nio.channels.AsynchronousChannelGroup; -import org.classpath.icedtea.java.nio.channels.AsynchronousDatagramChannel; -import org.classpath.icedtea.java.nio.channels.AsynchronousSocketChannel; -import org.classpath.icedtea.java.nio.channels.AsynchronousServerSocketChannel; -import org.classpath.icedtea.java.nio.channels.IllegalChannelGroupException; +import java.nio.channels.AsynchronousChannelGroup; +import java.nio.channels.AsynchronousDatagramChannel; +import java.nio.channels.AsynchronousSocketChannel; +import java.nio.channels.AsynchronousServerSocketChannel; +import java.nio.channels.IllegalChannelGroupException; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider; +import java.nio.channels.spi.AsynchronousChannelProvider; public class LinuxAsynchronousChannelProvider extends AsynchronousChannelProvider
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/Port.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/Port.java Fri Feb 20 14:50:00 2009 +0000 @@ -34,9 +34,9 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import org.classpath.icedtea.java.nio.channels.ShutdownChannelGroupException; +import java.nio.channels.ShutdownChannelGroupException; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider; +import java.nio.channels.spi.AsynchronousChannelProvider; /** * Base implementation of AsynchronousChannelGroupImpl for Unix systems.
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/SolarisAsynchronousChannelProvider.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/SolarisAsynchronousChannelProvider.java Fri Feb 20 14:50:00 2009 +0000 @@ -28,15 +28,15 @@ import java.util.concurrent.ExecutorService; import java.io.IOException; -import org.classpath.icedtea.java.net.ProtocolFamily; +import java.net.ProtocolFamily; -import org.classpath.icedtea.java.nio.channels.AsynchronousChannelGroup; -import org.classpath.icedtea.java.nio.channels.AsynchronousDatagramChannel; -import org.classpath.icedtea.java.nio.channels.AsynchronousSocketChannel; -import org.classpath.icedtea.java.nio.channels.AsynchronousServerSocketChannel; -import org.classpath.icedtea.java.nio.channels.IllegalChannelGroupException; +import java.nio.channels.AsynchronousChannelGroup; +import java.nio.channels.AsynchronousDatagramChannel; +import java.nio.channels.AsynchronousSocketChannel; +import java.nio.channels.AsynchronousServerSocketChannel; +import java.nio.channels.IllegalChannelGroupException; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider; +import java.nio.channels.spi.AsynchronousChannelProvider; public class SolarisAsynchronousChannelProvider extends AsynchronousChannelProvider
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/SolarisEventPort.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/SolarisEventPort.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,7 +29,7 @@ import java.io.IOException; import sun.misc.Unsafe; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider; +import java.nio.channels.spi.AsynchronousChannelProvider; /** * AsynchronousChannelGroup implementation based on the Solaris 10 event port
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java Fri Feb 20 14:50:00 2009 +0000 @@ -38,9 +38,9 @@ import java.security.AccessController; import java.security.PrivilegedAction; -import org.classpath.icedtea.java.nio.channels.AcceptPendingException; -import org.classpath.icedtea.java.nio.channels.AsynchronousSocketChannel; -import org.classpath.icedtea.java.nio.channels.CompletionHandler; +import java.nio.channels.AcceptPendingException; +import java.nio.channels.AsynchronousSocketChannel; +import java.nio.channels.CompletionHandler; /** * Unix implementation of AsynchronousServerSocketChannel
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java Fri Feb 20 14:50:00 2009 +0000 @@ -38,9 +38,9 @@ import java.security.PrivilegedAction; import sun.security.action.GetBooleanAction; -import org.classpath.icedtea.java.nio.channels.CompletionHandler; -import org.classpath.icedtea.java.nio.channels.InterruptedByTimeoutException; -import org.classpath.icedtea.java.nio.channels.ShutdownChannelGroupException; +import java.nio.channels.CompletionHandler; +import java.nio.channels.InterruptedByTimeoutException; +import java.nio.channels.ShutdownChannelGroupException; /** * Unix implementation of AsynchronousSocketChannel
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,7 +29,7 @@ import java.security.PrivilegedAction; import sun.security.action.GetPropertyAction; -import org.classpath.icedtea.java.nio.file.spi.FileSystemProvider; +import java.nio.file.spi.FileSystemProvider; /** * Creates this platform's default FileSystemProvider.
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/DefaultFileTypeDetector.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/DefaultFileTypeDetector.java Fri Feb 20 14:50:00 2009 +0000 @@ -25,7 +25,7 @@ package sun.nio.fs; -import org.classpath.icedtea.java.nio.file.spi.FileTypeDetector; +import java.nio.file.spi.FileTypeDetector; public class DefaultFileTypeDetector { private DefaultFileTypeDetector() { }
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,7 +29,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; -import org.classpath.icedtea.java.nio.file.FileRef; +import java.nio.file.FileRef; /** * File type detector that uses the GNOME I/O library or the deprecated
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -30,9 +30,9 @@ import java.io.IOException; import sun.misc.Unsafe; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; -import org.classpath.icedtea.java.nio.file.attribute.DosFileAttributes; -import org.classpath.icedtea.java.nio.file.attribute.DosFileAttributeView; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.DosFileAttributes; +import java.nio.file.attribute.DosFileAttributeView; import static sun.nio.fs.UnixNativeDispatcher.*; import static sun.nio.fs.UnixConstants.*;
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java Fri Feb 20 14:50:00 2009 +0000 @@ -31,13 +31,13 @@ import sun.security.action.GetPropertyAction; import static sun.nio.fs.LinuxNativeDispatcher.*; -import org.classpath.icedtea.java.nio.file.FileStore; -import org.classpath.icedtea.java.nio.file.LinkOption; -import org.classpath.icedtea.java.nio.file.WatchService; +import java.nio.file.FileStore; +import java.nio.file.LinkOption; +import java.nio.file.WatchService; -import org.classpath.icedtea.java.nio.file.attribute.DosFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.NamedAttributeView; +import java.nio.file.attribute.DosFileAttributeView; +import java.nio.file.attribute.FileAttributeView; +import java.nio.file.attribute.NamedAttributeView; /** * Linux implementation of FileSystem
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxNamedAttributeView.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxNamedAttributeView.java Fri Feb 20 14:50:00 2009 +0000 @@ -30,10 +30,10 @@ import java.util.*; import sun.misc.Unsafe; -import org.classpath.icedtea.java.nio.channels.AsynchronousFileChannel; -import org.classpath.icedtea.java.nio.channels.FileChannel; +import java.nio.channels.AsynchronousFileChannel; +import java.nio.channels.FileChannel; -import org.classpath.icedtea.java.nio.file.FileSystemException; +import java.nio.file.FileSystemException; import static sun.nio.fs.UnixConstants.*; import static sun.nio.fs.LinuxNativeDispatcher.*;
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxWatchService.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxWatchService.java Fri Feb 20 14:50:00 2009 +0000 @@ -31,11 +31,11 @@ import java.io.IOException; import sun.misc.Unsafe; -import org.classpath.icedtea.java.nio.file.NotDirectoryException; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.StandardWatchEventKind; -import org.classpath.icedtea.java.nio.file.WatchEvent; -import org.classpath.icedtea.java.nio.file.WatchKey; +import java.nio.file.NotDirectoryException; +import java.nio.file.Path; +import java.nio.file.StandardWatchEventKind; +import java.nio.file.WatchEvent; +import java.nio.file.WatchKey; import static sun.nio.fs.UnixNativeDispatcher.*; import static sun.nio.fs.UnixConstants.*;
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java Fri Feb 20 14:50:00 2009 +0000 @@ -34,12 +34,12 @@ import sun.misc.SharedSecrets; import sun.misc.JavaIOFileDescriptorAccess; -import org.classpath.icedtea.java.nio.channels.AsynchronousFileChannel; -import org.classpath.icedtea.java.nio.channels.FileChannel; +import java.nio.channels.AsynchronousFileChannel; +import java.nio.channels.FileChannel; -import org.classpath.icedtea.java.nio.file.LinkOption; -import org.classpath.icedtea.java.nio.file.OpenOption; -import org.classpath.icedtea.java.nio.file.StandardOpenOption; +import java.nio.file.LinkOption; +import java.nio.file.OpenOption; +import java.nio.file.StandardOpenOption; import static sun.nio.fs.UnixNativeDispatcher.*; import static sun.nio.fs.UnixConstants.*;
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixCopyFile.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixCopyFile.java Fri Feb 20 14:50:00 2009 +0000 @@ -31,13 +31,13 @@ import java.util.concurrent.ExecutionException; import com.sun.nio.file.ExtendedCopyOption; -import org.classpath.icedtea.java.nio.file.AtomicMoveNotSupportedException; -import org.classpath.icedtea.java.nio.file.CopyOption; -import org.classpath.icedtea.java.nio.file.DirectoryNotEmptyException; -import org.classpath.icedtea.java.nio.file.FileAlreadyExistsException; -import org.classpath.icedtea.java.nio.file.LinkOption; -import org.classpath.icedtea.java.nio.file.LinkPermission; -import org.classpath.icedtea.java.nio.file.StandardCopyOption; +import java.nio.file.AtomicMoveNotSupportedException; +import java.nio.file.CopyOption; +import java.nio.file.DirectoryNotEmptyException; +import java.nio.file.FileAlreadyExistsException; +import java.nio.file.LinkOption; +import java.nio.file.LinkPermission; +import java.nio.file.StandardCopyOption; import static sun.nio.fs.UnixNativeDispatcher.*; import static sun.nio.fs.UnixConstants.*;
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixDirectoryStream.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixDirectoryStream.java Fri Feb 20 14:50:00 2009 +0000 @@ -32,9 +32,9 @@ import java.io.IOException; import static sun.nio.fs.UnixNativeDispatcher.*; -import org.classpath.icedtea.java.nio.file.ClosedDirectoryStreamException; -import org.classpath.icedtea.java.nio.file.DirectoryStream; -import org.classpath.icedtea.java.nio.file.Path; +import java.nio.file.ClosedDirectoryStreamException; +import java.nio.file.DirectoryStream; +import java.nio.file.Path; /** * Unix implementation of java.nio.file.DirectoryStream
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixException.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixException.java Fri Feb 20 14:50:00 2009 +0000 @@ -27,10 +27,10 @@ import java.io.IOException; -import org.classpath.icedtea.java.nio.file.AccessDeniedException; -import org.classpath.icedtea.java.nio.file.FileAlreadyExistsException; -import org.classpath.icedtea.java.nio.file.FileSystemException; -import org.classpath.icedtea.java.nio.file.NoSuchFileException; +import java.nio.file.AccessDeniedException; +import java.nio.file.FileAlreadyExistsException; +import java.nio.file.FileSystemException; +import java.nio.file.NoSuchFileException; /** * Internal exception thrown by native methods when error detected.
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileAttributeViews.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileAttributeViews.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,16 +29,16 @@ import java.util.concurrent.TimeUnit; import java.io.IOException; -import org.classpath.icedtea.java.nio.file.ProviderMismatchException; +import java.nio.file.ProviderMismatchException; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileOwnerAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.GroupPrincipal; -import org.classpath.icedtea.java.nio.file.attribute.PosixFileAttributes; -import org.classpath.icedtea.java.nio.file.attribute.PosixFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipal; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.BasicFileAttributeView; +import java.nio.file.attribute.FileOwnerAttributeView; +import java.nio.file.attribute.GroupPrincipal; +import java.nio.file.attribute.PosixFileAttributes; +import java.nio.file.attribute.PosixFileAttributeView; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.UserPrincipal; import static sun.nio.fs.UnixNativeDispatcher.*;
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileAttributes.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileAttributes.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,11 +29,11 @@ import java.util.Set; import java.util.HashSet; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; -import org.classpath.icedtea.java.nio.file.attribute.PosixFileAttributes; -import org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission; -import org.classpath.icedtea.java.nio.file.attribute.GroupPrincipal; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipal; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.PosixFileAttributes; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.GroupPrincipal; +import java.nio.file.attribute.UserPrincipal; /** * Unix implementation of PosixFileAttributes.
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileModeAttribute.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileModeAttribute.java Fri Feb 20 14:50:00 2009 +0000 @@ -27,8 +27,8 @@ import java.util.*; -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; -import org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.PosixFilePermission; class UnixFileModeAttribute { static final int ALL_PERMISSIONS =
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileStore.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileStore.java Fri Feb 20 14:50:00 2009 +0000 @@ -32,18 +32,18 @@ import java.security.AccessController; import java.security.PrivilegedAction; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.FileStore; -import org.classpath.icedtea.java.nio.file.FileSystem; -import org.classpath.icedtea.java.nio.file.Paths; +import java.nio.file.FileRef; +import java.nio.file.FileStore; +import java.nio.file.FileSystem; +import java.nio.file.Paths; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileOwnerAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileStoreAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileStoreSpaceAttributes; -import org.classpath.icedtea.java.nio.file.attribute.FileStoreSpaceAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.PosixFileAttributeView; +import java.nio.file.attribute.BasicFileAttributeView; +import java.nio.file.attribute.FileAttributeView; +import java.nio.file.attribute.FileOwnerAttributeView; +import java.nio.file.attribute.FileStoreAttributeView; +import java.nio.file.attribute.FileStoreSpaceAttributes; +import java.nio.file.attribute.FileStoreSpaceAttributeView; +import java.nio.file.attribute.PosixFileAttributeView; /** * Base implementation of FileStore for Unix/like implementations.
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystem.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystem.java Fri Feb 20 14:50:00 2009 +0000 @@ -32,21 +32,21 @@ import java.security.AccessController; import sun.security.action.GetBooleanAction; -import org.classpath.icedtea.java.nio.file.FileStore; -import org.classpath.icedtea.java.nio.file.FileSystem; -import org.classpath.icedtea.java.nio.file.LinkOption; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.PathMatcher; +import java.nio.file.FileStore; +import java.nio.file.FileSystem; +import java.nio.file.LinkOption; +import java.nio.file.Path; +import java.nio.file.PathMatcher; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileOwnerAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.PosixFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.GroupPrincipal; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipal; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipalLookupService; +import java.nio.file.attribute.BasicFileAttributeView; +import java.nio.file.attribute.FileAttributeView; +import java.nio.file.attribute.FileOwnerAttributeView; +import java.nio.file.attribute.PosixFileAttributeView; +import java.nio.file.attribute.GroupPrincipal; +import java.nio.file.attribute.UserPrincipal; +import java.nio.file.attribute.UserPrincipalLookupService; -import org.classpath.icedtea.java.nio.file.spi.FileSystemProvider; +import java.nio.file.spi.FileSystemProvider; /** * Base implementation of FileSystem for Unix-like implementations.
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java Fri Feb 20 14:50:00 2009 +0000 @@ -30,20 +30,20 @@ import java.io.IOException; import java.util.*; -import org.classpath.icedtea.java.nio.channels.AsynchronousFileChannel; -import org.classpath.icedtea.java.nio.channels.FileChannel; +import java.nio.channels.AsynchronousFileChannel; +import java.nio.channels.FileChannel; -import org.classpath.icedtea.java.nio.channels.spi.AsynchronousChannelProvider.ThreadPoolType; +import java.nio.channels.spi.AsynchronousChannelProvider.ThreadPoolType; -import org.classpath.icedtea.java.nio.file.FileSystem; -import org.classpath.icedtea.java.nio.file.FileSystemAlreadyExistsException; -import org.classpath.icedtea.java.nio.file.OpenOption; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.ProviderMismatchException; +import java.nio.file.FileSystem; +import java.nio.file.FileSystemAlreadyExistsException; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.ProviderMismatchException; -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.FileAttribute; -import org.classpath.icedtea.java.nio.file.spi.FileSystemProvider; +import java.nio.file.spi.FileSystemProvider; import sun.nio.ch.ThreadPool;
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java Fri Feb 20 14:50:00 2009 +0000 @@ -33,34 +33,34 @@ import java.util.*; import sun.security.util.SecurityConstants; -import org.classpath.icedtea.java.io.FilePermission; +import java.io.FilePermission; -import org.classpath.icedtea.java.nio.channels.SeekableByteChannel; +import java.nio.channels.SeekableByteChannel; -import org.classpath.icedtea.java.nio.file.AccessMode; -import org.classpath.icedtea.java.nio.file.CopyOption; -import org.classpath.icedtea.java.nio.file.DirectoryNotEmptyException; -import org.classpath.icedtea.java.nio.file.DirectoryStream; -import org.classpath.icedtea.java.nio.file.FileRef; -import org.classpath.icedtea.java.nio.file.FileStore; -import org.classpath.icedtea.java.nio.file.FileSystemException; -import org.classpath.icedtea.java.nio.file.InvalidPathException; -import org.classpath.icedtea.java.nio.file.LinkOption; -import org.classpath.icedtea.java.nio.file.LinkPermission; -import org.classpath.icedtea.java.nio.file.NotDirectoryException; -import org.classpath.icedtea.java.nio.file.NotLinkException; -import org.classpath.icedtea.java.nio.file.OpenOption; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.ProviderMismatchException; -import org.classpath.icedtea.java.nio.file.StandardOpenOption; -import org.classpath.icedtea.java.nio.file.WatchEvent; -import org.classpath.icedtea.java.nio.file.WatchKey; -import org.classpath.icedtea.java.nio.file.WatchService; +import java.nio.file.AccessMode; +import java.nio.file.CopyOption; +import java.nio.file.DirectoryNotEmptyException; +import java.nio.file.DirectoryStream; +import java.nio.file.FileRef; +import java.nio.file.FileStore; +import java.nio.file.FileSystemException; +import java.nio.file.InvalidPathException; +import java.nio.file.LinkOption; +import java.nio.file.LinkPermission; +import java.nio.file.NotDirectoryException; +import java.nio.file.NotLinkException; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.ProviderMismatchException; +import java.nio.file.StandardOpenOption; +import java.nio.file.WatchEvent; +import java.nio.file.WatchKey; +import java.nio.file.WatchService; -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; -import org.classpath.icedtea.java.nio.file.attribute.FileAttributeView; +import java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.FileAttributeView; -import org.classpath.icedtea.java.nio.file.spi.AbstractPath; +import java.nio.file.spi.AbstractPath; import static sun.nio.fs.UnixNativeDispatcher.*; import static sun.nio.fs.UnixConstants.*;
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixSecureDirectoryStream.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixSecureDirectoryStream.java Fri Feb 20 14:50:00 2009 +0000 @@ -29,29 +29,29 @@ import java.util.concurrent.TimeUnit; import java.io.IOException; -import org.classpath.icedtea.java.nio.channels.SeekableByteChannel; +import java.nio.channels.SeekableByteChannel; -import org.classpath.icedtea.java.nio.file.AtomicMoveNotSupportedException; -import org.classpath.icedtea.java.nio.file.ClosedDirectoryStreamException; -import org.classpath.icedtea.java.nio.file.DirectoryNotEmptyException; -import org.classpath.icedtea.java.nio.file.DirectoryStream; -import org.classpath.icedtea.java.nio.file.LinkOption; -import org.classpath.icedtea.java.nio.file.NotDirectoryException; -import org.classpath.icedtea.java.nio.file.OpenOption; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.ProviderMismatchException; -import org.classpath.icedtea.java.nio.file.SecureDirectoryStream; +import java.nio.file.AtomicMoveNotSupportedException; +import java.nio.file.ClosedDirectoryStreamException; +import java.nio.file.DirectoryNotEmptyException; +import java.nio.file.DirectoryStream; +import java.nio.file.LinkOption; +import java.nio.file.NotDirectoryException; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.ProviderMismatchException; +import java.nio.file.SecureDirectoryStream; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributes; -import org.classpath.icedtea.java.nio.file.attribute.BasicFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileAttribute; -import org.classpath.icedtea.java.nio.file.attribute.FileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.FileOwnerAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.GroupPrincipal; -import org.classpath.icedtea.java.nio.file.attribute.PosixFileAttributes; -import org.classpath.icedtea.java.nio.file.attribute.PosixFileAttributeView; -import org.classpath.icedtea.java.nio.file.attribute.PosixFilePermission; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipal; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.BasicFileAttributeView; +import java.nio.file.attribute.FileAttribute; +import java.nio.file.attribute.FileAttributeView; +import java.nio.file.attribute.FileOwnerAttributeView; +import java.nio.file.attribute.GroupPrincipal; +import java.nio.file.attribute.PosixFileAttributes; +import java.nio.file.attribute.PosixFileAttributeView; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.UserPrincipal; import static sun.nio.fs.UnixNativeDispatcher.*; import static sun.nio.fs.UnixConstants.*;
--- a/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixUserPrincipals.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/src/solaris/classes/sun/nio/fs/UnixUserPrincipals.java Fri Feb 20 14:50:00 2009 +0000 @@ -27,9 +27,9 @@ import java.io.IOException; -import org.classpath.icedtea.java.nio.file.attribute.GroupPrincipal; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipal; -import org.classpath.icedtea.java.nio.file.attribute.UserPrincipalNotFoundException; +import java.nio.file.attribute.GroupPrincipal; +import java.nio.file.attribute.UserPrincipal; +import java.nio.file.attribute.UserPrincipalNotFoundException; import static sun.nio.fs.UnixNativeDispatcher.*;
--- a/overlays/nio2/openjdk/jdk/test/demo/nio/ZipFileSystem/Sanity.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/test/demo/nio/ZipFileSystem/Sanity.java Fri Feb 20 14:50:00 2009 +0000 @@ -25,14 +25,14 @@ import java.net.URI; import java.io.IOException; -import org.classpath.icedtea.java.nio.file.FileSystem; -import org.classpath.icedtea.java.nio.file.FileVisitResult; -import org.classpath.icedtea.java.nio.file.Path; -import org.classpath.icedtea.java.nio.file.Paths; +import java.nio.file.FileSystem; +import java.nio.file.FileVisitResult; +import java.nio.file.Path; +import java.nio.file.Paths; -import org.classpath.icedtea.java.nio.file.attribute.Attributes; +import java.nio.file.attribute.Attributes; -import org.classpath.icedtea.java.nio.file.spi.FileSystemProvider; +import java.nio.file.spi.FileSystemProvider; /** * Sanity check zip provider by running a few simple tests.
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/io/Inputs/Basic.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/io/Inputs/Basic.java Fri Feb 20 14:50:00 2009 +0000 @@ -30,9 +30,9 @@ import java.nio.charset.UnsupportedCharsetException; import java.nio.charset.MalformedInputException; -import org.classpath.icedtea.java.io.Inputs; +import java.io.Inputs; -import org.classpath.icedtea.java.nio.file.Path; +import java.nio.file.Path; public class Basic { static final Random rand = new Random();
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java Fri Feb 20 14:50:00 2009 +0000 @@ -23,7 +23,7 @@ import java.util.concurrent.*; -import org.classpath.icedtea.java.nio.channels.AsynchronousChannelGroup; +import java.nio.channels.AsynchronousChannelGroup; /** * Test that arbitrary tasks can be submitted to a channel group's thread pool.
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Basic.java Fri Feb 13 20:38:41 2009 +0000 +++ b/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Basic.java Fri Feb 20 14:50:00 2009 +0000 @@ -35,7 +35,7 @@ import java.util.concurrent.*; import java.io.IOException; -import org.classpath.icedtea.java.nio.channels.AsynchronousChannelGroup; +import java.nio.channels.AsynchronousChannelGroup; public class Basic { static final Random rand = new Random();
--- a/patches/icedtea-doc-headers.patch Fri Feb 13 20:38:41 2009 +0000 +++ b/patches/icedtea-doc-headers.patch Fri Feb 20 14:50:00 2009 +0000 @@ -31,7 +31,7 @@ JAVADOCWINDOWTITLE = 'Java Platform SE $(JDK_MINOR_VERSION)' JAVADOCHEADER = '<strong>Java$(TRADEMARK) Platform<br>Standard Ed. $(JDK_MINOR_VERSION)</strong>' -JAVADOCBOTTOM = '<font size="-1"><a href="http://bugs.sun.com/services/bugreport/index.jsp">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="{@docroot}/../../webnotes/devdocs-vs-specs.html">Java SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Copyright $(THIS_YEAR) Sun Microsystems, Inc. All Rights Reserved. Use is subject to <a href="{@docroot}/../legal/license.html">license terms</a>. Also see the <a href="http://java.sun.com/docs/redist.html">documentation redistribution policy</a>.</font>' -++ JAVADOCBOTTOM = '<font size="-1"><a href="http://icedtea.classpath.org/bugzilla/">Submit a bug or feature</a> <p>Copyright $(THIS_YEAR) Sun Microsystems, Inc. All rights reserved. Use is subject to the terms of the <a href="http://www.gnu.org/copyleft/gpl.html">GNU General Public License</a>.</font>' ++JAVADOCBOTTOM = '<font size="-1"><a href="http://icedtea.classpath.org/bugzilla/">Submit a bug or feature</a> <p>Copyright $(THIS_YEAR) Sun Microsystems, Inc. All rights reserved. Use is subject to the terms of the <a href="http://www.gnu.org/copyleft/gpl.html">GNU General Public License</a>.</font>' JAVADOCOVERVIEW = $(SHARE_SRC)/classes/overview-core.html -#
--- a/patches/icedtea-nio2.patch Fri Feb 13 20:38:41 2009 +0000 +++ b/patches/icedtea-nio2.patch Fri Feb 20 14:50:00 2009 +0000 @@ -13,8 +13,8 @@ java.rmi.dgc \ diff -Nru openjdk.orig/jdk/make/java/nio/FILES_java.gmk openjdk/jdk/make/java/nio/FILES_java.gmk --- openjdk.orig/jdk/make/java/nio/FILES_java.gmk 2009-02-11 23:12:43.000000000 +0000 -+++ openjdk/jdk/make/java/nio/FILES_java.gmk 2009-02-12 16:05:24.000000000 +0000 -@@ -149,7 +149,150 @@ ++++ openjdk/jdk/make/java/nio/FILES_java.gmk 2009-02-20 11:03:22.000000000 +0000 +@@ -149,7 +149,147 @@ java/lang/StringCoding.java \ \ sun/misc/Cleaner.java \ @@ -122,9 +122,6 @@ + \ + java/util/concurrent/ScheduledThreadPoolExecutor.java \ + \ -+ misc/JavaUtilConcurrentThreadPoolExecutorAccess.java \ -+ misc/JavaNetGetIndexAccess.java \ -+ \ + com/sun/nio/file/ExtendedCopyOption.java \ + com/sun/nio/file/ExtendedOpenOption.java \ + com/sun/nio/file/ExtendedWatchEventModifier.java \ @@ -166,13 +163,13 @@ # Generated coder classes # -@@ -267,7 +410,14 @@ +@@ -267,7 +407,14 @@ \ java/nio/charset/CharacterCodingException.java \ java/nio/charset/IllegalCharsetNameException.java \ - java/nio/charset/UnsupportedCharsetException.java + java/nio/charset/UnsupportedCharsetException.java \ -+ \ ++ \ + java/nio/channels/AcceptPendingException.java \ + java/nio/channels/IllegalChannelGroupException.java \ + java/nio/channels/InterruptedByTimeoutException.java \ @@ -700,2083 +697,1469 @@ all build clean clobber:: $(SUBDIRS-loop) -diff -Nru openjdk.orig/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java openjdk/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java ---- openjdk.orig/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java 2009-02-11 23:11:27.000000000 +0000 -+++ openjdk/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java 2009-02-11 23:14:46.000000000 +0000 -@@ -56,6 +56,9 @@ - // The protocol family of the socket - private final ProtocolFamily family; - -+ // The protocol family of the socket -+ private final ProtocolFamily family; -+ - // IDs of native threads doing reads and writes, for signalling - private volatile long readerThread = 0; - private volatile long writerThread = 0; -@@ -94,6 +97,9 @@ - // Multicast support - private MembershipRegistry registry; +diff -Nru openjdk.orig/jdk/src/share/classes/java/io/File.java openjdk/jdk/src/share/classes/java/io/File.java +--- openjdk.orig/jdk/src/share/classes/java/io/File.java 2009-02-13 21:09:13.000000000 +0000 ++++ openjdk/jdk/src/share/classes/java/io/File.java 2009-02-14 01:11:10.000000000 +0000 +@@ -31,13 +31,28 @@ + import java.net.MalformedURLException; + import java.net.URISyntaxException; + import java.util.ArrayList; ++import java.util.EnumSet; + import java.util.Map; + import java.util.Hashtable; ++import java.util.Random; ++import java.util.Set; ++import java.util.concurrent.atomic.AtomicInteger; + import java.security.AccessController; + import java.security.AccessControlException; ++import java.security.PrivilegedAction; + import java.security.SecureRandom; + import sun.security.action.GetPropertyAction; -+ // Multicast support -+ private MembershipRegistry registry; ++import java.nio.file.FileAlreadyExistsException; ++import java.nio.file.FileSystems; ++import java.nio.file.InvalidPathException; ++import java.nio.file.Path; ++import java.nio.file.Paths; + - // -- End of fields protected by stateLock - ++import java.nio.file.attribute.FileAttribute; ++import java.nio.file.attribute.FileAttributeView; ++import java.nio.file.attribute.PosixFilePermission; ++import java.nio.file.attribute.PosixFilePermissions; -@@ -532,6 +538,7 @@ - assert IOStatus.check(n); - } - } -+ return this; - } - - private long read0(ByteBuffer[] bufs) throws IOException { -@@ -1079,4 +1086,350 @@ - initIDs(); + /** + * An abstract representation of file and directory pathnames. +@@ -131,6 +146,19 @@ + * created, the abstract pathname represented by a <code>File</code> object + * will never change. + * ++ * <h4>Interoperability with {@code java.nio.file} package</h4> ++ * ++ * <p> {@note new} ++ * The <a href="../../java/nio/file/package-summary.html">{@code java.nio.file}</a> ++ * package defines interfaces and classes for the Java virtual machine to access ++ * files, file attributes, and file systems. This API may be used to overcome ++ * many of the limitations of the {@code java.io.File} class. ++ * 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 ++ * locate a file. The resulting {@code Path} provides more efficient and ++ * extensive access to file attributes, additional file operations, and I/O ++ * exceptions to help diagnose errors when an operation on a file fails. ++ * + * @author unascribed + * @since JDK1.0 + */ +@@ -401,6 +429,203 @@ + this.prefixLength = fs.prefixLength(this.path); } -+ public SocketAddress getRemoteAddress() throws IOException { -+ synchronized (stateLock) { -+ if (!isOpen()) -+ throw new ClosedChannelException(); -+ return remoteAddress; -+ } -+ } -+ -+ public SocketAddress getLocalAddress() throws IOException { -+ synchronized (stateLock) { -+ if (!isOpen()) -+ throw new ClosedChannelException(); -+ return localAddress; -+ } -+ } -+ -+ public <T> DatagramChannel setOption(SocketOption<T> name, T value) -+ throws IOException -+ { -+ if (name == null) -+ throw new NullPointerException(); -+ if (!supportedOptions().contains(name)) -+ throw new UnsupportedOperationException("'" + name + "' not supported"); -+ -+ synchronized (stateLock) { -+ ensureOpen(); -+ -+ if (name == StandardSocketOption.IP_TOS) { -+ // IPv4 only; no-op for IPv6 -+ if (family == StandardProtocolFamily.INET) { -+ Net.setSocketOption(fd, family, name, value); -+ } -+ return this; -+ } -+ -+ if (name == StandardSocketOption.IP_MULTICAST_TTL || -+ name == StandardSocketOption.IP_MULTICAST_LOOP) -+ { -+ // options are protocol dependent -+ Net.setSocketOption(fd, family, name, value); -+ return this; -+ } -+ -+ if (name == StandardSocketOption.IP_MULTICAST_IF) { -+ if (value == null) -+ throw new IllegalArgumentException("Cannot set IP_MULTICAST_IF to 'null'"); -+ NetworkInterface interf = (NetworkInterface)value; -+ if (family == StandardProtocolFamily.INET6) { -+ int index = SharedSecrets.getJavaNetGetIndexAccess().getIndex(interf); -+ if (index == -1) -+ throw new IOException("Network interface cannot be identified"); -+ Net.setInterface6(fd, index); -+ } else { -+ // need IPv4 address to identify interface -+ Inet4Address target = Net.anyInet4Address(interf); -+ if (target == null) -+ throw new IOException("Network interface not configured for IPv4"); -+ int targetAddress = Net.inet4AsInt(target); -+ Net.setInterface4(fd, targetAddress); -+ } -+ return this; -+ } -+ -+ // remaining options don't need any special handling -+ Net.setSocketOption(fd, Net.UNSPEC, name, value); -+ return this; -+ } -+ } -+ -+ @SuppressWarnings("unchecked") -+ public <T> T getOption(SocketOption<T> name) -+ throws IOException -+ { -+ if (name == null) -+ throw new NullPointerException(); -+ if (!supportedOptions().contains(name)) -+ throw new UnsupportedOperationException("'" + name + "' not supported"); -+ -+ synchronized (stateLock) { -+ ensureOpen(); ++ /* -- Temporary files -- */ ++ ++ private static class TemporaryDirectory { ++ private TemporaryDirectory() { } + -+ if (name == StandardSocketOption.IP_TOS) { -+ // IPv4 only; always return 0 on IPv6 -+ if (family == StandardProtocolFamily.INET) { -+ return (T) Net.getSocketOption(fd, family, name); -+ } else { -+ return (T) Integer.valueOf(0); -+ } -+ } -+ -+ if (name == StandardSocketOption.IP_MULTICAST_TTL || -+ name == StandardSocketOption.IP_MULTICAST_LOOP) -+ { -+ return (T) Net.getSocketOption(fd, family, name); -+ } -+ -+ if (name == StandardSocketOption.IP_MULTICAST_IF) { -+ if (family == StandardProtocolFamily.INET) { -+ int address = Net.getInterface4(fd); -+ if (address == 0) -+ return null; // default interface -+ -+ InetAddress ia = Net.inet4FromInt(address); -+ NetworkInterface ni = NetworkInterface.getByInetAddress(ia); -+ if (ni == null) -+ throw new IOException("Unable to map address to interface"); -+ return (T) ni; -+ } else { -+ int index = Net.getInterface6(fd); -+ if (index == 0) -+ return null; // default interface -+ -+ NetworkInterface ni = SharedSecrets.getJavaNetGetIndexAccess().getByIndex(index); -+ if (ni == null) -+ throw new IOException("Unable to map index to interface"); -+ return (T) ni; -+ } -+ } ++ static final File valueAsFile = ++ new File(AccessController.doPrivileged(new GetPropertyAction("java.io.tmpdir"))); + -+ // no special handling -+ return (T) Net.getSocketOption(fd, Net.UNSPEC, name); -+ } -+ } -+ -+ private static class LazyInitialization { -+ static final Set<SocketOption<?>> defaultOptions = defaultOptions(); -+ -+ private static Set<SocketOption<?>> defaultOptions() { -+ HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(8); -+ set.add(StandardSocketOption.SO_SNDBUF); -+ set.add(StandardSocketOption.SO_RCVBUF); -+ set.add(StandardSocketOption.SO_REUSEADDR); -+ set.add(StandardSocketOption.SO_BROADCAST); -+ set.add(StandardSocketOption.IP_TOS); -+ set.add(StandardSocketOption.IP_MULTICAST_IF); -+ set.add(StandardSocketOption.IP_MULTICAST_TTL); -+ set.add(StandardSocketOption.IP_MULTICAST_LOOP); -+ return Collections.unmodifiableSet(set); -+ } -+ } -+ -+ public final Set<SocketOption<?>> supportedOptions() { -+ return LazyInitialization.defaultOptions; -+ } -+ -+ /** -+ * Joins channel's socket to the given group/interface and -+ * optional source address. -+ */ -+ private MembershipKey innerJoin(InetAddress group, -+ NetworkInterface interf, -+ InetAddress source) -+ throws IOException -+ { -+ if (!group.isMulticastAddress()) -+ throw new IllegalArgumentException("Group not a multicast address"); -+ -+ // check multicast address is compatible with this socket -+ if (!(group instanceof Inet4Address)) { -+ if (family == StandardProtocolFamily.INET) -+ throw new IllegalArgumentException("Group is not IPv4 address"); -+ if (!(group instanceof Inet6Address)) -+ throw new IllegalArgumentException("Address type not supported"); ++ // file name generation ++ private static final AtomicInteger counter = ++ new AtomicInteger(new Random().nextInt() & 0xffff); ++ static File generateFile(String prefix, String suffix, File dir) { ++ int n = counter.getAndIncrement(); ++ return new File(dir, prefix + Integer.toString(n) + suffix); + } + -+ // check source address -+ if (source != null) { -+ if (source.isAnyLocalAddress()) -+ throw new IllegalArgumentException("Source address is a wildcard address"); -+ if (source.isMulticastAddress()) -+ throw new IllegalArgumentException("Source address is multicast address"); -+ if (source.getClass() != group.getClass()) -+ throw new IllegalArgumentException("Source address is different type to group"); -+ } -+ -+ SecurityManager sm = System.getSecurityManager(); -+ if (sm != null) -+ sm.checkMulticast(group); -+ -+ synchronized (stateLock) { -+ if (!isOpen()) -+ throw new ClosedChannelException(); -+ -+ // check the registry to see if we are already a member of the group -+ if (registry == null) { -+ registry = new MembershipRegistry(); -+ } else { -+ // return existing membership key -+ MembershipKey key = registry.checkMembership(group, interf, source); -+ if (key != null) -+ return key; -+ } -+ -+ MembershipKeyImpl key; -+ if (family == StandardProtocolFamily.INET6) { -+ int index = SharedSecrets.getJavaNetGetIndexAccess().getIndex(interf); -+ if (index == -1) -+ throw new IOException("Network interface cannot be identified"); -+ -+ // need multicast and source address as byte arrays -+ byte[] groupAddress = Net.inet6AsByteArray(group); -+ byte[] sourceAddress = (source == null) ? null : -+ Net.inet6AsByteArray(source); -+ -+ // join the group -+ int n = Net.join6(fd, groupAddress, index, sourceAddress); -+ if (n == IOStatus.UNAVAILABLE) -+ throw new UnsupportedOperationException(); -+ -+ key = new MembershipKeyImpl.Type6(this, group, interf, source, -+ groupAddress, index, sourceAddress); -+ -+ } else { -+ // need IPv4 address to identify interface -+ Inet4Address target = Net.anyInet4Address(interf); -+ if (target == null) -+ throw new IOException("Network interface not configured for IPv4"); -+ -+ int groupAddress = Net.inet4AsInt(group); -+ int targetAddress = Net.inet4AsInt(target); -+ int sourceAddress = (source == null) ? 0 : Net.inet4AsInt(source); -+ -+ // join the group -+ int n = Net.join4(fd, groupAddress, targetAddress, sourceAddress); -+ if (n == IOStatus.UNAVAILABLE) -+ throw new UnsupportedOperationException(); -+ -+ key = new MembershipKeyImpl.Type4(this, group, interf, source, -+ groupAddress, targetAddress, sourceAddress); -+ } -+ -+ registry.add(key); -+ return key; -+ } -+ } -+ -+ -+ public MembershipKey join(InetAddress group, -+ NetworkInterface interf) -+ throws IOException -+ { -+ return innerJoin(group, interf, null); -+ } -+ -+ -+ public MembershipKey join(InetAddress group, -+ NetworkInterface interf, -+ InetAddress source) -+ throws IOException -+ { -+ if (source == null) -+ throw new NullPointerException("source address is null"); -+ return innerJoin(group, interf, source); -+ } -+ -+ /** -+ * Block datagrams from given source if a memory to receive all -+ * datagrams. -+ */ -+ void block(MembershipKeyImpl key, InetAddress source) -+ throws IOException -+ { -+ assert key.channel() == this; -+ assert key.sourceAddress() == null; -+ -+ synchronized (stateLock) { -+ if (!key.isValid()) -+ throw new IllegalStateException("key is no longer valid"); -+ if (source.isAnyLocalAddress()) -+ throw new IllegalArgumentException("Source address is a wildcard address"); -+ if (source.isMulticastAddress()) -+ throw new IllegalArgumentException("Source address is multicast address"); -+ if (source.getClass() != key.group().getClass()) -+ throw new IllegalArgumentException("Source address is different type to group"); -+ -+ int n; -+ if (family == StandardProtocolFamily.INET6) { -+ MembershipKeyImpl.Type6 key6 = -+ (MembershipKeyImpl.Type6)key; -+ n = Net.block6(fd, key6.groupAddress(), key6.index(), -+ Net.inet6AsByteArray(source)); -+ } else { -+ MembershipKeyImpl.Type4 key4 = -+ (MembershipKeyImpl.Type4)key; -+ n = Net.block4(fd, key4.groupAddress(), key4.interfaceAddress(), -+ Net.inet4AsInt(source)); -+ } -+ if (n == IOStatus.UNAVAILABLE) { -+ // ancient kernel -+ throw new UnsupportedOperationException(); -+ } -+ } ++ // default file permissions ++ static final FileAttribute<Set<PosixFilePermission>> defaultPosixFilePermissions = ++ PosixFilePermissions.asFileAttribute(EnumSet ++ .of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE)); ++ static final boolean isPosix = isPosix(); ++ static boolean isPosix() { ++ return AccessController.doPrivileged( ++ new PrivilegedAction<Boolean>() { ++ public Boolean run() { ++ try { ++ return FileSystems.getDefault().getPath(valueAsFile.getPath()) ++ .getFileStore().supportsFileAttributeView("posix"); ++ } catch (IOException e) { ++ throw new IOError(e); ++ } ++ } ++ }); ++ } + } + + /** -+ * Unblock given source. ++ * {@note new} ++ * Creates an empty file in the default temporary-file directory, using ++ * the given prefix and suffix to generate its name. This method is ++ * equivalent to invoking the {@link #createTempFile(String,String) ++ * createTempFile(prefix, suffix)} method with the addition that the ++ * resulting pathname may be requested to be deleted when the Java virtual ++ * machine terminates, and the initial file attributes to set atomically ++ * when creating the file may be specified. ++ * ++ * <p> When the value of the {@code deleteOnExit} method is {@code true} ++ * then the resulting file is requested to be deleted when the Java virtual ++ * machine terminates as if by invoking the {@link #deleteOnExit deleteOnExit} ++ * method. ++ * ++ * <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. ++ * ++ * @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 deleteOnExit ++ * {@code true} if the file denoted by resulting pathname be ++ * deleted when the Java virtual machine terminates ++ * @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</code> 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. When the {@code ++ * deleteOnExit} parameter has the value {@code true} then the ++ * security manager's {@link ++ * java.lang.SecurityManager#checkDelete(java.lang.String)} is ++ * invoked to check delete access to the file. ++ * @since 1.7 + */ -+ void unblock(MembershipKeyImpl key, InetAddress source) -+ throws IOException -+ { -+ assert key.channel() == this; -+ assert key.sourceAddress() == null; -+ -+ synchronized (stateLock) { -+ if (!key.isValid()) -+ throw new IllegalStateException("key is no longer valid"); -+ -+ if (family == StandardProtocolFamily.INET6) { -+ MembershipKeyImpl.Type6 key6 = -+ (MembershipKeyImpl.Type6)key; -+ Net.unblock6(fd, key6.groupAddress(), key6.index(), -+ Net.inet6AsByteArray(source)); -+ } else { -+ MembershipKeyImpl.Type4 key4 = -+ (MembershipKeyImpl.Type4)key; -+ Net.unblock4(fd, key4.groupAddress(), key4.interfaceAddress(), -+ Net.inet4AsInt(source)); -+ } -+ } -+ } -+ -+ // package-private -+ void drop(MembershipKeyImpl key) ++ public static File createTempFile(String prefix, ++ String suffix, ++ boolean deleteOnExit, ++ FileAttribute<?>... attrs) + throws IOException + { -+ assert key.channel() == this; -+ -+ synchronized (stateLock) { -+ if (!key.isValid()) -+ return; -+ -+ if (family == StandardProtocolFamily.INET6) { -+ MembershipKeyImpl.Type6 key6 = -+ (MembershipKeyImpl.Type6)key; -+ Net.drop6(fd, key6.groupAddress(), key6.index(), key6.source()); ++ if (prefix.length() < 3) ++ throw new IllegalArgumentException("Prefix string too short"); ++ suffix = (suffix == null) ? ".tmp" : suffix; ++ ++ // special case POSIX environments so that 0600 is used as the file mode ++ if (TemporaryDirectory.isPosix) { ++ if (attrs.length == 0) { ++ // no attributes so use default permissions ++ attrs = new FileAttribute<?>[1]; ++ attrs[0] = TemporaryDirectory.defaultPosixFilePermissions; + } else { -+ MembershipKeyImpl.Type4 key4 = (MembershipKeyImpl.Type4)key; -+ Net.drop4(fd, key4.groupAddress(), key4.interfaceAddress(), -+ key4.source()); ++ // check if posix permissions given; if not use default ++ boolean hasPermissions = false; ++ for (int i=0; i<attrs.length; i++) { ++ if (attrs[i].name().equals("posix:permissions")) { ++ hasPermissions = true; ++ break; ++ } ++ } ++ if (!hasPermissions) { ++ FileAttribute<?>[] copy = new FileAttribute<?>[attrs.length+1]; ++ System.arraycopy(attrs, 0, copy, 0, attrs.length); ++ attrs = copy; ++ attrs[attrs.length-1] = ++ TemporaryDirectory.defaultPosixFilePermissions; ++ } ++ } ++ } ++ ++ // use Path#createFile to create file ++ SecurityManager sm = System.getSecurityManager(); ++ for (;;) { ++ File f = TemporaryDirectory ++ .generateFile(prefix, suffix, TemporaryDirectory.valueAsFile); ++ if (sm != null && deleteOnExit) ++ sm.checkDelete(f.getPath()); ++ try { ++ f.toPath().createFile(attrs); ++ if (deleteOnExit) ++ DeleteOnExitHook.add(f.getPath()); ++ return f; ++ } catch (InvalidPathException e) { ++ // don't reveal temporary directory location ++ if (sm != null) ++ throw new IllegalArgumentException("Invalid prefix or suffix"); ++ throw e; ++ } catch (SecurityException e) { ++ // don't reveal temporary directory location ++ if (sm != null) ++ throw new SecurityException("Unable to create temporary file"); ++ throw e; ++ } catch (FileAlreadyExistsException e) { ++ // ignore ++ } ++ } ++ } ++ ++ // -- Integration with java.nio.file -- ++ ++ private volatile transient Path filePath; ++ ++ /** ++ * {@note new} ++ * Returns a {@link Path java.nio.file.Path} object constructed from the ++ * this abstract path. The first invocation of this method works as if ++ * invoking it were equivalent to evaluating the expression: ++ * <blockquote><pre> ++ * {@link FileSystems#getDefault FileSystems.getDefault}().{@link FileSystem#getPath getPath}(this.{@link #getPath getPath}()); ++ * </pre></blockquote> ++ * Subsequent invocations of this method return the same {@code Path}. ++ * ++ * <p> If this abstract pathname is the empty abstract pathname then this ++ * method returns a {@code Path} that may be used to access to the current ++ * user directory. ++ * ++ * @return A {@code Path} constructed from this abstract path. The resulting ++ * {@code Path} is associated with the {@link FileSystems#getDefault ++ * default-filesystem}. ++ * ++ * @throws InvalidPathException ++ * If a {@code Path} object cannot be constructed from the abstract ++ * path (see {@link java.nio.file.FileSystem#getPath FileSystem.getPath}) ++ * ++ * @since 1.7 ++ */ ++ public Path toPath() { ++ if (filePath == null) { ++ synchronized (this) { ++ if (filePath == null) { ++ String path = getPath(); ++ if (path.length() == 0) { ++ // assume default file system treats "." as current directory ++ filePath = Paths.get("."); ++ } else { ++ filePath = Paths.get(path); ++ } ++ } + } -+ -+ key.invalidate(); -+ registry.remove(key); -+ } -+ } ++ } ++ return filePath; ++ } + + /* -- Path-component accessors -- */ + +diff -Nru openjdk.orig/jdk/src/share/classes/java/io/FilePermission.java openjdk/jdk/src/share/classes/java/io/FilePermission.java +--- openjdk.orig/jdk/src/share/classes/java/io/FilePermission.java 2009-02-13 21:09:13.000000000 +0000 ++++ openjdk/jdk/src/share/classes/java/io/FilePermission.java 2009-02-13 22:03:14.000000000 +0000 +@@ -29,13 +29,13 @@ + import java.util.Enumeration; + import java.util.List; + import java.util.ArrayList; +-import java.util.StringTokenizer; + import java.util.Vector; + import java.util.Collections; ++import java.io.IOException; + import java.io.ObjectStreamField; + import java.io.ObjectOutputStream; + import java.io.ObjectInputStream; +-import java.io.IOException; ++import java.io.Serializable; + import sun.security.util.SecurityConstants; + + /** +@@ -56,9 +56,11 @@ + * (recursively) all files and subdirectories contained in the current + * directory. + * <P> ++ * {@note revised} + * The actions to be granted are passed to the constructor in a string containing + * a list of one or more comma-separated keywords. The possible keywords are +- * "read", "write", "execute", and "delete". Their meaning is defined as follows: ++ * "read", "write", "execute", "delete", and "readlink". Their meaning is ++ * defined as follows: + * <P> + * <DL> + * <DT> read <DD> read permission +@@ -69,6 +71,11 @@ + * <DT> delete + * <DD> delete permission. Allows <code>File.delete</code> to + * be called. Corresponds to <code>SecurityManager.checkDelete</code>. ++ * <DT> readlink ++ * <DD> read link permission. Allows the target of a ++ * <a href="../nio/file/package-summary.html#links">symbolic link</a> ++ * to be read by invoking the {@link java.nio.file.Path#readSymbolicLink ++ * readSymbolicLink } method. + * </DL> + * <P> + * The actions string is converted to lowercase before processing. +@@ -114,11 +121,15 @@ + * Delete action. + */ + private final static int DELETE = 0x8; ++ /** ++ * Read link action. ++ */ ++ private final static int READLINK = 0x10; + + /** +- * All actions (read,write,execute,delete) ++ * All actions (read,write,execute,delete,readlink) + */ +- private final static int ALL = READ|WRITE|EXECUTE|DELETE; ++ private final static int ALL = READ|WRITE|EXECUTE|DELETE|READLINK; + /** + * No actions. + */ +@@ -235,7 +246,7 @@ + * <i>path</i> is the pathname of a file or directory, and <i>actions</i> + * contains a comma-separated list of the desired actions granted on the + * file or directory. Possible actions are +- * "read", "write", "execute", and "delete". ++ * "read", "write", "execute", "delete", and "readlink". + * + * <p>A pathname that ends in "/*" (where "/" is + * the file separator character, <code>File.separatorChar</code>) +@@ -425,6 +436,8 @@ + return EXECUTE; + } else if (actions == SecurityConstants.FILE_DELETE_ACTION) { + return DELETE; ++ } else if (actions == SecurityConstants.FILE_READLINK_ACTION) { ++ return READLINK; + } + + char[] a = actions.toCharArray(); +@@ -485,6 +498,18 @@ + matchlen = 6; + mask |= DELETE; + ++ } else if (i >= 7 && (a[i-7] == 'r' || a[i-7] == 'R') && ++ (a[i-6] == 'e' || a[i-6] == 'E') && ++ (a[i-5] == 'a' || a[i-5] == 'A') && ++ (a[i-4] == 'd' || a[i-4] == 'D') && ++ (a[i-3] == 'l' || a[i-3] == 'L') && ++ (a[i-2] == 'i' || a[i-2] == 'I') && ++ (a[i-1] == 'n' || a[i-1] == 'N') && ++ (a[i] == 'k' || a[i] == 'K')) ++ { ++ matchlen = 8; ++ mask |= READLINK; + - } -diff -Nru openjdk.orig/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java openjdk/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java ---- openjdk.orig/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java 2009-02-11 23:11:27.000000000 +0000 -+++ openjdk/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java 2009-02-12 16:36:46.000000000 +0000 -@@ -100,7 +100,6 @@ - throw new ClosedChannelException(); - } - -- - // -- Standard channel operations -- + } else { + // parse error + throw new IllegalArgumentException( +@@ -529,7 +554,7 @@ + /** + * Return the canonical string representation of the actions. + * Always returns present actions in the following order: +- * read, write, execute, delete. ++ * read, write, execute, delete, readlink. + * + * @return the canonical string representation of the actions. + */ +@@ -561,14 +586,20 @@ + sb.append("delete"); + } - protected void implCloseChannel() throws IOException { -@@ -295,6 +294,10 @@ - } - } - -+ public FileChannel positionSBC(long newPosition) throws IOException { -+ return position(newPosition); -+ } ++ if ((mask & READLINK) == READLINK) { ++ if (comma) sb.append(','); ++ else comma = true; ++ sb.append("readlink"); ++ } + - public long size() throws IOException { - ensureOpen(); - synchronized (positionLock) { -@@ -365,6 +368,10 @@ - } + return sb.toString(); } -+ public FileChannel truncateSBC(long size) throws IOException { -+ return truncate(size); -+ } -+ - public void force(boolean metaData) throws IOException { - ensureOpen(); - int rv = -1; -diff -Nru openjdk.orig/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java~ openjdk/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java~ ---- openjdk.orig/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java~ 1970-01-01 01:00:00.000000000 +0100 -+++ openjdk/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java~ 2009-02-11 23:14:46.000000000 +0000 -@@ -0,0 +1,1326 @@ -+/* -+ * Copyright 2000-2008 Sun Microsystems, Inc. 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. Sun designates this -+ * particular file as subject to the "Classpath" exception as provided -+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -+ * CA 95054 USA or visit www.sun.com if you need additional information or -+ * have any questions. -+ */ -+ -+package sun.nio.ch; -+ -+import java.io.FileDescriptor; -+import java.io.FileInputStream; -+import java.io.FileOutputStream; -+import java.io.RandomAccessFile; -+import java.io.IOException; -+import java.nio.ByteBuffer; -+import java.nio.MappedByteBuffer; -+import java.nio.BufferPoolMXBean; -+import java.nio.channels.*; -+import java.nio.channels.spi.*; -+import java.util.ArrayList; -+import java.util.List; -+import java.util.Iterator; -+import java.util.concurrent.ConcurrentHashMap; -+import java.lang.ref.WeakReference; -+import java.lang.ref.ReferenceQueue; -+import java.lang.reflect.Field; -+import java.security.AccessController; -+import java.security.PrivilegedAction; -+import javax.management.ObjectName; -+import javax.management.MalformedObjectNameException; -+ -+import sun.misc.Cleaner; -+import sun.security.action.GetPropertyAction; -+ -+public class FileChannelImpl -+ extends FileChannel -+{ -+ -+ // Used to make native read and write calls -+ private static final NativeDispatcher nd; -+ -+ // Memory allocation size for mapping buffers -+ private static final long allocationGranularity; -+ -+ // File descriptor -+ private final FileDescriptor fd; -+ -+ // File access mode (immutable) -+ private final boolean writable; -+ private final boolean readable; -+ -+ // Required to prevent finalization of creating stream (immutable) -+ private final Object parent; -+ -+ // Thread-safe set of IDs of native threads, for signalling -+ private final NativeThreadSet threads = new NativeThreadSet(2); -+ -+ // Lock for operations involving position and size -+ private final Object positionLock = new Object(); -+ -+ private FileChannelImpl(FileDescriptor fd, boolean readable, -+ boolean writable, Object parent) -+ { -+ this.fd = fd; -+ this.readable = readable; -+ this.writable = writable; -+ this.parent = parent; -+ } -+ -+ // Invoked by getChannel() methods -+ // of java.io.File{Input,Output}Stream and RandomAccessFile -+ // -+ public static FileChannel open(FileDescriptor fd, -+ boolean readable, boolean writable, -+ Object parent) -+ { -+ return new FileChannelImpl(fd, readable, writable, parent); -+ } -+ -+ private void ensureOpen() throws IOException { -+ if (!isOpen()) -+ throw new ClosedChannelException(); -+ } -+ -+import org.classpath.icedtea.java.nio.channels.FileChannel; -+ -+ // -- Standard channel operations -- -+ -+ protected void implCloseChannel() throws IOException { -+ -+ nd.preClose(fd); -+ threads.signal(); -+ -+ // Invalidate and release any locks that we still hold -+ if (fileLockTable != null) { -+ fileLockTable.removeAll( new FileLockTable.Releaser() { -+ public void release(FileLock fl) throws IOException { -+ ((FileLockImpl)fl).invalidate(); -+ release0(fd, fl.position(), fl.size()); -+ } -+ }); -+ } -+ -+ if (parent != null) { -+ -+ // Close the fd via the parent stream's close method. The parent -+ // will reinvoke our close method, which is defined in the -+ // superclass AbstractInterruptibleChannel, but the isOpen logic in -+ // that method will prevent this method from being reinvoked. -+ // -+ ((java.io.Closeable)parent).close(); -+ } else { -+ nd.close(fd); -+ } -+ -+ } -+ -+ public int read(ByteBuffer dst) throws IOException { -+ ensureOpen(); -+ if (!readable) -+ throw new NonReadableChannelException(); -+ synchronized (positionLock) { -+ int n = 0; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return 0; -+ ti = threads.add(); -+ do { -+ n = IOUtil.read(fd, dst, -1, nd, positionLock); -+ } while ((n == IOStatus.INTERRUPTED) && isOpen()); -+ return IOStatus.normalize(n); -+ } finally { -+ threads.remove(ti); -+ end(n > 0); -+ assert IOStatus.check(n); -+ } -+ } -+ } -+ -+ private long read0(ByteBuffer[] dsts) throws IOException { -+ ensureOpen(); -+ if (!readable) -+ throw new NonReadableChannelException(); -+ synchronized (positionLock) { -+ long n = 0; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return 0; -+ ti = threads.add(); -+ do { -+ n = IOUtil.read(fd, dsts, nd); -+ } while ((n == IOStatus.INTERRUPTED) && isOpen()); -+ return IOStatus.normalize(n); -+ } finally { -+ threads.remove(ti); -+ end(n > 0); -+ assert IOStatus.check(n); -+ } -+ } -+ } -+ -+ public long read(ByteBuffer[] dsts, int offset, int length) -+ throws IOException -+ { -+ if ((offset < 0) || (length < 0) || (offset > dsts.length - length)) -+ throw new IndexOutOfBoundsException(); -+ // ## Fix IOUtil.write so that we can avoid this array copy -+ return read0(Util.subsequence(dsts, offset, length)); -+ } -+ -+ public int write(ByteBuffer src) throws IOException { -+ ensureOpen(); -+ if (!writable) -+ throw new NonWritableChannelException(); -+ synchronized (positionLock) { -+ int n = 0; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return 0; -+ ti = threads.add(); -+ do { -+ n = IOUtil.write(fd, src, -1, nd, positionLock); -+ } while ((n == IOStatus.INTERRUPTED) && isOpen()); -+ return IOStatus.normalize(n); -+ } finally { -+ threads.remove(ti); -+ end(n > 0); -+ assert IOStatus.check(n); -+ } -+ } -+ } -+ -+ private long write0(ByteBuffer[] srcs) throws IOException { -+ ensureOpen(); -+ if (!writable) -+ throw new NonWritableChannelException(); -+ synchronized (positionLock) { -+ long n = 0; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return 0; -+ ti = threads.add(); -+ do { -+ n = IOUtil.write(fd, srcs, nd); -+ } while ((n == IOStatus.INTERRUPTED) && isOpen()); -+ return IOStatus.normalize(n); -+ } finally { -+ threads.remove(ti); -+ end(n > 0); -+ assert IOStatus.check(n); -+ } -+ } -+ } -+ -+ public long write(ByteBuffer[] srcs, int offset, int length) -+ throws IOException -+ { -+ if ((offset < 0) || (length < 0) || (offset > srcs.length - length)) -+ throw new IndexOutOfBoundsException(); -+ // ## Fix IOUtil.write so that we can avoid this array copy -+ return write0(Util.subsequence(srcs, offset, length)); -+ } + /** + * Returns the "canonical string representation" of the actions. + * That is, this method always returns present actions in the following order: +- * read, write, execute, delete. For example, if this FilePermission object +- * allows both write and read actions, a call to <code>getActions</code> ++ * read, write, execute, delete, readlink. For example, if this FilePermission ++ * object allows both write and read actions, a call to <code>getActions</code> + * will return the string "read,write". + * + * @return the canonical string representation of the actions. +@@ -678,7 +709,7 @@ + implements Serializable { + + // Not serialized; see serialization section at end of class +- private transient List perms; ++ private transient List<Permission> perms; + + /** + * Create an empty FilePermissions object. +@@ -686,7 +717,7 @@ + */ + + public FilePermissionCollection() { +- perms = new ArrayList(); ++ perms = new ArrayList<Permission>(); + } + + /** +@@ -791,7 +822,7 @@ + // Don't call out.defaultWriteObject() + + // Write out Vector +- Vector permissions = new Vector(perms.size()); ++ Vector<Permission> permissions = new Vector<Permission>(perms.size()); + synchronized (this) { + permissions.addAll(perms); + } +@@ -804,6 +835,7 @@ + /* + * Reads in a Vector of FilePermissions and saves them in the perms field. + */ ++ @SuppressWarnings("unchecked") + private void readObject(ObjectInputStream in) throws IOException, + ClassNotFoundException { + // Don't call defaultReadObject() +@@ -812,8 +844,8 @@ + ObjectInputStream.GetField gfields = in.readFields(); + + // Get the one we want +- Vector permissions = (Vector)gfields.get("permissions", null); +- perms = new ArrayList(permissions.size()); ++ Vector<Permission> permissions = (Vector<Permission>)gfields.get("permissions", null); ++ perms = new ArrayList<Permission>(permissions.size()); + perms.addAll(permissions); + } + } +diff -Nru openjdk.orig/jdk/src/share/classes/java/net/StandardProtocolFamily.java openjdk/jdk/src/share/classes/java/net/StandardProtocolFamily.java +--- openjdk.orig/jdk/src/share/classes/java/net/StandardProtocolFamily.java 2009-02-13 21:09:28.000000000 +0000 ++++ openjdk/jdk/src/share/classes/java/net/StandardProtocolFamily.java 2009-02-13 22:04:11.000000000 +0000 +@@ -26,7 +26,7 @@ + package java.net; + + /** +- * Defines the standard family of communication protocols. ++ * Defines the standard families of communication protocols. + * + * @since 1.7 + */ +diff -Nru openjdk.orig/jdk/src/share/classes/java/net/StandardSocketOption.java openjdk/jdk/src/share/classes/java/net/StandardSocketOption.java +--- openjdk.orig/jdk/src/share/classes/java/net/StandardSocketOption.java 2009-02-13 21:09:28.000000000 +0000 ++++ openjdk/jdk/src/share/classes/java/net/StandardSocketOption.java 2009-02-13 22:04:28.000000000 +0000 +@@ -59,6 +59,7 @@ + * + * @see <a href="http://www.ietf.org/rfc/rfc919.txt">RFC 929: + * Broadcasting Internet Datagrams</a> ++ * @see DatagramSocket#setBroadcast + */ + public static final SocketOption<Boolean> SO_BROADCAST = + new StdSocketOption<Boolean>("SO_BROADCAST", Boolean.class); +@@ -78,6 +79,7 @@ + * + * @see <a href="http://www.ietf.org/rfc/rfc1122.txt">RFC 1122 + * Requirements for Internet Hosts -- Communication Layers</a> ++ * @see Socket#setKeepAlive + */ + public static final SocketOption<Boolean> SO_KEEPALIVE = + new StdSocketOption<Boolean>("SO_KEEPALIVE", Boolean.class); +@@ -107,6 +109,8 @@ + * socket is bound or connected. Whether an implementation allows the + * socket send buffer to be changed after the socket is bound is system + * dependent. ++ * ++ * @see Socket#setSendBufferSize + */ + public static final SocketOption<Integer> SO_SNDBUF = + new StdSocketOption<Integer>("SO_SNDBUF", Integer.class); +@@ -145,6 +149,8 @@ + * + * @see <a href="http://www.ietf.org/rfc/rfc1323.txt">RFC 1323: TCP + * Extensions for High Performance</a> ++ * @see Socket#setReceiveBufferSize ++ * @see ServerSocket#setReceiveBufferSize + */ + public static final SocketOption<Integer> SO_RCVBUF = + new StdSocketOption<Integer>("SO_RCVBUF", Integer.class); +@@ -175,6 +181,7 @@ + * + * @see <a href="http://www.ietf.org/rfc/rfc793.txt">RFC 793: Transmission + * Control Protocol</a> ++ * @see ServerSocket#setReuseAddress + */ + public static final SocketOption<Boolean> SO_REUSEADDR = + new StdSocketOption<Boolean>("SO_REUSEADDR", Boolean.class); +@@ -205,6 +212,8 @@ + * is system dependent. Setting the linger interval to a value that is + * greater than its maximum value causes the linger interval to be set to + * its maximum value. ++ * ++ * @see Socket#setSoLinger + */ + public static final SocketOption<Integer> SO_LINGER = + new StdSocketOption<Integer>("SO_LINGER", Integer.class); +@@ -215,15 +224,15 @@ + /** + * The Type of Service (ToS) octet in the Internet Protocol (IP) header. + * +- * <p> The value of this socket option is an {@code Integer}, the least +- * significant 8 bits of which represents the value of the ToS octet in IP +- * packets sent by sockets to an {@link StandardProtocolFamily#INET IPv4} +- * socket. The interpretation of the ToS octet is network specific and +- * is not defined by this class. Further information on the ToS octet can be +- * found in <a href="http://www.ietf.org/rfc/rfc1349.txt">RFC 1349</a> +- * and <a href="http://www.ietf.org/rfc/rfc2474.txt">RFC 2474</a>. The +- * value of the socket option is a <em>hint</em>. An implementation may +- * ignore the value, or ignore specific values. ++ * <p> The value of this socket option is an {@code Integer} representing ++ * the value of the ToS octet in IP packets sent by sockets to an {@link ++ * StandardProtocolFamily#INET IPv4} socket. The interpretation of the ToS ++ * octet is network specific and is not defined by this class. Further ++ * information on the ToS octet can be found in <a ++ * href="http://www.ietf.org/rfc/rfc1349.txt">RFC 1349</a> and <a ++ * href="http://www.ietf.org/rfc/rfc2474.txt">RFC 2474</a>. The value ++ * of the socket option is a <em>hint</em>. An implementation may ignore the ++ * value, or ignore specific values. + * + * <p> The initial/default value of the TOS field in the ToS octet is + * implementation specific but will typically be {@code 0}. For +@@ -235,6 +244,8 @@ + * <p> The behavior of this socket option on a stream-oriented socket, or an + * {@link StandardProtocolFamily#INET6 IPv6} socket, is not defined in this + * release. ++ * ++ * @see DatagramSocket#setTrafficClass + */ + public static final SocketOption<Integer> IP_TOS = + new StdSocketOption<Integer>("IP_TOS", Integer.class); +@@ -257,6 +268,7 @@ + * is system dependent. + * + * @see java.nio.channels.MulticastChannel ++ * @see MulticastSocket#setInterface + */ + public static final SocketOption<NetworkInterface> IP_MULTICAST_IF = + new StdSocketOption<NetworkInterface>("IP_MULTICAST_IF", NetworkInterface.class); +@@ -283,6 +295,7 @@ + * prior to binding the socket is system dependent. + * + * @see java.nio.channels.MulticastChannel ++ * @see MulticastSocket#setTimeToLive + */ + public static final SocketOption<Integer> IP_MULTICAST_TTL = + new StdSocketOption<Integer>("IP_MULTICAST_TTL", Integer.class); +@@ -307,6 +320,7 @@ + * binding the socket is system dependent. + * + * @see java.nio.channels.MulticastChannel ++ * @see MulticastSocket#setLoopbackMode + */ + public static final SocketOption<Boolean> IP_MULTICAST_LOOP = + new StdSocketOption<Boolean>("IP_MULTICAST_LOOP", Boolean.class); +@@ -328,11 +342,12 @@ + * coalescing impacts performance. The socket option may be enabled at any + * time. In other words, the Nagle Algorithm can be disabled. Once the option + * is enabled, it is system dependent whether it can be subsequently +- * disabled. In that case, invoking the {@code setOption} method to disable +- * the option has no effect. ++ * disabled. If it cannot, then invoking the {@code setOption} method to ++ * disable the option has no effect. + * + * @see <a href="http://www.ietf.org/rfc/rfc1122.txt">RFC 1122: + * Requirements for Internet Hosts -- Communication Layers</a> ++ * @see Socket#setTcpNoDelay + */ + public static final SocketOption<Boolean> TCP_NODELAY = + new StdSocketOption<Boolean>("TCP_NODELAY", Boolean.class); +diff -Nru openjdk.orig/jdk/src/share/classes/java/nio/channels/Channels.java openjdk/jdk/src/share/classes/java/nio/channels/Channels.java +--- openjdk.orig/jdk/src/share/classes/java/nio/channels/Channels.java 2009-02-13 21:10:32.000000000 +0000 ++++ openjdk/jdk/src/share/classes/java/nio/channels/Channels.java 2009-02-14 01:20:16.000000000 +0000 +@@ -42,6 +42,7 @@ + import java.nio.charset.CoderResult; + import java.nio.charset.UnsupportedCharsetException; + import java.nio.channels.spi.AbstractInterruptibleChannel; ++import java.util.concurrent.ExecutionException; + import sun.nio.ch.ChannelInputStream; + import sun.nio.cs.StreamDecoder; + import sun.nio.cs.StreamEncoder; +@@ -469,4 +470,151 @@ + return newWriter(ch, Charset.forName(csName).newEncoder(), -1); + } + ++ /** ++ * {@note new} ++ * Constructs a stream that reads bytes from the given channel. ++ * ++ * <p> The stream will not be buffered, and it will not support the {@link ++ * InputStream#mark mark} or {@link InputStream#reset reset} methods. The ++ * stream will be safe for access by multiple concurrent threads. Closing ++ * the stream will in turn cause the channel to be closed. </p> ++ * ++ * @param ch ++ * The channel from which bytes will be read ++ * ++ * @return A new input stream ++ * ++ * @since 1.7 ++ */ ++ public static InputStream newInputStream(final AsynchronousByteChannel ch) { ++ return new InputStream() { ++ private ByteBuffer bb = null; ++ private byte[] bs = null; // Invoker's previous array ++ private byte[] b1 = null; + + -+ // -- Other operations -- -+ -+ public long position() throws IOException { -+ ensureOpen(); -+ synchronized (positionLock) { -+ long p = -1; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) ++ public synchronized int read() throws IOException { ++ if (b1 == null) ++ b1 = new byte[1]; ++ int n = this.read(b1); ++ if (n == 1) ++ return b1[0] & 0xff; ++ return -1; ++ } ++ ++ public synchronized int read(byte[] bs, int off, int len) ++ throws IOException ++ { ++ if ((off < 0) || (off > bs.length) || (len < 0) || ++ ((off + len) > bs.length) || ((off + len) < 0)) { ++ throw new IndexOutOfBoundsException(); ++ } else if (len == 0) + return 0; -+ ti = threads.add(); -+ do { -+ p = position0(fd, -1); -+ } while ((p == IOStatus.INTERRUPTED) && isOpen()); -+ return IOStatus.normalize(p); -+ } finally { -+ threads.remove(ti); -+ end(p > -1); -+ assert IOStatus.check(p); -+ } -+ } -+ } ++ ++ ByteBuffer bb = ((this.bs == bs) ++ ? this.bb ++ : ByteBuffer.wrap(bs)); ++ bb.position(off); ++ bb.limit(Math.min(off + len, bb.capacity())); ++ this.bb = bb; ++ this.bs = bs; + -+ public FileChannel position(long newPosition) throws IOException { -+ ensureOpen(); -+ if (newPosition < 0) -+ throw new IllegalArgumentException(); -+ synchronized (positionLock) { -+ long p = -1; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return null; -+ ti = threads.add(); -+ do { -+ p = position0(fd, newPosition); -+ } while ((p == IOStatus.INTERRUPTED) && isOpen()); -+ return this; -+ } finally { -+ threads.remove(ti); -+ end(p > -1); -+ assert IOStatus.check(p); ++ boolean interrupted = false; ++ try { ++ for (;;) { ++ try { ++ return ch.read(bb).get(); ++ } catch (ExecutionException ee) { ++ throw new IOException(ee.getCause()); ++ } catch (InterruptedException ie) { ++ interrupted = true; ++ } ++ } ++ } finally { ++ if (interrupted) ++ Thread.currentThread().interrupt(); ++ } ++ } ++ ++ ++ public void close() throws IOException { ++ ch.close(); + } -+ } -+ } -+ -+ public FileChannel positionSBC(long newPosition) throws IOException { -+ return position(newPosition); -+ } ++ }; ++ } ++ ++ /** ++ * {@note new} ++ * Constructs a stream that writes bytes to the given channel. ++ * ++ * <p> The stream will not be buffered. The stream will be safe for access ++ * by multiple concurrent threads. Closing the stream will in turn cause ++ * the channel to be closed. </p> ++ * ++ * @param ch ++ * The channel to which bytes will be written ++ * ++ * @return A new output stream ++ * ++ * @since 1.7 ++ */ ++ public static OutputStream newOutputStream(final AsynchronousByteChannel ch) { ++ return new OutputStream() { ++ ++ private ByteBuffer bb = null; ++ private byte[] bs = null; // Invoker's previous array ++ private byte[] b1 = null; ++ ++ public synchronized void write(int b) throws IOException { ++ if (b1 == null) ++ b1 = new byte[1]; ++ b1[0] = (byte)b; ++ this.write(b1); ++ } ++ ++ ++ public synchronized void write(byte[] bs, int off, int len) ++ throws IOException ++ { ++ if ((off < 0) || (off > bs.length) || (len < 0) || ++ ((off + len) > bs.length) || ((off + len) < 0)) { ++ throw new IndexOutOfBoundsException(); ++ } else if (len == 0) { ++ return; ++ } ++ ByteBuffer bb = ((this.bs == bs) ++ ? this.bb ++ : ByteBuffer.wrap(bs)); ++ bb.limit(Math.min(off + len, bb.capacity())); ++ bb.position(off); ++ this.bb = bb; ++ this.bs = bs; + -+ public long size() throws IOException { -+ ensureOpen(); -+ synchronized (positionLock) { -+ long s = -1; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return -1; -+ ti = threads.add(); -+ do { -+ s = size0(fd); -+ } while ((s == IOStatus.INTERRUPTED) && isOpen()); -+ return IOStatus.normalize(s); -+ } finally { -+ threads.remove(ti); -+ end(s > -1); -+ assert IOStatus.check(s); ++ boolean interrupted = false; ++ try { ++ while (bb.remaining() > 0) { ++ try { ++ ch.write(bb).get(); ++ } catch (ExecutionException ee) { ++ throw new IOException(ee.getCause()); ++ } catch (InterruptedException ie) { ++ interrupted = true; ++ } ++ } ++ } finally { ++ if (interrupted) ++ Thread.currentThread().interrupt(); ++ } ++ } ++ ++ ++ public void close() throws IOException { ++ ch.close(); + } -+ } -+ } ++ }; ++ } ++ ++ + } ++ + -+ public FileChannel truncate(long size) throws IOException { -+ ensureOpen(); -+ if (size < 0) -+ throw new IllegalArgumentException(); -+ if (size > size()) -+ return this; -+ if (!writable) -+ throw new NonWritableChannelException(); -+ synchronized (positionLock) { -+ int rv = -1; -+ long p = -1; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return null; -+ ti = threads.add(); -+ -+ // get current position -+ do { -+ p = position0(fd, -1); -+ } while ((p == IOStatus.INTERRUPTED) && isOpen()); -+ if (!isOpen()) -+ return null; -+ assert p >= 0; +diff -Nru openjdk.orig/jdk/src/share/classes/java/nio/channels/DatagramChannel.java openjdk/jdk/src/share/classes/java/nio/channels/DatagramChannel.java +--- openjdk.orig/jdk/src/share/classes/java/nio/channels/DatagramChannel.java 2009-02-13 21:10:32.000000000 +0000 ++++ openjdk/jdk/src/share/classes/java/nio/channels/DatagramChannel.java 2009-02-14 01:15:49.000000000 +0000 +@@ -31,12 +31,13 @@ + import java.net.SocketOption; + import java.net.SocketAddress; + import java.nio.ByteBuffer; +-import java.nio.channels.spi.*; ++import java.nio.channels.spi.AbstractSelectableChannel; ++import java.nio.channels.spi.SelectorProvider; + + /** + * A selectable channel for datagram-oriented sockets. + * +- * <p> A datagram channel is created by invoking one of the {@link #open open} methods ++ * <p> {@note revised} A datagram channel is created by invoking one of the {@link #open open} methods + * of this class. It is not possible to create a channel for an arbitrary, + * pre-existing datagram socket. A newly-created datagram channel is open but not + * connected. A datagram channel need not be connected in order for the {@link #send +@@ -53,7 +54,8 @@ + * be determined by invoking its {@link #isConnected isConnected} method. + * + * <p> Socket options are configured using the {@link #setOption(SocketOption,Object) +- * setOption} method. Datagram channels support the following options: ++ * setOption} method. A datagram channel to an Internet Protocol socket supports ++ * the following options: + * <blockquote> + * <table border> + * <tr> +@@ -106,6 +108,7 @@ + * @author Mark Reinhold + * @author JSR-51 Expert Group + * @since 1.4 ++ * @updated 1.7 + */ + + public abstract class DatagramChannel +diff -Nru openjdk.orig/jdk/src/share/classes/java/nio/channels/exceptions openjdk/jdk/src/share/classes/java/nio/channels/exceptions +--- openjdk.orig/jdk/src/share/classes/java/nio/channels/exceptions 2009-02-13 21:10:40.000000000 +0000 ++++ openjdk/jdk/src/share/classes/java/nio/channels/exceptions 2009-02-13 22:29:15.000000000 +0000 +@@ -150,6 +150,20 @@ + + SINCE=1.7 + ++SUPER=java.io.IOException + -+ // truncate file -+ do { -+ rv = truncate0(fd, size); -+ } while ((rv == IOStatus.INTERRUPTED) && isOpen()); -+ if (!isOpen()) -+ return null; ++gen InterruptedByTimeoutException " ++ * Checked exception received by a thread when a timeout elapses before an ++ * asynchronous operation completes." \ ++ -4268008601014042947L ++ ++SUPER=IllegalArgumentException ++ ++gen IllegalChannelGroupException " ++ * Unchecked exception thrown when an attempt is made to open a channel ++ * in a group that was not created by the same provider. " \ ++ -2495041211157744253L ++ + SUPER=IllegalStateException + + gen AlreadyBoundException " +@@ -157,3 +171,23 @@ + * network oriented channel that is already bound." \ + 6796072983322737592L + ++gen AcceptPendingException " ++ * Unchecked exception thrown when an attempt is made to initiate an accept ++ * operation on a channel and a previous accept operation has not completed." \ ++ 2721339977965416421L + -+ // set position to size if greater than size -+ if (p > size) -+ p = size; -+ do { -+ rv = (int)position0(fd, p); -+ } while ((rv == IOStatus.INTERRUPTED) && isOpen()); -+ return this; -+ } finally { -+ threads.remove(ti); -+ end(rv > -1); -+ assert IOStatus.check(rv); -+ } -+ } -+ } ++gen ReadPendingException " ++ * Unchecked exception thrown when an attempt is made to read from an ++ * asynchronous socket channel and a previous read has not completed." \ ++ 1986315242191227217L ++ ++gen WritePendingException " ++ * Unchecked exception thrown when an attempt is made to write to an ++ * asynchronous socket channel and a previous write has not completed." \ ++ 7031871839266032276L + -+ public FileChannel truncateSBC(long size) throws IOException { -+ return truncate(size); -+ } ++gen ShutdownChannelGroupException " ++ * Unchecked exception thrown when an attempt is made to construct a channel in ++ * a group that is shutdown or the completion handler for an I/O operation ++ * cannot be invoked because the channel group is shutdown." \ ++ -3903801676350154157L +diff -Nru openjdk.orig/jdk/src/share/classes/java/nio/channels/FileChannel.java openjdk/jdk/src/share/classes/java/nio/channels/FileChannel.java +--- openjdk.orig/jdk/src/share/classes/java/nio/channels/FileChannel.java 2009-02-13 21:10:32.000000000 +0000 ++++ openjdk/jdk/src/share/classes/java/nio/channels/FileChannel.java 2009-02-14 01:14:05.000000000 +0000 +@@ -30,17 +30,27 @@ + import java.nio.MappedByteBuffer; + import java.nio.channels.spi.AbstractInterruptibleChannel; + ++import java.nio.file.OpenOption; ++import java.nio.file.Path; ++import java.nio.file.attribute.FileAttribute; ++import java.nio.file.spi.FileSystemProvider; + -+ public void force(boolean metaData) throws IOException { -+ ensureOpen(); -+ int rv = -1; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return; -+ ti = threads.add(); -+ do { -+ rv = force0(fd, metaData); -+ } while ((rv == IOStatus.INTERRUPTED) && isOpen()); -+ } finally { -+ threads.remove(ti); -+ end(rv > -1); -+ assert IOStatus.check(rv); -+ } -+ } -+ -+ // Assume at first that the underlying kernel supports sendfile(); -+ // set this to false if we find out later that it doesn't -+ // -+ private static volatile boolean transferSupported = true; -+ -+ // Assume that the underlying kernel sendfile() will work if the target -+ // fd is a pipe; set this to false if we find out later that it doesn't -+ // -+ private static volatile boolean pipeSupported = true; -+ -+ // Assume that the underlying kernel sendfile() will work if the target -+ // fd is a file; set this to false if we find out later that it doesn't -+ // -+ private static volatile boolean fileSupported = true; -+ -+ private long transferToDirectly(long position, int icount, -+ WritableByteChannel target) -+ throws IOException -+ { -+ if (!transferSupported) -+ return IOStatus.UNSUPPORTED; -+ -+ FileDescriptor targetFD = null; -+ if (target instanceof FileChannelImpl) { -+ if (!fileSupported) -+ return IOStatus.UNSUPPORTED_CASE; -+ targetFD = ((FileChannelImpl)target).fd; -+ } else if (target instanceof SelChImpl) { -+ // Direct transfer to pipe causes EINVAL on some configurations -+ if ((target instanceof SinkChannelImpl) && !pipeSupported) -+ return IOStatus.UNSUPPORTED_CASE; -+ targetFD = ((SelChImpl)target).getFD(); -+ } -+ if (targetFD == null) -+ return IOStatus.UNSUPPORTED; -+ int thisFDVal = IOUtil.fdVal(fd); -+ int targetFDVal = IOUtil.fdVal(targetFD); -+ if (thisFDVal == targetFDVal) // Not supported on some configurations -+ return IOStatus.UNSUPPORTED; -+ -+ long n = -1; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return -1; -+ ti = threads.add(); -+ do { -+ n = transferTo0(thisFDVal, position, icount, targetFDVal); -+ } while ((n == IOStatus.INTERRUPTED) && isOpen()); -+ if (n == IOStatus.UNSUPPORTED_CASE) { -+ if (target instanceof SinkChannelImpl) -+ pipeSupported = false; -+ if (target instanceof FileChannelImpl) -+ fileSupported = false; -+ return IOStatus.UNSUPPORTED_CASE; -+ } -+ if (n == IOStatus.UNSUPPORTED) { -+ // Don't bother trying again -+ transferSupported = false; -+ return IOStatus.UNSUPPORTED; -+ } -+ return IOStatus.normalize(n); -+ } finally { -+ threads.remove(ti); -+ end (n > -1); -+ } -+ } -+ -+ private long transferToTrustedChannel(long position, int icount, -+ WritableByteChannel target) -+ throws IOException -+ { -+ if ( !((target instanceof FileChannelImpl) -+ || (target instanceof SelChImpl))) -+ return IOStatus.UNSUPPORTED; -+ -+ // Trusted target: Use a mapped buffer -+ MappedByteBuffer dbb = null; -+ try { -+ dbb = map(MapMode.READ_ONLY, position, icount); -+ // ## Bug: Closing this channel will not terminate the write -+ return target.write(dbb); -+ } finally { -+ if (dbb != null) -+ unmap(dbb); -+ } -+ } -+ -+ private long transferToArbitraryChannel(long position, int icount, -+ WritableByteChannel target) -+ throws IOException -+ { -+ // Untrusted target: Use a newly-erased buffer -+ int c = Math.min(icount, TRANSFER_SIZE); -+ ByteBuffer bb = Util.getTemporaryDirectBuffer(c); -+ long tw = 0; // Total bytes written -+ long pos = position; -+ try { -+ Util.erase(bb); -+ while (tw < icount) { -+ bb.limit(Math.min((int)(icount - tw), TRANSFER_SIZE)); -+ int nr = read(bb, pos); -+ if (nr <= 0) -+ break; -+ bb.flip(); -+ // ## Bug: Will block writing target if this channel -+ // ## is asynchronously closed -+ int nw = target.write(bb); -+ tw += nw; -+ if (nw != nr) -+ break; -+ pos += nw; -+ bb.clear(); -+ } -+ return tw; -+ } catch (IOException x) { -+ if (tw > 0) -+ return tw; -+ throw x; -+ } finally { -+ Util.releaseTemporaryDirectBuffer(bb); -+ } -+ } -+ -+ public long transferTo(long position, long count, -+ WritableByteChannel target) ++import java.util.Collections; ++import java.util.HashSet; ++import java.util.Set; + + /** + * A channel for reading, writing, mapping, and manipulating a file. + * +- * <p> A file channel has a current <i>position</i> within its file which can +- * be both {@link #position() </code>queried<code>} and {@link #position(long) +- * </code>modified<code>}. The file itself contains a variable-length sequence ++ * <p> {@note revised} ++ * A file channel is a {@link SeekableByteChannel} that is connected to ++ * a file. It has a current <i>position</i> within its file which can ++ * be both {@link #position() <i>queried</i>} and {@link #position(long) ++ * <i>modified</i>}. The file itself contains a variable-length sequence + * of bytes that can be read and written and whose current {@link #size +- * </code><i>size</i><code>} can be queried. The size of the file increases ++ * <i>size</i>} can be queried. The size of the file increases + * when bytes are written beyond its current size; the size of the file +- * decreases when it is {@link #truncate </code><i>truncated</i><code>}. The ++ * decreases when it is {@link #truncate <i>truncated</i>}. The + * file may also have some associated <i>metadata</i> such as access + * permissions, content type, and last-modification time; this class does not + * define methods for metadata access. +@@ -50,12 +60,12 @@ + * + * <ul> + * +- * <li><p> Bytes may be {@link #read(ByteBuffer, long) </code>read<code>} or +- * {@link #write(ByteBuffer, long) </code>written<code>} at an absolute ++ * <li><p> Bytes may be {@link #read(ByteBuffer, long) read} or ++ * {@link #write(ByteBuffer, long) <i>written</i>} at an absolute + * position in a file in a way that does not affect the channel's current + * position. </p></li> + * +- * <li><p> A region of a file may be {@link #map </code>mapped<code>} ++ * <li><p> A region of a file may be {@link #map <i>mapped</i>} + * directly into memory; for large files this is often much more efficient + * than invoking the usual <tt>read</tt> or <tt>write</tt> methods. + * </p></li> +@@ -64,13 +74,13 @@ + * out<code>} to the underlying storage device, ensuring that data are not + * lost in the event of a system crash. </p></li> + * +- * <li><p> Bytes can be transferred from a file {@link #transferTo </code>to +- * some other channel<code>}, and {@link #transferFrom </code>vice +- * versa<code>}, in a way that can be optimized by many operating systems ++ * <li><p> Bytes can be transferred from a file {@link #transferTo <i>to ++ * some other channel</i>}, and {@link #transferFrom <i>vice ++ * versa</i>}, in a way that can be optimized by many operating systems + * into a very fast transfer directly to or from the filesystem cache. + * </p></li> + * +- * <li><p> A region of a file may be {@link FileLock </code>locked<code>} ++ * <li><p> A region of a file may be {@link FileLock <i>locked</i>} + * against access by other programs. </p></li> + * + * </ul> +@@ -96,25 +106,23 @@ + * machine. The exact nature of any such inconsistencies are system-dependent + * and are therefore unspecified. + * +- * <p> This class does not define methods for opening existing files or for +- * creating new ones; such methods may be added in a future release. In this +- * release a file channel can be obtained from an existing {@link +- * java.io.FileInputStream#getChannel FileInputStream}, {@link ++ * <p> A file channel is created by invoking one of the {@link #open open} ++ * methods defined by this class. A file channel can also be obtained from an ++ * existing {@link java.io.FileInputStream#getChannel FileInputStream}, {@link + * java.io.FileOutputStream#getChannel FileOutputStream}, or {@link + * java.io.RandomAccessFile#getChannel RandomAccessFile} object by invoking + * that object's <tt>getChannel</tt> method, which returns a file channel that +- * is connected to the same underlying file. ++ * is connected to the same underlying file. Where the file channel is obtained ++ * from an existing stream or random access file then the state of the file ++ * channel is intimately connected to that of the object whose <tt>getChannel</tt> ++ * method returned the channel. Changing the channel's position, whether ++ * explicitly or by reading or writing bytes, will change the file position of ++ * the originating object, and vice versa. Changing the file's length via the ++ * file channel will change the length seen via the originating object, and vice ++ * versa. Changing the file's content by writing bytes will change the content ++ * seen by the originating object, and vice versa. + * +- * <p> The state of a file channel is intimately connected to that of the +- * object whose <tt>getChannel</tt> method returned the channel. Changing the +- * channel's position, whether explicitly or by reading or writing bytes, will +- * change the file position of the originating object, and vice versa. +- * Changing the file's length via the file channel will change the length seen +- * via the originating object, and vice versa. Changing the file's content by +- * writing bytes will change the content seen by the originating object, and +- * vice versa. +- * +- * <a name="open-mode"><p> At various points this class specifies that an ++ * <a name="open-mode"></a> <p> At various points this class specifies that an + * instance that is "open for reading," "open for writing," or "open for + * reading and writing" is required. A channel obtained via the {@link + * java.io.FileInputStream#getChannel getChannel} method of a {@link +@@ -127,7 +135,7 @@ + * was created with mode <tt>"r"</tt> and will be open for reading and writing + * if the instance was created with mode <tt>"rw"</tt>. + * +- * <a name="append-mode"><p> A file channel that is open for writing may be in ++ * <a name="append-mode"></a><p> A file channel that is open for writing may be in + * <i>append mode</i>, for example if it was obtained from a file-output stream + * that was created by invoking the {@link + * java.io.FileOutputStream#FileOutputStream(java.io.File,boolean) +@@ -147,11 +155,12 @@ + * @author Mike McCloskey + * @author JSR-51 Expert Group + * @since 1.4 ++ * @updated 1.7 + */ + + public abstract class FileChannel + extends AbstractInterruptibleChannel +- implements ByteChannel, GatheringByteChannel, ScatteringByteChannel ++ implements ByteChannel, GatheringByteChannel, ScatteringByteChannel, SeekableByteChannel + { + + /** +@@ -978,4 +987,176 @@ + return tryLock(0L, Long.MAX_VALUE, false); + } + ++ /** ++ * {@note new} ++ * Opens or creates a file, returning a file channel to access the file. ++ * ++ * <p> The {@code options} parameter determines how the file is opened. ++ * The {@link StandardOpenOption#READ READ} and {@link StandardOpenOption#WRITE ++ * WRITE} options determine if the file should be opened for reading and/or ++ * writing. If neither option (or the {@link StandardOpenOption#APPEND APPEND} ++ * option) is contained in the array then the file is opened for reading. ++ * By default reading or writing commences at the beginning of the file. ++ * ++ * <p> In the addition to {@code READ} and {@code WRITE}, the following ++ * options may be present: ++ * ++ * <table border=1 cellpadding=5 summary=""> ++ * <tr> <th>Option</th> <th>Description</th> </tr> ++ * <tr> ++ * <td> {@link StandardOpenOption#APPEND APPEND} </td> ++ * <td> If this option is present then the file is opened for writing and ++ * each invocation of the channel's {@code write} method first advances ++ * the position to the end of the file and then writes the requested ++ * data. Whether the advancement of the position and the writing of the ++ * data are done in a single atomic operation is system-dependent and ++ * therefore unspecified. This option may not be used in conjunction ++ * with the {@code READ} or {@code TRUNCATE_EXISTING} options. </td> ++ * </tr> ++ * <tr> ++ * <td> {@link StandardOpenOption#TRUNCATE_EXISTING TRUNCATE_EXISTING} </td> ++ * <td> If this option is present then the existing file is truncated to ++ * a size of 0 bytes. This option is ignored when the file is opened only ++ * for reading. </td> ++ * </tr> ++ * <tr> ++ * <td> {@link StandardOpenOption#CREATE_NEW CREATE_NEW} </td> ++ * <td> If this option is present then a new file is created, failing if ++ * the file already exists. When creating a file the check for the ++ * existence of the file and the creation of the file if it does not exist ++ * is atomic with respect to other file system operations. This option is ++ * ignored when the file is opened only for reading. </td> ++ * </tr> ++ * <tr> ++ * <td > {@link StandardOpenOption#CREATE CREATE} </td> ++ * <td> If this option is present then an existing file is opened if it ++ * exists, otherwise a new file is created. When creating a file the check ++ * for the existence of the file and the creation of the file if it does ++ * not exist is atomic with respect to other file system operations. This ++ * option is ignored if the {@code CREATE_NEW} option is also present or ++ * the file is opened only for reading. </td> ++ * </tr> ++ * <tr> ++ * <td > {@link StandardOpenOption#DELETE_ON_CLOSE DELETE_ON_CLOSE} </td> ++ * <td> When this option is present then the implementation makes a ++ * <em>best effort</em> attempt to delete the file when closed by the ++ * the {@link #close close} method. If the {@code close} method is not ++ * invoked then a <em>best effort</em> attempt is made to delete the file ++ * when the Java virtual machine terminates. </td> ++ * </tr> ++ * <tr> ++ * <td>{@link StandardOpenOption#SPARSE SPARSE} </td> ++ * <td> When creating a new file this option is a <em>hint</em> that the ++ * new file will be sparse. This option is ignored when not creating ++ * a new file. </td> ++ * </tr> ++ * <tr> ++ * <td> {@link StandardOpenOption#SYNC SYNC} </td> ++ * <td> Requires that every update to the file's content or metadata be ++ * written synchronously to the underlying storage device. (see <a ++ * href="../file/package-summary.html#integrity"> Synchronized I/O file ++ * integrity</a>). </td> ++ * <tr> ++ * <tr> ++ * <td> {@link StandardOpenOption#DSYNC DSYNC} </td> ++ * <td> Requires that every update to the file's content be written ++ * synchronously to the underlying storage device. (see <a ++ * href="../file/package-summary.html#integrity"> Synchronized I/O file ++ * integrity</a>). </td> ++ * </tr> ++ * </table> ++ * ++ * <p> An implementation may also support additional options. ++ * ++ * <p> The {@code attrs} parameter is an optional array of file {@link ++ * FileAttribute file-attributes} to set atomically when creating the file. ++ * ++ * <p> The new channel is created by invoking the {@link ++ * FileSystemProvider#newFileChannel newFileChannel} method on the ++ * provider that created the {@code Path}. ++ * ++ * @param file ++ * The path of 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 file channel ++ * ++ * @throws IllegalArgumentException ++ * If the set contains an invalid combination of options ++ * @throws UnsupportedOperationException ++ * If the {@code file} is associated with a provider that does not ++ * support creating file channels, or an unsupported open option is ++ * specified, or the array contains an attribute that cannot be set ++ * atomically when creating the file ++ * @throws IOException ++ * If an I/O error occurs ++ * @throws SecurityException ++ * If a security manager is installed and it denies an ++ * unspecified permission required by the implementation. ++ * In the case of the default provider, the {@link ++ * SecurityManager#checkRead(String)} method is invoked to check ++ * read access if the file is opened for reading. The {@link ++ * SecurityManager#checkWrite(String)} method is invoked to check ++ * write access if the file is opened for writing ++ * ++ * @since 1.7 ++ */ ++ public static FileChannel open(Path file, ++ Set<? extends OpenOption> options, ++ FileAttribute<?>... attrs) + throws IOException + { -+ ensureOpen(); -+ if (!target.isOpen()) -+ throw new ClosedChannelException(); -+ if (!readable) -+ throw new NonReadableChannelException(); -+ if (target instanceof FileChannelImpl && -+ !((FileChannelImpl)target).writable) -+ throw new NonWritableChannelException(); -+ if ((position < 0) || (count < 0)) -+ throw new IllegalArgumentException(); -+ long sz = size(); -+ if (position > sz) -+ return 0; -+ int icount = (int)Math.min(count, Integer.MAX_VALUE); -+ if ((sz - position) < icount) -+ icount = (int)(sz - position); -+ -+ long n; -+ -+ // Attempt a direct transfer, if the kernel supports it -+ if ((n = transferToDirectly(position, icount, target)) >= 0) -+ return n; -+ -+ // Attempt a mapped transfer, but only to trusted channel types -+ if ((n = transferToTrustedChannel(position, icount, target)) >= 0) -+ return n; -+ -+ // Slow path for untrusted targets -+ return transferToArbitraryChannel(position, icount, target); -+ } -+ -+ private long transferFromFileChannel(FileChannelImpl src, -+ long position, long count) -+ throws IOException -+ { -+ // Note we could loop here to accumulate more at once -+ synchronized (src.positionLock) { -+ long p = src.position(); -+ int icount = (int)Math.min(Math.min(count, Integer.MAX_VALUE), -+ src.size() - p); -+ // ## Bug: Closing this channel will not terminate the write -+ MappedByteBuffer bb = src.map(MapMode.READ_ONLY, p, icount); -+ try { -+ long n = write(bb, position); -+ src.position(p + n); -+ return n; -+ } finally { -+ unmap(bb); -+ } -+ } -+ } -+ -+ private static final int TRANSFER_SIZE = 8192; -+ -+ private long transferFromArbitraryChannel(ReadableByteChannel src, -+ long position, long count) ++ FileSystemProvider provider = file.getFileSystem().provider(); ++ return provider.newFileChannel(file, options, attrs); ++ } ++ ++ private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0]; ++ ++ /** ++ * {@note new} ++ * Opens or creates a file, returning a file channel to access the file. ++ * ++ * <p> An invocation of this method behaves in exactly the same way as the ++ * invocation ++ * <pre> ++ * fc.{@link #open(Path,Set,FileAttribute[]) open}(file, options, new FileAttribute<?>[0]); ++ * </pre> ++ * ++ * @param file ++ * The path of the file to open or create ++ * @param options ++ * Options specifying how the file is opened ++ * ++ * @return A new file channel ++ * ++ * @throws IllegalArgumentException ++ * If the set contains an invalid combination of options ++ * @throws UnsupportedOperationException ++ * If the {@code file} is associated with a provider that does not ++ * support creating file channels, or an unsupported open option is ++ * specified ++ * @throws IOException ++ * If an I/O error occurs ++ * @throws SecurityException ++ * If a security manager is installed and it denies an ++ * unspecified permission required by the implementation. ++ * In the case of the default provider, the {@link ++ * SecurityManager#checkRead(String)} method is invoked to check ++ * read access if the file is opened for reading. The {@link ++ * SecurityManager#checkWrite(String)} method is invoked to check ++ * write access if the file is opened for writing ++ * ++ * @since 1.7 ++ */ ++ public static FileChannel open(Path file, OpenOption... options) + throws IOException + { -+ // Untrusted target: Use a newly-erased buffer -+ int c = (int)Math.min(count, TRANSFER_SIZE); -+ ByteBuffer bb = Util.getTemporaryDirectBuffer(c); -+ long tw = 0; // Total bytes written -+ long pos = position; -+ try { -+ Util.erase(bb); -+ while (tw < count) { -+ bb.limit((int)Math.min((count - tw), (long)TRANSFER_SIZE)); -+ // ## Bug: Will block reading src if this channel -+ // ## is asynchronously closed -+ int nr = src.read(bb); -+ if (nr <= 0) -+ break; -+ bb.flip(); -+ int nw = write(bb, pos); -+ tw += nw; -+ if (nw != nr) -+ break; -+ pos += nw; -+ bb.clear(); -+ } -+ return tw; -+ } catch (IOException x) { -+ if (tw > 0) -+ return tw; -+ throw x; -+ } finally { -+ Util.releaseTemporaryDirectBuffer(bb); -+ } ++ Set<OpenOption> set = new HashSet<OpenOption>(options.length); ++ Collections.addAll(set, options); ++ return open(file, set, NO_ATTRIBUTES); + } -+ -+ public long transferFrom(ReadableByteChannel src, -+ long position, long count) -+ throws IOException + } +diff -Nru openjdk.orig/jdk/src/share/classes/java/nio/channels/FileLock.java openjdk/jdk/src/share/classes/java/nio/channels/FileLock.java +--- openjdk.orig/jdk/src/share/classes/java/nio/channels/FileLock.java 2009-02-13 21:10:32.000000000 +0000 ++++ openjdk/jdk/src/share/classes/java/nio/channels/FileLock.java 2009-02-13 22:22:43.000000000 +0000 +@@ -27,14 +27,16 @@ + + import java.io.IOException; + +- + /** + * A token representing a lock on a region of a file. + * + * <p> A file-lock object is created each time a lock is acquired on a file via + * one of the {@link FileChannel#lock(long,long,boolean) lock} or {@link +- * FileChannel#tryLock(long,long,boolean) tryLock} methods of the {@link +- * FileChannel} class. ++ * FileChannel#tryLock(long,long,boolean) tryLock} methods of the ++ * {@link FileChannel} class, or the {@link ++ * AsynchronousFileChannel#lock(long,long,boolean,Object,CompletionHandler) lock} ++ * or {@link AsynchronousFileChannel#tryLock(long,long,boolean) tryLock} ++ * methods of the {@link AsynchronousFileChannel} class. + * + * <p> A file-lock object is initially valid. It remains valid until the lock + * is released by invoking the {@link #release release} method, by closing the +@@ -70,8 +72,7 @@ + * <p> File-lock objects are safe for use by multiple concurrent threads. + * + * +- * <a name="pdep"> +- * <h4> Platform dependencies </h4> ++ * <a name="pdep"><h4> Platform dependencies </h4></a> + * + * <p> This file-locking API is intended to map directly to the native locking + * facility of the underlying operating system. Thus the locks held on a file +@@ -93,7 +94,7 @@ + * + * <p> On some systems, acquiring a mandatory lock on a region of a file + * prevents that region from being {@link java.nio.channels.FileChannel#map +- * </code>mapped into memory<code>}, and vice versa. Programs that combine ++ * <i>mapped into memory</i>}, and vice versa. Programs that combine + * locking and mapping should be prepared for this combination to fail. + * + * <p> On some systems, closing a channel releases all locks held by the Java +@@ -113,11 +114,12 @@ + * @author Mark Reinhold + * @author JSR-51 Expert Group + * @since 1.4 ++ * @updated 1.7 + */ + + public abstract class FileLock { + +- private final FileChannel channel; ++ private final Channel channel; + private final long position; + private final long size; + private final boolean shared; +@@ -159,11 +161,66 @@ + } + + /** +- * Returns the file channel upon whose file this lock is held. </p> ++ * {@note new} Initializes a new instance of this class. ++ * ++ * @param channel ++ * The channel upon whose file this lock is held ++ * ++ * @param position ++ * The position within the file at which the locked region starts; ++ * must be non-negative ++ * ++ * @param size ++ * The size of the locked region; must be non-negative, and the sum ++ * <tt>position</tt> + <tt>size</tt> must be non-negative ++ * ++ * @param shared ++ * <tt>true</tt> if this lock is shared, ++ * <tt>false</tt> if it is exclusive ++ * ++ * @throws IllegalArgumentException ++ * If the preconditions on the parameters do not hold ++ * ++ * @since 1.7 ++ */ ++ protected FileLock(AsynchronousFileChannel channel, ++ long position, long size, boolean shared) + { -+ ensureOpen(); -+ if (!src.isOpen()) -+ throw new ClosedChannelException(); -+ if (!writable) -+ throw new NonWritableChannelException(); -+ if ((position < 0) || (count < 0)) -+ throw new IllegalArgumentException(); -+ if (position > size()) -+ return 0; -+ if (src instanceof FileChannelImpl) -+ return transferFromFileChannel((FileChannelImpl)src, -+ position, count); -+ -+ return transferFromArbitraryChannel(src, position, count); -+ } -+ -+ public int read(ByteBuffer dst, long position) throws IOException { -+ if (dst == null) -+ throw new NullPointerException(); -+ if (position < 0) -+ throw new IllegalArgumentException("Negative position"); -+ if (!readable) -+ throw new NonReadableChannelException(); -+ ensureOpen(); -+ int n = 0; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return -1; -+ ti = threads.add(); -+ do { -+ n = IOUtil.read(fd, dst, position, nd, positionLock); -+ } while ((n == IOStatus.INTERRUPTED) && isOpen()); -+ return IOStatus.normalize(n); -+ } finally { -+ threads.remove(ti); -+ end(n > 0); -+ assert IOStatus.check(n); -+ } -+ } -+ -+ public int write(ByteBuffer src, long position) throws IOException { -+ if (src == null) -+ throw new NullPointerException(); + if (position < 0) + throw new IllegalArgumentException("Negative position"); -+ if (!writable) -+ throw new NonWritableChannelException(); -+ ensureOpen(); -+ int n = 0; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return -1; -+ ti = threads.add(); -+ do { -+ n = IOUtil.write(fd, src, position, nd, positionLock); -+ } while ((n == IOStatus.INTERRUPTED) && isOpen()); -+ return IOStatus.normalize(n); -+ } finally { -+ threads.remove(ti); -+ end(n > 0); -+ assert IOStatus.check(n); -+ } -+ } -+ -+ -+ // -- Memory-mapped buffers -- -+ -+ private static class Unmapper -+ implements Runnable -+ { -+ // keep track of mapped buffer usage -+ static volatile int count; -+ static volatile long totalSize; -+ static volatile long totalCapacity; -+ -+ private long address; -+ private long size; -+ private int cap; -+ -+ private Unmapper(long address, long size, int cap) { -+ assert (address != 0); -+ this.address = address; -+ this.size = size; -+ this.cap = cap; -+ -+ synchronized (Unmapper.class) { -+ count++; -+ totalSize += size; -+ totalCapacity += cap; -+ } -+ } -+ -+ public void run() { -+ if (address == 0) -+ return; -+ unmap0(address, size); -+ address = 0; -+ -+ synchronized (Unmapper.class) { -+ count--; -+ totalSize -= size; -+ totalCapacity -= cap; -+ } -+ } -+ } -+ -+ private static void unmap(MappedByteBuffer bb) { -+ Cleaner cl = ((DirectBuffer)bb).cleaner(); -+ if (cl != null) -+ cl.clean(); -+ } -+ -+ private static final int MAP_RO = 0; -+ private static final int MAP_RW = 1; -+ private static final int MAP_PV = 2; -+ -+ public MappedByteBuffer map(MapMode mode, long position, long size) -+ throws IOException -+ { -+ ensureOpen(); -+ if (position < 0L) -+ throw new IllegalArgumentException("Negative position"); -+ if (size < 0L) ++ if (size < 0) + throw new IllegalArgumentException("Negative size"); + if (position + size < 0) -+ throw new IllegalArgumentException("Position + size overflow"); -+ if (size > Integer.MAX_VALUE) -+ throw new IllegalArgumentException("Size exceeds Integer.MAX_VALUE"); -+ int imode = -1; -+ if (mode == MapMode.READ_ONLY) -+ imode = MAP_RO; -+ else if (mode == MapMode.READ_WRITE) -+ imode = MAP_RW; -+ else if (mode == MapMode.PRIVATE) -+ imode = MAP_PV; -+ assert (imode >= 0); -+ if ((mode != MapMode.READ_ONLY) && !writable) -+ throw new NonWritableChannelException(); -+ if (!readable) -+ throw new NonReadableChannelException(); -+ -+ long addr = -1; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return null; -+ ti = threads.add(); -+ if (size() < position + size) { // Extend file size -+ if (!writable) { -+ throw new IOException("Channel not open for writing " + -+ "- cannot extend file to required size"); -+ } -+ int rv; -+ do { -+ rv = truncate0(fd, position + size); -+ } while ((rv == IOStatus.INTERRUPTED) && isOpen()); -+ } -+ if (size == 0) { -+ addr = 0; -+ if ((!writable) || (imode == MAP_RO)) -+ return Util.newMappedByteBufferR(0, 0, null); -+ else -+ return Util.newMappedByteBuffer(0, 0, null); -+ } -+ -+ int pagePosition = (int)(position % allocationGranularity); -+ long mapPosition = position - pagePosition; -+ long mapSize = size + pagePosition; -+ try { -+ // If no exception was thrown from map0, the address is valid -+ addr = map0(imode, mapPosition, mapSize); -+ } catch (OutOfMemoryError x) { -+ // An OutOfMemoryError may indicate that we've exhausted memory -+ // so force gc and re-attempt map -+ System.gc(); -+ try { -+ Thread.sleep(100); -+ } catch (InterruptedException y) { -+ Thread.currentThread().interrupt(); -+ } -+ try { -+ addr = map0(imode, mapPosition, mapSize); -+ } catch (OutOfMemoryError y) { -+ // After a second OOME, fail -+ throw new IOException("Map failed", y); -+ } -+ } -+ -+ assert (IOStatus.checkAll(addr)); -+ assert (addr % allocationGranularity == 0); -+ int isize = (int)size; -+ Unmapper um = new Unmapper(addr, size + pagePosition, isize); -+ if ((!writable) || (imode == MAP_RO)) -+ return Util.newMappedByteBufferR(isize, addr + pagePosition, um); -+ else -+ return Util.newMappedByteBuffer(isize, addr + pagePosition, um); -+ } finally { -+ threads.remove(ti); -+ end(IOStatus.checkAll(addr)); -+ } ++ throw new IllegalArgumentException("Negative position + size"); ++ this.channel = channel; ++ this.position = position; ++ this.size = size; ++ this.shared = shared; + } + + /** -+ * Returns the management interface for mapped buffers -+ */ -+ public static BufferPoolMXBean getMappedBufferPoolMXBean() { -+ return LazyInitialization.mappedBufferPoolMXBean; -+ } -+ -+ // Lazy initialization of management interface -+ private static class LazyInitialization { -+ static final BufferPoolMXBean mappedBufferPoolMXBean = mappedBufferPoolMXBean(); -+ -+ private static BufferPoolMXBean mappedBufferPoolMXBean() { -+ final String pool = "mapped"; -+ final ObjectName obj; -+ try { -+ obj = new ObjectName("java.nio:type=BufferPool,name=" + pool); -+ } catch (MalformedObjectNameException x) { -+ throw new AssertionError(x); -+ } -+ return new BufferPoolMXBean() { -+ -+ public ObjectName getObjectName() { -+ return obj; -+ } -+ -+ public String getName() { -+ return pool; -+ } -+ -+ public long getCount() { -+ return Unmapper.count; -+ } -+ -+ public long getTotalCapacity() { -+ return Unmapper.totalCapacity; -+ } -+ -+ public long getMemoryUsed() { -+ return Unmapper.totalSize; -+ } -+ }; -+ } -+ } -+ -+ // -- Locks -- -+ -+ public static final int NO_LOCK = -1; // Failed to lock -+ public static final int LOCKED = 0; // Obtained requested lock -+ public static final int RET_EX_LOCK = 1; // Obtained exclusive lock -+ public static final int INTERRUPTED = 2; // Request interrupted -+ -+ // keeps track of locks on this file -+ private volatile FileLockTable fileLockTable; -+ -+ // indicates if file locks are maintained system-wide (as per spec) -+ private static boolean isSharedFileLockTable; -+ -+ // indicates if the disableSystemWideOverlappingFileLockCheck property -+ // has been checked -+ private static volatile boolean propertyChecked; -+ -+ // The lock list in J2SE 1.4/5.0 was local to each FileChannel instance so -+ // the overlap check wasn't system wide when there were multiple channels to -+ // the same file. This property is used to get 1.4/5.0 behavior if desired. -+ private static boolean isSharedFileLockTable() { -+ if (!propertyChecked) { -+ synchronized (FileChannelImpl.class) { -+ if (!propertyChecked) { -+ String value = AccessController.doPrivileged( -+ new GetPropertyAction( -+ "sun.nio.ch.disableSystemWideOverlappingFileLockCheck")); -+ isSharedFileLockTable = ((value == null) || value.equals("false")); -+ propertyChecked = true; -+ } -+ } -+ } -+ return isSharedFileLockTable; -+ } -+ -+ private FileLockTable fileLockTable() { -+ if (fileLockTable == null) { -+ synchronized (this) { -+ if (fileLockTable == null) { -+ fileLockTable = isSharedFileLockTable() ? -+ new SharedFileLockTable(this) : new SimpleFileLockTable(); -+ } -+ } -+ } -+ return fileLockTable; -+ } -+ -+ public FileLock lock(long position, long size, boolean shared) -+ throws IOException -+ { -+ ensureOpen(); -+ if (shared && !readable) -+ throw new NonReadableChannelException(); -+ if (!shared && !writable) -+ throw new NonWritableChannelException(); -+ FileLockImpl fli = new FileLockImpl(this, position, size, shared); -+ FileLockTable flt = fileLockTable(); -+ flt.add(fli); -+ boolean i = true; -+ int ti = -1; -+ try { -+ begin(); -+ if (!isOpen()) -+ return null; -+ ti = threads.add(); -+ int result = lock0(fd, true, position, size, shared); -+ if (result == RET_EX_LOCK) { -+ assert shared; -+ FileLockImpl fli2 = new FileLockImpl(this, position, size, -+ false); -+ flt.replace(fli, fli2); -+ return fli2; -+ } -+ if (result == INTERRUPTED || result == NO_LOCK) { -+ flt.remove(fli); -+ i = false; -+ } -+ } catch (IOException e) { -+ flt.remove(fli); -+ throw e; -+ } finally { -+ threads.remove(ti); -+ try { -+ end(i); -+ } catch (ClosedByInterruptException e) { -+ throw new FileLockInterruptionException(); -+ } -+ } -+ return fli; -+ } -+ -+ public FileLock tryLock(long position, long size, boolean shared) -+ throws IOException -+ { -+ ensureOpen(); -+ if (shared && !readable) -+ throw new NonReadableChannelException(); -+ if (!shared && !writable) -+ throw new NonWritableChannelException(); -+ FileLockImpl fli = new FileLockImpl(this, position, size, shared); -+ FileLockTable flt = fileLockTable(); -+ flt.add(fli); -+ int result = lock0(fd, false, position, size, shared); -+ if (result == NO_LOCK) { -+ flt.remove(fli); -+ return null; -+ } -+ if (result == RET_EX_LOCK) { -+ assert shared; -+ FileLockImpl fli2 = new FileLockImpl(this, position, size, -+ false); -+ flt.replace(fli, fli2); -+ return fli2; -+ } -+ return fli; -+ } -+ -+ void release(FileLockImpl fli) throws IOException { -+ ensureOpen(); -+ release0(fd, fli.position(), fli.size()); -+ assert fileLockTable != null; -+ fileLockTable.remove(fli); -+ } -+ -+ -+ // -- File lock support -- -+ -+ /** -+ * A table of FileLocks. -+ */ -+ private interface FileLockTable { -+ /** -+ * Adds a file lock to the table. -+ * -+ * @throws OverlappingFileLockException if the file lock overlaps -+ * with an existing file lock in the table -+ */ -+ void add(FileLock fl) throws OverlappingFileLockException; -+ -+ /** -+ * Remove an existing file lock from the table. -+ */ -+ void remove(FileLock fl); -+ -+ /** -+ * An implementation of this interface releases a given file lock. -+ * Used with removeAll. -+ */ -+ interface Releaser { -+ void release(FileLock fl) throws IOException; -+ } -+ -+ /** -+ * Removes all file locks from the table. -+ * <p> -+ * The Releaser#release method is invoked for each file lock before -+ * it is removed. -+ * -+ * @throws IOException if the release method throws IOException -+ */ -+ void removeAll(Releaser r) throws IOException; -+ -+ /** -+ * Replaces an existing file lock in the table. -+ */ -+ void replace(FileLock fl1, FileLock fl2); ++ * {@note revised} ++ * Returns the file channel upon whose file this lock was acquired. + * +- * @return The file channel ++ * <p> This method has been superseded by the {@link #acquiredBy acquiredBy} ++ * method. ++ * ++ * @return The file channel, or {@code null} if the file lock was not ++ * acquired by a file channel. + */ + public final FileChannel channel() { ++ return (channel instanceof FileChannel) ? (FileChannel)channel : null; + } + + /** -+ * A simple file lock table that maintains a list of FileLocks obtained by a -+ * FileChannel. Use to get 1.4/5.0 behaviour. ++ * {@note new} ++ * Returns the channel upon whose file this lock was acquired. ++ * ++ * @return The channel upon whose file this lock was acquired. ++ * ++ * @since 1.7 + */ -+ private static class SimpleFileLockTable implements FileLockTable { -+ // synchronize on list for access -+ private List<FileLock> lockList = new ArrayList<FileLock>(2); -+ -+ public SimpleFileLockTable() { -+ } -+ -+ private void checkList(long position, long size) -+ throws OverlappingFileLockException -+ { -+ assert Thread.holdsLock(lockList); -+ for (FileLock fl: lockList) { -+ if (fl.overlaps(position, size)) { -+ throw new OverlappingFileLockException(); -+ } -+ } -+ } -+ -+ public void add(FileLock fl) throws OverlappingFileLockException { -+ synchronized (lockList) { -+ checkList(fl.position(), fl.size()); -+ lockList.add(fl); -+ } -+ } -+ -+ public void remove(FileLock fl) { -+ synchronized (lockList) { -+ lockList.remove(fl); -+ } -+ } ++ public Channel acquiredBy() { + return channel; + } + +diff -Nru openjdk.orig/jdk/src/share/classes/java/nio/channels/package-info.java openjdk/jdk/src/share/classes/java/nio/channels/package-info.java +--- openjdk.orig/jdk/src/share/classes/java/nio/channels/package-info.java 2009-02-13 21:10:32.000000000 +0000 ++++ openjdk/jdk/src/share/classes/java/nio/channels/package-info.java 2009-02-13 22:23:47.000000000 +0000 +@@ -46,6 +46,10 @@ + * <td>Can read/write to/from a buffer</td></tr> + * <tr><td valign=top><tt> <i>{@link java.nio.channels.SeekableByteChannel}</i></tt></td> + * <td>A {@code ByteChannel} connected to an entity that contains a variable-length sequence of bytes</td></tr> ++ * <tr><td valign=top><tt> <i>{@link java.nio.channels.AsynchronousChannel}</i></tt></td> ++ * <td>Supports asynchronous I/O operations.</td></tr> ++ * <tr><td valign=top><tt> <i>{@link java.nio.channels.AsynchronousByteChannel}</i></tt></td> ++ * <td>Can read and write bytes asynchronously</td></tr> + * <tr><td valign=top><tt> <i>{@link java.nio.channels.NetworkChannel}</i></tt></td> + * <td>A channel to a network socket</td></tr> + * <tr><td valign=top><tt> <i>{@link java.nio.channels.MulticastChannel}</i></tt></td> +@@ -218,12 +222,70 @@ + * directly; custom channel classes should extend the appropriate {@link + * java.nio.channels.SelectableChannel} subclasses defined in this package. + * ++ * <a name="async"></a> ++ * ++ * <blockquote><table cellspacing=1 cellpadding=0 summary="Lists asynchronous channels and their descriptions"> ++ * <tr><th><p align="left">Asynchronous I/O</p></th><th><p align="left">Description</p></th></tr> ++ * <tr><td valign=top><tt>{@link java.nio.channels.AsynchronousFileChannel}</tt></td> ++ * <td>An asynchronous channel for reading, writing, and manipulating a file</td></tr> ++ * <tr><td valign=top><tt>{@link java.nio.channels.AsynchronousSocketChannel}</tt></td> ++ * <td>An asynchronous channel to a stream-oriented connecting socket</td></tr> ++ * <tr><td valign=top><tt>{@link java.nio.channels.AsynchronousServerSocketChannel} </tt></td> ++ * <td>An asynchronous channel to a stream-oriented listening socket</td></tr> ++ * <tr><td valign=top><tt>{@link java.nio.channels.AsynchronousDatagramChannel}</tt></td> ++ * <td>An asynchronous channel to a datagram-oriented socket</td></tr> ++ * <tr><td valign=top><tt>{@link java.nio.channels.CompletionHandler}</tt></td> ++ * <td>A handler for consuming the result of an asynchronous operation</td></tr> ++ * <tr><td valign=top><tt>{@link java.nio.channels.AsynchronousChannelGroup}</tt></td> ++ * <td>A grouping of asynchronous channels for the purpose of resource sharing</td></tr> ++ * </table></blockquote> ++ * ++ * <p> {@link java.nio.channels.AsynchronousChannel Asynchronous channels} are a ++ * special type of channel capable of asynchronous I/O operations. Asynchronous ++ * channels are non-blocking and define methods to initiate asynchronous ++ * operations, returning a {@link java.util.concurrent.Future} representing the ++ * pending result of each operation. The {@code Future} can be used to poll or ++ * wait for the result of the operation. Asynchronous I/O operations can also ++ * specify a {@link java.nio.channels.CompletionHandler} to invoke when the ++ * operation completes. A completion handler is user provided code that is executed ++ * to consume the result of I/O operation. ++ * ++ * <p> This package defines asynchronous-channel classes that are connected to ++ * a stream-oriented connecting or listening socket, or a datagram-oriented socket. ++ * It also defines the {@link java.nio.channels.AsynchronousFileChannel} class ++ * for asynchronous reading, writing, and manipulating a file. As with the {@link ++ * java.nio.channels.FileChannel} it supports operations to truncate the file ++ * to a specific size, force updates to the file to be written to the storage ++ * device, or acquire locks on the whole file or on a specific region of the file. ++ * Unlike the {@code FileChannel} it does not define methods for mapping a ++ * region of the file directly into memory. Where memory mapped I/O is required, ++ * then a {@code FileChannel} can be used. ++ * ++ * <p> Asynchronous channels are bound to an asynchronous channel group for the ++ * purpose of resource sharing. A group has an associated {@link ++ * java.util.concurrent.ExecutorService} to which tasks are submitted to handle ++ * I/O events and dispatch to completion handlers that consume the result of ++ * asynchronous operations performed on channels in the group. The group can ++ * optionally be specified when creating the channel or the channel can be bound ++ * to a <em>default group</em>. Sophisticated users may wish to create their ++ * own asynchronous channel groups or configure the {@code ExecutorService} ++ * that will be used for the default group. ++ * ++ * <p> As with selectors, the implementatin of asynchronous channels can be ++ * replaced by "plugging in" an alternative definition or instance of the {@link ++ * java.nio.channels.spi.AsynchronousChannelProvider} class defined in the ++ * <tt>{@link java.nio.channels.spi}</tt> package. It is not expected that many ++ * developers will actually make use of this facility; it is provided primarily ++ * so that sophisticated users can take advantage of operating-system-specific ++ * asynchronous I/O mechanisms when very high performance is required. ++ * + * <hr width="80%"> + * <p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor + * or method in any class or interface in this package will cause a {@link + * java.lang.NullPointerException NullPointerException} to be thrown. + * + * @since 1.4 ++ * @updated 1.7 + * @author Mark Reinhold + * @author JSR-51 Expert Group + */ +diff -Nru openjdk.orig/jdk/src/share/classes/java/util/Scanner.java openjdk/jdk/src/share/classes/java/util/Scanner.java +--- openjdk.orig/jdk/src/share/classes/java/util/Scanner.java 2009-02-13 21:10:48.000000000 +0000 ++++ openjdk/jdk/src/share/classes/java/util/Scanner.java 2009-02-13 22:32:01.000000000 +0000 +@@ -32,9 +32,10 @@ + import java.nio.channels.*; + import java.nio.charset.*; + import java.text.*; +-import java.util.Locale; + import sun.misc.LRUCache; + ++import java.nio.file.FileRef; + -+ public void removeAll(Releaser releaser) throws IOException { -+ synchronized(lockList) { -+ Iterator<FileLock> i = lockList.iterator(); -+ while (i.hasNext()) { -+ FileLock fl = i.next(); -+ releaser.release(fl); -+ i.remove(); -+ } -+ } -+ } -+ -+ public void replace(FileLock fl1, FileLock fl2) { -+ synchronized (lockList) { -+ lockList.remove(fl1); -+ lockList.add(fl2); -+ } -+ } -+ } -+ -+ /** -+ * A weak reference to a FileLock. -+ * <p> -+ * SharedFileLockTable uses a list of file lock references to avoid keeping the -+ * FileLock (and FileChannel) alive. + /** + * A simple text scanner which can parse primitive types and strings using + * regular expressions. +@@ -673,6 +674,49 @@ + } + + /** ++ * {@note new} ++ * Constructs a new <code>Scanner</code> that produces values scanned ++ * from the specified file. Bytes from the file are converted into ++ * characters using the underlying platform's ++ * {@linkplain java.nio.charset.Charset#defaultCharset() default charset}. ++ * ++ * @param source ++ * A file to be scanned ++ * @throws IOException ++ * if an I/O error occurs opening source ++ * ++ * @since 1.7 + */ -+ private static class FileLockReference extends WeakReference<FileLock> { -+ private FileKey fileKey; -+ -+ FileLockReference(FileLock referent, -+ ReferenceQueue<FileLock> queue, -+ FileKey key) { -+ super(referent, queue); -+ this.fileKey = key; -+ } -+ -+ private FileKey fileKey() { -+ return fileKey; -+ } ++ public Scanner(FileRef source) ++ throws IOException ++ { ++ this(source.newByteChannel()); + } + + /** -+ * A file lock table that is over a system-wide map of all file locks. ++ * {@note new} ++ * Constructs a new <code>Scanner</code> that produces values scanned ++ * from the specified file. Bytes from the file are converted into ++ * characters using the specified charset. ++ * ++ * @param source ++ * A file to be scanned ++ * @param charsetName ++ * The encoding type used to convert bytes from the file ++ * into characters to be scanned ++ * @throws IOException ++ * if an I/O error occurs opening source ++ * @throws IllegalArgumentException ++ * if the specified encoding is not found ++ * @since 1.7 + */ -+ private static class SharedFileLockTable implements FileLockTable { -+ // The system-wide map is a ConcurrentHashMap that is keyed on the FileKey. -+ // The map value is a list of file locks represented by FileLockReferences. -+ // All access to the list must be synchronized on the list. -+ private static ConcurrentHashMap<FileKey, ArrayList<FileLockReference>> lockMap = -+ new ConcurrentHashMap<FileKey, ArrayList<FileLockReference>>(); -+ -+ // reference queue for cleared refs -+ private static ReferenceQueue<FileLock> queue = new ReferenceQueue<FileLock>(); -+ -+ // the enclosing file channel -+ private FileChannelImpl fci; -+ -+ // File key for the file that this channel is connected to -+ private FileKey fileKey; -+ -+ public SharedFileLockTable(FileChannelImpl fci) { -+ this.fci = fci; -+ this.fileKey = FileKey.create(fci.fd); -+ } -+ -+ public void add(FileLock fl) throws OverlappingFileLockException { -+ ArrayList<FileLockReference> list = lockMap.get(fileKey); -+ -+ for (;;) { -+ -+ // The key isn't in the map so we try to create it atomically -+ if (list == null) { -+ list = new ArrayList<FileLockReference>(2); -+ ArrayList<FileLockReference> prev; -+ synchronized (list) { -+ prev = lockMap.putIfAbsent(fileKey, list); -+ if (prev == null) { -+ // we successfully created the key so we add the file lock -+ list.add(new FileLockReference(fl, queue, fileKey)); -+ break; -+ } -+ } -+ // someone else got there first -+ list = prev; -+ } -+ -+ // There is already a key. It is possible that some other thread -+ // is removing it so we re-fetch the value from the map. If it -+ // hasn't changed then we check the list for overlapping locks -+ // and add the new lock to the list. -+ synchronized (list) { -+ ArrayList<FileLockReference> current = lockMap.get(fileKey); -+ if (list == current) { -+ checkList(list, fl.position(), fl.size()); -+ list.add(new FileLockReference(fl, queue, fileKey)); -+ break; -+ } -+ list = current; -+ } -+ -+ } -+ -+ // process any stale entries pending in the reference queue -+ removeStaleEntries(); -+ } -+ -+ private void removeKeyIfEmpty(FileKey fk, ArrayList<FileLockReference> list) { -+ assert Thread.holdsLock(list); -+ assert lockMap.get(fk) == list; -+ if (list.isEmpty()) { -+ lockMap.remove(fk); -+ } -+ } -+ -+ public void remove(FileLock fl) { -+ assert fl != null; -+ -+ // the lock must exist so the list of locks must be present -+ ArrayList<FileLockReference> list = lockMap.get(fileKey); -+ assert list != null; -+ -+ synchronized (list) { -+ int index = 0; -+ while (index < list.size()) { -+ FileLockReference ref = list.get(index); -+ FileLock lock = ref.get(); -+ if (lock == fl) { -+ assert (lock != null) && (lock.channel() == fci); -+ ref.clear(); -+ list.remove(index); -+ break; -+ } -+ index++; -+ } -+ } -+ } -+ -+ public void removeAll(Releaser releaser) throws IOException { -+ ArrayList<FileLockReference> list = lockMap.get(fileKey); -+ if (list != null) { -+ synchronized (list) { -+ int index = 0; -+ while (index < list.size()) { -+ FileLockReference ref = list.get(index); -+ FileLock lock = ref.get(); -+ -+ // remove locks obtained by this channel -+ if (lock != null && lock.channel() == fci) { -+ // invoke the releaser to invalidate/release the lock -+ releaser.release(lock); -+ -+ // remove the lock from the list -+ ref.clear(); -+ list.remove(index); -+ } else { -+ index++; -+ } -+ } -+ -+ // once the lock list is empty we remove it from the map -+ removeKeyIfEmpty(fileKey, list); -+ } -+ } -+ } -+ -+ public void replace(FileLock fromLock, FileLock toLock) { -+ // the lock must exist so there must be a list -+ ArrayList<FileLockReference> list = lockMap.get(fileKey); -+ assert list != null; -+ -+ synchronized (list) { -+ for (int index=0; index<list.size(); index++) { -+ FileLockReference ref = list.get(index); -+ FileLock lock = ref.get(); -+ if (lock == fromLock) { -+ ref.clear(); -+ list.set(index, new FileLockReference(toLock, queue, fileKey)); -+ break; -+ } -+ } -+ } -+ } -+ -+ // Check for overlapping file locks -+ private void checkList(List<FileLockReference> list, long position, long size) -+ throws OverlappingFileLockException -+ { -+ assert Thread.holdsLock(list); -+ for (FileLockReference ref: list) { -+ FileLock fl = ref.get(); -+ if (fl != null && fl.overlaps(position, size)) -+ throw new OverlappingFileLockException(); -+ } -+ } -+ -+ // Process the reference queue -+ private void removeStaleEntries() { -+ FileLockReference ref; -+ while ((ref = (FileLockReference)queue.poll()) != null) { -+ FileKey fk = ref.fileKey(); -+ ArrayList<FileLockReference> list = lockMap.get(fk); -+ if (list != null) { -+ synchronized (list) { -+ list.remove(ref); -+ removeKeyIfEmpty(fk, list); -+ } -+ } -+ } -+ } ++ public Scanner(FileRef source, String charsetName) ++ throws IOException ++ { ++ this(source.newByteChannel(), charsetName); + } + -+ // -- Native methods -- -+ -+ // Grabs a file lock -+ native int lock0(FileDescriptor fd, boolean blocking, long pos, long size, -+ boolean shared) throws IOException; -+ -+ // Releases a file lock -+ native void release0(FileDescriptor fd, long pos, long size) -+ throws IOException; -+ -+ // Creates a new mapping -+ private native long map0(int prot, long position, long length) -+ throws IOException; -+ -+ // Removes an existing mapping -+ private static native int unmap0(long address, long length); -+ -+ // Forces output to device -+ private native int force0(FileDescriptor fd, boolean metaData); -+ -+ // Truncates a file -+ private native int truncate0(FileDescriptor fd, long size); -+ -+ // Transfers from src to dst, or returns -2 if kernel can't do that -+ private native long transferTo0(int src, long position, long count, int dst); -+ -+ // Sets or reports this file's position -+ // If offset is -1, the current position is returned -+ // otherwise the position is set to offset -+ private native long position0(FileDescriptor fd, long offset); -+ -+ // Reports this file's size -+ private native long size0(FileDescriptor fd); -+ -+ // Caches fieldIDs -+ private static native long initIDs(); -+ -+ static { -+ Util.load(); -+ allocationGranularity = initIDs(); -+ nd = new FileDispatcher(); -+ } -+ -+} ++ /** + * Constructs a new <code>Scanner</code> that produces values scanned + * from the specified string. + * +diff -Nru openjdk.orig/jdk/src/share/classes/sun/nio/ch/MembershipRegistry.java openjdk/jdk/src/share/classes/sun/nio/ch/MembershipRegistry.java +--- openjdk.orig/jdk/src/share/classes/sun/nio/ch/MembershipRegistry.java 2009-02-14 02:09:45.000000000 +0000 ++++ openjdk/jdk/src/share/classes/sun/nio/ch/MembershipRegistry.java 2009-02-14 03:34:58.000000000 +0000 +@@ -120,10 +120,12 @@ + * Invalidate all keys in the registry + */ + void invalidateAll() { +- for (InetAddress group: groups.keySet()) { +- for (MembershipKeyImpl key: groups.get(group)) { +- key.invalidate(); ++ if (groups != null) { ++ for (InetAddress group: groups.keySet()) { ++ for (MembershipKeyImpl key: groups.get(group)) { ++ key.invalidate(); ++ } + } +- } ++ } + } + } diff -Nru openjdk.orig/jdk/src/share/classes/sun/nio/ch/Net.java openjdk/jdk/src/share/classes/sun/nio/ch/Net.java --- openjdk.orig/jdk/src/share/classes/sun/nio/ch/Net.java 2009-02-11 23:11:27.000000000 +0000 -+++ openjdk/jdk/src/share/classes/sun/nio/ch/Net.java 2009-02-11 23:14:46.000000000 +0000 -@@ -32,6 +32,15 @@ ++++ openjdk/jdk/src/share/classes/sun/nio/ch/Net.java 2009-02-14 01:49:30.000000000 +0000 +@@ -32,7 +32,6 @@ import java.security.AccessController; import java.security.PrivilegedAction; -+import java.security.AccessController; -+import java.security.PrivilegedAction; -+ -+import java.util.Enumeration; -+ -+import org.classpath.icedtea.java.net.ProtocolFamily; -+import org.classpath.icedtea.java.net.SocketOption; -+import org.classpath.icedtea.java.net.StandardProtocolFamily; -+import org.classpath.icedtea.java.net.StandardSocketOption; - +- class Net { // package-private -@@ -489,4 +498,314 @@ + private Net() { } +@@ -207,7 +206,7 @@ + // -- Socket options + + static void setSocketOption(FileDescriptor fd, ProtocolFamily family, +- SocketOption name, Object value) ++ SocketOption<?> name, Object value) + throws IOException + { + if (value == null) +@@ -262,7 +261,7 @@ + } + + static Object getSocketOption(FileDescriptor fd, ProtocolFamily family, +- SocketOption name) ++ SocketOption<?> name) + throws IOException + { + Class<?> type = name.type(); +@@ -489,4 +488,11 @@ initIDs(); } + // From 1.7 + -+ static native void listen(FileDescriptor fd, int backlog) throws IOException; -+ -+ // unspecified protocol family -+ static final ProtocolFamily UNSPEC = new ProtocolFamily() { -+ public String name() { -+ return "UNSPEC"; -+ } -+ }; -+ -+ // -- Socket options -+ -+ static void setSocketOption(FileDescriptor fd, ProtocolFamily family, -+ SocketOption<?> name, Object value) -+ throws IOException -+ { -+ if (value == null) -+ throw new IllegalArgumentException("Invalid option value"); -+ -+ // only simple values supported by this method -+ Class<?> type = name.type(); -+ if (type != Integer.class && type != Boolean.class) -+ throw new AssertionError("Should not reach here"); -+ -+ // special handling -+ if (name == StandardSocketOption.SO_RCVBUF || -+ name == StandardSocketOption.SO_SNDBUF) -+ { -+ int i = ((Integer)value).intValue(); -+ if (i < 0) -+ throw new IllegalArgumentException("Invalid send/receive buffer size"); -+ } -+ if (name == StandardSocketOption.SO_LINGER) { -+ int i = ((Integer)value).intValue(); -+ if (i < 0) -+ value = Integer.valueOf(-1); -+ if (i > 65535) -+ value = Integer.valueOf(65535); -+ } -+ if (name == StandardSocketOption.IP_TOS) { -+ int i = ((Integer)value).intValue(); -+ if (i < 0 || i > 255) -+ throw new IllegalArgumentException("Invalid IP_TOS value"); -+ } -+ if (name == StandardSocketOption.IP_MULTICAST_TTL) { -+ int i = ((Integer)value).intValue(); -+ if (i < 0 || i > 255) -+ throw new IllegalArgumentException("Invalid TTL/hop value"); -+ } -+ -+ // map option name to platform level/name -+ OptionKey key = SocketOptionRegistry.findOption(name, family); -+ if (key == null) -+ throw new AssertionError("Option not found"); -+ -+ int arg; -+ if (type == Integer.class) { -+ arg = ((Integer)value).intValue(); -+ } else { -+ boolean b = ((Boolean)value).booleanValue(); -+ arg = (b) ? 1 : 0; -+ } -+ -+ boolean mayNeedConversion = (family == UNSPEC); -+ setIntOption1(fd, mayNeedConversion, key.level(), key.name(), arg); -+ } -+ -+ static Object getSocketOption(FileDescriptor fd, ProtocolFamily family, -+ SocketOption<?> name) -+ throws IOException -+ { -+ Class<?> type = name.type(); -+ -+ // only simple values supported by this method -+ if (type != Integer.class && type != Boolean.class) -+ throw new AssertionError("Should not reach here"); -+ -+ // map option name to platform level/name -+ OptionKey key = SocketOptionRegistry.findOption(name, family); -+ if (key == null) -+ throw new AssertionError("Option not found"); -+ -+ boolean mayNeedConversion = (family == UNSPEC); -+ int value = getIntOption0(fd, mayNeedConversion, key.level(), key.name()); -+ -+ if (type == Integer.class) { -+ return Integer.valueOf(value); -+ } else { -+ return (value == 0) ? Boolean.FALSE : Boolean.TRUE; -+ } -+ } -+ -+ private static native int getIntOption0(FileDescriptor fd, boolean mayNeedConversion, -+ int level, int opt) -+ throws IOException; -+ + private static native void setIntOption1(FileDescriptor fd, boolean mayNeedConversion, + int level, int opt, int arg) + throws IOException; + -+ public final static int SHUT_RD = 0; -+ public final static int SHUT_WR = 1; -+ -+ static native void shutdown(FileDescriptor fd, int how) throws IOException; -+ -+ static native void setInterface6(FileDescriptor fd, int index) throws IOException; -+ -+ static native void setInterface4(FileDescriptor fd, int interf) throws IOException; -+ -+ static native int getInterface4(FileDescriptor fd) throws IOException; -+ -+ static native int getInterface6(FileDescriptor fd) throws IOException; -+ -+ /** -+ * Returns any IPv4 address of the given network interface, or -+ * null if the interface does not have any IPv4 addresses. -+ */ -+ static Inet4Address anyInet4Address(final NetworkInterface interf) { -+ return AccessController.doPrivileged(new PrivilegedAction<Inet4Address>() { -+ public Inet4Address run() { -+ Enumeration<InetAddress> addrs = interf.getInetAddresses(); -+ while (addrs.hasMoreElements()) { -+ InetAddress addr = addrs.nextElement(); -+ if (addr instanceof Inet4Address) { -+ return (Inet4Address)addr; -+ } -+ } -+ return null; -+ } -+ }); -+ } -+ -+ /** -+ * Returns an IPv4 address as an int. -+ */ -+ static int inet4AsInt(InetAddress ia) { -+ if (ia instanceof Inet4Address) { -+ byte[] addr = ia.getAddress(); -+ int address = addr[3] & 0xFF; -+ address |= ((addr[2] << 8) & 0xFF00); -+ address |= ((addr[1] << 16) & 0xFF0000); -+ address |= ((addr[0] << 24) & 0xFF000000); -+ return address; -+ } -+ throw new AssertionError("Should not reach here"); -+ } -+ -+ /** -+ * Returns an InetAddress from the given IPv4 address -+ * represented as an int. -+ */ -+ static InetAddress inet4FromInt(int address) { -+ byte[] addr = new byte[4]; -+ addr[0] = (byte) ((address >>> 24) & 0xFF); -+ addr[1] = (byte) ((address >>> 16) & 0xFF); -+ addr[2] = (byte) ((address >>> 8) & 0xFF); -+ addr[3] = (byte) (address & 0xFF); -+ try { -+ return InetAddress.getByAddress(addr); -+ } catch (UnknownHostException uhe) { -+ throw new AssertionError("Should not reach here"); -+ } -+ } -+ -+ /** -+ * Returns an IPv6 address as a byte array -+ */ -+ static byte[] inet6AsByteArray(InetAddress ia) { -+ if (ia instanceof Inet6Address) { -+ return ia.getAddress(); -+ } -+ -+ // need to construct IPv4-mapped address -+ if (ia instanceof Inet4Address) { -+ byte[] ip4address = ia.getAddress(); -+ byte[] address = new byte[16]; -+ address[10] = (byte)0xff; -+ address[11] = (byte)0xff; -+ address[12] = ip4address[0]; -+ address[13] = ip4address[1]; -+ address[14] = ip4address[2]; -+ address[15] = ip4address[3]; -+ return address; -+ } -+ -+ throw new AssertionError("Should not reach here"); -+ } -+ -+ // -- Miscellaneous utilities -- -+ -+ private static volatile boolean checkedIPv6 = false; -+ private static volatile boolean isIPv6Available; -+ -+ /** -+ * Tells whether dual-IPv4/IPv6 sockets should be used. -+ */ -+ static boolean isIPv6Available() { -+ if (!checkedIPv6) { -+ isIPv6Available = isIPv6Available0(); -+ checkedIPv6 = true; -+ } -+ return isIPv6Available; -+ } -+ -+ /** -+ * Join IPv6 multicast group -+ */ -+ static int join6(FileDescriptor fd, byte[] group, int index, byte[] source) -+ throws IOException -+ { -+ return joinOrDrop6(true, fd, group, index, source); -+ } -+ -+ /** -+ * Drop membership of IPv6 multicast group -+ */ -+ static void drop6(FileDescriptor fd, byte[] group, int index, byte[] source) -+ throws IOException -+ { -+ joinOrDrop6(false, fd, group, index, source); -+ } -+ -+ private static native int joinOrDrop6(boolean join, FileDescriptor fd, byte[] group, int index, byte[] source) -+ throws IOException; -+ -+ /** -+ * Block IPv6 source -+ */ -+ static int block6(FileDescriptor fd, byte[] group, int index, byte[] source) -+ throws IOException -+ { -+ return blockOrUnblock6(true, fd, group, index, source); -+ } -+ -+ /** -+ * Unblock IPv6 source -+ */ -+ static void unblock6(FileDescriptor fd, byte[] group, int index, byte[] source) -+ throws IOException -+ { -+ blockOrUnblock6(false, fd, group, index, source); -+ } -+ -+ static native int blockOrUnblock6(boolean block, FileDescriptor fd, byte[] group, int index, byte[] source) -+ throws IOException; -+ -+ /** -+ * Join IPv4 multicast group -+ */ -+ static int join4(FileDescriptor fd, int group, int interf, int source) -+ throws IOException -+ { -+ return joinOrDrop4(true, fd, group, interf, source); -+ } -+ -+ /** -+ * Drop membership of IPv4 multicast group -+ */ -+ static void drop4(FileDescriptor fd, int group, int interf, int source) -+ throws IOException -+ { -+ joinOrDrop4(false, fd, group, interf, source); -+ } -+ -+ private static native int joinOrDrop4(boolean join, FileDescriptor fd, int group, int interf, int source) -+ throws IOException; -+ -+ /** -+ * Block IPv4 source -+ */ -+ static int block4(FileDescriptor fd, int group, int interf, int source) -+ throws IOException -+ { -+ return blockOrUnblock4(true, fd, group, interf, source); -+ } -+ -+ /** -+ * Unblock IPv4 source -+ */ -+ static void unblock4(FileDescriptor fd, int group, int interf, int source) -+ throws IOException -+ { -+ blockOrUnblock4(false, fd, group, interf, source); -+ } -+ -+ private static native int blockOrUnblock4(boolean block, FileDescriptor fd, int group, -+ int interf, int source) -+ throws IOException; -+ -+ static int connect(FileDescriptor fd, InetAddress remote, int remotePort) -+ throws IOException -+ { -+ return connect(UNSPEC, fd, remote, remotePort); -+ } -+ -+ static int connect(ProtocolFamily family, FileDescriptor fd, InetAddress remote, int remotePort) -+ throws IOException -+ { -+ boolean preferIPv6 = isIPv6Available() && -+ (family != StandardProtocolFamily.INET); -+ return connect0(preferIPv6, fd, remote, remotePort); -+ } -+ -+ private static native int connect0(boolean preferIPv6, -+ FileDescriptor fd, -+ InetAddress remote, -+ int remotePort) -+ throws IOException; + } diff -Nru openjdk.orig/jdk/src/share/classes/sun/security/util/SecurityConstants.java openjdk/jdk/src/share/classes/sun/security/util/SecurityConstants.java @@ -2855,17 +2238,15 @@ } diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/nio/ch/InheritedChannel.java openjdk/jdk/src/solaris/classes/sun/nio/ch/InheritedChannel.java --- openjdk.orig/jdk/src/solaris/classes/sun/nio/ch/InheritedChannel.java 2009-02-11 23:11:51.000000000 +0000 -+++ openjdk/jdk/src/solaris/classes/sun/nio/ch/InheritedChannel.java 2009-02-11 23:14:46.000000000 +0000 -@@ -34,7 +34,8 @@ ++++ openjdk/jdk/src/solaris/classes/sun/nio/ch/InheritedChannel.java 2009-02-14 01:21:46.000000000 +0000 +@@ -34,6 +34,7 @@ import java.nio.channels.SocketChannel; import java.nio.channels.ServerSocketChannel; import java.nio.channels.DatagramChannel; --import java.nio.channels.spi.SelectorProvider; + -+import org.classpath.icedtea.java.nio.channels.spi.SelectorProvider; + import java.nio.channels.spi.SelectorProvider; class InheritedChannel { - diff -Nru openjdk.orig/jdk/src/windows/classes/sun/nio/ch/FileDispatcher.java openjdk/jdk/src/windows/classes/sun/nio/ch/FileDispatcher.java --- openjdk.orig/jdk/src/windows/classes/sun/nio/ch/FileDispatcher.java 2009-02-11 23:11:51.000000000 +0000 +++ openjdk/jdk/src/windows/classes/sun/nio/ch/FileDispatcher.java 2009-02-11 23:14:46.000000000 +0000