changeset 1719:ab30fa9f3e55

Move NIO2 tests to right directory. 2009-03-06 Andrew John Hughes <ahughes@redhat.com> * 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/Attack.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Identity.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/PrivilegedThreadFactory.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Restart.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Unbounded.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousDatagramChannel/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/CustomThreadPool.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/Lock.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/MyThreadFactory.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/java.policy.allow, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/java.policy.deny, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousSocketChannel/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousSocketChannel/Leaky.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/Channels/Basic2.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/META-INF/services/java.nio.channels.spi.AsynchronousChannelProvider, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/DirectoryStream/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/DirectoryStream/Filters.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/DirectoryStream/SecureDS.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/FileStore/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/FileSystem/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/ContentType.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/CreateFileTree.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/ForceLoad.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/META-INF/services/java.nio.file.spi.FileTypeDetector, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/Misc.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/PrintFileTree.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/SimpleFileTypeDetector.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/SkipSiblings.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/TerminateWalk.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/content_type.sh, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/walk_file_tree.sh, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/CopyAndMove.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/DeleteOnClose.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/InterruptCopy.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/Links.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/Misc.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/PathOps.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/SBC.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/TemporaryFiles.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/UriImportExport.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/delete_on_close.sh, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/temporary_files.sh, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/PathMatcher/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/TestUtil.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/FileTreeModifier.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/WithSecurityManager.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/denyAll.policy, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/grantDirAndOneLevel.policy, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/grantDirAndTree.policy, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/grantDirOnly.policy, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/AclFileAttributeView/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/Attributes/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/BasicFileAttributeView/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/DosFileAttributeView/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/FileStoreAttributeView/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/PosixFileAttributeView/Basic.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/spi/SetDefaultProvider.java, * overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/spi/TestProvider.java: Moved to... * overlays/nio2/openjdk/jdk/test/java/io/Inputs/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Attack.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Identity.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/PrivilegedThreadFactory.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousDatagramChannel/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/CustomThreadPool.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/Lock.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/MyThreadFactory.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/java.policy.allow, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/java.policy.deny, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousSocketChannel/Leaky.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/Channels/Basic2.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/META-INF/services/java.nio.channels.spi.AsynchronousChannelProvider, * overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java, * overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh, * overlays/nio2/openjdk/jdk/test/java/nio/file/DirectoryStream/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/DirectoryStream/Filters.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/DirectoryStream/SecureDS.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/FileStore/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/FileSystem/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Files/ContentType.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Files/CreateFileTree.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Files/ForceLoad.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Files/META-INF/services/java.nio.file.spi.FileTypeDetector, * overlays/nio2/openjdk/jdk/test/java/nio/file/Files/Misc.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Files/PrintFileTree.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Files/SimpleFileTypeDetector.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Files/SkipSiblings.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Files/TerminateWalk.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Files/content_type.sh, * overlays/nio2/openjdk/jdk/test/java/nio/file/Files/walk_file_tree.sh, * overlays/nio2/openjdk/jdk/test/java/nio/file/Path/CopyAndMove.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Path/DeleteOnClose.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Path/InterruptCopy.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Path/Links.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Path/Misc.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Path/PathOps.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Path/SBC.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Path/TemporaryFiles.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Path/UriImportExport.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/Path/delete_on_close.sh, * overlays/nio2/openjdk/jdk/test/java/nio/file/Path/temporary_files.sh, * overlays/nio2/openjdk/jdk/test/java/nio/file/PathMatcher/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/TestUtil.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/FileTreeModifier.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/WithSecurityManager.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/denyAll.policy, * overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/grantDirAndOneLevel.policy, * overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/grantDirAndTree.policy, * overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/grantDirOnly.policy, * overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/AclFileAttributeView/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/Attributes/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/BasicFileAttributeView/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/DosFileAttributeView/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/FileStoreAttributeView/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/NamedAttributeView/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/PosixFileAttributeView/Basic.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/spi/SetDefaultProvider.java, * overlays/nio2/openjdk/jdk/test/java/nio/file/spi/TestProvider.java: here.
author Andrew John Hughes <ahughes@redhat.com>
date Fri, 06 Mar 2009 12:26:40 +0000
parents e6271aa33a0c
children a0f00c50a187
files ChangeLog overlays/nio2/openjdk/jdk/test/java/io/Inputs/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Attack.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Identity.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/PrivilegedThreadFactory.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousDatagramChannel/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/CustomThreadPool.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/Lock.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/MyThreadFactory.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/java.policy.allow overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/java.policy.deny overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousSocketChannel/Leaky.java overlays/nio2/openjdk/jdk/test/java/nio/channels/Channels/Basic2.java overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/META-INF/services/java.nio.channels.spi.AsynchronousChannelProvider overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh overlays/nio2/openjdk/jdk/test/java/nio/file/DirectoryStream/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/file/DirectoryStream/Filters.java overlays/nio2/openjdk/jdk/test/java/nio/file/DirectoryStream/SecureDS.java overlays/nio2/openjdk/jdk/test/java/nio/file/FileStore/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/file/FileSystem/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/file/Files/ContentType.java overlays/nio2/openjdk/jdk/test/java/nio/file/Files/CreateFileTree.java overlays/nio2/openjdk/jdk/test/java/nio/file/Files/ForceLoad.java overlays/nio2/openjdk/jdk/test/java/nio/file/Files/META-INF/services/java.nio.file.spi.FileTypeDetector overlays/nio2/openjdk/jdk/test/java/nio/file/Files/Misc.java overlays/nio2/openjdk/jdk/test/java/nio/file/Files/PrintFileTree.java overlays/nio2/openjdk/jdk/test/java/nio/file/Files/SimpleFileTypeDetector.java overlays/nio2/openjdk/jdk/test/java/nio/file/Files/SkipSiblings.java overlays/nio2/openjdk/jdk/test/java/nio/file/Files/TerminateWalk.java overlays/nio2/openjdk/jdk/test/java/nio/file/Files/content_type.sh overlays/nio2/openjdk/jdk/test/java/nio/file/Files/walk_file_tree.sh overlays/nio2/openjdk/jdk/test/java/nio/file/Path/CopyAndMove.java overlays/nio2/openjdk/jdk/test/java/nio/file/Path/DeleteOnClose.java overlays/nio2/openjdk/jdk/test/java/nio/file/Path/InterruptCopy.java overlays/nio2/openjdk/jdk/test/java/nio/file/Path/Links.java overlays/nio2/openjdk/jdk/test/java/nio/file/Path/Misc.java overlays/nio2/openjdk/jdk/test/java/nio/file/Path/PathOps.java overlays/nio2/openjdk/jdk/test/java/nio/file/Path/SBC.java overlays/nio2/openjdk/jdk/test/java/nio/file/Path/TemporaryFiles.java overlays/nio2/openjdk/jdk/test/java/nio/file/Path/UriImportExport.java overlays/nio2/openjdk/jdk/test/java/nio/file/Path/delete_on_close.sh overlays/nio2/openjdk/jdk/test/java/nio/file/Path/temporary_files.sh overlays/nio2/openjdk/jdk/test/java/nio/file/PathMatcher/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/file/TestUtil.java overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/FileTreeModifier.java overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/WithSecurityManager.java overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/denyAll.policy overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/grantDirAndOneLevel.policy overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/grantDirAndTree.policy overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/grantDirOnly.policy overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/AclFileAttributeView/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/Attributes/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/BasicFileAttributeView/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/DosFileAttributeView/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/FileStoreAttributeView/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/NamedAttributeView/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/PosixFileAttributeView/Basic.java overlays/nio2/openjdk/jdk/test/java/nio/file/spi/SetDefaultProvider.java overlays/nio2/openjdk/jdk/test/java/nio/file/spi/TestProvider.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/Attack.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Identity.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/PrivilegedThreadFactory.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Restart.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Unbounded.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousDatagramChannel/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/CustomThreadPool.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/Lock.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/MyThreadFactory.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/java.policy.allow overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/java.policy.deny overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousSocketChannel/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousSocketChannel/Leaky.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/Channels/Basic2.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/META-INF/services/java.nio.channels.spi.AsynchronousChannelProvider overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/DirectoryStream/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/DirectoryStream/Filters.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/DirectoryStream/SecureDS.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/FileStore/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/FileSystem/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/ContentType.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/CreateFileTree.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/ForceLoad.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/META-INF/services/java.nio.file.spi.FileTypeDetector overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/Misc.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/PrintFileTree.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/SimpleFileTypeDetector.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/SkipSiblings.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/TerminateWalk.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/content_type.sh overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/walk_file_tree.sh overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/CopyAndMove.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/DeleteOnClose.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/InterruptCopy.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/Links.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/Misc.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/PathOps.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/SBC.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/TemporaryFiles.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/UriImportExport.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/delete_on_close.sh overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/temporary_files.sh overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/PathMatcher/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/TestUtil.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/FileTreeModifier.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/WithSecurityManager.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/denyAll.policy overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/grantDirAndOneLevel.policy overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/grantDirAndTree.policy overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/grantDirOnly.policy overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/AclFileAttributeView/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/Attributes/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/BasicFileAttributeView/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/DosFileAttributeView/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/FileStoreAttributeView/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/PosixFileAttributeView/Basic.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/spi/SetDefaultProvider.java overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/spi/TestProvider.java
diffstat 145 files changed, 11923 insertions(+), 11776 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 05 09:41:58 2009 +0000
+++ b/ChangeLog	Fri Mar 06 12:26:40 2009 +0000
@@ -1,3 +1,150 @@
+2009-03-06  Andrew John Hughes  <ahughes@redhat.com>
+
+	* 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/Attack.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Identity.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/PrivilegedThreadFactory.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Restart.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Unbounded.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousDatagramChannel/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/CustomThreadPool.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/Lock.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/MyThreadFactory.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/java.policy.allow,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/java.policy.deny,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousSocketChannel/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousSocketChannel/Leaky.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/Channels/Basic2.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/META-INF/services/java.nio.channels.spi.AsynchronousChannelProvider,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/DirectoryStream/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/DirectoryStream/Filters.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/DirectoryStream/SecureDS.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/FileStore/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/FileSystem/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/ContentType.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/CreateFileTree.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/ForceLoad.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/META-INF/services/java.nio.file.spi.FileTypeDetector,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/Misc.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/PrintFileTree.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/SimpleFileTypeDetector.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/SkipSiblings.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/TerminateWalk.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/content_type.sh,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/walk_file_tree.sh,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/CopyAndMove.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/DeleteOnClose.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/InterruptCopy.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/Links.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/Misc.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/PathOps.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/SBC.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/TemporaryFiles.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/UriImportExport.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/delete_on_close.sh,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/temporary_files.sh,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/PathMatcher/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/TestUtil.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/FileTreeModifier.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/WithSecurityManager.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/denyAll.policy,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/grantDirAndOneLevel.policy,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/grantDirAndTree.policy,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/grantDirOnly.policy,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/AclFileAttributeView/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/Attributes/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/BasicFileAttributeView/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/DosFileAttributeView/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/FileStoreAttributeView/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/PosixFileAttributeView/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/spi/SetDefaultProvider.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/spi/TestProvider.java: Moved to...
+	* overlays/nio2/openjdk/jdk/test/java/io/Inputs/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Attack.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Identity.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/PrivilegedThreadFactory.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousDatagramChannel/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/CustomThreadPool.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/Lock.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/MyThreadFactory.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/java.policy.allow,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/java.policy.deny,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousSocketChannel/Leaky.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/Channels/Basic2.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/META-INF/services/java.nio.channels.spi.AsynchronousChannelProvider,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/DirectoryStream/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/DirectoryStream/Filters.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/DirectoryStream/SecureDS.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/FileStore/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/FileSystem/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Files/ContentType.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Files/CreateFileTree.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Files/ForceLoad.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Files/META-INF/services/java.nio.file.spi.FileTypeDetector,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Files/Misc.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Files/PrintFileTree.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Files/SimpleFileTypeDetector.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Files/SkipSiblings.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Files/TerminateWalk.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Files/content_type.sh,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Files/walk_file_tree.sh,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Path/CopyAndMove.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Path/DeleteOnClose.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Path/InterruptCopy.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Path/Links.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Path/Misc.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Path/PathOps.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Path/SBC.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Path/TemporaryFiles.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Path/UriImportExport.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Path/delete_on_close.sh,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/Path/temporary_files.sh,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/PathMatcher/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/TestUtil.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/FileTreeModifier.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/WithSecurityManager.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/denyAll.policy,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/grantDirAndOneLevel.policy,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/grantDirAndTree.policy,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/grantDirOnly.policy,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/AclFileAttributeView/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/Attributes/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/BasicFileAttributeView/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/DosFileAttributeView/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/FileStoreAttributeView/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/NamedAttributeView/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/PosixFileAttributeView/Basic.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/spi/SetDefaultProvider.java,
+	* overlays/nio2/openjdk/jdk/test/java/nio/file/spi/TestProvider.java: here.
+
 2009-03-05  Gary Benson  <gbenson@redhat.com>
 
 	* ports/hotspot/src/share/vm/shark/sharkInliner.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/io/Inputs/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,218 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @summary Basic unit test for java.io.Inputs class
+ */
+
+import java.io.*;
+import java.util.*;
+import java.nio.charset.UnsupportedCharsetException;
+import java.nio.charset.MalformedInputException;
+
+import java.io.Inputs;
+
+import java.nio.file.Path;
+
+public class Basic {
+    static final Random rand = new Random();
+
+    public static void main(String[] args) throws IOException {
+        Path dir = createTempDir();
+        try {
+            testReadAllBytesMethods(dir);
+            testReadAllLinesMethods(dir);
+        } finally {
+            dir.delete();
+        }
+    }
+
+    static void testReadAllBytesMethods(Path dir) throws IOException {
+        // create file with random bytes
+        byte[] bytes = new byte[1 + rand.nextInt(64*1024)];
+        rand.nextBytes(bytes);
+        Path file = dir.resolve("foo");
+        Outputs.write(file, bytes);
+
+        try {
+            byte[] result;
+
+            // check all bytes are read
+            result = Inputs.readAllBytes(file);
+            if (!Arrays.equals(bytes, result))
+                throw new RuntimeException("Unexpected bytes");
+            result = Inputs.readAllBytes(new File(file.toString()));
+            if (!Arrays.equals(bytes, result))
+                throw new RuntimeException("Unexpected bytes");
+
+            // via URL connection
+            InputStream in = file.toUri().toURL().openConnection().getInputStream();
+            try {
+                result = Inputs.readAllBytes(in);
+            if (!Arrays.equals(bytes, result))
+                throw new RuntimeException("Unexpected bytes");
+            } finally {
+                in.close();
+            }
+
+            // test zero-length file
+            Outputs.write(file, new byte[0]);
+            if (Inputs.readAllBytes(file).length != 0)
+                throw new RuntimeException("Unexpected bytes");
+
+            // NullPointerException
+            try {
+                Inputs.readAllBytes((FileRef)null);
+                throw new RuntimeException("NullPointerException expected");
+            } catch (NullPointerException npe) { }
+
+            try {
+                Inputs.readAllBytes((File)null);
+                throw new RuntimeException("NullPointerException expected");
+            } catch (NullPointerException npe) { }
+
+            try {
+                Inputs.readAllBytes((InputStream)null);
+                throw new RuntimeException("NullPointerException expected");
+            } catch (NullPointerException npe) { }
+
+        } finally {
+            file.delete();
+        }
+    }
+
+    static void testReadAllLinesMethods(Path dir) throws IOException {
+        String[] poem = { "I met a traveler from an antique land",
+                          "Who said: Two vast and trunkless legs of stone",
+                          "Stand in the desert. Near them, on the sand",
+                          "Half sunk, a shattered visage lies, whose frown,",
+                          "And wrinkled lip, and sneer of cold command,",
+                          "Tell that its sculptor well those passions read",
+                          "Which yet survive, stamped on these lifeless things,",
+                          "The hand that mocked them, and the heart that fed;",
+                          "And on the pedestal these words appear:",
+                          "My name is Ozymandias, king of kings:",
+                          "Look upon my works, ye Mighty, and despair!",
+                          "Nothing beside remains. Round the decay",
+                          "Of that colossal wreck, boundless and bare",
+                          "The lone and level sands stretch far away." };
+        List<String> poemAsList = Arrays.asList(poem);
+
+        Path file = dir.resolve("Shelley");
+        try {
+            Outputs.writeLines(file, poem);
+
+            checkEquals(poemAsList, Inputs.readAllLines(file));
+            checkEquals(poemAsList, Inputs.readAllLines(file, "UTF-8"));
+            checkEquals(poemAsList, Inputs.readAllLines(new File(file.toString())));
+            checkEquals(poemAsList,
+                Inputs.readAllLines(new File(file.toString()), "UTF-8"));
+            InputStream in = file.newInputStream();
+            try {
+                checkEquals(poemAsList, Inputs.readAllLines(in));
+            } finally {
+                in.close();
+            }
+            InputStreamReader reader = new InputStreamReader(file.newInputStream());
+            try {
+                checkEquals(poemAsList, Inputs.readAllLines(reader));
+            } finally {
+                reader.close();
+            }
+
+            // IOException
+            try {
+                Inputs.readAllLines(dir.resolve("doesNotExist"));
+                throw new RuntimeException("IOException expected");
+            } catch (IOException ignore) { }
+
+            // MalformedInputException
+            OutputStream out = file.newOutputStream();
+            try {
+                out.write((byte)0xC2);  // malformed 2-byte sequence
+                out.write((byte)0x00);
+            } finally {
+                out.close();
+            }
+            try {
+                Inputs.readAllLines(file, "UTF-8");
+                throw new RuntimeException("MalformedInputException expected");
+            } catch (MalformedInputException ignore) { }
+
+            // UnsupportedCharsetException
+            try {
+                Inputs.readAllLines(file, "BAD-CHARSET");
+                throw new RuntimeException("UnsupportedCharsetException expected");
+            } catch (UnsupportedCharsetException ignore) { }
+
+            try {
+                Inputs.readAllLines(new File(file.toString()), "BAD-CHARSET");
+                throw new RuntimeException("UnsupportedCharsetException expected");
+            } catch (UnsupportedCharsetException ignore) { }
+            in = file.newInputStream();
+            try {
+                try {
+                    Inputs.readAllLines(in, "BAD-CHARSET");
+                    throw new RuntimeException("UnsupportedCharsetException expected");
+                } catch (UnsupportedCharsetException ignore) { }
+            } finally {
+                in.close();
+            }
+
+            // NulPointerException
+            try {
+                Inputs.readAllLines((FileRef)null);
+                throw new RuntimeException("NullPointerException expected");
+            } catch (NullPointerException npe) { }
+            try {
+                Inputs.readAllLines((FileRef)null, "UTF-8");
+                throw new RuntimeException("NullPointerException expected");
+            } catch (NullPointerException npe) { }
+
+            try {
+                Inputs.readAllLines(file, null);
+                throw new RuntimeException("NullPointerException expected");
+            } catch (NullPointerException npe) { }
+
+        } finally {
+            file.delete();
+        }
+    }
+
+    static void checkEquals(List<String> expected, List<String> actual) {
+        if (!actual.equals(expected))
+            throw new RuntimeException();
+    }
+
+
+    static Path createTempDir() throws IOException {
+        Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir"));
+        Random r = new Random();
+
+        Path dir;
+        do {
+            dir = tmpdir.resolve("name" + r.nextInt());
+        } while (dir.exists());
+        return dir.createDirectory();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.util.concurrent.*;
+
+import java.nio.channels.AsynchronousChannelGroup;
+
+/**
+ * Test that arbitrary tasks can be submitted to a channel group's thread pool.
+ */
+
+public class AsExecutor {
+
+    public static void main(String[] args) throws Exception {
+        // create channel groups
+        ThreadFactory factory = new PrivilegedThreadFactory();
+        int nThreads = 5;
+        ExecutorService pool = Executors.newFixedThreadPool(5, factory);
+        AsynchronousChannelGroup group1 = AsynchronousChannelGroup
+            .withFixedThreadPool(pool, nThreads);
+        AsynchronousChannelGroup group2 = AsynchronousChannelGroup
+            .withCachedThreadPool(Executors.newCachedThreadPool(factory), 0);
+
+        try {
+            // execute simple tasks
+            testSimpleTask(group1);
+            testSimpleTask(group2);
+
+            // install security manager and test again
+            System.setSecurityManager( new SecurityManager() );
+            testSimpleTask(group1);
+            testSimpleTask(group2);
+
+            // attempt to execute tasks that run with only frames from boot
+            // class loader on the stack.
+            testAttackingTask(group1);
+            testAttackingTask(group2);
+        } finally {
+            group1.shutdown();
+            group2.shutdown();
+        }
+    }
+
+    static void testSimpleTask(AsynchronousChannelGroup group) throws Exception {
+        Executor executor = (Executor)group;
+        final CountDownLatch latch = new CountDownLatch(1);
+        executor.execute(new Runnable() {
+            public void run() {
+                latch.countDown();
+            }
+        });
+        latch.await();
+    }
+
+    static void testAttackingTask(AsynchronousChannelGroup group) throws Exception {
+        Executor executor = (Executor)group;
+        Attack task = new Attack();
+        executor.execute(task);
+        task.waitUntilDone();
+        if (!task.failedDueToSecurityException())
+            throw new RuntimeException("SecurityException expected");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Attack.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.net.*;
+import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * A task that attempts to attack the current host.
+ */
+
+public class Attack implements Runnable {
+    private final CountDownLatch latch = new CountDownLatch(1);
+    private volatile boolean failedDueToSecurityException;
+
+    public void Attack() {
+        // check class is on boot class path
+        if (Attack.class.getClassLoader() != null)
+            throw new RuntimeException("Attack class not on boot class path");
+    }
+
+
+    public void run() {
+        try {
+            new Socket("127.0.0.1", 9999).close();
+            throw new RuntimeException("Connected (not expected)");
+        } catch (IOException e) {
+            throw new RuntimeException("IOException (not expected)");
+        } catch (SecurityException e) {
+            failedDueToSecurityException = true;
+        } finally {
+            latch.countDown();
+        }
+    }
+
+    public void waitUntilDone() throws InterruptedException {
+        latch.await();
+    }
+
+    public boolean failedDueToSecurityException() {
+        return failedDueToSecurityException;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,261 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4607272
+ * @summary Unit test for AsynchronousChannelGroup
+ * @build Basic
+ * @run main/othervm -XX:-UseVMInterruptibleIO Basic
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.channels.*;
+import java.net.*;
+import java.util.*;
+import java.util.concurrent.*;
+import java.io.IOException;
+
+import java.nio.channels.AsynchronousChannelGroup;
+
+public class Basic {
+    static final Random rand = new Random();
+
+    public static void main(String[] args) throws Exception {
+        shutdownTests();
+        shutdownNowTests();
+        afterShutdownTests();
+        miscTests();
+    }
+
+    static void shutdownTests() throws Exception {
+        System.out.println("-- test shutdown --");
+
+        // test shutdown with no channels in groups
+        for (int i=0; i<500; i++) {
+            ExecutorService pool;
+            AsynchronousChannelGroup group;
+            if (rand.nextBoolean()) {
+                pool = Executors.newCachedThreadPool();
+                group = AsynchronousChannelGroup.withCachedThreadPool(pool, rand.nextInt(5));
+            } else {
+                int nThreads = 1 + rand.nextInt(8);
+                pool = Executors.newFixedThreadPool(nThreads);
+                group = AsynchronousChannelGroup.withFixedThreadPool(pool, nThreads);
+            }
+            group.shutdown();
+            if (!group.isShutdown())
+                throw new RuntimeException("Group should be shutdown");
+            // group should terminate quickly
+            boolean terminated = group.awaitTermination(3, TimeUnit.SECONDS);
+            if (!terminated)
+                throw new RuntimeException("Group should have terminated");
+            if (!pool.isTerminated())
+                throw new RuntimeException("Executor should have terminated");
+        }
+
+        // shutdown with channel in group
+        for (int i=0; i<500; i++) {
+            ExecutorService pool;
+            AsynchronousChannelGroup group;
+            if (rand.nextBoolean()) {
+                pool = Executors.newCachedThreadPool();
+                group = AsynchronousChannelGroup.withCachedThreadPool(pool, rand.nextInt(10));
+            } else {
+                int nThreads = 1 + rand.nextInt(8);
+                pool = Executors.newFixedThreadPool(nThreads);
+                group = AsynchronousChannelGroup.withFixedThreadPool(pool, nThreads);
+            }
+            // create channel that is bound to group
+            AsynchronousChannel ch;
+            switch (rand.nextInt(3)) {
+                case 0 : ch = AsynchronousSocketChannel.open(group); break;
+                case 1 : ch = AsynchronousServerSocketChannel.open(group); break;
+                case 2 : ch = AsynchronousDatagramChannel.open(null, group); break;
+                default : throw new AssertionError();
+            }
+            group.shutdown();
+            if (!group.isShutdown())
+                throw new RuntimeException("Group should be shutdown");
+
+            // last channel so should terminate after this channel is closed
+            ch.close();
+
+            // group should terminate quickly
+            boolean terminated = group.awaitTermination(3, TimeUnit.SECONDS);
+            if (!terminated)
+                throw new RuntimeException("Group should have terminated");
+            if (!pool.isTerminated())
+                throw new RuntimeException("Executor should have terminated");
+        }
+    }
+
+    static void shutdownNowTests() throws Exception {
+        System.out.println("-- test shutdownNow --");
+
+        for (int i=0; i< 10; i++) {
+            ExecutorService pool;
+            AsynchronousChannelGroup group;
+            if (rand.nextBoolean()) {
+                pool = Executors.newCachedThreadPool();
+                group = AsynchronousChannelGroup
+                    .withCachedThreadPool(pool, rand.nextInt(5));
+            } else {
+                int nThreads = 1 + rand.nextInt(8);
+                pool = Executors.newFixedThreadPool(nThreads);
+                group = AsynchronousChannelGroup.withFixedThreadPool(pool, nThreads);
+            }
+
+            // I/O in progress
+            AsynchronousChannel ch;
+            if (rand.nextBoolean()) {
+                AsynchronousServerSocketChannel listener = AsynchronousServerSocketChannel
+                    .open(group).bind(new InetSocketAddress(0));
+                listener.accept();
+                ch = listener;
+            } else {
+                AsynchronousDatagramChannel adc =
+                    AsynchronousDatagramChannel.open(null, group);
+                adc.receive(ByteBuffer.allocate(100));
+                ch = adc;
+            }
+
+            // forceful shutdown
+            group.shutdownNow();
+
+            // shutdownNow is required to close all channels
+            if (ch.isOpen())
+                throw new RuntimeException("Channel should be closed");
+
+            boolean terminated = group.awaitTermination(3, TimeUnit.SECONDS);
+            if (!terminated)
+                throw new RuntimeException("Group should have terminated");
+            if (!pool.isTerminated())
+                throw new RuntimeException("Executor should have terminated");
+        }
+    }
+
+    // test creating channels in group after group is shutdown
+    static void afterShutdownTests() throws Exception {
+        System.out.println("-- test operations after group is shutdown  --");
+        ExecutorService pool = Executors.newFixedThreadPool(1);
+        AsynchronousChannelGroup group =
+            AsynchronousChannelGroup.withFixedThreadPool(pool, 1);
+
+        AsynchronousSocketChannel ch = AsynchronousSocketChannel.open(group);
+        AsynchronousServerSocketChannel listener = AsynchronousServerSocketChannel.open(group);
+
+        // initiate accept
+        listener.bind(new InetSocketAddress(0));
+        Future<AsynchronousSocketChannel> result = listener.accept();
+
+        // shutdown group
+        group.shutdown();
+        if (!group.isShutdown())
+            throw new RuntimeException("Group should be shutdown");
+
+        // attempt to create another channel
+        try {
+            AsynchronousSocketChannel.open(group);
+            throw new RuntimeException("ShutdownChannelGroupException expected");
+        } catch (ShutdownChannelGroupException x) {
+        }
+        try {
+            AsynchronousServerSocketChannel.open(group);
+            throw new RuntimeException("ShutdownChannelGroupException expected");
+        } catch (ShutdownChannelGroupException x) {
+        }
+
+        // attempt to create another channel by connecting. This should cause
+        // the accept operation to fail.
+        InetAddress lh = InetAddress.getLocalHost();
+        int port = ((InetSocketAddress)listener.getLocalAddress()).getPort();
+        InetSocketAddress isa = new InetSocketAddress(lh, port);
+        ch.connect(isa).get();
+        try {
+            result.get();
+            throw new RuntimeException("Connection was accepted");
+        } catch (ExecutionException x) {
+            Throwable cause = x.getCause();
+            if (!(cause instanceof IOException))
+                throw new RuntimeException("Cause should be IOException");
+            cause = cause.getCause();
+            if (!(cause instanceof ShutdownChannelGroupException))
+                throw new RuntimeException("IOException cause should be ShutdownChannelGroupException");
+        }
+
+        // initiate another accept even though channel group is shutdown.
+        Future<AsynchronousSocketChannel> res = listener.accept();
+        try {
+            res.get(3, TimeUnit.SECONDS);
+            throw new RuntimeException("TimeoutException expected");
+        } catch (TimeoutException x) {
+        }
+        // connect to the listener which should cause the accept to complete
+        AsynchronousSocketChannel.open().connect(isa);
+        try {
+            res.get();
+            throw new RuntimeException("Connection was accepted");
+        } catch (ExecutionException x) {
+            Throwable cause = x.getCause();
+            if (!(cause instanceof IOException))
+                throw new RuntimeException("Cause should be IOException");
+            cause = cause.getCause();
+            if (!(cause instanceof ShutdownChannelGroupException))
+                throw new RuntimeException("IOException cause should be ShutdownChannelGroupException");
+        }
+
+        // group should *not* terminate as channels are open
+        boolean terminated = group.awaitTermination(3, TimeUnit.SECONDS);
+        if (terminated)
+            throw new RuntimeException("Group should not have terminated");
+
+        // close channel; group should terminate quickly
+        ch.close();
+        listener.close();
+        terminated = group.awaitTermination(3, TimeUnit.SECONDS);
+        if (!terminated)
+            throw new RuntimeException("Group should have terminated");
+    }
+
+    static void miscTests() throws Exception {
+        System.out.println("-- miscellenous tests --");
+        try {
+            AsynchronousChannelGroup.withFixedThreadPool(null, 1);
+            throw new RuntimeException("NPE expected");
+        } catch (NullPointerException x) {
+        }
+        ExecutorService pool = Executors.newCachedThreadPool();
+        try {
+            AsynchronousChannelGroup.withFixedThreadPool(pool, 0);
+            throw new RuntimeException("IAE expected");
+        } catch (IllegalArgumentException e) {
+        } finally {
+            pool.shutdown();
+        }
+        try {
+            AsynchronousChannelGroup.withCachedThreadPool(null, 0);
+            throw new RuntimeException("NPE expected");
+        } catch (NullPointerException x) {
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,137 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4607272
+ * @summary Unit test for AsynchronousChannelGroup
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.channels.*;
+import java.net.*;
+import java.util.concurrent.*;
+import java.io.IOException;
+
+/**
+ * This test verifies that a channel or channel group can be closed from a
+ * completion handler when there are no threads available to handle I/O events.
+ */
+
+public class GroupOfOne {
+
+    public static void main(String[] args) throws Exception {
+        // create listener to accept connections
+        final AsynchronousServerSocketChannel listener =
+            AsynchronousServerSocketChannel.open()
+                .bind(new InetSocketAddress(0));
+        listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
+            public void completed(AsynchronousSocketChannel ch, Void att) {
+                listener.accept(null, this);
+            }
+            public void failed(Throwable exc, Void att) {
+            }
+            public void cancelled(Void att) {
+            }
+        });
+
+        int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
+        SocketAddress sa = new InetSocketAddress(InetAddress.getLocalHost(), port);
+
+        test(sa, true, false);
+        test(sa, false, true);
+        test(sa, true, true);
+    }
+
+    static void test(SocketAddress sa,
+                     final boolean closeChannel,
+                     final boolean shutdownGroup)
+        throws Exception
+    {
+        // group with 1 thread
+        ExecutorService pool = Executors.newFixedThreadPool(1);
+        final AsynchronousChannelGroup group =
+            AsynchronousChannelGroup.withFixedThreadPool(pool, 1);
+        final AsynchronousSocketChannel ch = AsynchronousSocketChannel.open(group);
+
+        // the latch counts down when:
+        // 1. The read operation fails (expected)
+        // 2. the close/shutdown completes
+        final CountDownLatch latch = new CountDownLatch(2);
+
+        ch.connect(sa, null, new CompletionHandler<Void,Void>() {
+            public void completed(Void result, Void att)  {
+                System.out.println("Connected");
+
+                // initiate I/O operation that does not complete (successfully)
+                ByteBuffer buf = ByteBuffer.allocate(100);
+                ch.read(buf, null, new CompletionHandler<Integer,Void>() {
+                    public void completed(Integer bytesRead, Void att)  {
+                        throw new RuntimeException();
+                    }
+                    public void failed(Throwable exc, Void att) {
+                        if (!(exc instanceof AsynchronousCloseException))
+                            throw new RuntimeException(exc);
+                        System.out.println("Read failed (expected)");
+                        latch.countDown();
+                    }
+                    public void cancelled(Void att) {
+                        throw new RuntimeException();
+                    }
+                });
+
+                // close channel or shutdown group
+                try {
+                    if (closeChannel) {
+                        System.out.print("Close channel ...");
+                        ch.close();
+                        System.out.println(" done.");
+                    }
+                    if (shutdownGroup) {
+                        System.out.print("Shutdown group ...");
+                        group.shutdownNow();
+                        System.out.println(" done.");
+                    }
+                    latch.countDown();
+                } catch (IOException e) {
+                    throw new RuntimeException();
+                }
+            }
+            public void failed(Throwable exc, Void att) {
+                throw new RuntimeException(exc);
+            }
+            public void cancelled(Void att) {
+                throw new RuntimeException();
+            }
+        });
+
+        latch.await();
+
+        // clean-up
+        group.shutdown();
+        boolean terminated = group.awaitTermination(5, TimeUnit.SECONDS);
+        if (!terminated)
+            throw new RuntimeException("Group did not terminate");
+
+        System.out.println("TEST OKAY");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Identity.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,167 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4607272
+ * @summary Unit test for AsynchronousChannelGroup
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.channels.*;
+import java.net.*;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+/**
+ * Tests that the completion handler is invoked by a thread with
+ * the expected identity.
+ */
+
+public class Identity {
+    static final Random rand = new Random();
+    static final CountDownLatch done = new CountDownLatch(1);
+    static final AtomicBoolean failed = new AtomicBoolean(false);
+
+    static void fail(String msg) {
+        failed.set(true);
+        done.countDown();
+        throw new RuntimeException(msg);
+    }
+
+    // thread-local identifies the thread
+    private static final ThreadLocal<Integer> myGroup =
+        new ThreadLocal<Integer>() {
+ protected Integer initialValue() {
+                return Integer.valueOf(-1);
+            }
+        };
+
+    // creates a ThreadFactory that constructs groups with the given identity
+    static final ThreadFactory createThreadFactory(final int groupId) {
+        return new ThreadFactory() {
+
+            public Thread newThread(final Runnable r) {
+                Thread t = new Thread(new Runnable() {
+                    public void run() {
+                        myGroup.set(groupId);
+                        r.run();
+                    }});
+                t.setDaemon(true);
+                return t;
+            }
+        };
+    }
+
+    public static void main(String[] args) throws Exception {
+        // create listener to accept connections
+        final AsynchronousServerSocketChannel listener =
+            AsynchronousServerSocketChannel.open()
+                .bind(new InetSocketAddress(0));
+        listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
+            public void completed(final AsynchronousSocketChannel ch, Void att) {
+                listener.accept(null, this);
+
+                final ByteBuffer buf = ByteBuffer.allocate(100);
+                ch.read(buf, null, new CompletionHandler<Integer,Void>() {
+                    public void completed(Integer bytesRead, Void att) {
+                        buf.clear();
+                        ch.read(buf, null, this);
+                    }
+                    public void failed(Throwable exc, Void att) {
+                    }
+                    public void cancelled(Void att) {
+                    }
+                });
+            }
+            public void failed(Throwable exc, Void att) {
+            }
+            public void cancelled(Void att) {
+            }
+        });
+        int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
+        SocketAddress sa = new InetSocketAddress(InetAddress.getLocalHost(), port);
+
+        // create 3-10 channels, each in its own group
+        final int groupCount = 3 + rand.nextInt(8);
+        final AsynchronousSocketChannel[] channel = new AsynchronousSocketChannel[groupCount];
+        for (int i=0; i<groupCount; i++) {
+            ThreadFactory factory = createThreadFactory(i);
+            AsynchronousChannelGroup group;
+            if (rand.nextBoolean()) {
+                int nThreads = 1 + rand.nextInt(10);
+                ExecutorService pool = Executors.newFixedThreadPool(nThreads, factory);
+                group = AsynchronousChannelGroup.withFixedThreadPool(pool, nThreads);
+            } else {
+                ExecutorService pool = Executors.newCachedThreadPool(factory);
+                group = AsynchronousChannelGroup.withCachedThreadPool(pool, rand.nextInt(5));
+            }
+
+            // create channel in group and connect it to the server
+            AsynchronousSocketChannel ch = AsynchronousSocketChannel.open(group);
+            ch.connect(sa).get();
+            channel[i] = ch;
+        }
+
+        // randomly write to each channel, ensuring that the completion handler
+        // is always invoked by a thread with the right identity.
+        final AtomicInteger writeCount = new AtomicInteger(100);
+        channel[0].write(getBuffer(), 0, new CompletionHandler<Integer,Integer>() {
+            public void completed(Integer bytesWritten, Integer groupId) {
+                if (bytesWritten != 1)
+                    fail("Expected 1 byte to be written");
+                if (!myGroup.get().equals(groupId))
+                    fail("Handler invoked by thread with the wrong identity");
+                if (writeCount.decrementAndGet() > 0) {
+                    int id = rand.nextInt(groupCount);
+                    channel[id].write(getBuffer(), id, this);
+                } else {
+                    done.countDown();
+                }
+            }
+            public void failed(Throwable exc, Integer groupId) {
+                fail(exc.getMessage());
+            }
+            public void cancelled(Integer groupId) {
+                fail("I/O operation was cancelled");
+            }
+        });
+
+        // wait until
+        done.await();
+        if (failed.get())
+            throw new RuntimeException("Test failed - see log for details");
+    }
+
+    static ByteBuffer getBuffer() {
+        ByteBuffer buf;
+        if (rand.nextBoolean()) {
+            buf = ByteBuffer.allocateDirect(1);
+        } else {
+            buf = ByteBuffer.allocate(1);
+        }
+        buf.put((byte)0);
+        buf.flip();
+        return buf;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/PrivilegedThreadFactory.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.util.concurrent.ThreadFactory;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * The "privileged" ThreadFactory used by the AsExecutor test.
+ */
+
+public class PrivilegedThreadFactory implements ThreadFactory {
+    public void PrivilegedThreadPoolFactory() {
+        // check class is on boot class path
+        if (PrivilegedThreadFactory.class.getClassLoader() != null)
+            throw new RuntimeException("PrivilegedThreadFactory class not on boot class path");
+    }
+
+
+    public Thread newThread(final Runnable r) {
+        return AccessController.doPrivileged(new PrivilegedAction<Thread>() {
+
+            public Thread run() {
+                Thread t = new Thread(r);
+                t.setDaemon(true);
+                return t;
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,134 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4607272
+ * @summary Unit test for AsynchronousChannelGroup
+ * @build Restart
+ * @run main/othervm -XX:-UseVMInterruptibleIO Restart
+ */
+
+import java.nio.channels.*;
+import java.net.*;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+import java.io.IOException;
+
+/**
+ * Exercise replacement of threads in the thread pool when completion handlers
+ * terminate due to errors or runtime exceptions.
+ */
+
+public class Restart {
+    static final Random rand = new Random();
+
+    public static void main(String[] args) throws Exception {
+        // thread group for thread pools
+        final ThreadGroup tg = new ThreadGroup("test");
+
+        // keep track of the number of threads that terminate
+        final AtomicInteger exceptionCount = new AtomicInteger(0);
+        final Thread.UncaughtExceptionHandler ueh =
+            new Thread.UncaughtExceptionHandler() {
+                public void uncaughtException(Thread t, Throwable e) {
+                    exceptionCount.incrementAndGet();
+                }
+            };
+        ThreadFactory factory = new ThreadFactory() {
+
+            public Thread newThread(Runnable r) {
+                Thread t = new Thread(tg, r);
+                t.setUncaughtExceptionHandler(ueh);
+                return t;
+            }
+        };
+
+        // group with fixed thread pool
+        int nThreads = 1 + rand.nextInt(4);
+        ExecutorService pool = Executors.newFixedThreadPool(nThreads, factory);
+        AsynchronousChannelGroup group =
+            AsynchronousChannelGroup.withFixedThreadPool(pool, nThreads);
+        testRestart(group, 100);
+        group.shutdown();
+
+        // group with thread pool created automatically
+        pool = Executors.newCachedThreadPool(factory);
+        group = AsynchronousChannelGroup.withCachedThreadPool(pool, rand.nextInt(5));
+        testRestart(group, 100);
+        group.shutdown();
+
+        // give time for threads to terminate
+        Thread.sleep(3000);
+        int actual = exceptionCount.get();
+        if (actual != 200)
+            throw new RuntimeException(actual + " exceptions, expected: " + 200);
+    }
+
+    static void testRestart(AsynchronousChannelGroup group, int count)
+        throws Exception
+    {
+        AsynchronousServerSocketChannel listener =
+            AsynchronousServerSocketChannel.open(group)
+                .bind(new InetSocketAddress(0));
+
+        for (int i=0; i<count; i++) {
+            final CountDownLatch latch = new CountDownLatch(1);
+
+            listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
+                public void completed(AsynchronousSocketChannel ch, Void att) {
+                    try {
+                        ch.close();
+                    } catch (IOException ignore) { }
+
+                    latch.countDown();
+
+                    // throw error or runtime exception
+                    if (rand.nextBoolean()) {
+                        throw new Error();
+                    } else {
+                        throw new RuntimeException();
+                    }
+                }
+                public void failed(Throwable exc, Void att) {
+                }
+                public void cancelled(Void att) {
+                }
+            });
+
+            // establish loopback connection which should cause completion
+            // handler to be invoked.
+            int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
+            AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
+            InetAddress lh = InetAddress.getLocalHost();
+            ch.connect(new InetSocketAddress(lh, port)).get();
+            ch.close();
+
+            // wait for handler to be invoked
+            latch.await();
+        }
+
+        // clean-up
+        listener.close();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4607272
+ * @summary Unit test for AsynchronousChannelGroup
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.channels.*;
+import java.net.*;
+import java.util.concurrent.*;
+import java.io.IOException;
+
+public class Unbounded {
+    // number of concurrent completion handlers
+    static final int CONCURRENCY_COUNT = 512;
+
+    public static void main(String[] args) throws Exception {
+        // all accepted connections are added to a queue
+        final ArrayBlockingQueue<AsynchronousSocketChannel> queue =
+            new ArrayBlockingQueue<AsynchronousSocketChannel>(CONCURRENCY_COUNT);
+
+        // create listener to accept connections
+        final AsynchronousServerSocketChannel listener =
+            AsynchronousServerSocketChannel.open()
+                .bind(new InetSocketAddress(0));
+        listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
+            public void completed(AsynchronousSocketChannel ch, Void att) {
+                queue.add(ch);
+                listener.accept(null, this);
+            }
+            public void failed(Throwable exc, Void att) {
+            }
+            public void cancelled(Void att) {
+            }
+        });
+        System.out.println("Listener created.");
+
+        // establish lots of connections
+        int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
+        SocketAddress sa = new InetSocketAddress(InetAddress.getLocalHost(), port);
+        AsynchronousSocketChannel[] channels =
+            new AsynchronousSocketChannel[CONCURRENCY_COUNT];
+        for (int i=0; i<CONCURRENCY_COUNT; i++) {
+            int attempts = 0;
+            for (;;) {
+                try {
+                    channels[i] = AsynchronousSocketChannel.open();
+                    channels[i].connect(sa).get();
+                    break;
+                } catch (IOException x) {
+                    // probably resource issue so back off and retry
+                    if (++attempts >= 3)
+                        throw x;
+                    Thread.sleep(50);
+                }
+            }
+        }
+        System.out.println("All connection established.");
+
+        // the barrier where all threads (plus the main thread) wait
+        final CyclicBarrier barrier = new CyclicBarrier(CONCURRENCY_COUNT+1);
+
+        // initiate a read operation on each channel.
+        for (int i=0; i<CONCURRENCY_COUNT; i++) {
+            ByteBuffer buf = ByteBuffer.allocateDirect(100);
+            channels[i].read( buf, channels[i],
+                new CompletionHandler<Integer,AsynchronousSocketChannel>() {
+                    public void completed(Integer bytesRead, AsynchronousSocketChannel ch) {
+                        try {
+                            ch.close();
+                            barrier.await();
+                        } catch (Exception x) {
+                            throw new AssertionError(x);
+                        }
+                    }
+                    public void failed(Throwable exc, AsynchronousSocketChannel ch) {
+                    }
+                    public void cancelled(AsynchronousSocketChannel ch) {
+                    }
+                });
+        }
+        System.out.println("All read operations outstanding.");
+
+        // write data to each of the accepted connections
+        int remaining = CONCURRENCY_COUNT;
+        while (remaining > 0) {
+            AsynchronousSocketChannel ch = queue.take();
+            ch.write(ByteBuffer.wrap("welcome".getBytes())).get();
+            ch.close();
+            remaining--;
+        }
+
+        // wait for all threads to reach the barrier
+        System.out.println("Waiting for all threads to reach barrier");
+        barrier.await();
+        listener.close();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,52 @@
+#
+# 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.
+#
+# 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.
+#
+
+# @test
+# @bug 4607272
+# @summary Unit test for AsynchronousChannelGrou#execute
+# @build AsExecutor PrivilegedThreadFactory Attack
+# @run shell run_any_task.sh
+
+# if TESTJAVA isn't set then we assume an interactive run.
+
+if [ -z "$TESTJAVA" ]; then
+    TESTSRC=.
+    TESTCLASSES=.
+    JAVA=java
+    JAR=jar
+else
+    JAVA="${TESTJAVA}/bin/java"
+    JAR="${TESTJAVA}/bin/jar"
+fi
+
+echo "Creating JAR file ..."
+$JAR -cf "${TESTCLASSES}/Privileged.jar" \
+    -C "${TESTCLASSES}" PrivilegedThreadFactory.class \
+    -C "${TESTCLASSES}" PrivilegedThreadFactory\$1.class \
+    -C "${TESTCLASSES}" Attack.class
+
+echo "Running test ..."
+$JAVA -XX:-UseVMInterruptibleIO \
+    -Xbootclasspath/a:"${TESTCLASSES}/Privileged.jar" \
+    -classpath "${TESTCLASSES}" \
+    AsExecutor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousDatagramChannel/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,377 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4527345
+ * @summary Unit test for AsynchronousDatagramChannel
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.channels.*;
+import java.net.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+public class Basic {
+
+    public static void main(String[] args) throws Exception {
+        doReceiveTests();
+        doReadTests();
+        doSendTests();
+        doWriteTests();
+        doMulticastTests();
+    }
+
+    // basic receive tests
+    static void doReceiveTests() throws Exception {
+        final byte[] msg = "hello".getBytes();
+
+        AsynchronousDatagramChannel ch = AsynchronousDatagramChannel.open()
+            .bind(new InetSocketAddress(0));
+        int port = ((InetSocketAddress)(ch.getLocalAddress())).getPort();
+        InetAddress rh = InetAddress.getLocalHost();
+        final SocketAddress sa = new InetSocketAddress(rh, port);
+
+        DatagramChannel sender = DatagramChannel.open();
+        ByteBuffer dst = ByteBuffer.allocateDirect(100);
+
+        // Test: datagram packet received immediately
+        sender.send(ByteBuffer.wrap(msg), sa);
+        dst.clear();
+        ch.receive(dst).get(1, TimeUnit.SECONDS);
+        if (dst.flip().remaining() != msg.length)
+            throw new RuntimeException("Unexpected number of bytes read");
+
+        // Test: datagram packet not received immediately
+        dst.clear();
+        final CountDownLatch latch = new CountDownLatch(1);
+        ch.receive(dst, null, new CompletionHandler<SocketAddress,Void>() {
+            public void completed(SocketAddress source, Void att) {
+                latch.countDown();
+            }
+            public void failed (Throwable exc, Void att) {
+            }
+            public void cancelled(Void att) {
+            }
+        });
+        Thread.sleep(2000);
+        sender.send(ByteBuffer.wrap(msg), sa);
+        latch.await(2, TimeUnit.SECONDS);  // wait for completion handler
+
+        // Test: timeout
+        dst.clear();
+        final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
+        ch.receive(dst, 2, TimeUnit.SECONDS, null, new CompletionHandler<SocketAddress,Void>() {
+            public void completed(SocketAddress source, Void att) {
+            }
+            public void failed (Throwable exc, Void att) {
+                exception.set(exc);
+            }
+            public void cancelled(Void att) {
+            }
+        });
+        Throwable result;
+        while ((result = exception.get()) == null) {
+            Thread.sleep(100);
+        }
+        if (!(result instanceof InterruptedByTimeoutException))
+            throw new RuntimeException("InterruptedByTimeoutException expected");
+
+        // AsynchronousCloseException
+        dst = ByteBuffer.allocateDirect(100);
+        exception.set(null);
+        ch.receive(dst, null, new CompletionHandler<SocketAddress,Void>() {
+            public void completed(SocketAddress source, Void att) {
+            }
+            public void failed (Throwable exc, Void att) {
+                exception.set(exc);
+            }
+            public void cancelled(Void att) {
+            }
+        });
+        ch.close();
+        while ((result = exception.get()) == null) {
+            Thread.sleep(100);
+        }
+        if (!(result instanceof AsynchronousCloseException))
+            throw new RuntimeException("AsynchronousCloseException expected");
+
+        // done
+        sender.close();
+    }
+
+    // basic read tests
+    static void doReadTests() throws Exception {
+        final byte[] msg = "hello".getBytes();
+
+        AsynchronousDatagramChannel ch = AsynchronousDatagramChannel.open()
+            .bind(new InetSocketAddress(0));
+        int port = ((InetSocketAddress)(ch.getLocalAddress())).getPort();
+        InetAddress lh = InetAddress.getLocalHost();
+        final SocketAddress sa = new InetSocketAddress(lh, port);
+
+        DatagramChannel sender = DatagramChannel.open();
+        ByteBuffer dst = ByteBuffer.allocateDirect(100);
+
+        // Test: not connected
+        try {
+            ch.read(dst);
+            throw new RuntimeException("NotYetConnectedException expected");
+        } catch (NotYetConnectedException e) {
+        }
+
+        // connect the channel
+        sender.bind(new InetSocketAddress(0));
+        ch.connect(new InetSocketAddress(lh,
+                ((InetSocketAddress)(sender.getLocalAddress())).getPort()));
+
+        // Test: datagram packet received immediately
+        sender.send(ByteBuffer.wrap(msg), sa);
+        dst.clear();
+        ch.read(dst).get(1, TimeUnit.SECONDS);
+        if (dst.flip().remaining() != msg.length)
+            throw new RuntimeException("Unexpected number of bytes read");
+
+        // Test: datagram packet not received immediately
+        dst.clear();
+        final CountDownLatch l1 = new CountDownLatch(1);
+        ch.read(dst, null, new CompletionHandler<Integer,Void>() {
+            public void completed(Integer bytesRead, Void att) {
+                l1.countDown();
+            }
+            public void failed (Throwable exc, Void att) {
+            }
+            public void cancelled(Void att) {
+            }
+        });
+        Thread.sleep(2000);
+        sender.send(ByteBuffer.wrap(msg), sa);
+        l1.await(2, TimeUnit.SECONDS);
+
+        // Test: timeout
+        dst.clear();
+        final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
+        ch.read(dst, 2, TimeUnit.SECONDS, null, new CompletionHandler<Integer,Void>() {
+            public void completed(Integer bytesRead, Void att) {
+            }
+            public void failed (Throwable exc, Void att) {
+                exception.set(exc);
+            }
+            public void cancelled(Void att) {
+            }
+        });
+        Throwable result;
+        while ((result = exception.get()) == null) {
+            Thread.sleep(100);
+        }
+        if (!(result instanceof InterruptedByTimeoutException))
+            throw new RuntimeException("InterruptedByTimeoutException expected");
+
+        // AsynchronousCloseException
+        dst.clear();
+        exception.set(null);
+        ch.read(dst, null, new CompletionHandler<Integer,Void>() {
+            public void completed(Integer bytesRead, Void att) {
+            }
+            public void failed (Throwable exc, Void att) {
+                exception.set(exc);
+            }
+            public void cancelled(Void att) {
+            }
+        });
+        ch.close();
+        while ((result = exception.get()) == null) {
+            Thread.sleep(100);
+        }
+        if (!(result instanceof AsynchronousCloseException))
+            throw new RuntimeException("AsynchronousCloseException expected");
+
+        // done
+        sender.close();
+    }
+
+    // basic send tests
+    static void doSendTests() throws Exception {
+        final byte[] msg = "hello".getBytes();
+
+        DatagramChannel reader = DatagramChannel.open()
+            .bind(new InetSocketAddress(0));
+        int port = ((InetSocketAddress)(reader.getLocalAddress())).getPort();
+        InetAddress rh = InetAddress.getLocalHost();
+        SocketAddress sa = new InetSocketAddress(rh, port);
+
+        AsynchronousDatagramChannel ch = AsynchronousDatagramChannel.open();
+
+        // Test: send datagram packet to reader
+        int bytesSent = ch.send(ByteBuffer.wrap(msg), sa).get();
+        if (bytesSent != msg.length)
+            throw new RuntimeException("Unexpected number of bytes sent");
+
+        // check received
+        ByteBuffer dst = ByteBuffer.allocateDirect(100);
+        reader.receive(dst);
+        dst.flip();
+        if (dst.remaining() != msg.length)
+            throw new RuntimeException("Unexpected number of bytes received");
+
+        // Test: send datagram packet to reader and check completion handler
+        // is invoked
+        final CountDownLatch l2 = new CountDownLatch(1);
+        ch.send(ByteBuffer.wrap(msg), sa, null, new CompletionHandler<Integer,Void>() {
+            public void completed(Integer bytesSent, Void att) {
+                if (bytesSent != msg.length)
+                    throw new RuntimeException("Unexpected number of bytes received");
+                l2.countDown();
+            }
+            public void failed (Throwable exc, Void att) {
+            }
+            public void cancelled(Void att) {
+            }
+        });
+        l2.await(5, TimeUnit.SECONDS);
+
+        // check received
+        dst.clear();
+        reader.receive(dst);
+        dst.flip();
+        if (dst.remaining() != msg.length)
+            throw new RuntimeException("Unexpected number of bytes received");
+
+        // Test: check that failed method is invoked
+        ch.close();
+        final CountDownLatch l3 = new CountDownLatch(1);
+        ch.send(ByteBuffer.wrap(msg), sa, null, new CompletionHandler<Integer,Void>() {
+            public void completed(Integer bytesSent, Void att) {
+                throw new RuntimeException("completed method invoked");
+            }
+            public void failed (Throwable exc, Void att) {
+                if (exc instanceof ClosedChannelException) {
+                    l3.countDown();
+                } else {
+                    throw new RuntimeException(exc);
+                }
+            }
+            public void cancelled(Void att) {
+            }
+        });
+        l3.await(5, TimeUnit.SECONDS);
+
+        // done
+        reader.close();
+    }
+
+    // basic write tests
+    static void doWriteTests() throws Exception {
+        final byte[] msg = "hello".getBytes();
+
+        DatagramChannel reader = DatagramChannel.open()
+            .bind(new InetSocketAddress(0));
+        int port = ((InetSocketAddress)(reader.getLocalAddress())).getPort();
+        InetAddress rh = InetAddress.getLocalHost();
+        SocketAddress sa = new InetSocketAddress(rh, port);
+
+        AsynchronousDatagramChannel ch = AsynchronousDatagramChannel.open();
+
+        // Test: unconnected
+        try {
+            ch.write(ByteBuffer.wrap(msg)).get();
+            throw new RuntimeException("NotYetConnectedException expected");
+        } catch (NotYetConnectedException e) {
+        }
+
+        // Test: connect, and write datagram
+        ch.connect(sa);
+        int bytesSent = ch.write(ByteBuffer.wrap(msg)).get();
+        if (bytesSent != msg.length)
+            throw new RuntimeException("Unexpected number of bytes sent");
+
+        // check received
+        ByteBuffer dst = ByteBuffer.allocateDirect(100);
+        reader.receive(dst);
+        dst.flip();
+        if (dst.remaining() != msg.length)
+            throw new RuntimeException("Unexpected number of bytes received");
+
+        // Test: write datagram and check completion handler is invoked
+        final CountDownLatch l2 = new CountDownLatch(1);
+        ch.write(ByteBuffer.wrap(msg), null, new CompletionHandler<Integer,Void>() {
+            public void completed(Integer bytesSent, Void att) {
+                if (bytesSent != msg.length)
+                    throw new RuntimeException("Unexpected number of bytes received");
+                l2.countDown();
+            }
+            public void failed (Throwable exc, Void att) {
+            }
+            public void cancelled(Void att) {
+            }
+        });
+        l2.await(5, TimeUnit.SECONDS);
+
+        // check received
+        dst.clear();
+        reader.receive(dst);
+        dst.flip();
+        if (dst.remaining() != msg.length)
+            throw new RuntimeException("Unexpected number of bytes received");
+
+        // done
+        ch.close();
+        reader.close();
+    }
+
+    // basic multicast test
+    static void doMulticastTests() throws Exception {
+        final byte[] msg = "hello".getBytes();
+
+        AsynchronousDatagramChannel ch = AsynchronousDatagramChannel
+            .open(StandardProtocolFamily.INET, null)
+            .setOption(StandardSocketOption.SO_REUSEADDR, true)
+            .bind(new InetSocketAddress(0));
+
+        InetAddress lh = InetAddress.getLocalHost();
+        int port = ((InetSocketAddress)(ch.getLocalAddress())).getPort();
+
+        // join group
+        InetAddress group = InetAddress.getByName("225.4.5.6");
+        NetworkInterface interf = NetworkInterface.getByInetAddress(lh);
+        MembershipKey key = ch.join(group, interf);
+
+        // check key
+        if (key.channel() != ch)
+            throw new RuntimeException("Not the expected channel");
+
+        // send message to group
+        DatagramChannel sender = DatagramChannel.open();
+        sender.send(ByteBuffer.wrap(msg), new InetSocketAddress(group, port));
+        sender.close();
+
+        // check message received
+        ByteBuffer dst = ByteBuffer.allocate(200);
+        SocketAddress source = ch.receive(dst).get(2, TimeUnit.SECONDS);
+        if (!((InetSocketAddress)source).getAddress().equals(lh))
+            throw new RuntimeException("Unexpected source");
+
+        // done
+        ch.close();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,585 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4607272
+ * @summary Unit test for AsynchronousFileChannel
+ */
+
+import java.nio.file.*;
+import java.nio.channels.*;
+import java.nio.ByteBuffer;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.AtomicReference;
+import static java.nio.file.StandardOpenOption.*;
+
+public class Basic {
+
+    private static final Random rand = new Random();
+
+    public static void main(String[] args) throws IOException {
+        // create temporary file
+        File blah = File.createTempFile("blah", null);
+        blah.deleteOnExit();
+
+        final AsynchronousFileChannel ch = AsynchronousFileChannel
+            .open(blah.toPath(), READ, WRITE);
+
+        // run tests
+        testUsingCompletionHandlers(ch);
+        testUsingWaitOnResult(ch);
+        testLocking(ch);
+        testInterruptHandlerThread(ch);
+
+        // close channel and invoke test that expects channel to be closed
+        ch.close();
+        testClosedChannel(ch);
+
+        // these tests open the file themselves
+        testCustomThreadPool(blah.toPath());
+        testAsynchronousClose(blah.toPath());
+        testCancel(blah.toPath());
+        testTruncate(blah.toPath());
+    }
+
+    /*
+     * Generate buffer with random contents
+     * Writes buffer to file using a CompletionHandler to consume the result
+     *    of each write operation
+     * Reads file to EOF to a new buffer using a CompletionHandler to consume
+     *    the result of each read operation
+     * Compares buffer contents
+     */
+    static void testUsingCompletionHandlers(AsynchronousFileChannel ch)
+        throws IOException
+    {
+        System.out.println("testUsingCompletionHandlers");
+
+        ch.truncate(0L);
+
+        // generate buffer with random elements and write it to file
+        ByteBuffer src = genBuffer();
+        writeFully(ch, src, 0L);
+
+        // read to EOF or buffer is full
+        ByteBuffer dst = (rand.nextBoolean()) ?
+            ByteBuffer.allocateDirect(src.capacity()) :
+            ByteBuffer.allocate(src.capacity());
+        readAll(ch, dst, 0L);
+
+        // check buffers are the same
+        src.flip();
+        dst.flip();
+        if (!src.equals(dst)) {
+            throw new RuntimeException("Contents differ");
+        }
+    }
+
+    /*
+     * Generate buffer with random contents
+     * Writes buffer to file, invoking the Future's get method to wait for
+     *    each write operation to complete
+     * Reads file to EOF to a new buffer, invoking the Future's get method to
+     *    wait for each write operation to complete
+     * Compares buffer contents
+     */
+    static void testUsingWaitOnResult(AsynchronousFileChannel ch)
+        throws IOException
+    {
+        System.out.println("testUsingWaitOnResult");
+
+        ch.truncate(0L);
+
+        // generate buffer
+        ByteBuffer src = genBuffer();
+
+        // write buffer completely to file
+        long position = 0L;
+        while (src.hasRemaining()) {
+            Future<Integer> result = ch.write(src, position);
+            try {
+                int n = result.get();
+                // update position
+                position += n;
+            } catch (ExecutionException x) {
+                throw new RuntimeException(x.getCause());
+            } catch (InterruptedException x) {
+                throw new RuntimeException(x);
+            }
+        }
+
+        // read file into new buffer
+        ByteBuffer dst = (rand.nextBoolean()) ?
+            ByteBuffer.allocateDirect(src.capacity()) :
+            ByteBuffer.allocate(src.capacity());
+        position = 0L;
+        int n;
+        do {
+            Future<Integer> result = ch.read(dst, position);
+            try {
+                n = result.get();
+
+                // update position
+                if (n > 0) position += n;
+            } catch (ExecutionException x) {
+                throw new RuntimeException(x.getCause());
+            } catch (InterruptedException x) {
+                throw new RuntimeException(x);
+            }
+        } while (n > 0);
+
+        // check buffers are the same
+        src.flip();
+        dst.flip();
+        if (!src.equals(dst)) {
+            throw new RuntimeException("Contents differ");
+        }
+    }
+
+    // exercise lock methods
+    static void testLocking(AsynchronousFileChannel ch)
+        throws IOException
+    {
+        System.out.println("testLocking");
+
+        // test 1 - acquire lock and check that tryLock throws
+        // OverlappingFileLockException
+        FileLock fl;
+        try {
+            fl = ch.lock().get();
+        } catch (ExecutionException x) {
+            throw new RuntimeException(x);
+        } catch (InterruptedException x) {
+            throw new RuntimeException("Should not be interrupted");
+        }
+        if (!fl.acquiredBy().equals(ch))
+            throw new RuntimeException("FileLock#acquiredBy returned incorrect channel");
+        try {
+            ch.tryLock();
+            throw new RuntimeException("OverlappingFileLockException expected");
+        } catch (OverlappingFileLockException x) {
+        }
+        fl.release();
+
+        // test 2 - acquire try and check that lock throws OverlappingFileLockException
+        fl = ch.tryLock();
+        if (fl == null)
+            throw new RuntimeException("Unable to acquire lock");
+        try {
+            ch.lock(null, new CompletionHandler<FileLock,Void> () {
+                public void completed(FileLock result, Void att) {
+                }
+                public void failed(Throwable exc, Void att) {
+                }
+                public void cancelled(Void att) {
+                }
+            });
+            throw new RuntimeException("OverlappingFileLockException expected");
+        } catch (OverlappingFileLockException x) {
+        }
+        fl.release();
+    }
+
+    // interrupt should not close channel
+    static void testInterruptHandlerThread(final AsynchronousFileChannel ch) {
+        System.out.println("testInterruptHandlerThread");
+
+        ByteBuffer buf = ByteBuffer.allocateDirect(100);
+        final CountDownLatch latch = new CountDownLatch(1);
+
+        ch.read(buf, 0L, null, new CompletionHandler<Integer,Void>() {
+            public void completed(Integer result, Void att) {
+                try {
+                    Thread.currentThread().interrupt();
+                    long size = ch.size();
+                    latch.countDown();
+                } catch (IOException x) {
+                    x.printStackTrace();
+                }
+            }
+            public void failed(Throwable exc, Void att) {
+            }
+            public void cancelled(Void att) {
+            }
+        });
+
+        // wait for handler to complete
+        await(latch);
+    }
+
+    // invoke method on closed channel
+    static void testClosedChannel(AsynchronousFileChannel ch) {
+        System.out.println("testClosedChannel");
+
+        if (ch.isOpen())
+            throw new RuntimeException("Channel should be closed");
+
+        ByteBuffer buf = ByteBuffer.allocateDirect(100);
+
+        // check read fails with ClosedChannelException
+        try {
+            ch.read(buf, 0L).get();
+            throw new RuntimeException("ExecutionException expected");
+        } catch (ExecutionException x) {
+            if (!(x.getCause() instanceof ClosedChannelException))
+                throw new RuntimeException("Cause of ClosedChannelException expected");
+        } catch (InterruptedException x) {
+        }
+
+        // check write fails with ClosedChannelException
+        try {
+            ch.write(buf, 0L).get();
+            throw new RuntimeException("ExecutionException expected");
+        } catch (ExecutionException x) {
+            if (!(x.getCause() instanceof ClosedChannelException))
+                throw new RuntimeException("Cause of ClosedChannelException expected");
+        } catch (InterruptedException x) {
+        }
+
+        // check lock fails with ClosedChannelException
+        try {
+            ch.lock().get();
+            throw new RuntimeException("ExecutionException expected");
+        } catch (ExecutionException x) {
+            if (!(x.getCause() instanceof ClosedChannelException))
+                throw new RuntimeException("Cause of ClosedChannelException expected");
+        } catch (InterruptedException x) {
+        }
+    }
+
+
+    // exercise custom thread pool
+    static void testCustomThreadPool(Path file) throws IOException {
+        System.out.println("testCustomThreadPool");
+
+        // records threads that are created
+        final List<Thread> threads = new ArrayList<Thread>();
+
+        ThreadFactory threadFactory = new ThreadFactory() {
+
+             public Thread newThread(Runnable r) {
+                 Thread t = new Thread(r);
+                 t.setDaemon(true);
+                 synchronized (threads) {
+                     threads.add(t);
+                 }
+                 return t;
+             }
+        };
+
+        // exercise tests with varied number of threads
+        for (int nThreads=1; nThreads<=5; nThreads++) {
+            synchronized (threads) {
+                threads.clear();
+            }
+            ExecutorService executor = Executors.newFixedThreadPool(nThreads, threadFactory);
+            Set<StandardOpenOption> opts = EnumSet.of(WRITE);
+            AsynchronousFileChannel ch = AsynchronousFileChannel.open(file, opts, executor);
+            try {
+                for (int i=0; i<10; i++) {
+                    // do I/O operation to see which thread invokes the completion handler
+                    final AtomicReference<Thread> invoker = new AtomicReference<Thread>();
+                    final CountDownLatch latch = new CountDownLatch(1);
+
+                    ch.write(genBuffer(), 0L, null, new CompletionHandler<Integer,Void>() {
+                        public void completed(Integer result, Void att) {
+                            invoker.set(Thread.currentThread());
+                            latch.countDown();
+                        }
+                        public void failed(Throwable exc, Void att) {
+                        }
+                        public void cancelled(Void att) {
+                        }
+                    });
+                    await(latch);
+
+                    // check invoker
+                    boolean found = false;
+                    synchronized (threads) {
+                        for (Thread t: threads) {
+                            if (t == invoker.get()) {
+                                found = true;
+                                break;
+                            }
+                        }
+                    }
+                    if (!found)
+                        throw new RuntimeException("Invoker thread not found");
+                }
+            } finally {
+                ch.close();
+            }
+        }
+    }
+
+    // exercise asynchronous close
+    static void testAsynchronousClose(Path file) throws IOException {
+        System.out.println("testAsynchronousClose");
+
+        // create file
+        AsynchronousFileChannel ch = AsynchronousFileChannel
+            .open(file, WRITE, TRUNCATE_EXISTING);
+        long size = 0L;
+        do {
+            ByteBuffer buf = genBuffer();
+            int n = buf.remaining();
+            writeFully(ch, buf, size);
+            size += n;
+        } while (size < (50L * 1024L * 1024L));
+
+        ch.close();
+
+        ch = AsynchronousFileChannel.open(file, WRITE, SYNC);
+
+        // randomize number of writers, buffer size, and positions
+
+        int nwriters = 1 + rand.nextInt(8);
+        ByteBuffer[] buf = new ByteBuffer[nwriters];
+        long[] position = new long[nwriters];
+        for (int i=0; i<nwriters; i++) {
+            buf[i] = genBuffer();
+            position[i] = rand.nextInt((int)size);
+        }
+
+        // initiate I/O
+        Future[] result = new Future[nwriters];
+        for (int i=0; i<nwriters; i++) {
+            result[i] = ch.write(buf[i], position[i]);
+        }
+
+        // close file
+        ch.close();
+
+        // write operations should complete or fail with AsynchronousCloseException
+        for (int i=0; i<nwriters; i++) {
+            try {
+                result[i].get();
+            } catch (ExecutionException x) {
+                Throwable cause = x.getCause();
+                if (!(cause instanceof AsynchronousCloseException))
+                    throw new RuntimeException(cause);
+            } catch (CancellationException  x) {
+                throw new RuntimeException(x);   // should not happen
+            } catch (InterruptedException x) {
+                throw new RuntimeException(x);   // should not happen
+            }
+        }
+    }
+
+    // exercise cancel method
+    static void testCancel(Path file) throws IOException {
+        System.out.println("testCancel");
+
+        for (int i=0; i<2; i++) {
+            boolean mayInterruptIfRunning = (i == 0) ? false : true;
+
+            // open with SYNC option to improve chances that write will not
+            // complete immediately
+            AsynchronousFileChannel ch = AsynchronousFileChannel
+                .open(file, WRITE, SYNC);
+
+            // start write operation
+            final CountDownLatch latch = new CountDownLatch(1);
+            Future<Integer> res = ch.write(genBuffer(), 0L, null,
+                new CompletionHandler<Integer,Void>() {
+                    public void completed(Integer result, Void att) {
+                    }
+                    public void failed(Throwable exc, Void att) {
+                    }
+                    public void cancelled(Void att) {
+                        latch.countDown();
+                    }
+            });
+
+            // cancel operation
+            boolean cancelled = res.cancel(mayInterruptIfRunning);
+
+            // check post-conditions
+            if (!res.isDone())
+                throw new RuntimeException("isDone should return true");
+            if (res.isCancelled() != cancelled)
+                throw new RuntimeException("isCancelled not consistent");
+            try {
+                res.get();
+                if (!cancelled)
+                    throw new RuntimeException("CancellationException expected");
+            } catch (CancellationException x) {
+                // expected
+            } catch (ExecutionException x) {
+                throw new RuntimeException(x);
+            } catch (InterruptedException x) {
+                throw new RuntimeException(x);
+            }
+            try {
+                res.get(1, TimeUnit.SECONDS);
+                throw new RuntimeException("CancellationException expected");
+            } catch (CancellationException x) {
+                // expected
+            } catch (ExecutionException x) {
+                throw new RuntimeException(x);
+            } catch (TimeoutException x) {
+                throw new RuntimeException(x);
+            } catch (InterruptedException x) {
+                throw new RuntimeException(x);
+            }
+
+            // check that cancelled method is invoked
+            if (cancelled)
+                await(latch);
+
+            ch.close();
+        }
+    }
+
+    // exercise truncate method
+    static void testTruncate(Path file) throws IOException {
+        System.out.println("testTruncate");
+
+        // basic tests
+        AsynchronousFileChannel ch = AsynchronousFileChannel
+            .open(file, CREATE, WRITE, TRUNCATE_EXISTING);
+        try {
+            writeFully(ch, genBuffer(), 0L);
+            long size = ch.size();
+
+            // attempt to truncate to a size greater than the current size
+            if (ch.truncate(size + 1L).size() != size)
+                throw new RuntimeException("Unexpected size after truncation");
+
+            // truncate file
+            if (ch.truncate(size - 1L).size() != (size - 1L))
+                throw new RuntimeException("Unexpected size after truncation");
+
+            // invalid size
+            try {
+                ch.truncate(-1L);
+                throw new RuntimeException("IllegalArgumentException expected");
+            } catch (IllegalArgumentException e) { }
+
+        } finally {
+            ch.close();
+        }
+
+        // channel is closed
+        try {
+            ch.truncate(0L);
+            throw new RuntimeException("ClosedChannelException expected");
+        } catch (ClosedChannelException  e) { }
+
+        // channel is read-only
+        ch = AsynchronousFileChannel.open(file, READ);
+        try {
+            try {
+            ch.truncate(0L);
+                throw new RuntimeException("NonWritableChannelException expected");
+            } catch (NonWritableChannelException  e) { }
+        } finally {
+            ch.close();
+        }
+    }
+
+    // returns ByteBuffer with random bytes
+    static ByteBuffer genBuffer() {
+        int size = 1024 + rand.nextInt(16000);
+        byte[] buf = new byte[size];
+        boolean useDirect = rand.nextBoolean();
+        if (useDirect) {
+            ByteBuffer bb = ByteBuffer.allocateDirect(buf.length);
+            bb.put(buf);
+            bb.flip();
+            return bb;
+        } else {
+            return ByteBuffer.wrap(buf);
+        }
+    }
+
+    // writes all remaining bytes in the buffer to the given channel at the
+    // given position
+    static void writeFully(final AsynchronousFileChannel ch,
+                           final ByteBuffer src,
+                           long position)
+    {
+        final CountDownLatch latch = new CountDownLatch(1);
+
+        // use position as attachment
+        ch.write(src, position, position, new CompletionHandler<Integer,Long>() {
+            public void completed(Integer result, Long position) {
+                int n = result;
+                if (src.hasRemaining()) {
+                    long p = position + n;
+                    ch.write(src, p, p, this);
+                } else {
+                    latch.countDown();
+                }
+            }
+            public void failed(Throwable exc, Long position) {
+            }
+            public void cancelled(Long position) {
+            }
+        });
+
+        // wait for writes to complete
+        await(latch);
+    }
+
+    static void readAll(final AsynchronousFileChannel ch,
+                        final ByteBuffer dst,
+                       long position)
+    {
+        final CountDownLatch latch = new CountDownLatch(1);
+
+        // use position as attachment
+        ch.read(dst, position, position, new CompletionHandler<Integer,Long>() {
+            public void completed(Integer result, Long position) {
+                int n = result;
+                if (n > 0) {
+                    long p = position + n;
+                    ch.read(dst, p, p, this);
+                } else {
+                    latch.countDown();
+                }
+            }
+            public void failed(Throwable exc, Long position) {
+            }
+            public void cancelled(Long position) {
+            }
+        });
+
+        // wait for reads to complete
+        await(latch);
+    }
+
+    static void await(CountDownLatch latch) {
+        // wait until done
+        boolean done = false;
+        while (!done) {
+            try {
+                latch.await();
+                done = true;
+            } catch (InterruptedException x) { }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/CustomThreadPool.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4607272
+ * @summary Unit test for java.nio.channels.AsynchronousFileChannel
+ * @build CustomThreadPool MyThreadFactory
+ * @run main/othervm -Djava.nio.channels.DefaultThreadPool.threadFactory=MyThreadFactory CustomThreadPool
+ */
+
+import java.io.File;
+import static java.nio.file.StandardOpenOption.*;
+import java.nio.ByteBuffer;
+import java.nio.channels.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class CustomThreadPool {
+
+    public static void main(String[] args) throws Exception {
+        File blah = File.createTempFile("blah", null);
+        blah.deleteOnExit();
+        AsynchronousFileChannel ch =
+            AsynchronousFileChannel.open(blah.toPath(), READ, WRITE);
+        ByteBuffer src = ByteBuffer.wrap("Scooby Snacks".getBytes());
+
+        final AtomicReference<Thread> invoker = new AtomicReference<Thread>();
+        ch.write(src, 0, invoker,
+            new CompletionHandler<Integer,AtomicReference<Thread>>() {
+                public void completed(Integer result, AtomicReference<Thread> invoker) {
+                    invoker.set(Thread.currentThread());
+                }
+                public void failed(Throwable exc, AtomicReference<Thread> invoker) {
+                }
+                public void cancelled(AtomicReference<Thread> invoker) {
+                }
+            });
+        Thread t;
+        while ((t = invoker.get()) == null) {
+            Thread.sleep(100);
+        }
+        ch.close();
+
+        // check handler was run by known thread
+        if (!MyThreadFactory.created(t))
+            throw new RuntimeException("Handler invoked by unknown thread");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/Lock.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,340 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+
+/* @test
+ * @bug 4607272
+ * @summary Unit test for AsynchronousFileChannel#lock method
+ */
+
+import java.net.*;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.nio.file.*;
+import static java.nio.file.StandardOpenOption.*;
+import java.nio.channels.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Random;
+import java.util.concurrent.*;
+
+public class Lock {
+
+    static final Random rand = new Random();
+
+    public static void main(String[] args) throws Exception {
+        if (args.length > 0 && args[0].equals("-lockslave")) {
+            int port = Integer.parseInt(args[1]);
+            runLockSlave(port);
+            System.exit(0);
+        }
+
+        LockSlaveMirror slave = startLockSlave();
+        try {
+
+             // create temporary file
+            File blah = File.createTempFile("blah", null);
+            blah.deleteOnExit();
+
+            testLockProtocol(blah, slave);
+            testAsyncClose(blah, slave);
+
+        } finally {
+            slave.shutdown();
+        }
+    }
+
+    // test locking protocol
+    static void testLockProtocol(File file, LockSlaveMirror slave)
+        throws Exception
+    {
+        FileLock fl;
+
+        // slave VM opens file and acquires exclusive lock
+        slave.open(file.getPath()).lock();
+
+        AsynchronousFileChannel ch = AsynchronousFileChannel
+            .open(file.toPath(), READ, WRITE);
+
+        // this VM tries to acquire lock
+        // (lock should not be acquire until released by slave VM)
+        Future<FileLock> result = ch.lock();
+        try {
+            result.get(2, TimeUnit.SECONDS);
+            throw new RuntimeException("Timeout expected");
+        } catch (TimeoutException x) {
+        }
+
+        // slave VM releases lock
+        slave.unlock();
+
+        // this VM should now acquire lock
+        fl = result.get();
+        fl.release();
+
+        // slave VM acquires lock on range
+        slave.lock(0, 10, false);
+
+        // this VM acquires lock on non-overlapping range
+        fl = ch.lock(10, 10, false, null, null).get();
+        fl.release();
+
+        // done
+        ch.close();
+        slave.close();
+    }
+
+    // test close of channel with outstanding lock operation
+    static void testAsyncClose(File file, LockSlaveMirror slave) throws Exception {
+        // slave VM opens file and acquires exclusive lock
+        slave.open(file.getPath()).lock();
+
+        for (int i=0; i<100; i++) {
+            AsynchronousFileChannel ch = AsynchronousFileChannel
+                .open(file.toPath(), READ, WRITE);
+
+            // try to lock file (should not complete because file is locked by slave)
+            Future<FileLock> result = ch.lock();
+            try {
+                result.get(rand.nextInt(100), TimeUnit.MILLISECONDS);
+                throw new RuntimeException("Timeout expected");
+            } catch (TimeoutException x) {
+            }
+
+            // close channel with lock operation outstanding
+            ch.close();
+
+            // operation should complete with AsynchronousCloseException
+            try {
+                result.get();
+                throw new RuntimeException("ExecutionException expected");
+            } catch (ExecutionException x) {
+                if (!(x.getCause() instanceof AsynchronousCloseException)) {
+                    x.getCause().printStackTrace();
+                    throw new RuntimeException("AsynchronousCloseException expected");
+                }
+            }
+        }
+
+        slave.close();
+    }
+
+    // starts a "lock slave" in another process, returning a mirror object to
+    // control the slave
+    static LockSlaveMirror startLockSlave() throws Exception {
+        ServerSocketChannel ssc = ServerSocketChannel.open()
+            .bind(new InetSocketAddress(0));
+        int port = ((InetSocketAddress)(ssc.getLocalAddress())).getPort();
+
+        String sep = FileSystems.getDefault().getSeparator();
+
+        String command = System.getProperty("java.home") +
+            sep + "bin" + sep + "java Lock -lockslave " + port;
+        Process p = Runtime.getRuntime().exec(command);
+        IOHandler.handle(p.getInputStream());
+        IOHandler.handle(p.getErrorStream());
+
+        // wait for slave to connect
+        SocketChannel sc = ssc.accept();
+        return new LockSlaveMirror(sc);
+    }
+
+    // commands that the slave understands
+    static final String OPEN_CMD    = "open";
+    static final String CLOSE_CMD   = "close";
+    static final String LOCK_CMD    = "lock";
+    static final String UNLOCK_CMD  = "unlock";
+    static final char TERMINATOR    = ';';
+
+    // provides a proxy to a "lock slave"
+    static class LockSlaveMirror {
+        private final SocketChannel sc;
+
+        LockSlaveMirror(SocketChannel sc) {
+            this.sc = sc;
+        }
+
+        private void sendCommand(String cmd, String... params)
+            throws IOException
+        {
+            for (String s: params) {
+                cmd += " " + s;
+            }
+            cmd += TERMINATOR;
+
+            ByteBuffer buf = Charset.defaultCharset().encode(cmd);
+            while (buf.hasRemaining()) {
+                sc.write(buf);
+            }
+
+            // wait for ack
+            buf = ByteBuffer.allocate(1);
+            int n = sc.read(buf);
+            if (n != 1)
+                throw new RuntimeException("Reply expected");
+            if (buf.get(0) != TERMINATOR)
+                throw new RuntimeException("Terminated expected");
+        }
+
+        LockSlaveMirror open(String file) throws IOException {
+            sendCommand(OPEN_CMD, file);
+            return this;
+        }
+
+        void close() throws IOException {
+            sendCommand(CLOSE_CMD);
+        }
+
+        LockSlaveMirror lock() throws IOException {
+            sendCommand(LOCK_CMD);
+            return this;
+        }
+
+
+        LockSlaveMirror lock(long position, long size, boolean shared)
+            throws IOException
+        {
+            sendCommand(LOCK_CMD, position + "," + size + "," + shared);
+            return this;
+        }
+
+        LockSlaveMirror unlock() throws IOException {
+            sendCommand(UNLOCK_CMD);
+            return this;
+        }
+
+        void shutdown() throws IOException {
+            sc.close();
+        }
+    }
+
+    // Helper class to direct process output to the parent System.out
+    static class IOHandler implements Runnable {
+        private final InputStream in;
+
+        IOHandler(InputStream in) {
+            this.in = in;
+        }
+
+        static void handle(InputStream in) {
+            IOHandler handler = new IOHandler(in);
+            Thread thr = new Thread(handler);
+            thr.setDaemon(true);
+            thr.start();
+        }
+
+        public void run() {
+            try {
+                byte b[] = new byte[100];
+                for (;;) {
+                    int n = in.read(b);
+                    if (n < 0) return;
+                    for (int i=0; i<n; i++) {
+                        System.out.print((char)b[i]);
+                    }
+                }
+            } catch (IOException ioe) { }
+        }
+    }
+
+    // slave process that responds to simple commands a socket connection
+    static void runLockSlave(int port) throws Exception {
+
+        // establish connection to parent
+        SocketChannel sc = SocketChannel.open(new InetSocketAddress(port));
+        ByteBuffer buf = ByteBuffer.allocateDirect(1024);
+
+        FileChannel fc = null;
+        FileLock fl = null;
+        try {
+            for (;;) {
+
+                // read command (ends with ";")
+                buf.clear();
+                int n, last = 0;
+                do {
+                    n = sc.read(buf);
+                    if (n < 0)
+                        return;
+                    if (n == 0)
+                        throw new AssertionError();
+                    last += n;
+                } while (buf.get(last-1) != TERMINATOR);
+
+                // decode into command and optional parameter
+                buf.flip();
+                String s = Charset.defaultCharset().decode(buf).toString();
+                int sp = s.indexOf(" ");
+                String cmd = (sp < 0) ? s.substring(0, s.length()-1) :
+                    s.substring(0, sp);
+                String param = (sp < 0) ? "" : s.substring(sp+1, s.length()-1);
+
+                // execute
+                if (cmd.equals(OPEN_CMD)) {
+                    if (fc != null)
+                        throw new RuntimeException("File already open");
+                    fc = FileChannel.open(Paths.get(param),READ, WRITE);
+                }
+                if (cmd.equals(CLOSE_CMD)) {
+                    if (fc == null)
+                        throw new RuntimeException("No file open");
+                    fc.close();
+                    fc = null;
+                    fl = null;
+                }
+                if (cmd.equals(LOCK_CMD)) {
+                    if (fl != null)
+                        throw new RuntimeException("Already holding lock");
+
+                    if (param.length() == 0) {
+                        fl = fc.lock();
+                    } else {
+                        String[] values = param.split(",");
+                        if (values.length != 3)
+                            throw new RuntimeException("Lock parameter invalid");
+                        long position = Long.parseLong(values[0]);
+                        long size = Long.parseLong(values[1]);
+                        boolean shared = Boolean.parseBoolean(values[2]);
+                        fl = fc.lock(position, size, shared);
+                    }
+                }
+
+                if (cmd.equals(UNLOCK_CMD)) {
+                    if (fl == null)
+                        throw new RuntimeException("Not holding lock");
+                    fl.release();
+                    fl = null;
+                }
+
+                // send reply
+                byte[] reply = { TERMINATOR };
+                n = sc.write(ByteBuffer.wrap(reply));
+            }
+
+        } finally {
+            sc.close();
+            if (fc != null) fc.close();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousFileChannel/MyThreadFactory.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.util.concurrent.ThreadFactory;
+import java.util.*;
+
+public class MyThreadFactory implements ThreadFactory {
+
+    private static final Set<Thread> threads = new HashSet<Thread>();
+
+    static boolean created(Thread t) {
+        synchronized (threads) {
+            return threads.contains(t);
+        }
+    }
+
+    public MyThreadFactory() {
+    }
+
+
+    public Thread newThread(Runnable r) {
+        Thread t = new Thread(r);
+        t.setDaemon(true);
+        synchronized (threads) {
+            threads.add(t);
+        }
+        return t;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,136 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4607272
+ * @summary Unit test for AsynchronousServerSocketChannel
+ * @run main/timeout=180 Basic
+ */
+
+import java.nio.channels.*;
+import java.net.*;
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Basic {
+
+    public static void main(String[] args) throws Exception {
+        testBind();
+        testAccept();
+    }
+
+    static void testBind() throws Exception {
+        System.out.println("-- bind --");
+
+        AsynchronousServerSocketChannel ch = AsynchronousServerSocketChannel.open();
+        if (ch.getLocalAddress() != null)
+            throw new RuntimeException("Local address should be 'null'");
+        ch.bind(new InetSocketAddress(0), 20);
+
+        // check local address after binding
+        InetSocketAddress local = (InetSocketAddress)ch.getLocalAddress();
+        if (local.getPort() == 0)
+            throw new RuntimeException("Unexpected port");
+        if (!local.getAddress().isAnyLocalAddress())
+            throw new RuntimeException("Not bound to a wildcard address");
+
+        // try to re-bind
+        try {
+            ch.bind(new InetSocketAddress(0));
+            throw new RuntimeException("AlreadyBoundException expected");
+        } catch (AlreadyBoundException x) {
+        }
+        ch.close();
+
+        // check ClosedChannelException
+        ch = AsynchronousServerSocketChannel.open();
+        ch.close();
+        try {
+            ch.bind(new InetSocketAddress(0));
+            throw new RuntimeException("ClosedChannelException  expected");
+        } catch (ClosedChannelException  x) {
+        }
+    }
+
+    static void testAccept() throws Exception {
+        System.out.println("-- accept --");
+
+        final AsynchronousServerSocketChannel listener =
+            AsynchronousServerSocketChannel.open().bind(new InetSocketAddress(0));
+
+        InetAddress lh = InetAddress.getLocalHost();
+        int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
+        final InetSocketAddress isa = new InetSocketAddress(lh, port);
+
+        // establish a few loopback connections
+        for (int i=0; i<100; i++) {
+            SocketChannel sc = SocketChannel.open(isa);
+            AsynchronousSocketChannel ch = listener.accept().get();
+            sc.close();
+            ch.close();
+        }
+
+       final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
+
+        // start accepting
+        listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
+            public void completed(AsynchronousSocketChannel ch, Void att) {
+                try {
+                    ch.close();
+                } catch (IOException ignore) { }
+            }
+            public void failed(Throwable exc, Void att) {
+                exception.set(exc);
+            }
+            public void cancelled(Void att) {
+            }
+        });
+
+        // check AcceptPendingException
+        try {
+            listener.accept();
+            throw new RuntimeException("AcceptPendingException expected");
+        } catch (AcceptPendingException x) {
+        }
+
+        // asynchronous close
+        listener.close();
+        while (exception.get() == null)
+            Thread.sleep(100);
+        if (!(exception.get() instanceof AsynchronousCloseException))
+            throw new RuntimeException("AsynchronousCloseException expected");
+
+        // once closed when a further attemt should throw ClosedChannelException
+        try {
+            listener.accept().get();
+            throw new RuntimeException("ExecutionException expected");
+        } catch (ExecutionException x) {
+            if (!(x.getCause() instanceof ClosedChannelException))
+                throw new RuntimeException("Cause of ClosedChannelException expected");
+        } catch (InterruptedException x) {
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,76 @@
+/*
+ * Copyright 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4607272
+ * @summary Unit test for AsynchronousServerServerSocketChannel
+ * @build WithSecurityManager
+ * @run main/othervm WithSecurityManager allow
+ * @run main/othervm WithSecurityManager deny
+ */
+
+import java.nio.file.Paths;
+import java.nio.channels.*;
+import java.net.*;
+import java.util.concurrent.*;
+
+public class WithSecurityManager {
+    public static void main(String[] args) throws Exception {
+        boolean allow = false;
+        String policy = (args[0].equals("allow")) ? "java.policy.allow" :
+            "java.policy.deny";
+
+        String testSrc = System.getProperty("test.src");
+        if (testSrc == null)
+            testSrc = ".";
+
+        System.setProperty("java.security.policy",
+            Paths.get(testSrc).resolve(policy).toString());
+        System.setSecurityManager(new SecurityManager());
+
+        AsynchronousServerSocketChannel listener =
+            AsynchronousServerSocketChannel.open().bind(new InetSocketAddress(0));
+
+        InetAddress lh = InetAddress.getLocalHost();
+        int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
+
+        // establish and accept connection
+        SocketChannel sc = SocketChannel.open(new InetSocketAddress(lh, port));
+        Future<AsynchronousSocketChannel> result = listener.accept();
+
+        if (allow) {
+            // no security exception
+            result.get().close();
+        } else {
+            try {
+                result.get();
+            } catch (ExecutionException x) {
+                if (!(x.getCause() instanceof SecurityException))
+                    throw new RuntimeException("SecurityException expected");
+            }
+        }
+
+        sc.close();
+        listener.close();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/java.policy.allow	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,3 @@
+grant {
+    permission java.net.SocketPermission "*:1024-", "accept,connect,resolve";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousServerSocketChannel/java.policy.deny	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,3 @@
+grant {
+    permission java.net.SocketPermission "*:1024-", "connect,resolve";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,805 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4607272
+ * @summary Unit test for AsynchronousSocketChannel
+ * @run main/timeout=600 Basic
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.channels.*;
+import static java.net.StandardSocketOption.*;
+import java.net.*;
+import java.util.Random;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+import java.io.IOException;
+
+public class Basic {
+    static final Random rand = new Random();
+
+    public static void main(String[] args) throws Exception {
+        testBind();
+        testSocketOptions();
+        testConnect();
+        testCloseWhenPending();
+        testCancel();
+        testRead1();
+        testRead2();
+        testRead3();
+        testWrite1();
+        testWrite2();
+        testTimeout();
+        testShutdown();
+    }
+
+    static class Server {
+        private final ServerSocketChannel ssc;
+        private final InetSocketAddress address;
+
+        Server() throws IOException {
+            ssc = ServerSocketChannel.open().bind(new InetSocketAddress(0));
+
+            InetAddress lh = InetAddress.getLocalHost();
+            int port = ((InetSocketAddress)(ssc.getLocalAddress())).getPort();
+            address = new InetSocketAddress(lh, port);
+        }
+
+        InetSocketAddress address() {
+            return address;
+        }
+
+        SocketChannel accept() throws IOException {
+            return ssc.accept();
+        }
+
+        void close() {
+            try {
+                ssc.close();
+            } catch (IOException ignore) { }
+        }
+
+    }
+
+    static void testBind() throws Exception {
+        System.out.println("-- bind --");
+
+        AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
+        if (ch.getLocalAddress() != null)
+            throw new RuntimeException("Local address should be 'null'");
+        ch.bind(new InetSocketAddress(0));
+
+        // check local address after binding
+        InetSocketAddress local = (InetSocketAddress)ch.getLocalAddress();
+        if (local.getPort() == 0)
+            throw new RuntimeException("Unexpected port");
+        if (!local.getAddress().isAnyLocalAddress())
+            throw new RuntimeException("Not bound to a wildcard address");
+
+        // try to re-bind
+        try {
+            ch.bind(new InetSocketAddress(0));
+            throw new RuntimeException("AlreadyBoundException expected");
+        } catch (AlreadyBoundException x) {
+        }
+        ch.close();
+
+        // check ClosedChannelException
+        ch = AsynchronousSocketChannel.open();
+        ch.close();
+        try {
+            ch.bind(new InetSocketAddress(0));
+            throw new RuntimeException("ClosedChannelException  expected");
+        } catch (ClosedChannelException  x) {
+        }
+    }
+
+    static void testSocketOptions() throws Exception {
+        System.out.println("-- socket options --");
+
+        AsynchronousSocketChannel ch = AsynchronousSocketChannel.open()
+            .setOption(SO_RCVBUF, 128*1024)
+            .setOption(SO_SNDBUF, 128*1024)
+            .setOption(SO_REUSEADDR, true)
+            .bind(new InetSocketAddress(0));
+
+        // default values
+        if ((Boolean)ch.getOption(SO_KEEPALIVE))
+            throw new RuntimeException("Default of SO_KEEPALIVE should be 'false'");
+        if ((Boolean)ch.getOption(TCP_NODELAY))
+            throw new RuntimeException("Default of TCP_NODELAY should be 'false'");
+
+        // set and check
+        if (!(Boolean)ch.setOption(SO_KEEPALIVE, true).getOption(SO_KEEPALIVE))
+            throw new RuntimeException("SO_KEEPALIVE did not change");
+        if (!(Boolean)ch.setOption(TCP_NODELAY, true).getOption(TCP_NODELAY))
+            throw new RuntimeException("SO_KEEPALIVE did not change");
+
+        // read others (can't check as actual value is implementation dependent)
+        ch.getOption(SO_RCVBUF);
+        ch.getOption(SO_SNDBUF);
+
+        ch.close();
+    }
+
+    static void testConnect() throws Exception {
+        System.out.println("-- connect --");
+
+        Server server = new Server();
+        AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
+        ch.connect(server.address()).get();
+
+        // check local address
+        if (ch.getLocalAddress() == null)
+            throw new RuntimeException("Not bound to local address");
+
+        // check remote address
+        InetSocketAddress remote = (InetSocketAddress)ch.getRemoteAddress();
+        if (remote.getPort() != server.address().getPort())
+            throw new RuntimeException("Connected to unexpected port");
+        if (!remote.getAddress().equals(server.address().getAddress()))
+            throw new RuntimeException("Connected to unexpected address");
+
+        // try to connect again
+        try {
+            ch.connect(server.address()).get();
+            throw new RuntimeException("AlreadyConnectedException expected");
+        } catch (AlreadyConnectedException x) {
+        }
+        ch.close();
+
+        // check that connect fails with ClosedChannelException)
+        ch = AsynchronousSocketChannel.open();
+        ch.close();
+        try {
+            ch.connect(server.address()).get();
+            throw new RuntimeException("ExecutionException expected");
+        } catch (ExecutionException x) {
+            if (!(x.getCause() instanceof ClosedChannelException))
+                throw new RuntimeException("Cause of ClosedChannelException expected");
+        }
+        final AtomicReference<Throwable> connectException =
+            new AtomicReference<Throwable>();
+        ch.connect(server.address(), null, new CompletionHandler<Void,Void>() {
+            public void completed(Void result, Void att) {
+            }
+            public void failed(Throwable exc, Void att) {
+                connectException.set(exc);
+            }
+            public void cancelled(Void att) {
+            }
+        });
+        while (connectException.get() == null) {
+            Thread.sleep(100);
+        }
+        if (!(connectException.get() instanceof ClosedChannelException))
+            throw new RuntimeException("ClosedChannelException expected");
+
+        System.out.println("-- connect to non-existent host --");
+
+        // test failure
+        InetAddress badHost = InetAddress.getByName("1.2.3.4");
+        if (!badHost.isReachable(10*1000)) {
+
+            ch = AsynchronousSocketChannel.open();
+            try {
+                ch.connect(new InetSocketAddress(badHost, 9876)).get();
+                throw new RuntimeException("Connection should not be established");
+            } catch (ExecutionException x) {
+            }
+            if (ch.isOpen())
+                throw new RuntimeException("Channel should be closed");
+        }
+
+        server.close();
+    }
+
+    static void testCloseWhenPending() throws Exception {
+        System.out.println("-- asynchronous close when connecting --");
+
+        AsynchronousSocketChannel ch;
+
+        // asynchronous close while connecting
+        InetAddress rh = InetAddress.getByName("1.2.3.4");
+        if (!rh.isReachable(3000)) {
+            InetSocketAddress isa = new InetSocketAddress(rh, 1234);
+
+            ch = AsynchronousSocketChannel.open();
+            Future<Void> result = ch.connect(isa);
+
+            // give time to initiate the connect (SYN)
+            Thread.sleep(50);
+
+            // close
+            ch.close();
+
+            // check that AsynchronousCloseException is thrown
+            try {
+                result.get();
+                throw new RuntimeException("Should not connect");
+            } catch (ExecutionException x) {
+                if (!(x.getCause() instanceof AsynchronousCloseException))
+                    throw new RuntimeException(x);
+            }
+        }
+
+        System.out.println("-- asynchronous close when reading --");
+
+        Server server = new Server();
+        ch = AsynchronousSocketChannel.open();
+        ch.connect(server.address()).get();
+
+        ByteBuffer dst = ByteBuffer.allocateDirect(100);
+        Future<Integer> result = ch.read(dst);
+
+        // attempt a second read - should fail with ReadPendingException
+        ByteBuffer buf = ByteBuffer.allocateDirect(100);
+        try {
+            ch.read(buf);
+            throw new RuntimeException("ReadPendingException expected");
+        } catch (ReadPendingException x) {
+        }
+
+        // close channel (should cause initial read to complete)
+        ch.close();
+
+        // check that AsynchronousCloseException is thrown
+        try {
+            result.get();
+            throw new RuntimeException("Should not read");
+        } catch (ExecutionException x) {
+            if (!(x.getCause() instanceof AsynchronousCloseException))
+                throw new RuntimeException(x);
+        }
+
+        System.out.println("-- asynchronous close when writing --");
+
+        ch = AsynchronousSocketChannel.open();
+        ch.connect(server.address()).get();
+
+        final AtomicReference<Throwable> writeException =
+            new AtomicReference<Throwable>();
+
+        // write bytes to fill socket buffer
+        ch.write(genBuffer(), ch, new CompletionHandler<Integer,AsynchronousSocketChannel>() {
+            public void completed(Integer result, AsynchronousSocketChannel ch) {
+                ch.write(genBuffer(), ch, this);
+            }
+            public void failed(Throwable x, AsynchronousSocketChannel ch) {
+                writeException.set(x);
+            }
+            public void cancelled(AsynchronousSocketChannel ch) {
+            }
+        });
+
+        // give time for socket buffer to fill up.
+        Thread.sleep(5*1000);
+
+        //  attempt a concurrent write - should fail with WritePendingException
+        try {
+            ch.write(genBuffer());
+            throw new RuntimeException("WritePendingException expected");
+        } catch (WritePendingException x) {
+        }
+
+        // close channel - should cause initial write to complete
+        ch.close();
+
+        // wait for exception
+        while (writeException.get() == null) {
+            Thread.sleep(100);
+        }
+        if (!(writeException.get() instanceof AsynchronousCloseException))
+            throw new RuntimeException("AsynchronousCloseException expected");
+
+        server.close();
+    }
+
+    static void testCancel() throws Exception {
+        System.out.println("-- cancel --");
+
+        Server server = new Server();
+
+        for (int i=0; i<2; i++) {
+            boolean mayInterruptIfRunning = (i == 0) ? false : true;
+
+            // establish loopback connection
+            AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
+            ch.connect(server.address()).get();
+            SocketChannel peer = server.accept();
+
+            // start read operation
+            final CountDownLatch latch = new CountDownLatch(1);
+            ByteBuffer buf = ByteBuffer.allocate(1);
+            Future<Integer> res = ch.read(buf, null,
+                new CompletionHandler<Integer,Void>() {
+                    public void completed(Integer result, Void att) {
+                    }
+                    public void failed(Throwable exc, Void att) {
+                    }
+                    public void cancelled(Void att) {
+                        latch.countDown();
+                    }
+            });
+
+            // cancel operation
+            boolean cancelled = res.cancel(mayInterruptIfRunning);
+
+            // check post-conditions
+            if (!res.isDone())
+                throw new RuntimeException("isDone should return true");
+            if (res.isCancelled() != cancelled)
+                throw new RuntimeException("isCancelled not consistent");
+            try {
+                res.get();
+                throw new RuntimeException("CancellationException expected");
+            } catch (CancellationException x) {
+            }
+            try {
+                res.get(1, TimeUnit.SECONDS);
+                throw new RuntimeException("CancellationException expected");
+            } catch (CancellationException x) {
+            }
+
+            // check that completion handler executed.
+            latch.await();
+
+            ch.close();
+            peer.close();
+        }
+
+        server.close();
+    }
+
+    static void testRead1() throws Exception {
+        System.out.println("-- read (1) --");
+
+        Server server = new Server();
+        final AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
+        ch.connect(server.address()).get();
+
+        // read with 0 bytes remaining should complete immediately
+        ByteBuffer buf = ByteBuffer.allocate(1);
+        buf.put((byte)0);
+        int n = ch.read(buf).get();
+        if (n != 0)
+            throw new RuntimeException("0 expected");
+
+        // write bytes and close connection
+        SocketChannel sc = server.accept();
+        ByteBuffer src = genBuffer();
+        sc.setOption(StandardSocketOption.SO_SNDBUF, src.remaining());
+        while (src.hasRemaining())
+            sc.write(src);
+        sc.close();
+
+        // reads should complete immediately
+        final ByteBuffer dst = ByteBuffer.allocateDirect(src.capacity() + 100);
+        final CountDownLatch latch = new CountDownLatch(1);
+        ch.read(dst, null, new CompletionHandler<Integer,Void>() {
+            public void completed(Integer result, Void att) {
+                int n = result;
+                if (n > 0) {
+                    ch.read(dst, null, this);
+                } else {
+                    latch.countDown();
+                }
+            }
+            public void failed(Throwable exc, Void att) {
+            }
+            public void cancelled(Void att) {
+            }
+        });
+
+        latch.await();
+
+        // check buffers
+        src.flip();
+        dst.flip();
+        if (!src.equals(dst)) {
+            throw new RuntimeException("Contents differ");
+        }
+
+        // close channel
+        ch.close();
+
+        // check read fails with ClosedChannelException
+        try {
+            ch.read(dst).get();
+            throw new RuntimeException("ExecutionException expected");
+        } catch (ExecutionException x) {
+            if (!(x.getCause() instanceof ClosedChannelException))
+                throw new RuntimeException("Cause of ClosedChannelException expected");
+        }
+
+        server.close();
+    }
+
+    static void testRead2() throws Exception {
+        System.out.println("-- read (2) --");
+
+        Server server = new Server();
+
+        final AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
+        ch.connect(server.address()).get();
+        SocketChannel sc = server.accept();
+
+        ByteBuffer src = genBuffer();
+
+        // read until the buffer is full
+        final ByteBuffer dst = ByteBuffer.allocateDirect(src.capacity());
+        final CountDownLatch latch = new CountDownLatch(1);
+        ch.read(dst, null, new CompletionHandler<Integer,Void>() {
+            public void completed(Integer result, Void att) {
+                if (dst.hasRemaining()) {
+                    ch.read(dst, null, this);
+                } else {
+                    latch.countDown();
+                }
+            }
+            public void failed(Throwable exc, Void att) {
+            }
+            public void cancelled(Void att) {
+            }
+        });
+
+        // trickle the writing
+        do {
+            int rem = src.remaining();
+            int size = (rem <= 100) ? rem : 50 + rand.nextInt(rem - 100);
+            ByteBuffer buf = ByteBuffer.allocate(size);
+            for (int i=0; i<size; i++)
+                buf.put(src.get());
+            buf.flip();
+            Thread.sleep(50 + rand.nextInt(1500));
+            while (buf.hasRemaining())
+                sc.write(buf);
+        } while (src.hasRemaining());
+
+        // wait until ascynrhonous reading has completed
+        latch.await();
+
+        // check buffers
+        src.flip();
+        dst.flip();
+        if (!src.equals(dst)) {
+           throw new RuntimeException("Contents differ");
+        }
+
+        sc.close();
+        ch.close();
+        server.close();
+    }
+
+    // exercise scattering read
+    static void testRead3() throws Exception {
+        System.out.println("-- read (3) --");
+
+        Server server = new Server();
+        final AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
+        ch.connect(server.address()).get();
+        SocketChannel sc = server.accept();
+
+        ByteBuffer[] dsts = new ByteBuffer[3];
+        for (int i=0; i<dsts.length; i++) {
+            dsts[i] = ByteBuffer.allocateDirect(100);
+        }
+
+        // scattering read that completes ascynhronously
+        final CountDownLatch latch = new CountDownLatch(1);
+        ch.read(dsts, 0, dsts.length, 0L, TimeUnit.SECONDS, null,
+            new CompletionHandler<Long,Void>() {
+                public void completed(Long result, Void att) {
+                    long n = result;
+                    if (n <= 0)
+                        throw new RuntimeException("No bytes read");
+                    latch.countDown();
+                }
+                public void failed(Throwable exc, Void att) {
+                }
+                public void cancelled(Void att) {
+                }
+        });
+
+        // write some bytes
+        sc.write(genBuffer());
+
+        // read should now complete
+        latch.await();
+
+        // write more bytes
+        sc.write(genBuffer());
+
+        // read should complete immediately
+        for (int i=0; i<dsts.length; i++) {
+            dsts[i].rewind();
+        }
+        long n = ch
+            .read(dsts, 0, dsts.length, 0L, TimeUnit.SECONDS, null, null).get();
+        if (n <= 0)
+            throw new RuntimeException("No bytes read");
+
+        ch.close();
+        sc.close();
+        server.close();
+    }
+
+    static void testWrite1() throws Exception {
+        System.out.println("-- write (1) --");
+
+        Server server = new Server();
+        final AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
+        ch.connect(server.address()).get();
+        SocketChannel sc = server.accept();
+
+        // write with 0 bytes remaining should complete immediately
+        ByteBuffer buf = ByteBuffer.allocate(1);
+        buf.put((byte)0);
+        int n = ch.write(buf).get();
+        if (n != 0)
+            throw new RuntimeException("0 expected");
+
+        // write all bytes and close connection when done
+        final ByteBuffer src = genBuffer();
+        ch.write(src, null, new CompletionHandler<Integer,Void>() {
+            public void completed(Integer result, Void att) {
+                if (src.hasRemaining()) {
+                    ch.write(src, null, this);
+                } else {
+                    try {
+                        ch.close();
+                    } catch (IOException ignore) { }
+                }
+            }
+            public void failed(Throwable exc, Void att) {
+            }
+            public void cancelled(Void att) {
+            }
+        });
+
+        // read to EOF or buffer full
+        ByteBuffer dst = ByteBuffer.allocateDirect(src.capacity() + 100);
+        do {
+            n = sc.read(dst);
+        } while (n > 0);
+        sc.close();
+
+        // check buffers
+        src.flip();
+        dst.flip();
+        if (!src.equals(dst)) {
+            throw new RuntimeException("Contents differ");
+        }
+
+        // check write fails with ClosedChannelException
+        try {
+            ch.read(dst).get();
+            throw new RuntimeException("ExecutionException expected");
+        } catch (ExecutionException x) {
+            if (!(x.getCause() instanceof ClosedChannelException))
+                throw new RuntimeException("Cause of ClosedChannelException expected");
+        }
+
+        server.close();
+    }
+
+    // exercise gathering write
+    static void testWrite2() throws Exception {
+        System.out.println("-- write (2) --");
+
+        Server server = new Server();
+        final AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
+        ch.connect(server.address()).get();
+        SocketChannel sc = server.accept();
+
+        // write buffers (should complete immediately)
+        ByteBuffer[] srcs = genBuffers(1);
+        long n = ch
+            .write(srcs, 0, srcs.length, 0L, TimeUnit.SECONDS, null, null).get();
+        if (n <= 0)
+            throw new RuntimeException("No bytes written");
+
+        // set to true to signal that no more buffers should be written
+        final AtomicBoolean continueWriting = new AtomicBoolean(true);
+
+        // number of bytes written
+        final AtomicLong bytesWritten = new AtomicLong(n);
+
+        // write until socket buffer is full so as to create the conditions
+        // for when a write does not complete immediately
+        srcs = genBuffers(1);
+        ch.write(srcs, 0, srcs.length, 0L, TimeUnit.SECONDS, null,
+            new CompletionHandler<Long,Void>() {
+                public void completed(Long result, Void att) {
+                    long n = result;
+                    if (n <= 0)
+                        throw new RuntimeException("No bytes written");
+                    bytesWritten.addAndGet(n);
+                    if (continueWriting.get()) {
+                        ByteBuffer[] srcs = genBuffers(8);
+                        ch.write(srcs, 0, srcs.length, 0L, TimeUnit.SECONDS,
+                            null, this);
+                    }
+                }
+                public void failed(Throwable exc, Void att) {
+                }
+                public void cancelled(Void att) {
+                }
+        });
+
+        // give time for socket buffer to fill up.
+        Thread.sleep(5*1000);
+
+        // signal handler to stop further writing
+        continueWriting.set(false);
+
+        // read until done
+        ByteBuffer buf = ByteBuffer.allocateDirect(4096);
+        long total = 0L;
+        do {
+            n = sc.read(buf);
+            if (n <= 0)
+                throw new RuntimeException("No bytes read");
+            buf.rewind();
+            total += n;
+        } while (total < bytesWritten.get());
+
+        ch.close();
+        sc.close();
+        server.close();
+    }
+
+    static void testShutdown() throws Exception {
+        System.out.println("-- shutdown--");
+
+        Server server = new Server();
+        AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
+        ch.connect(server.address()).get();
+        SocketChannel sc = server.accept();
+
+        ByteBuffer buf = ByteBuffer.allocateDirect(1000);
+        int n;
+
+        // check read
+        ch.shutdownInput();
+        n = ch.read(buf).get();
+        if (n != -1)
+            throw new RuntimeException("-1 expected");
+        // check full with full buffer
+        buf.put(new byte[100]);
+        n = ch.read(buf).get();
+        if (n != -1)
+            throw new RuntimeException("-1 expected");
+
+        // check write
+        ch.shutdownOutput();
+        try {
+            ch.write(buf).get();
+            throw new RuntimeException("ClosedChannelException expected");
+        } catch (ExecutionException x) {
+            if (!(x.getCause() instanceof ClosedChannelException))
+                throw new RuntimeException("ClosedChannelException expected");
+        }
+
+        sc.close();
+        ch.close();
+        server.close();
+    }
+
+    static void testTimeout() throws Exception {
+        Server server = new Server();
+        AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
+        ch.connect(server.address()).get();
+
+        System.out.println("-- timeout when reading --");
+
+        // this read should timeout
+        ByteBuffer dst = ByteBuffer.allocate(512);
+        try {
+            ch.read(dst, 3, TimeUnit.SECONDS, null, null).get();
+            throw new RuntimeException("Read did not timeout");
+        } catch (ExecutionException x) {
+            if (!(x.getCause() instanceof InterruptedByTimeoutException))
+                throw new RuntimeException("InterruptedByTimeoutException expected");
+        }
+
+        // after a timeout then further reading should throw unspecified runtime exception
+        boolean exceptionThrown = false;
+        try {
+            ch.read(dst);
+        } catch (RuntimeException x) {
+            exceptionThrown = true;
+        }
+        if (!exceptionThrown)
+            throw new RuntimeException("RuntimeException expected after timeout.");
+
+
+        System.out.println("-- timeout when writing --");
+
+        final AtomicReference<Throwable> writeException = new AtomicReference<Throwable>();
+
+        final long timeout = 5;
+        final TimeUnit unit = TimeUnit.SECONDS;
+
+        // write bytes to fill socket buffer
+        ch.write(genBuffer(), timeout, unit, ch,
+            new CompletionHandler<Integer,AsynchronousSocketChannel>()
+        {
+            public void completed(Integer result, AsynchronousSocketChannel ch) {
+                ch.write(genBuffer(), timeout, unit, ch, this);
+            }
+            public void failed(Throwable exc, AsynchronousSocketChannel ch) {
+                writeException.set(exc);
+            }
+            public void cancelled(AsynchronousSocketChannel ch) {
+            }
+        });
+
+        // wait for exception
+        while (writeException.get() == null) {
+            Thread.sleep(100);
+        }
+        if (!(writeException.get() instanceof InterruptedByTimeoutException))
+            throw new RuntimeException("InterruptedByTimeoutException expected");
+
+        // after a timeout then further writing should throw unspecified runtime exception
+        exceptionThrown = false;
+        try {
+            ch.write(genBuffer());
+        } catch (RuntimeException x) {
+            exceptionThrown = true;
+        }
+        if (!exceptionThrown)
+            throw new RuntimeException("RuntimeException expected after timeout.");
+
+        ch.close();
+    }
+
+   // returns ByteBuffer with random bytes
+   static ByteBuffer genBuffer() {
+       int size = 1024 + rand.nextInt(16000);
+       byte[] buf = new byte[size];
+       rand.nextBytes(buf);
+       boolean useDirect = rand.nextBoolean();
+       if (useDirect) {
+           ByteBuffer bb = ByteBuffer.allocateDirect(buf.length);
+           bb.put(buf);
+           bb.flip();
+           return bb;
+       } else {
+           return ByteBuffer.wrap(buf);
+       }
+   }
+
+   // return ByteBuffer[] with random bytes
+   static ByteBuffer[] genBuffers(int max) {
+       int len = 1;
+       if (max > 1)
+           len += rand.nextInt(max);
+       ByteBuffer[] bufs = new ByteBuffer[len];
+       for (int i=0; i<len; i++)
+           bufs[i] = genBuffer();
+       return bufs;
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/AsynchronousSocketChannel/Leaky.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4607272
+ * @summary Unit test for AsynchronousSocketChannel
+ * @run main/othervm -XX:+DisableExplicitGC -mx64m Leaky
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.channels.*;
+import java.net.*;
+import java.util.concurrent.Future;
+
+/**
+ * Heap buffers must be substituted with direct buffers when doing I/O. This
+ * test creates a scenario on Windows that challenges the per-thread buffer
+ * cache and quickly leads to an OutOfMemoryError if temporary buffers are
+ * not returned to the native heap.
+ */
+
+public class Leaky {
+
+    static final int K = 1024;
+
+    static class Connection {
+        private final AsynchronousSocketChannel client;
+        private final SocketChannel peer;
+        private final ByteBuffer dst;
+        private Future<Integer> readResult;
+
+        Connection() throws Exception {
+            ServerSocketChannel ssc =
+                ServerSocketChannel.open().bind(new InetSocketAddress(0));
+            InetAddress lh = InetAddress.getLocalHost();
+            int port = ((InetSocketAddress)(ssc.getLocalAddress())).getPort();
+            SocketAddress remote = new InetSocketAddress(lh, port);
+            client = AsynchronousSocketChannel.open();
+            client.connect(remote).get();
+            peer = ssc.accept();
+            ssc.close();
+            dst = ByteBuffer.allocate(K*K);
+        }
+
+        void startRead() {
+            dst.clear();
+            readResult = client.read(dst);
+        }
+
+        void write() throws Exception {
+            peer.write(ByteBuffer.wrap("X".getBytes()));
+        }
+
+        void finishRead() throws Exception {
+            readResult.get();
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        final int CONNECTION_COUNT = 10;
+        Connection[] connections = new Connection[CONNECTION_COUNT];
+        for (int i=0; i<CONNECTION_COUNT; i++) {
+            connections[i] = new Connection();
+        }
+
+        for (int i=0; i<1024; i++) {
+            // initiate reads
+            for (Connection conn: connections) {
+                conn.startRead();
+            }
+
+            // write data so that the read can complete
+            for (Connection conn: connections) {
+                conn.write();
+            }
+
+            // complete read
+            for (Connection conn: connections) {
+                conn.finishRead();
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/Channels/Basic2.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,172 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4607272
+ * @summary Test Channels methods for interoperability between streams and
+ *     asynchronous byte channels
+ */
+
+import java.net.*;
+import java.io.*;
+import java.nio.channels.*;
+import java.util.Random;
+
+public class Basic2 {
+
+    static final Random rand = new Random();
+
+    public static void main(String[] args) throws Exception {
+        // establish loopback connection
+        AsynchronousServerSocketChannel listener =
+            AsynchronousServerSocketChannel.open().bind(new InetSocketAddress(0));
+        int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
+        InetSocketAddress isa =
+            new InetSocketAddress(InetAddress.getLocalHost(), port);
+        AsynchronousSocketChannel ch1 = AsynchronousSocketChannel.open();
+        ch1.connect(isa).get();
+        AsynchronousSocketChannel ch2 = listener.accept().get();
+
+        // start thread to write to stream
+        Writer writer = new Writer(Channels.newOutputStream(ch1));
+        Thread writerThread = new Thread(writer);
+        writerThread.start();
+
+        // start thread to read from stream
+        Reader reader = new Reader(Channels.newInputStream(ch2));
+        Thread readerThread = new Thread(reader);
+        readerThread.start();
+
+        // wait for threads to complete
+        writerThread.join();
+        readerThread.join();
+
+        // check that reader received what we expected
+        if (reader.total() != writer.total())
+            throw new RuntimeException("Unexpected number of bytes read");
+        if (reader.hash() != writer.hash())
+            throw new RuntimeException("Hash incorrect for bytes read");
+
+        // channels should be closed
+        if (ch1.isOpen() || ch2.isOpen())
+            throw new RuntimeException("Channels should be closed");
+    }
+
+    static class Reader implements Runnable {
+        private final InputStream in;
+        private volatile int total;
+        private volatile int hash;
+
+        Reader(InputStream in) {
+            this.in = in;
+        }
+
+        public void run() {
+            try {
+                int n;
+                do {
+                    // random offset/len
+                    byte[] buf = new byte[128 + rand.nextInt(128)];
+                    int len, off;
+                    if (rand.nextBoolean()) {
+                        len = buf.length;
+                        off = 0;
+                        n = in.read(buf);
+                    } else {
+                        len = 1 + rand.nextInt(64);
+                        off = rand.nextInt(64);
+                        n = in.read(buf, off, len);
+                    }
+                    if (n > len)
+                        throw new RuntimeException("Too many bytes read");
+                    if (n > 0) {
+                        total += n;
+                        for (int i=0; i<n; i++) {
+                            int value = buf[off + i];
+                            hash = hash ^ value;
+                        }
+                    }
+                } while (n > 0);
+                in.close();
+
+            } catch (IOException x) {
+                x.printStackTrace();
+            }
+        }
+
+        int total() { return total; }
+        int hash() { return hash; }
+    }
+
+    static class Writer implements Runnable {
+        private final OutputStream out;
+        private final int total;
+        private volatile int hash;
+
+        Writer(OutputStream out) {
+            this.out = out;
+            this.total = 50*1000 + rand.nextInt(50*1000);
+        }
+
+        public void run() {
+            hash = 0;
+            int rem = total;
+            try {
+                do {
+                    byte[] buf = new byte[1 + rand.nextInt(rem)];
+                    int off, len;
+
+                    // write random bytes
+                    if (rand.nextBoolean()) {
+                        off = 0;
+                        len = buf.length;
+                    } else {
+                        off = rand.nextInt(buf.length);
+                        int r = buf.length - off;
+                        len = (r <= 1) ? 1 : (1 + rand.nextInt(r));
+                    }
+                    for (int i=0; i<len; i++) {
+                        byte value = (byte)rand.nextInt(256);
+                        buf[off + i] = value;
+                        hash = hash ^ value;
+                    }
+                    if ((off == 0) && (len == buf.length)) {
+                        out.write(buf);
+                    } else {
+                        out.write(buf, off, len);
+                    }
+                    rem -= len;
+                } while (rem > 0);
+
+                // close stream when done
+                out.close();
+
+            } catch (IOException x) {
+                x.printStackTrace();
+            }
+        }
+
+        int total() { return total; }
+        int hash() { return hash; }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,38 @@
+/*
+ * Copyright 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.
+ *
+ * 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.
+ */
+
+import java.nio.channels.spi.AsynchronousChannelProvider;
+
+public class CheckProvider {
+    public static void main(String[] args) {
+        Class<?> c = AsynchronousChannelProvider.provider().getClass();
+
+        String expected = args[0];
+        String actual = c.getName();
+
+        if (!actual.equals(expected))
+            throw new RuntimeException("Provider is of type '" + actual +
+                "', expected '" + expected + "'");
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/META-INF/services/java.nio.channels.spi.AsynchronousChannelProvider	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,1 @@
+Provider1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright 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.
+ *
+ * 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.
+ */
+
+import java.nio.channels.spi.AsynchronousChannelProvider;
+import java.nio.channels.spi.AsynchronousChannelProvider.ThreadPoolType;
+import java.nio.channels.*;
+import java.net.ProtocolFamily;
+import java.util.concurrent.ExecutorService;
+import java.io.IOException;
+
+public class Provider1 extends AsynchronousChannelProvider {
+    public Provider1() {
+    }
+
+
+    public AsynchronousChannelGroup openAsynchronousChannelGroup
+        (ThreadPoolType poolType, ExecutorService executor, int n) throws IOException
+    {
+        throw new RuntimeException();
+    }
+
+
+    public AsynchronousSocketChannel openAsynchronousSocketChannel
+        (AsynchronousChannelGroup group) throws IOException
+    {
+        throw new RuntimeException();
+    }
+
+
+    public AsynchronousServerSocketChannel openAsynchronousServerSocketChannel
+        (AsynchronousChannelGroup group) throws IOException
+    {
+        throw new RuntimeException();
+    }
+
+
+    public AsynchronousDatagramChannel openAsynchronousDatagramChannel
+        (ProtocolFamily family, AsynchronousChannelGroup group) throws IOException
+    {
+        throw new RuntimeException();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright 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.
+ *
+ * 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.
+ */
+
+import java.nio.channels.spi.AsynchronousChannelProvider;
+import java.nio.channels.spi.AsynchronousChannelProvider.ThreadPoolType;
+import java.nio.channels.*;
+import java.net.ProtocolFamily;
+import java.util.concurrent.ExecutorService;
+import java.io.IOException;
+
+public class Provider2 extends AsynchronousChannelProvider {
+    public Provider2() {
+    }
+
+
+    public AsynchronousChannelGroup openAsynchronousChannelGroup
+        (ThreadPoolType poolType, ExecutorService executor, int n) throws IOException
+    {
+        throw new RuntimeException();
+    }
+
+
+    public AsynchronousSocketChannel openAsynchronousSocketChannel
+        (AsynchronousChannelGroup group) throws IOException
+    {
+        throw new RuntimeException();
+    }
+
+
+    public AsynchronousServerSocketChannel openAsynchronousServerSocketChannel
+        (AsynchronousChannelGroup group) throws IOException
+    {
+        throw new RuntimeException();
+    }
+
+
+    public AsynchronousDatagramChannel openAsynchronousDatagramChannel
+        (ProtocolFamily family, AsynchronousChannelGroup group) throws IOException
+    {
+        throw new RuntimeException();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,71 @@
+#
+# Copyright 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.
+#
+# 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.
+#
+
+# @test
+# @summary Unit test for java.nio.channels.spi.AsynchronousChannelProvider
+# @build Provider1 Provider2 CheckProvider
+# @run shell custom_provider.sh
+
+# if TESTJAVA isn't set then we assume an interactive run.
+
+if [ -z "$TESTJAVA" ]; then
+    TESTSRC=.
+    TESTCLASSES=.
+    JAVA=java
+else
+    JAVA="${TESTJAVA}/bin/java"
+fi
+
+OS=`uname -s`
+case "$OS" in
+    Windows_* )
+        CLASSPATH="${TESTCLASSES};${TESTSRC}"
+        ;;
+    * )
+        CLASSPATH=${TESTCLASSES}:${TESTSRC}
+        ;;
+esac
+export CLASSPATH
+
+failures=0
+
+go() {
+    echo ''
+    $JAVA $1 $2 $3 2>&1
+    if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
+}
+
+# Run the tests
+
+go CheckProvider Provider1
+go -Djava.nio.channels.spi.AsynchronousChannelProvider=Provider2 CheckProvider \
+  Provider2
+
+#
+# Results
+#
+echo ''
+if [ $failures -gt 0 ];
+  then echo "$failures test(s) failed";
+  else echo "All test(s) passed"; fi
+exit $failures
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/DirectoryStream/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,153 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.DirectoryStream
+ * @library ..
+ */
+
+import java.nio.file.*;
+import java.util.*;
+import java.io.IOException;
+
+public class Basic {
+    static boolean found;
+
+    static void doTest(final Path dir) throws IOException {
+        // test that directory is empty
+        Files.withDirectory(dir, new FileAction<FileRef>() {
+            public void invoke(FileRef entry) {
+                throw new RuntimeException("directory not empty");
+            }
+        });
+
+        // create file in directory
+        final Path foo = Paths.get("foo");
+        dir.resolve(foo).createFile();
+
+        // iterate over directory and check there is one entry
+        found = false;
+        Files.withDirectory(dir, new FileAction<Path>() {
+            public void invoke(Path entry) {
+                if (entry.getName().equals(foo)) {
+                    if (found)
+                        throw new RuntimeException("entry already found");
+                    found = true;
+                } else {
+                    throw new RuntimeException("entry " + entry.getName() +
+                        " not expected");
+                }
+            }
+        });
+        if (!found)
+            throw new RuntimeException("entry not found");
+
+        // check filtering: f* should match foo
+        DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
+            private PathMatcher matcher =
+                dir.getFileSystem().getNameMatcher("glob", "f*");
+            public boolean accept(Path file) {
+                return matcher.matches(file);
+            }
+        };
+        Files.withDirectory(dir, filter, new FileAction<Path>() {
+            public void invoke(Path entry) {
+                if (!entry.getName().equals(foo))
+                    throw new RuntimeException("entry not expected");
+            }
+        });
+
+        // check filtering: z* should not match any files
+        filter = new DirectoryStream.Filter<Path>() {
+            private PathMatcher matcher =
+                dir.getFileSystem().getNameMatcher("glob", "z*");
+            public boolean accept(Path file) {
+                return matcher.matches(file);
+            }
+        };
+        Files.withDirectory(dir, filter, new FileAction<FileRef>() {
+            public void invoke(FileRef entry) {
+                throw new RuntimeException("no matching entries expected");
+            }
+        });
+
+        // test NotDirectoryException
+        try {
+            dir.resolve(foo).newDirectoryStream();
+            throw new RuntimeException("NotDirectoryException not thrown");
+        } catch (NotDirectoryException x) {
+        }
+
+        // test iterator remove method
+        DirectoryStream<Path> stream = dir.newDirectoryStream();
+        Iterator<Path> i = stream.iterator();
+        while (i.hasNext()) {
+            Path entry = i.next();
+            if (!entry.getName().equals(foo))
+                throw new RuntimeException("entry not expected");
+            i.remove();
+        }
+        stream.close();
+
+        // test IllegalStateException
+        stream =  dir.newDirectoryStream();
+        i = stream.iterator();
+        try {
+            stream.iterator();
+            throw new RuntimeException("IllegalStateException not thrown as expected");
+        } catch (IllegalStateException x) {
+        }
+        stream.close();
+        try {
+            stream.iterator();
+            throw new RuntimeException("IllegalStateException not thrown as expected");
+        } catch (IllegalStateException x) {
+        }
+        try {
+            i.hasNext();
+            throw new RuntimeException("ConcurrentModificationException not thrown as expected");
+        } catch (ConcurrentModificationException x) {
+            Throwable t = x.getCause();
+            if (!(t instanceof IllegalStateException))
+                throw new RuntimeException("Cause is not IllegalStateException as expected");
+        }
+        try {
+            i.next();
+            throw new RuntimeException("IllegalStateException not thrown as expected");
+        } catch (ConcurrentModificationException x) {
+            Throwable t = x.getCause();
+            if (!(t instanceof IllegalStateException))
+                throw new RuntimeException("Cause is not IllegalStateException as expected");
+        }
+    }
+
+    public static void main(String[] args) throws IOException {
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            doTest(dir);
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/DirectoryStream/Filters.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,241 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.DirectoryStreamFilters
+ * @library ..
+ */
+
+import java.nio.file.*;
+import static java.nio.file.DirectoryStreamFilters.*;
+import java.nio.file.attribute.Attributes;
+import java.io.*;
+import java.util.*;
+
+public class Filters {
+    static final Random rand = new Random();
+
+    // returns a filter that only accepts files that are larger than a given size
+    static DirectoryStream.Filter<FileRef> newMinimumSizeFilter(final long min) {
+        return new DirectoryStream.Filter<FileRef>() {
+            public boolean accept(FileRef file) {
+                try {
+                    long size = Attributes.readBasicFileAttributes(file).size();
+                    return size >= min;
+                } catch (IOException e) {
+                    throw new IOError(e);
+                }
+            }
+        };
+    }
+
+    // returns a filter that only accepts files that are matched by a given glob
+    static DirectoryStream.Filter<Path> newGlobFilter(final String glob) {
+        return new DirectoryStream.Filter<Path>() {
+            PathMatcher matcher = FileSystems.getDefault().getNameMatcher("glob", glob);
+            public boolean accept(Path file) {
+                return matcher.matches(file);
+            }
+        };
+    }
+
+    static final int BIG_FILE_THRESHOLD = 8192;
+
+    static int totalCount;
+    static int htmlCount;
+    static int bigAndHtmlCount;
+    static int bigOrHtmlCount;
+
+    // generates random files in the test directory and initializes the counts
+    static void setup(Path dir) throws IOException {
+        // create 10-26 files.
+        totalCount = 10 + rand.nextInt(17);
+        char firstChar = 'A';
+        for (int i=0; i<totalCount; i++) {
+            boolean isHtml = rand.nextBoolean();
+            boolean isBig = rand.nextBoolean();
+            if (isHtml) {
+                htmlCount++;
+                if (isBig) bigAndHtmlCount++;
+            }
+            if (isHtml || isBig)
+                bigOrHtmlCount++;
+            String name;
+            if (isHtml) {
+                name = firstChar + ".html";
+            } else {
+                name = firstChar + ".tmp";
+            }
+            firstChar++;
+            int size = rand.nextInt(BIG_FILE_THRESHOLD);
+            if (isBig)
+                size += BIG_FILE_THRESHOLD;
+            Path file = dir.resolve(name);
+            OutputStream out = file.newOutputStream();
+            try {
+                if (size > 0)
+                    out.write(new byte[size]);
+            } finally {
+                out.close();
+            }
+            System.out.format("Created %s, size %d byte(s)\n", name, size);
+        }
+    }
+
+    static boolean isHtml(Path file) {
+        return file.toString().endsWith(".html");
+    }
+
+    static boolean isBig(Path file) throws IOException {
+        long size = Attributes.readBasicFileAttributes(file).size();
+        return size >= BIG_FILE_THRESHOLD;
+    }
+
+    static void checkCount(int expected, int actual) {
+        if (actual != expected)
+            throw new RuntimeException("'" + expected +
+                "' entries expected, actual: " + actual);
+    }
+
+    static void doTests(Path dir) throws IOException {
+        final List<DirectoryStream.Filter<Path>> emptyList = Collections.emptyList();
+
+        // list containing two filters
+        List<DirectoryStream.Filter<? super Path>> filters =
+            new ArrayList<DirectoryStream.Filter<? super Path>>();
+        filters.add(newMinimumSizeFilter(BIG_FILE_THRESHOLD));
+        filters.add(newGlobFilter("*.html"));
+
+        int accepted;
+        DirectoryStream<Path> stream;
+
+        System.out.println("Test: newContentTypeFilter");
+        accepted = 0;
+        stream = dir.newDirectoryStream(newContentTypeFilter("text/html"));
+        try {
+            for (Path entry: stream) {
+                if (!isHtml(entry))
+                    throw new RuntimeException("html file expected");
+                accepted++;
+            }
+        } finally {
+            stream.close();
+        }
+        checkCount(htmlCount, accepted);
+
+        System.out.println("Test: allOf with list of filters");
+        accepted = 0;
+        stream = dir.newDirectoryStream(allOf(filters));
+        try {
+            for (Path entry: stream) {
+                if (!isHtml(entry))
+                    throw new RuntimeException("html file expected");
+                if (!isBig(entry))
+                    throw new RuntimeException("big file expected");
+                accepted++;
+            }
+        } finally {
+            stream.close();
+        }
+        checkCount(bigAndHtmlCount, accepted);
+
+        System.out.println("Test: allOf with empty list");
+        accepted = 0;
+        stream = dir.newDirectoryStream(allOf(emptyList));
+        try {
+            for (Path entry: stream) {
+                accepted++;
+            }
+        } finally {
+            stream.close();
+        }
+        checkCount(totalCount, accepted);
+
+        System.out.println("Test: anyOf with list of filters");
+        accepted = 0;
+        stream = dir.newDirectoryStream(anyOf(filters));
+        try {
+            for (Path entry: stream) {
+                if (!isHtml(entry) && !isBig(entry))
+                    throw new RuntimeException("html or big file expected");
+                accepted++;
+            }
+        } finally {
+            stream.close();
+        }
+        checkCount(bigOrHtmlCount, accepted);
+
+        System.out.println("Test: anyOf with empty list");
+        accepted = 0;
+        stream = dir.newDirectoryStream(anyOf(emptyList));
+        try {
+            for (Path entry: stream) {
+                accepted++;
+            }
+        } finally {
+            stream.close();
+        }
+        checkCount(0, accepted);
+
+        System.out.println("Test: complementOf");
+        accepted = 0;
+        stream = dir.newDirectoryStream(complementOf(newGlobFilter("*.html")));
+        try {
+            for (Path entry: stream) {
+                accepted++;
+            }
+        } finally {
+            stream.close();
+        }
+        checkCount(totalCount-htmlCount, accepted);
+
+        System.out.println("Test: nulls");
+        try {
+            newContentTypeFilter(null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException npe) { }
+        try {
+            allOf(null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException npe) { }
+        try {
+            anyOf(null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException npe) { }
+        try {
+            complementOf(null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException npe) { }
+    }
+
+    public static void main(String[] args) throws IOException {
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            setup(dir);
+            doTests(dir);
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/DirectoryStream/SecureDS.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,370 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.SecureDirectoryStream
+ * @library ..
+ */
+
+import java.nio.file.*;
+import static java.nio.file.StandardOpenOption.*;
+import static java.nio.file.LinkOption.*;
+import java.nio.file.attribute.*;
+import java.nio.channels.*;
+import java.io.IOException;
+import java.util.*;
+
+public class SecureDS {
+    static boolean supportsLinks;
+
+    public static void main(String[] args) throws IOException {
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            DirectoryStream stream = dir.newDirectoryStream();
+            stream.close();
+            if (!(stream instanceof SecureDirectoryStream)) {
+                System.out.println("SecureDirectoryStream not supported.");
+                return;
+            }
+
+            supportsLinks = TestUtil.supportsLinks(dir);
+
+            // run tests
+            doBasicTests(dir);
+            doMoveTests(dir);
+            miscTests(dir);
+
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+
+    // Exercise each of SecureDirectoryStream's method (except move)
+    static void doBasicTests(Path dir) throws IOException {
+        Path dir1 = dir.resolve("dir1").createDirectory();
+        Path dir2 = dir.resolve("dir2");
+
+        // create a file, directory, and two sym links in the directory
+        Path fileEntry = Paths.get("myfile");
+        dir1.resolve(fileEntry).createFile();
+        Path dirEntry = Paths.get("mydir");
+        dir1.resolve(dirEntry).createDirectory();
+        // myfilelink -> myfile
+        Path link1Entry = Paths.get("myfilelink");
+        if (supportsLinks)
+            dir1.resolve(link1Entry).createSymbolicLink(fileEntry);
+        // mydirlink -> mydir
+        Path link2Entry = Paths.get("mydirlink");
+        if (supportsLinks)
+            dir1.resolve(link2Entry).createSymbolicLink(dirEntry);
+
+        // open directory and then move it so that it is no longer accessible
+        // via its original path.
+        SecureDirectoryStream stream =
+            (SecureDirectoryStream)dir1.newDirectoryStream();
+        dir1.moveTo(dir2);
+
+        // Test: iterate over all entries
+        int count = 0;
+        for (Path entry: stream) { count++; }
+        assertTrue(count == (supportsLinks ? 4 : 2));
+
+        // Test: getFileAttributeView to access directory's attributes
+        assertTrue(stream
+            .getFileAttributeView(BasicFileAttributeView.class)
+                .readAttributes()
+                    .isDirectory());
+
+        // Test: dynamic access to directory's attributes
+        BasicFileAttributeView view = stream.
+            getFileAttributeView(BasicFileAttributeView.class);
+        Map<String,?> attrs = view.readAttributes("*");
+        assertTrue((Boolean)attrs.get("isDirectory"));
+        attrs = view.readAttributes("isRegularFile", "size");
+        assertTrue(!(Boolean)attrs.get("isRegularFile"));
+        assertTrue((Long)attrs.get("size") >= 0);
+        int linkCount = (Integer)view.getAttribute("linkCount");
+        assertTrue(linkCount > 0);
+        view.setAttribute("lastModifiedTime", 0L);
+
+        // Test: getFileAttributeView to access attributes of entries
+        assertTrue(stream
+            .getFileAttributeView(fileEntry, BasicFileAttributeView.class)
+                .readAttributes()
+                    .isRegularFile());
+        assertTrue(stream
+            .getFileAttributeView(fileEntry, BasicFileAttributeView.class, NOFOLLOW_LINKS)
+                .readAttributes()
+                    .isRegularFile());
+        assertTrue(stream
+            .getFileAttributeView(dirEntry, BasicFileAttributeView.class)
+                .readAttributes()
+                    .isDirectory());
+        assertTrue(stream
+            .getFileAttributeView(dirEntry, BasicFileAttributeView.class, NOFOLLOW_LINKS)
+                .readAttributes()
+                    .isDirectory());
+        if (supportsLinks) {
+            assertTrue(stream
+                .getFileAttributeView(link1Entry, BasicFileAttributeView.class)
+                    .readAttributes()
+                        .isRegularFile());
+            assertTrue(stream
+                .getFileAttributeView(link1Entry, BasicFileAttributeView.class, NOFOLLOW_LINKS)
+                    .readAttributes()
+                        .isSymbolicLink());
+            assertTrue(stream
+                .getFileAttributeView(link2Entry, BasicFileAttributeView.class)
+                    .readAttributes()
+                        .isDirectory());
+            assertTrue(stream
+                .getFileAttributeView(link2Entry, BasicFileAttributeView.class, NOFOLLOW_LINKS)
+                    .readAttributes()
+                        .isSymbolicLink());
+        }
+
+        // Test: dynamic access to entry attributes
+        view = stream
+             .getFileAttributeView(fileEntry, PosixFileAttributeView.class, NOFOLLOW_LINKS);
+        if (view != null) {
+            attrs = view.readAttributes("owner", "size");
+            UserPrincipal owner = (UserPrincipal)attrs.get("owner");
+            assertTrue(owner != null);
+            assertTrue((Long)attrs.get("size") >= 0L);
+            view.setAttribute("lastAccessTime", 0L);
+        }
+
+        // Test: newByteChannel
+        Set<StandardOpenOption> opts = Collections.emptySet();
+        stream.newByteChannel(fileEntry, opts).close();
+        if (supportsLinks) {
+            stream.newByteChannel(link1Entry, opts).close();
+            try {
+                Set<OpenOption> mixed = new HashSet<OpenOption>();
+                mixed.add(READ);
+                mixed.add(NOFOLLOW_LINKS);
+                stream.newByteChannel(link1Entry, mixed).close();
+                shouldNotGetHere();
+            } catch (IOException x) { }
+        }
+
+        // Test: newDirectoryStream
+        stream.newDirectoryStream(dirEntry, true, null).close();
+        stream.newDirectoryStream(dirEntry, false, null).close();
+        if (supportsLinks) {
+            stream.newDirectoryStream(link2Entry, true, null).close();
+            try {
+                stream.newDirectoryStream(link2Entry, false, null).close();
+                shouldNotGetHere();
+            } catch (IOException x) { }
+        }
+
+        // Test: delete
+        if (supportsLinks) {
+            stream.deleteFile(link1Entry);
+            stream.deleteFile(link2Entry);
+        }
+        stream.deleteDirectory(dirEntry);
+        stream.deleteFile(fileEntry);
+
+        // Test: remove
+        // (requires resetting environment to get new iterator)
+        stream.close();
+        dir2.moveTo(dir1);
+        dir1.resolve(fileEntry).createFile();
+        stream = (SecureDirectoryStream)dir1.newDirectoryStream();
+        dir1.moveTo(dir2);
+        Iterator<Path> iter = stream.iterator();
+        int removed = 0;
+        while (iter.hasNext()) {
+            iter.next();
+            iter.remove();
+            removed++;
+        }
+        assertTrue(removed == 1);
+
+        // clean-up
+        stream.close();
+        dir2.delete();
+    }
+
+    // Exercise SecureDirectoryStream's move method
+    static void doMoveTests(Path dir) throws IOException {
+        Path dir1 = dir.resolve("dir1").createDirectory();
+        Path dir2 = dir.resolve("dir2").createDirectory();
+
+        // create dir1/myfile, dir1/mydir, dir1/mylink
+        Path fileEntry = Paths.get("myfile");
+        dir1.resolve(fileEntry).createFile();
+        Path dirEntry = Paths.get("mydir");
+        dir1.resolve(dirEntry).createDirectory();
+        Path linkEntry = Paths.get("mylink");
+        if (supportsLinks)
+            dir1.resolve(linkEntry).createSymbolicLink(Paths.get("missing"));
+
+        // target name
+        Path target = Paths.get("newfile");
+
+        // open stream to both directories
+        SecureDirectoryStream stream1 =
+            (SecureDirectoryStream)dir1.newDirectoryStream();
+        SecureDirectoryStream stream2 =
+            (SecureDirectoryStream)dir2.newDirectoryStream();
+
+        // Test: move dir1/myfile -> dir2/newfile
+        stream1.move(fileEntry, stream2, target);
+        assertTrue(dir1.resolve(fileEntry).notExists());
+        assertTrue(dir2.resolve(target).exists());
+        stream2.deleteFile(target);
+
+        // Test: move dir1/mydir -> dir2/newfile
+        stream1.move(dirEntry, stream2, target);
+        assertTrue(dir1.resolve(dirEntry).notExists());
+        assertTrue(dir2.resolve(target).exists());
+        stream2.deleteDirectory(target);
+
+        // Test: move dir1/mylink -> dir2/newfile
+        if (supportsLinks) {
+            stream1.move(linkEntry, stream2, target);
+            assertTrue(dir2.resolve(target)
+                .getFileAttributeView(BasicFileAttributeView.class, NOFOLLOW_LINKS)
+                .readAttributes()
+                .isSymbolicLink());
+            stream2.deleteFile(target);
+        }
+
+        // Test: move between devices
+        String testDirAsString = System.getProperty("test.dir");
+        if (testDirAsString != null) {
+            Path testDir = Paths.get(testDirAsString);
+            if (!dir1.getFileStore().equals(testDir.getFileStore())) {
+                SecureDirectoryStream ts =
+                    (SecureDirectoryStream)testDir.newDirectoryStream();
+                dir1.resolve(fileEntry).createFile();
+                try {
+                    stream1.move(fileEntry, ts, target);
+                    shouldNotGetHere();
+                } catch (AtomicMoveNotSupportedException x) { }
+                ts.close();
+                stream1.deleteFile(fileEntry);
+            }
+        }
+
+        // clean-up
+        dir1.delete();
+        dir2.delete();
+    }
+
+    // null and ClosedDirectoryStreamException
+    static void miscTests(Path dir) throws IOException {
+        Path file = Paths.get("file");
+        dir.resolve(file).createFile();
+
+        SecureDirectoryStream stream =
+            (SecureDirectoryStream)dir.newDirectoryStream();
+
+        // NullPointerException
+        try {
+            stream.getFileAttributeView(null);
+            shouldNotGetHere();
+        } catch (NullPointerException x) { }
+        try {
+            stream.getFileAttributeView(null, BasicFileAttributeView.class);
+            shouldNotGetHere();
+        } catch (NullPointerException x) { }
+        try {
+            stream.getFileAttributeView(file, null);
+            shouldNotGetHere();
+        } catch (NullPointerException x) { }
+        try {
+            stream.newByteChannel(null, EnumSet.of(CREATE,WRITE));
+            shouldNotGetHere();
+        } catch (NullPointerException x) { }
+        try {
+            stream.newByteChannel(null, EnumSet.of(CREATE,WRITE,null));
+            shouldNotGetHere();
+        } catch (NullPointerException x) { }
+        try {
+            stream.newByteChannel(file, null);
+            shouldNotGetHere();
+        } catch (NullPointerException x) { }
+        try {
+            stream.move(null, stream, file);
+            shouldNotGetHere();
+        } catch (NullPointerException x) { }
+        try {
+            stream.move(file, null, file);
+            shouldNotGetHere();
+        } catch (NullPointerException x) { }
+        try {
+            stream.move(file, stream, null);
+            shouldNotGetHere();
+        } catch (NullPointerException x) { }
+        try {
+            stream.newDirectoryStream(null, true, null);
+            shouldNotGetHere();
+        } catch (NullPointerException x) { }
+        try {
+            stream.deleteFile(null);
+            shouldNotGetHere();
+        } catch (NullPointerException x) { }
+        try {
+            stream.deleteDirectory(null);
+            shouldNotGetHere();
+        } catch (NullPointerException x) { }
+
+        // close stream
+        stream.close();
+        stream.close();     // should be no-op
+
+        // ClosedDirectoryStreamException
+        try {
+            stream.newDirectoryStream(file, true, null);
+            shouldNotGetHere();
+        } catch (ClosedDirectoryStreamException x) { }
+        try {
+            stream.newByteChannel(file, EnumSet.of(READ));
+            shouldNotGetHere();
+        } catch (ClosedDirectoryStreamException x) { }
+        try {
+            stream.move(file, stream, file);
+            shouldNotGetHere();
+        } catch (ClosedDirectoryStreamException x) { }
+        try {
+            stream.deleteFile(file);
+            shouldNotGetHere();
+        } catch (ClosedDirectoryStreamException x) { }
+
+        // clean-up
+        dir.resolve(file).delete();
+    }
+
+    static void assertTrue(boolean b) {
+        if (!b) throw new RuntimeException("Assertion failed");
+    }
+
+    static void shouldNotGetHere() {
+        assertTrue(false);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/FileStore/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.FileStore
+ * @library ..
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.io.IOException;
+
+public class Basic {
+
+    public static void main(String[] args) throws IOException {
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            doTests(dir);
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+
+    static void assertTrue(boolean okay) {
+        if (!okay)
+            throw new RuntimeException("Assertion failed");
+    }
+
+    static void doTests(Path dir) throws IOException {
+        /**
+         * Test: Directory should be on FileStore that is writable
+         */
+        assertTrue(!dir.getFileStore().isReadOnly());
+
+        /**
+         * Test: Two files should have the same FileStore
+         */
+        FileStore store1 = dir.resolve("foo").createFile().getFileStore();
+        FileStore store2 = dir.resolve("bar").createFile().getFileStore();
+        assertTrue(store1.equals(store2));
+        assertTrue(store2.equals(store1));
+        assertTrue(store1.hashCode() == store2.hashCode());
+
+        /**
+         * Test: File and FileStore attributes
+         */
+        assertTrue(store1.supportsFileAttributeView("basic"));
+
+        /**
+         * Test: Enumerate all FileStores
+         */
+        for (FileStore store: FileSystems.getDefault().getFileStores()) {
+            System.out.format("%s (name=%s type=%s)\n", store, store.name(),
+                store.type());
+            Attributes.readFileStoreSpaceAttributes(store);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/FileSystem/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.FileSystem
+ * @library ..
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.io.IOException;
+
+/**
+ * Simple santity checks for java.nio.file.FileSystem
+ */
+public class Basic {
+
+    static void check(boolean okay, String msg) {
+        if (!okay)
+            throw new RuntimeException(msg);
+    }
+
+    static void checkSupported(FileSystem fs, String... views) {
+        for (String view: views) {
+            check(fs.supportedFileAttributeViews().contains(view),
+                "support for '" + view + "' expected");
+        }
+    }
+
+    public static void main(String[] args) throws IOException {
+        FileSystem fs = FileSystems.getDefault();
+
+        // close should throw UOE
+        try {
+            fs.close();
+            throw new RuntimeException("UnsupportedOperationException expected");
+        } catch (UnsupportedOperationException e) { }
+        check(fs.isOpen(), "should be open");
+
+        check(!fs.isReadOnly(), "should provide read-write access");
+
+        check(fs.provider().getScheme().equals("file"),
+            "should use 'file' scheme");
+
+        // santity check method - need to re-visit this in future as I/O errors
+        // are possible
+        for (FileStore store: fs.getFileStores()) {
+            System.out.println(store);
+        }
+
+        // sanity check supportedFileAttributeViews
+        checkSupported(fs, "basic");
+        String os = System.getProperty("os.name");
+        if (os.equals("SunOS"))
+            checkSupported(fs, "posix", "unix", "owner", "acl", "xattr");
+        if (os.equals("Linux"))
+            checkSupported(fs, "posix", "unix", "owner", "dos", "xattr");
+        if (os.equals("Windows"))
+            checkSupported(fs, "owner", "dos", "acl", "xattr");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Files/ContentType.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.nio.file.*;
+import java.io.*;
+
+/**
+ * Uses Files.probeContentType to probe html file and custom file type.
+ */
+
+public class ContentType {
+
+    static FileRef createHtmlFile() throws IOException {
+        Path file = File.createTempFile("foo", ".html").toPath();
+        OutputStream out = file.newOutputStream();
+        try {
+            out.write("<html><body>foo</body></html>".getBytes());
+        } finally {
+            out.close();
+        }
+
+        return file;
+    }
+
+    static FileRef createUnknownFile() throws IOException {
+        return File.createTempFile("unknown", "unknown-file-type-789").toPath();
+    }
+
+    static FileRef createGrapeFile() throws IOException {
+        return File.createTempFile("red", ".grape").toPath();
+    }
+
+    public static void main(String[] args) throws IOException {
+
+        // exercise default file type detector
+        FileRef file = createHtmlFile();
+        try {
+            String type = Files.probeContentType(file);
+            if (type == null) {
+                System.err.println("Content type cannot be determined - test skipped");
+            } else {
+                if (!type.equals("text/html"))
+                    throw new RuntimeException("Unexpected type: " + type);
+            }
+        } finally {
+            file.delete();
+        }
+        file = createUnknownFile();
+        try {
+            String type = Files.probeContentType(file);
+            if (type != null)
+                 throw new RuntimeException(file + " should not be recognized as:" +
+                     type);
+        } finally {
+            file.delete();
+        }
+
+        // exercise custom file type detector
+        file = createGrapeFile();
+        try {
+            String type = Files.probeContentType(file);
+            if (type == null)
+                throw new RuntimeException("Custom file type detector not installed?");
+            if (!type.equals("grape/unknown"))
+                throw new RuntimeException("Unexpected type: " + type);
+        } finally {
+            file.delete();
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Files/CreateFileTree.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.nio.file.*;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * Creates a file tree with possible cycles caused by symbolic links
+ * to ancestor directories.
+ */
+
+public class CreateFileTree {
+
+    static final Random rand = new Random();
+
+    public static Path createTemporaryDirectory() throws IOException {
+        Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir"));
+        Path dir;
+        do {
+            dir = tmpdir.resolve("name" + rand.nextInt());
+        } while (dir.exists());
+        dir.createDirectory();
+        return dir;
+    }
+
+    public static void main(String[] args) throws IOException {
+        Path top = createTemporaryDirectory();
+        if (!top.isAbsolute())
+            top = top.toAbsolutePath();
+
+        List<Path> dirs = new ArrayList<Path>();
+
+        // create tree
+        Queue<Path> queue = new ArrayDeque<Path>();
+        queue.add(top);
+        int total = 1 + rand.nextInt(20);
+        int n = 0;
+        Path dir;
+        while (((dir = queue.poll()) != null) && (n < total)) {
+            int r = Math.min((total-n), (1+rand.nextInt(3)));
+            for (int i=0; i<r; i++) {
+                String name = "dir" + (++n);
+                Path subdir = dir.resolve(name).createDirectory();
+                queue.offer(subdir);
+                dirs.add(subdir);
+            }
+        }
+        assert dirs.size() >= 2;
+
+        // create a few regular files in the file tree
+        int files = dirs.size() * 3;
+        for (int i=0; i<files; i++) {
+            String name = "file" + (i+1);
+            int x = rand.nextInt(dirs.size());
+            dirs.get(x).resolve(name).createFile();
+        }
+
+        // create a few sym links in the file tree so as to create cycles
+        int links = 1 + rand.nextInt(5);
+        for (int i=0; i<links; i++) {
+            int x = rand.nextInt(dirs.size());
+            int y;
+            do {
+                y = rand.nextInt(dirs.size());
+            } while (y != x);
+            String name = "link" + (i+1);
+            Path link = dirs.get(x).resolve(name);
+            Path target = dirs.get(y);
+            link.createSymbolicLink(target);
+        }
+
+        // done
+        System.out.println(top);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Files/ForceLoad.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Test library dependencies by invoking Files.probeContentType
+ *     before other methods that would cause nio.dll to be loaded.
+ */
+
+import java.nio.file.*;
+import java.io.IOException;
+
+public class ForceLoad {
+
+    public static void main(String[] args) throws IOException {
+        Files.probeContentType(Paths.get("."));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Files/META-INF/services/java.nio.file.spi.FileTypeDetector	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,1 @@
+SimpleFileTypeDetector
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Files/Misc.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.Files for miscellenous cases not
+ *   covered by other tests
+ * @library ..
+ */
+
+import java.nio.file.*;
+import java.io.IOException;
+import java.util.*;
+
+public class Misc {
+
+    static void npeExpected() {
+        throw new RuntimeException("NullPointerException expected");
+    }
+
+    public static void main(String[] args) throws IOException {
+        try {
+            Files.probeContentType(null);
+            npeExpected();
+        } catch (NullPointerException e) {
+        }
+
+        try {
+            Files.withDirectory(null, "*", new FileAction<Path>() {
+                public void invoke(Path entry) {
+                }
+            });
+            npeExpected();
+        } catch (NullPointerException e) {
+        }
+
+       try {
+            Files.withDirectory(Paths.get("."), (String)null, new FileAction<Path>() {
+                public void invoke(Path entry) {
+                }
+            });
+            npeExpected();
+        } catch (NullPointerException e) {
+        }
+
+        try {
+            Files.withDirectory(Paths.get("."), "*", null);
+            npeExpected();
+        } catch (NullPointerException e) {
+        }
+
+        // test propogation of IOException
+        Path tmpdir = TestUtil.createTemporaryDirectory();
+        try {
+            tmpdir.resolve("foo").createFile();
+            try {
+                Files.withDirectory(tmpdir, new FileAction<Path>() {
+                    public void invoke(Path entry) throws IOException {
+                        throw new IOException();
+                    }
+                });
+                throw new RuntimeException("IOException expected");
+            } catch (IOException e) {
+            }
+        } finally {
+            TestUtil.removeAll(tmpdir);
+        }
+
+        try {
+            Files.walkFileTree(null, EnumSet.noneOf(FileVisitOption.class),
+                Integer.MAX_VALUE, new SimpleFileVisitor<Path>(){});
+            npeExpected();
+        } catch (NullPointerException e) {
+        }
+
+        try {
+            Files.walkFileTree(Paths.get("."), null, Integer.MAX_VALUE,
+                new SimpleFileVisitor<Path>(){});
+            npeExpected();
+        } catch (NullPointerException e) {
+        }
+
+        try {
+            Files.walkFileTree(Paths.get("."), EnumSet.noneOf(FileVisitOption.class),
+                -1, new SimpleFileVisitor<Path>(){});
+            throw new RuntimeException("IllegalArgumentExpected expected");
+        } catch (IllegalArgumentException e) {
+        }
+
+        try {
+            Set<FileVisitOption> opts = new HashSet<FileVisitOption>(1);
+            opts.add(null);
+            Files.walkFileTree(Paths.get("."), opts, Integer.MAX_VALUE,
+                new SimpleFileVisitor<Path>(){});
+            npeExpected();
+        } catch (NullPointerException e) {
+        }
+
+        try {
+            Files.walkFileTree(Paths.get("."), EnumSet.noneOf(FileVisitOption.class),
+                Integer.MAX_VALUE, null);
+            npeExpected();
+        } catch (NullPointerException e) {
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Files/PrintFileTree.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * Invokes Files.walkFileTree to traverse a file tree and prints
+ * each of the directories and files. The -L option causes symbolic
+ * links to be followed.
+ */
+
+public class PrintFileTree {
+
+    public static void main(String[] args) throws Exception {
+        boolean followLinks = false;
+        Path dir;
+
+        if (args[0].equals("-L")) {
+            followLinks = true;
+            dir = Paths.get(args[1]);
+        } else {
+            dir = Paths.get(args[0]);
+        }
+
+        Set<FileVisitOption> options = new HashSet<FileVisitOption>();
+        if (followLinks)
+            options.add(FileVisitOption.FOLLOW_LINKS);
+
+        Files.walkFileTree(dir, options, Integer.MAX_VALUE, new FileVisitor<FileRef>() {
+            public FileVisitResult preVisitDirectory(FileRef dir) {
+                System.out.println(dir);
+                return FileVisitResult.CONTINUE;
+            }
+            public FileVisitResult preVisitDirectoryFailed(FileRef dir, IOException exc) {
+                exc.printStackTrace();
+                return FileVisitResult.CONTINUE;
+            }
+            public FileVisitResult visitFile(FileRef file, BasicFileAttributes attrs) {
+                System.out.println(file);
+                return FileVisitResult.CONTINUE;
+            }
+            public FileVisitResult postVisitDirectory(FileRef dir, IOException exc) {
+                if (exc != null) {
+                    exc.printStackTrace();
+                    return FileVisitResult.TERMINATE;
+                }
+                return FileVisitResult.CONTINUE;
+            }
+            public FileVisitResult visitFileFailed(FileRef file, IOException exc) {
+                exc.printStackTrace();
+                return FileVisitResult.TERMINATE;
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Files/SimpleFileTypeDetector.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.nio.file.*;
+import java.nio.file.spi.FileTypeDetector;
+import java.io.*;
+
+
+public class SimpleFileTypeDetector extends FileTypeDetector {
+    public SimpleFileTypeDetector() {
+    }
+
+    public String probeContentType(FileRef file) throws IOException {
+
+        System.out.println("probe " + file + "...");
+
+        if (file instanceof Path) {
+            String name = ((Path)file).toString();
+            if (name.endsWith(".grape")) {
+                return "grape/unknown";
+            }
+        }
+
+        // unknown
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Files/SkipSiblings.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * Unit test for Files.walkFileTree to test SKIP_SIBLINGS return value.
+ */
+
+public class SkipSiblings {
+
+    static final Random rand = new Random();
+    static final Set<Path> skipped = new HashSet<Path>();
+
+    // check if this path's directory has been skipped
+    static void check(Path path) {
+        if (skipped.contains(path.getParent()))
+            throw new RuntimeException(path + " should not have been visited");
+    }
+
+    // indicates if the siblings of this path should be skipped
+    static boolean skip(Path path) {
+        Path parent = path.getParent();
+        if (parent != null && rand.nextBoolean()) {
+            skipped.add(parent);
+            return true;
+        }
+        return false;
+    }
+
+    public static void main(String[] args) throws Exception {
+        Path dir = Paths.get(args[0]);
+
+        Files.walkFileTree(dir, new FileVisitor<Path>() {
+            public FileVisitResult preVisitDirectory(Path dir) {
+                check(dir);
+                if (skip(dir))
+                    return FileVisitResult.SKIP_SIBLINGS;
+                return FileVisitResult.CONTINUE;
+            }
+            public FileVisitResult preVisitDirectoryFailed(Path dir, IOException exc) {
+                throw new RuntimeException(exc);
+            }
+
+            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
+                check(file);
+                if (skip(file))
+                    return FileVisitResult.SKIP_SIBLINGS;
+                return FileVisitResult.CONTINUE;
+            }
+            public FileVisitResult postVisitDirectory(Path dir, IOException x) {
+                if (x != null)
+                    throw new RuntimeException(x);
+                check(dir);
+                return FileVisitResult.CONTINUE;
+            }
+            public FileVisitResult visitFileFailed(Path file, IOException x) {
+                throw new RuntimeException(x);
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Files/TerminateWalk.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * Unit test for Files.walkFileTree to test TERMINATE return value
+ */
+
+public class TerminateWalk {
+
+    static final Random rand = new Random();
+    static boolean terminated;
+
+    static FileVisitResult maybeTerminate() {
+        if (terminated)
+            throw new RuntimeException("FileVisitor invoked after termination");
+        if (rand.nextInt(10) == 0) {
+            terminated = true;
+            return FileVisitResult.TERMINATE;
+        } else {
+            return FileVisitResult.CONTINUE;
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        Path dir = Paths.get(args[0]);
+
+        Files.walkFileTree(dir, new FileVisitor<Path>() {
+            public FileVisitResult preVisitDirectory(Path dir) {
+                return maybeTerminate();
+            }
+            public FileVisitResult preVisitDirectoryFailed(Path dir, IOException exc) {
+                return maybeTerminate();
+            }
+            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
+                return maybeTerminate();
+            }
+            public FileVisitResult postVisitDirectory(Path dir, IOException x) {
+                return maybeTerminate();
+            }
+            public FileVisitResult visitFileFailed(Path file, IOException x) {
+                return maybeTerminate();
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Files/content_type.sh	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,70 @@
+#
+# 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.
+#
+# 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.
+#
+
+# @test
+# @bug 4313887
+# @summary Unit test for probeContentType method
+# @build ContentType SimpleFileTypeDetector
+# @run shell content_type.sh
+
+# if TESTJAVA isn't set then we assume an interactive run.
+
+if [ -z "$TESTJAVA" ]; then
+    TESTSRC=.
+    TESTCLASSES=.
+    JAVA=java
+else
+    JAVA="${TESTJAVA}/bin/java"
+fi
+
+OS=`uname -s`
+case "$OS" in
+    Windows_* )
+        CLASSPATH="${TESTCLASSES};${TESTSRC}"
+        ;;
+    * )
+        CLASSPATH=${TESTCLASSES}:${TESTSRC}
+        ;;
+esac
+export CLASSPATH
+
+failures=0
+
+go() {
+    echo ''
+    $JAVA $1 $2 $3 2>&1
+    if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
+}
+
+# Run the test
+
+go ContentType
+
+#
+# Results
+#
+echo ''
+if [ $failures -gt 0 ];
+  then echo "$failures test(s) failed";
+  else echo "All test(s) passed"; fi
+exit $failures
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Files/walk_file_tree.sh	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,86 @@
+#
+# 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.
+#
+# 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.
+#
+
+# @test
+# @bug 4313887
+# @summary Unit test for walkFileTree method
+# @build CreateFileTree PrintFileTree SkipSiblings TerminateWalk
+# @run shell walk_file_tree.sh
+
+# if TESTJAVA isn't set then we assume an interactive run.
+
+if [ -z "$TESTJAVA" ]; then
+    TESTSRC=.
+    TESTCLASSES=.
+    JAVA=java
+else
+    JAVA="${TESTJAVA}/bin/java"
+fi
+
+OS=`uname -s`
+case "$OS" in
+    Windows_* )
+        echo "This test does not run on Windows" 
+        exit 0
+        ;;
+    * )
+        CLASSPATH=${TESTCLASSES}:${TESTSRC}
+        ;;
+esac
+export CLASSPATH
+
+# create the file tree
+ROOT=`$JAVA CreateFileTree`
+if [ $? != 0 ]; then exit 1; fi
+
+failures=0
+
+# print the file tree and compare output with find(1)
+$JAVA PrintFileTree "$ROOT" > out1
+find "$ROOT" > out2
+diff out1 out2
+if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
+
+# repeat test following links (use -follow instead of -L
+# to allow running on older systems)
+$JAVA PrintFileTree -L "$ROOT" > out1
+find "$ROOT" -follow > out2
+diff out1 out2
+if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
+
+# test SKIP_SIBLINGS
+$JAVA SkipSiblings "$ROOT"
+if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
+
+# test TERMINATE
+$JAVA TerminateWalk "$ROOT"
+if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
+
+# clean-up
+rm -r "$ROOT"
+
+echo ''
+if [ $failures -gt 0 ];
+  then echo "$failures test(s) failed";
+  else echo "Test passed"; fi
+exit $failures
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Path/CopyAndMove.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,983 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.Path copyTo/moveTo methods
+ * @library ..
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.file.*;
+import static java.nio.file.StandardCopyOption.*;
+import static java.nio.file.LinkOption.*;
+import java.nio.file.attribute.*;
+import java.io.*;
+import java.util.*;
+
+public class CopyAndMove {
+    static final Random rand = new Random();
+    static boolean heads() { return rand.nextBoolean(); }
+    static boolean supportsLinks;
+
+    public static void main(String[] args) throws Exception {
+        Path dir1 = TestUtil.createTemporaryDirectory();
+        try {
+            supportsLinks = TestUtil.supportsLinks(dir1);
+
+            // Exercise copyTo
+            doCopyTests(dir1);
+
+            // Exercise moveTo
+            // if test.dir differs to temporary file system then can test
+            // moving between devices
+            String testDir = System.getProperty("test.dir");
+            Path dir2 = (testDir != null) ? Paths.get(testDir) : dir1;
+            doMoveTests(dir1, dir2);
+
+        } finally {
+            TestUtil.removeAll(dir1);
+        }
+    }
+
+    static void checkBasicAttributes(BasicFileAttributes attrs1,
+                                     BasicFileAttributes attrs2)
+    {
+        // check file type
+        assertTrue(attrs1.isRegularFile() == attrs2.isRegularFile());
+        assertTrue(attrs1.isDirectory() == attrs2.isDirectory());
+        assertTrue(attrs1.isSymbolicLink() == attrs2.isSymbolicLink());
+        assertTrue(attrs1.isOther() == attrs2.isOther());
+
+        // check last modified time (assume millisecond precision)
+        long time1 = attrs1.resolution().toMillis(attrs1.lastModifiedTime());
+        long time2 = attrs1.resolution().toMillis(attrs2.lastModifiedTime());
+        assertTrue(time1 == time2);
+
+        // check size
+        if (attrs1.isRegularFile())
+            assertTrue(attrs1.size() == attrs2.size());
+    }
+
+    static void checkPosixAttributes(PosixFileAttributes attrs1,
+                                     PosixFileAttributes attrs2)
+    {
+        assertTrue(attrs1.permissions().equals(attrs2.permissions()));
+        assertTrue(attrs1.owner().equals(attrs2.owner()));
+        assertTrue(attrs1.group().equals(attrs2.group()));
+    }
+
+    static void checkDosAttributes(DosFileAttributes attrs1,
+                                   DosFileAttributes attrs2)
+    {
+        assertTrue(attrs1.isReadOnly() == attrs2.isReadOnly());
+        assertTrue(attrs1.isHidden() == attrs2.isHidden());
+        assertTrue(attrs1.isArchive() == attrs2.isArchive());
+        assertTrue(attrs1.isSystem() == attrs2.isSystem());
+    }
+
+    static void checkNamedAttributes(Map<String,ByteBuffer> attrs1,
+                                     Map<String,ByteBuffer> attrs2)
+    {
+        assert attrs1.size() == attrs2.size();
+        for (String name: attrs1.keySet()) {
+            ByteBuffer bb1 = attrs1.get(name);
+            ByteBuffer bb2 = attrs2.get(name);
+            assertTrue(bb2 != null);
+            assertTrue(bb1.equals(bb2));
+        }
+    }
+
+    static Map<String,ByteBuffer> readNamedAttributes(Path file)
+        throws IOException
+    {
+        NamedAttributeView view = file
+            .getFileAttributeView(NamedAttributeView.class);
+        Map<String,ByteBuffer> result = new HashMap<String,ByteBuffer>();
+        for (String name: view.list()) {
+            int size = view.size(name);
+            ByteBuffer bb = ByteBuffer.allocate(size);
+            int n = view.read(name, bb);
+            assertTrue(n == size);
+            bb.flip();
+            result.put(name, bb);
+        }
+        return result;
+    }
+
+    // move source to target with verification
+    static void moveAndVerify(Path source, Path target, CopyOption... options)
+        throws IOException
+    {
+        // read attributes before file is moved
+        BasicFileAttributes basicAttributes = null;
+        PosixFileAttributes posixAttributes = null;
+        DosFileAttributes dosAttributes = null;
+        Map<String,ByteBuffer> namedAttributes = null;
+
+        // get file attributes of source file
+        String os = System.getProperty("os.name");
+        if (os.equals("SunOS") || os.equals("Linux")) {
+            posixAttributes = Attributes.readPosixFileAttributes(source, NOFOLLOW_LINKS);
+            basicAttributes = posixAttributes;
+        }
+        if (os.startsWith("Windows")) {
+            dosAttributes = Attributes.readDosFileAttributes(source, NOFOLLOW_LINKS);
+            basicAttributes = dosAttributes;
+        }
+        if (basicAttributes == null)
+            basicAttributes = Attributes.readBasicFileAttributes(source, NOFOLLOW_LINKS);
+
+        // hash file contents if regular file
+        int hash = (basicAttributes.isRegularFile()) ? computeHash(source) : 0;
+
+        // record link target if symbolic link
+        Path linkTarget = null;
+        if (basicAttributes.isSymbolicLink())
+            linkTarget = source.readSymbolicLink();
+
+        // read named attributes if available (and file is not a sym link)
+        if (!basicAttributes.isSymbolicLink() &&
+            source.getFileStore().supportsFileAttributeView("xattr"))
+        {
+            namedAttributes = readNamedAttributes(source);
+        }
+
+        // move file
+        source.moveTo(target, options);
+
+        // verify source does not exist
+        assertTrue(source.notExists());
+
+        // verify file contents
+        if (basicAttributes.isRegularFile()) {
+            if (computeHash(target) != hash)
+                throw new RuntimeException("Failed to verify move of regular file");
+        }
+
+        // verify link target
+        if (basicAttributes.isSymbolicLink()) {
+            if (!target.readSymbolicLink().equals(linkTarget))
+                throw new RuntimeException("Failed to verify move of symbolic link");
+        }
+
+        // verify basic attributes
+        checkBasicAttributes(basicAttributes,
+            Attributes.readBasicFileAttributes(target, NOFOLLOW_LINKS));
+
+        // verify POSIX attributes
+        if (posixAttributes != null && !basicAttributes.isSymbolicLink()) {
+            checkPosixAttributes(posixAttributes,
+                Attributes.readPosixFileAttributes(target, NOFOLLOW_LINKS));
+        }
+
+        // verify DOS attributes
+        if (dosAttributes != null && !basicAttributes.isSymbolicLink()) {
+            checkDosAttributes(dosAttributes,
+                Attributes.readDosFileAttributes(target, NOFOLLOW_LINKS));
+        }
+
+        // verify named attributes
+        if (namedAttributes != null &&
+            target.getFileStore().supportsFileAttributeView("xattr"))
+        {
+            checkNamedAttributes(namedAttributes, readNamedAttributes(target));
+        }
+    }
+
+    /**
+     * Tests all possible ways to invoke moveTo
+     */
+    static void doMoveTests(Path dir1, Path dir2) throws IOException {
+        Path source, target, entry;
+
+        boolean sameDevice = dir1.getFileStore().equals(dir2.getFileStore());
+
+        // -- regular file --
+
+        /**
+         * Test: move regular file, target does not exist
+         */
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir1);
+        moveAndVerify(source, target);
+        target.delete();
+
+        /**
+         * Test: move regular file, target exists
+         */
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir1).createFile();
+        try {
+            moveAndVerify(source, target);
+            throw new RuntimeException("FileAlreadyExistsException expected");
+        } catch (FileAlreadyExistsException x) {
+        }
+        target.delete();
+        target.createDirectory();
+        try {
+            moveAndVerify(source, target);
+            throw new RuntimeException("FileAlreadyExistsException expected");
+        } catch (FileAlreadyExistsException x) {
+        }
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: move regular file, target does not exist
+         */
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir1);
+        moveAndVerify(source, target, REPLACE_EXISTING);
+        target.delete();
+
+        /**
+         * Test: move regular file, target exists
+         */
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir1).createFile();
+        moveAndVerify(source, target, REPLACE_EXISTING);
+        target.delete();
+
+        /**
+         * Test: move regular file, target exists and is empty directory
+         */
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir1).createDirectory();
+        moveAndVerify(source, target, REPLACE_EXISTING);
+        target.delete();
+
+        /**
+         * Test: move regular file, target exists and is non-empty directory
+         */
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir1).createDirectory();
+        entry = target.resolve("foo").createFile();
+        try {
+            moveAndVerify(source, target);
+            throw new RuntimeException("FileAlreadyExistsException expected");
+        } catch (FileAlreadyExistsException x) {
+        }
+        entry.delete();
+        source.delete();
+        target.delete();
+
+        /**
+         * Test atomic move of regular file (same file store)
+         */
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir1);
+        moveAndVerify(source, target, ATOMIC_MOVE);
+        target.delete();
+
+        /**
+         * Test atomic move of regular file (different file store)
+         */
+        if (!sameDevice) {
+            source = createSourceFile(dir1);
+            target = getTargetFile(dir2);
+            try {
+                moveAndVerify(source, target, ATOMIC_MOVE);
+                throw new RuntimeException("AtomicMoveNotSupportedException expected");
+            } catch (AtomicMoveNotSupportedException x) {
+            }
+            source.delete();
+        }
+
+        // -- directories --
+
+        /*
+         * Test: move empty directory, target does not exist
+         */
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir1);
+        moveAndVerify(source, target);
+        target.delete();
+
+        /**
+         * Test: move empty directory, target exists
+         */
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir1).createFile();
+        try {
+            moveAndVerify(source, target);
+            throw new RuntimeException("FileAlreadyExistsException expected");
+        } catch (FileAlreadyExistsException x) {
+        }
+        target.delete();
+        target.createDirectory();
+        try {
+            moveAndVerify(source, target);
+            throw new RuntimeException("FileAlreadyExistsException expected");
+        } catch (FileAlreadyExistsException x) {
+        }
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: move empty directory, target does not exist
+         */
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir1);
+        moveAndVerify(source, target, REPLACE_EXISTING);
+        target.delete();
+
+        /**
+         * Test: move empty directory, target exists
+         */
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir1).createFile();
+        moveAndVerify(source, target, REPLACE_EXISTING);
+        target.delete();
+
+        /**
+         * Test: move empty, target exists and is empty directory
+         */
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir1).createDirectory();
+        moveAndVerify(source, target, REPLACE_EXISTING);
+        target.delete();
+
+        /**
+         * Test: move empty directory, target exists and is non-empty directory
+         */
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir1).createDirectory();
+        entry = target.resolve("foo").createFile();
+        try {
+            moveAndVerify(source, target, REPLACE_EXISTING);
+            throw new RuntimeException("FileAlreadyExistsException expected");
+        } catch (FileAlreadyExistsException x) {
+        }
+        entry.delete();
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: move non-empty directory (same file system)
+         */
+        source = createSourceDirectory(dir1);
+        source.resolve("foo").createFile();
+        target = getTargetFile(dir1);
+        moveAndVerify(source, target);
+        target.resolve("foo").delete();
+        target.delete();
+
+        /**
+         * Test: move non-empty directory (different file store)
+         */
+        if (!sameDevice) {
+            source = createSourceDirectory(dir1);
+            source.resolve("foo").createFile();
+            target = getTargetFile(dir2);
+            try {
+                moveAndVerify(source, target);
+                throw new RuntimeException("IOException expected");
+            } catch (IOException x) {
+            }
+            source.resolve("foo").delete();
+            source.delete();
+        }
+
+        /**
+         * Test atomic move of directory (same file store)
+         */
+        source = createSourceDirectory(dir1);
+        source.resolve("foo").createFile();
+        target = getTargetFile(dir1);
+        moveAndVerify(source, target, ATOMIC_MOVE);
+        target.resolve("foo").delete();
+        target.delete();
+
+        // -- symbolic links --
+
+        /**
+         * Test: Move symbolic link to file, target does not exist
+         */
+        if (supportsLinks) {
+            Path tmp = createSourceFile(dir1);
+            source = dir1.resolve("link").createSymbolicLink(tmp);
+            target = getTargetFile(dir1);
+            moveAndVerify(source, target);
+            target.delete();
+            tmp.delete();
+        }
+
+        /**
+         * Test: Move symbolic link to directory, target does not exist
+         */
+        if (supportsLinks) {
+            source = dir1.resolve("link").createSymbolicLink(dir2);
+            target = getTargetFile(dir1);
+            moveAndVerify(source, target);
+            target.delete();
+        }
+
+        /**
+         * Test: Move broken symbolic link, target does not exists
+         */
+        if (supportsLinks) {
+            Path tmp = Paths.get("doesnotexist");
+            source = dir1.resolve("link").createSymbolicLink(tmp);
+            target = getTargetFile(dir1);
+            moveAndVerify(source, target);
+            target.delete();
+        }
+
+        /**
+         * Test: Move symbolic link, target exists
+         */
+        if (supportsLinks) {
+            source = dir1.resolve("link").createSymbolicLink(dir2);
+            target = getTargetFile(dir1).createFile();
+            try {
+                moveAndVerify(source, target);
+                throw new RuntimeException("FileAlreadyExistsException expected");
+            } catch (FileAlreadyExistsException x) {
+            }
+            source.delete();
+            target.delete();
+        }
+
+        /**
+         * Test: Move regular file, target exists
+         */
+        if (supportsLinks) {
+            source = dir1.resolve("link").createSymbolicLink(dir2);
+            target = getTargetFile(dir1).createFile();
+            moveAndVerify(source, target, REPLACE_EXISTING);
+            target.delete();
+        }
+
+        /**
+         * Test: move symbolic link, target exists and is empty directory
+         */
+        if (supportsLinks) {
+            source = dir1.resolve("link").createSymbolicLink(dir2);
+            target = getTargetFile(dir1).createDirectory();
+            moveAndVerify(source, target, REPLACE_EXISTING);
+            target.delete();
+        }
+
+        /**
+         * Test: symbolic link, target exists and is non-empty directory
+         */
+        if (supportsLinks) {
+            source = dir1.resolve("link").createSymbolicLink(dir2);
+            target = getTargetFile(dir1).createDirectory();
+            entry = target.resolve("foo").createFile();
+            try {
+                moveAndVerify(source, target);
+                throw new RuntimeException("FileAlreadyExistsException expected");
+            } catch (FileAlreadyExistsException x) {
+            }
+            entry.delete();
+            source.delete();
+            target.delete();
+        }
+
+        /**
+         * Test atomic move of symbolic link (same file store)
+         */
+        if (supportsLinks) {
+            source = dir1.resolve("link").createSymbolicLink(dir1);
+            target = getTargetFile(dir1).createFile();
+            moveAndVerify(source, target, REPLACE_EXISTING);
+            target.delete();
+        }
+
+        // -- misc. tests --
+
+        /**
+         * Test nulls
+         */
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir1);
+        try {
+            source.moveTo(null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException x) { }
+        try {
+            source.moveTo(target, (CopyOption[])null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException x) { }
+        try {
+            CopyOption[] opts = { REPLACE_EXISTING, null };
+            source.moveTo(target, opts);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException x) { }
+        source.delete();
+
+        /**
+         * Test UOE
+         */
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir1);
+        try {
+            source.moveTo(target, new CopyOption() { });
+        } catch (UnsupportedOperationException x) { }
+        try {
+            source.moveTo(target, REPLACE_EXISTING,  new CopyOption() { });
+        } catch (UnsupportedOperationException x) { }
+        source.delete();
+    }
+
+    // copy source to target with verification
+    static void copyAndVerify(Path source, Path target, CopyOption... options)
+        throws IOException
+    {
+        source.copyTo(target, options);
+
+        // get attributes of source and target file to verify copy
+        boolean followLinks = true;
+        LinkOption[] linkOptions = new LinkOption[0];
+        boolean copyAttributes = false;
+        for (CopyOption opt : options) {
+            if (opt == NOFOLLOW_LINKS) {
+                followLinks = false;
+                linkOptions = new LinkOption[] { NOFOLLOW_LINKS };
+            }
+            if (opt == COPY_ATTRIBUTES)
+                copyAttributes = true;
+        }
+        BasicFileAttributes basicAttributes = Attributes
+            .readBasicFileAttributes(source, linkOptions);
+
+        // check hash if regular file
+        if (basicAttributes.isRegularFile())
+            assertTrue(computeHash(source) == computeHash(target));
+
+        // check link target if symbolic link
+        if (basicAttributes.isSymbolicLink())
+            assert( source.readSymbolicLink().equals(target.readSymbolicLink()));
+
+        // check that attributes are copied
+        if (copyAttributes && followLinks) {
+            checkBasicAttributes(basicAttributes,
+                Attributes.readBasicFileAttributes(source, linkOptions));
+
+            // check POSIX attributes are copied
+            String os = System.getProperty("os.name");
+            if (os.equals("SunOS") || os.equals("Linux")) {
+                checkPosixAttributes(
+                    Attributes.readPosixFileAttributes(source, linkOptions),
+                    Attributes.readPosixFileAttributes(target, linkOptions));
+            }
+
+            // check DOS attributes are copied
+            if (os.startsWith("Windows")) {
+                checkDosAttributes(
+                    Attributes.readDosFileAttributes(source, linkOptions),
+                    Attributes.readDosFileAttributes(target, linkOptions));
+            }
+
+            // check named attributes are copied
+            if (followLinks &&
+                source.getFileStore().supportsFileAttributeView("xattr") &&
+                target.getFileStore().supportsFileAttributeView("xattr"))
+            {
+                checkNamedAttributes(readNamedAttributes(source),
+                                     readNamedAttributes(target));
+            }
+        }
+    }
+
+    /**
+     * Tests all possible ways to invoke copyTo
+     */
+    static void doCopyTests(Path dir) throws IOException {
+        Path source, target, link, entry;
+
+        // -- regular file --
+
+        /**
+         * Test: move regular file, target does not exist
+         */
+        source = createSourceFile(dir);
+        target = getTargetFile(dir);
+        copyAndVerify(source, target);
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: copy regular file, target exists
+         */
+        source = createSourceFile(dir);
+        target = getTargetFile(dir).createFile();
+        try {
+            copyAndVerify(source, target);
+            throw new RuntimeException("FileAlreadyExistsException expected");
+        } catch (FileAlreadyExistsException x) {
+        }
+        target.delete();
+        target.createDirectory();
+        try {
+            copyAndVerify(source, target);
+            throw new RuntimeException("FileAlreadyExistsException expected");
+        } catch (FileAlreadyExistsException x) {
+        }
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: copy regular file, target does not exist
+         */
+        source = createSourceFile(dir);
+        target = getTargetFile(dir);
+        copyAndVerify(source, target, REPLACE_EXISTING);
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: copy regular file, target exists
+         */
+        source = createSourceFile(dir);
+        target = getTargetFile(dir).createFile();
+        copyAndVerify(source, target, REPLACE_EXISTING);
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: copy regular file, target exists and is empty directory
+         */
+        source = createSourceFile(dir);
+        target = getTargetFile(dir).createDirectory();
+        copyAndVerify(source, target, REPLACE_EXISTING);
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: copy regular file, target exists and is non-empty directory
+         */
+        source = createSourceFile(dir);
+        target = getTargetFile(dir).createDirectory();
+        entry = target.resolve("foo").createFile();
+        try {
+            copyAndVerify(source, target);
+            throw new RuntimeException("FileAlreadyExistsException expected");
+        } catch (FileAlreadyExistsException x) {
+        }
+        entry.delete();
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: copy regular file + attributes
+         */
+        source = createSourceFile(dir);
+        target = getTargetFile(dir);
+        copyAndVerify(source, target, COPY_ATTRIBUTES);
+        source.delete();
+        target.delete();
+
+
+        // -- directory --
+
+        /*
+         * Test: copy directory, target does not exist
+         */
+        source = createSourceDirectory(dir);
+        target = getTargetFile(dir);
+        copyAndVerify(source, target);
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: copy directory, target exists
+         */
+        source = createSourceDirectory(dir);
+        target = getTargetFile(dir).createFile();
+        try {
+            copyAndVerify(source, target);
+            throw new RuntimeException("FileAlreadyExistsException expected");
+        } catch (FileAlreadyExistsException x) {
+        }
+        target.delete();
+        target.createDirectory();
+        try {
+            copyAndVerify(source, target);
+            throw new RuntimeException("FileAlreadyExistsException expected");
+        } catch (FileAlreadyExistsException x) {
+        }
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: copy directory, target does not exist
+         */
+        source = createSourceDirectory(dir);
+        target = getTargetFile(dir);
+        copyAndVerify(source, target, REPLACE_EXISTING);
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: copy directory, target exists
+         */
+        source = createSourceDirectory(dir);
+        target = getTargetFile(dir).createFile();
+        copyAndVerify(source, target, REPLACE_EXISTING);
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: copy directory, target exists and is empty directory
+         */
+        source = createSourceDirectory(dir);
+        target = getTargetFile(dir).createDirectory();
+        copyAndVerify(source, target, REPLACE_EXISTING);
+        source.delete();
+        target.delete();
+
+        /**
+         * Test: copy directory, target exists and is non-empty directory
+         */
+        source = createSourceDirectory(dir);
+        target = getTargetFile(dir).createDirectory();
+        entry = target.resolve("foo").createFile();
+        try {
+            copyAndVerify(source, target, REPLACE_EXISTING);
+            throw new RuntimeException("FileAlreadyExistsException expected");
+        } catch (FileAlreadyExistsException x) {
+        }
+        entry.delete();
+        source.delete();
+        target.delete();
+
+        /*
+         * Test: copy directory + attributes
+         */
+        source = createSourceDirectory(dir);
+        target = getTargetFile(dir);
+        copyAndVerify(source, target, COPY_ATTRIBUTES);
+        source.delete();
+        target.delete();
+
+        // -- symbolic links --
+
+        /**
+         * Test: Follow link
+         */
+        if (supportsLinks) {
+            source = createSourceFile(dir);
+            link = dir.resolve("link").createSymbolicLink(source);
+            target = getTargetFile(dir);
+            copyAndVerify(link, target);
+            link.delete();
+            source.delete();
+        }
+
+        /**
+         * Test: Copy link (to file)
+         */
+        if (supportsLinks) {
+            source = createSourceFile(dir);
+            link = dir.resolve("link").createSymbolicLink(source);
+            target = getTargetFile(dir);
+            copyAndVerify(link, target, NOFOLLOW_LINKS);
+            link.delete();
+            source.delete();
+        }
+
+        /**
+         * Test: Copy link (to directory)
+         */
+        if (supportsLinks) {
+            source = dir.resolve("mydir").createDirectory();
+            link = dir.resolve("link").createSymbolicLink(source);
+            target = getTargetFile(dir);
+            copyAndVerify(link, target, NOFOLLOW_LINKS);
+            link.delete();
+            source.delete();
+        }
+
+        /**
+         * Test: Copy broken link
+         */
+        if (supportsLinks) {
+            assertTrue(source.notExists());
+            link = dir.resolve("link").createSymbolicLink(source);
+            target = getTargetFile(dir);
+            copyAndVerify(link, target, NOFOLLOW_LINKS);
+            link.delete();
+        }
+
+        /**
+         * Test: Copy link to UNC (Windows only)
+         */
+        if (supportsLinks &&
+            System.getProperty("os.name").startsWith("Windows"))
+        {
+            Path unc = Paths.get("\\\\rialto\\share\\file");
+            link = dir.resolve("link").createSymbolicLink(unc);
+            target = getTargetFile(dir);
+            copyAndVerify(link, target, NOFOLLOW_LINKS);
+            link.delete();
+        }
+
+        // -- misc. tests --
+
+        /**
+         * Test nulls
+         */
+        source = createSourceFile(dir);
+        target = getTargetFile(dir);
+        try {
+            source.copyTo(null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException x) { }
+        try {
+            source.copyTo(target, (CopyOption[])null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException x) { }
+        try {
+            CopyOption[] opts = { REPLACE_EXISTING, null };
+            source.copyTo(target, opts);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException x) { }
+        source.delete();
+
+        /**
+         * Test UOE
+         */
+        source = createSourceFile(dir);
+        target = getTargetFile(dir);
+        try {
+            source.copyTo(target, new CopyOption() { });
+        } catch (UnsupportedOperationException x) { }
+        try {
+            source.copyTo(target, REPLACE_EXISTING,  new CopyOption() { });
+        } catch (UnsupportedOperationException x) { }
+        source.delete();
+    }
+
+
+    static void assertTrue(boolean value) {
+        if (!value)
+            throw new RuntimeException("Assertion failed");
+    }
+
+    // computes simple hash of the given file
+    static int computeHash(Path file) throws IOException {
+        int h = 0;
+
+        InputStream in = file.newInputStream();
+        try {
+            byte[] buf = new byte[1024];
+            int n;
+            do {
+                n = in.read(buf);
+                for (int i=0; i<n; i++) {
+                    h = 31*h + (buf[i] & 0xff);
+                }
+            } while (n > 0);
+        } finally {
+            in.close();
+        }
+        return h;
+    }
+
+    // create file of random size in given directory
+    static Path createSourceFile(Path dir) throws IOException {
+        String name = "source" + Integer.toString(rand.nextInt());
+        Path file = dir.resolve(name).createFile();
+        byte[] bytes = new byte[rand.nextInt(128*1024)];
+        rand.nextBytes(bytes);
+        OutputStream out = file.newOutputStream();
+        try {
+            out.write(bytes);
+        } finally {
+            out.close();
+        }
+        randomizeAttributes(file);
+        return file;
+    }
+
+    // create directory in the given directory
+    static Path createSourceDirectory(Path dir) throws IOException {
+        String name = "sourcedir" + Integer.toString(rand.nextInt());
+        Path subdir = dir.resolve(name).createDirectory();
+        randomizeAttributes(subdir);
+        return subdir;
+    }
+
+    // "randomize" the file attributes of the given file.
+    static void randomizeAttributes(Path file) throws IOException {
+        String os = System.getProperty("os.name");
+        boolean isWindows = os.startsWith("Windows");
+        boolean isUnix = os.equals("SunOS") || os.equals("Linux");
+        boolean isDirectory = Attributes.readBasicFileAttributes(file, NOFOLLOW_LINKS)
+            .isDirectory();
+
+        if (isUnix) {
+            Set<PosixFilePermission> perms = Attributes
+                .readPosixFileAttributes(file, NOFOLLOW_LINKS).permissions();
+            PosixFilePermission[] toChange = {
+                PosixFilePermission.GROUP_READ,
+                PosixFilePermission.GROUP_WRITE,
+                PosixFilePermission.GROUP_EXECUTE,
+                PosixFilePermission.OTHERS_READ,
+                PosixFilePermission.OTHERS_WRITE,
+                PosixFilePermission.OTHERS_EXECUTE
+            };
+            for (PosixFilePermission perm: toChange) {
+                if (heads()) {
+                    perms.add(perm);
+                } else {
+                    perms.remove(perm);
+                }
+            }
+            Attributes.setPosixFilePermissions(file, perms);
+        }
+
+        if (isWindows) {
+            DosFileAttributeView view = file
+                .getFileAttributeView(DosFileAttributeView.class, NOFOLLOW_LINKS);
+            // only set or unset the hidden attribute
+            view.setHidden(heads());
+        }
+
+        boolean addNamedAttributes = heads() &&
+            file.getFileStore().supportsFileAttributeView("xattr");
+
+        // remove this when copying a direcory copies its named streams
+        if (isWindows && isDirectory) addNamedAttributes = false;
+
+        if (addNamedAttributes) {
+            NamedAttributeView view = file
+                .getFileAttributeView(NamedAttributeView.class);
+            int n = rand.nextInt(16);
+            while (n > 0) {
+                byte[] value = new byte[1 + rand.nextInt(100)];
+                view.write("user." + Integer.toString(n), ByteBuffer.wrap(value));
+                n--;
+            }
+        }
+    }
+
+    // create name for file in given directory
+    static Path getTargetFile(Path dir) throws IOException {
+        String name = "target" + Integer.toString(rand.nextInt());
+        return dir.resolve(name);
+    }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Path/DeleteOnClose.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.nio.file.*;
+import static java.nio.file.StandardOpenOption.*;
+import java.io.*;
+import java.util.*;
+
+public class DeleteOnClose {
+
+    public static void main(String[] args) throws IOException {
+        // open file but do not close it. Its existance will be checked by
+        // the calling script.
+        Paths.get(args[0]).newByteChannel(READ, WRITE, DELETE_ON_CLOSE);
+
+        // check temporary file has been deleted after closing it
+        Path file = File.createTempFile("blah", "tmp").toPath();
+        file.newByteChannel(READ, WRITE, DELETE_ON_CLOSE).close();
+        if (file.exists())
+            throw new RuntimeException("Temporary file was not deleted");
+
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            // check that DELETE_ON_CLOSE fails when file is a sym link
+            if (TestUtil.supportsLinks(dir)) {
+                file = dir.resolve("foo").createFile();
+                Path link = dir.resolve("link").createSymbolicLink(file);
+                try {
+                    link.newByteChannel(READ, WRITE, DELETE_ON_CLOSE);
+                    throw new RuntimeException("IOException expected");
+                } catch (IOException ignore) { }
+            }
+
+            // check that DELETE_ON_CLOSE works with files created via open
+            // directories
+            DirectoryStream stream = dir.newDirectoryStream();
+            try {
+                if (stream instanceof SecureDirectoryStream) {
+                    SecureDirectoryStream secure = (SecureDirectoryStream)stream;
+                    file = Paths.get("foo");
+
+                    Set<OpenOption> opts = new HashSet<OpenOption>();
+                    opts.add(WRITE);
+                    opts.add(DELETE_ON_CLOSE);
+                    secure.newByteChannel(file, opts).close();
+
+                    if (dir.resolve(file).exists())
+                        throw new RuntimeException("File not deleted");
+                }
+            } finally {
+                stream.close();
+            }
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Path/InterruptCopy.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for Sun-specific ExtendedCopyOption.INTERRUPTIBLE option
+ * @library ..
+ * @run main/othervm -XX:-UseVMInterruptibleIO InterruptCopy
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.Attributes;
+import java.io.*;
+import java.util.concurrent.*;
+import com.sun.nio.file.ExtendedCopyOption;
+
+public class InterruptCopy {
+
+    private static final long FILE_SIZE_TO_COPY = 512 * 1024 * 1024;
+    private static final int DELAY_IN_MS = 500;
+
+    public static void main(String[] args) throws Exception {
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            FileStore store = dir.getFileStore();
+            System.out.format("Checking space (%s)\n", store);
+            long usableSpace = Attributes
+                .readFileStoreSpaceAttributes(store).usableSpace();
+            if (usableSpace < 2*FILE_SIZE_TO_COPY) {
+                System.out.println("Insufficient disk space to run test.");
+                return;
+            }
+            doTest(dir);
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+
+    static void doTest(Path dir) throws Exception {
+        final Path source = dir.resolve("foo");
+        final Path target = dir.resolve("bar");
+
+        // create source file (don't create it as sparse file because we
+        // require the copy to take a long time)
+        System.out.println("Creating source file...");
+        byte[] buf = new byte[32*1024];
+        long total = 0;
+        OutputStream out = source.newOutputStream();
+        try {
+            do {
+                out.write(buf);
+                total += buf.length;
+            } while (total < FILE_SIZE_TO_COPY);
+        } finally {
+            out.close();
+        }
+        System.out.println("Source file created.");
+
+        ScheduledExecutorService pool =
+            Executors.newSingleThreadScheduledExecutor();
+        try {
+            // copy source to target in main thread, interrupting it after a delay
+            final Thread me = Thread.currentThread();
+            pool.schedule(new Runnable() {
+                public void run() {
+                    me.interrupt();
+                }}, DELAY_IN_MS, TimeUnit.MILLISECONDS);
+            System.out.println("Copying file...");
+            try {
+                source.copyTo(target, ExtendedCopyOption.INTERRUPTIBLE);
+                throw new RuntimeException("Copy completed (this is not expected)");
+            } catch (IOException e) {
+                boolean interrupted = Thread.interrupted();
+                if (!interrupted)
+                    throw new RuntimeException("Interrupt status was not set");
+                System.out.println("Copy failed (this is expected)");
+            }
+
+            // copy source to target via task in thread pool, interrupting it after
+            // a delay using cancel(true)
+            Future<Void> result = pool.submit(new Callable<Void>() {
+                public Void call() throws IOException {
+                    System.out.println("Copying file...");
+                    source.copyTo(target, ExtendedCopyOption.INTERRUPTIBLE,
+                        StandardCopyOption.REPLACE_EXISTING);
+                    return null;
+                }
+            });
+            Thread.sleep(DELAY_IN_MS);
+            boolean cancelled = result.cancel(true);
+            if (!cancelled)
+                result.get();
+            System.out.println("Copy cancelled.");
+        } finally {
+            pool.shutdown();
+            pool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Path/Links.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,143 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.Path createSymbolicLink,
+ *     readSymbolicLink, and createLink methods
+ * @library ..
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.io.*;
+import java.util.*;
+
+public class Links {
+
+    static final boolean isWindows =
+        System.getProperty("os.name").startsWith("Windows");
+
+    static void assertTrue(boolean okay) {
+        if (!okay)
+            throw new RuntimeException("Assertion failed");
+    }
+
+    /**
+     * Exercise createSymbolicLink and readLink methods
+     */
+    static void testSymLinks(Path dir) throws IOException {
+        Path link = dir.resolve("link");
+
+        // Check if sym links are supported
+        try {
+            link.createSymbolicLink(Paths.get("foo"));
+            link.delete();
+        } catch (UnsupportedOperationException x) {
+            // sym links not supported
+            return;
+        } catch (IOException x) {
+            // probably insufficient privileges to create sym links (Windows)
+            return;
+        }
+
+        // Test links to various targets
+        String[] windowsTargets =
+            { "foo", "C:\\foo", "\\foo", "\\\\server\\share\\foo" };
+        String[] otherTargets = { "relative", "/absolute" };
+
+        String[] targets = (isWindows) ? windowsTargets : otherTargets;
+        for (String s: targets) {
+            Path target = Paths.get(s);
+            link.createSymbolicLink(target);
+            try {
+                assertTrue(link.readSymbolicLink().equals(target));
+            } finally {
+                link.delete();
+            }
+        }
+    }
+
+    /**
+     * Exercise createLink method
+     */
+    static void testHardLinks(Path dir) throws IOException {
+        Path foo = dir.resolve("foo").createFile();
+        try {
+            Path bar;
+            try {
+                bar = dir.resolve("bar").createLink(foo);
+            } catch (UnsupportedOperationException x) {
+                return;
+            } catch (IOException x) {
+                // probably insufficient privileges (Windows)
+                return;
+            }
+            try {
+                Object key1 = Attributes
+                    .readBasicFileAttributes(foo).fileKey();
+                Object key2 = Attributes
+                    .readBasicFileAttributes(bar).fileKey();
+                assertTrue((key1 == null) || (key1.equals(key2)));
+
+                assertTrue(Attributes
+                    .readBasicFileAttributes(foo).linkCount() >= 2);
+                assertTrue(Attributes
+                    .readBasicFileAttributes(bar).linkCount() >= 2);
+
+            } finally {
+                bar.delete();
+            }
+
+
+        } finally {
+            foo.delete();
+        }
+    }
+
+    public static void main(String[] args) throws IOException {
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            testSymLinks(dir);
+            testHardLinks(dir);
+
+            // repeat tests on Windows with long path
+            if (isWindows) {
+                Path dirWithLongPath = null;
+                try {
+                    dirWithLongPath = TestUtil.createDirectoryWithLongPath(dir);
+                } catch (IOException x) {
+                    System.out.println("Unable to create long path: " + x);
+                }
+                if (dirWithLongPath != null) {
+                    System.out.println("");
+                    System.out.println("** REPEAT TESTS WITH LONG PATH **");
+                    testSymLinks(dirWithLongPath);
+                    testHardLinks(dirWithLongPath);
+                }
+            }
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Path/Misc.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,349 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.Path for miscellenous methods not
+ *   covered by other tests
+ * @library ..
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.io.*;
+import java.util.*;
+
+public class Misc {
+    static final boolean isWindows =
+        System.getProperty("os.name").startsWith("Windows");
+    static boolean supportsLinks;
+
+    public static void main(String[] args) throws IOException {
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            supportsLinks = TestUtil.supportsLinks(dir);
+
+            // equals and hashCode methods
+            equalsAndHashCode();
+
+            // checkAccess method
+            checkAccessTests(dir);
+
+            // toRealPath method
+            toRealPathTests(dir);
+
+            // isSameFile method
+            isSameFileTests(dir);
+
+            // isHidden method
+            isHiddenTests(dir);
+
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+
+    /**
+     * Exercise equals and hashCode methods
+     */
+    static void equalsAndHashCode() {
+
+        Path thisFile = Paths.get("this");
+        Path thatFile = Paths.get("that");
+
+        assertTrue(thisFile.equals(thisFile));
+        assertTrue(!thisFile.equals(thatFile));
+
+        assertTrue(!thisFile.equals(null));
+        assertTrue(!thisFile.equals(new Object()));
+
+        Path likeThis = Paths.get("This");
+        if (isWindows) {
+            // case insensitive
+            assertTrue(thisFile.equals(likeThis));
+            assertTrue(thisFile.hashCode() == likeThis.hashCode());
+        } else {
+            // case senstive
+            assertTrue(!thisFile.equals(likeThis));
+        }
+    }
+
+    /**
+     * Exercise checkAccess method
+     */
+    static void checkAccessTests(Path dir) throws IOException {
+        final Path file = dir.resolve("foo").createFile();
+
+        /**
+         * Test: This directory should readable and writable
+         */
+        dir.checkAccess();
+        dir.checkAccess(AccessMode.READ);
+        dir.checkAccess(AccessMode.WRITE);
+        dir.checkAccess(AccessMode.READ, AccessMode.WRITE);
+
+        /**
+         * Test: File does not exist
+         */
+        Path doesNotExist = dir.resolve("thisDoesNotExists");
+        try {
+            doesNotExist.checkAccess();
+            throw new RuntimeException("NoSuchFileException expected");
+        } catch (NoSuchFileException x) {
+        }
+        try {
+            doesNotExist.checkAccess(AccessMode.READ);
+            throw new RuntimeException("NoSuchFileException expected");
+        } catch (NoSuchFileException x) {
+        }
+        try {
+            doesNotExist.checkAccess(AccessMode.WRITE);
+            throw new RuntimeException("NoSuchFileException expected");
+        } catch (NoSuchFileException x) {
+        }
+        try {
+            doesNotExist.checkAccess(AccessMode.EXECUTE);
+            throw new RuntimeException("NoSuchFileException expected");
+        } catch (NoSuchFileException x) {
+        }
+
+        /**
+         * Test: Edit ACL to deny WRITE and EXECUTE
+         */
+        AclFileAttributeView view = file
+            .getFileAttributeView(AclFileAttributeView.class);
+        if (view != null &&
+            file.getFileStore().supportsFileAttributeView("acl"))
+        {
+            UserPrincipal owner = view.getOwner();
+            List<AclEntry> acl = view.getAcl();
+
+            // Insert entry to deny WRITE and EXECUTE
+            AclEntry entry = AclEntry.newBuilder()
+                .setType(AclEntryType.DENY)
+                .setPrincipal(owner)
+                .setPermissions(AclEntryPermission.WRITE_DATA,
+                    AclEntryPermission.EXECUTE)
+                .build();
+            acl.add(0, entry);
+            view.setAcl(acl);
+
+            try {
+                file.checkAccess(AccessMode.WRITE);
+                throw new RuntimeException("AccessDeniedException expected");
+            } catch (AccessDeniedException x) {
+            }
+
+            try {
+                file.checkAccess(AccessMode.EXECUTE);
+                throw new RuntimeException("AccessDeniedException expected");
+            } catch (AccessDeniedException x) {
+            }
+
+
+            // Restore ACL
+            acl.remove(0);
+            view.setAcl(acl);
+        }
+
+        /**
+         * Test: Windows DOS read-only attribute
+         */
+        if (isWindows) {
+            DosFileAttributeView dview =
+                file.getFileAttributeView(DosFileAttributeView.class);
+            dview.setReadOnly(true);
+            try {
+                file.checkAccess(AccessMode.WRITE);
+                throw new RuntimeException("AccessDeniedException expected");
+            } catch (AccessDeniedException x) {
+            }
+            dview.setReadOnly(false);
+
+            // Read-only attribute does not make direcory read-only
+            dview = dir.getFileAttributeView(DosFileAttributeView.class);
+            boolean save = dview.readAttributes().isReadOnly();
+            dview.setReadOnly(true);
+            dir.checkAccess(AccessMode.WRITE);
+            dview.setReadOnly(save);
+        }
+
+        /**
+         * Test: null
+         */
+        try {
+            file.checkAccess((AccessMode)null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException ignore) { }
+
+        // clean-up
+        file.delete();
+    }
+
+    /**
+     * Exercise toRealPath method
+     */
+    static void toRealPathTests(Path dir) throws IOException {
+        final Path file = dir.resolve("foo").createFile();
+        final Path link = dir.resolve("link");
+
+        /**
+         * Test: toRealPath(true) will access same file as toRealPath(false)
+         */
+        assertTrue(file.toRealPath(true).isSameFile(file.toRealPath(false)));
+
+        /**
+         * Test: toRealPath(true) should resolve links
+         */
+        if (supportsLinks) {
+            link.createSymbolicLink(file.toAbsolutePath());
+            assertTrue(link.toRealPath(true).equals(file.toRealPath(true)));
+            link.delete();
+        }
+
+
+        /**
+         * Test: toRealPath(false) should not resolve links
+         */
+        if (supportsLinks) {
+            link.createSymbolicLink(file.toAbsolutePath());
+            assertTrue(link.toRealPath(false).getName().equals(link.getName()));
+            link.delete();
+        }
+
+        /**
+         * Test: toRealPath should eliminate "."
+         */
+        assertTrue(dir.resolve(".").toRealPath(true).equals(dir.toRealPath(true)));
+        assertTrue(dir.resolve(".").toRealPath(false).equals(dir.toRealPath(false)));
+
+        /**
+         * Test: toRealPath should eliminate ".." when it doesn't follow a
+         *       symbolic link
+         */
+        Path subdir = dir.resolve("subdir").createDirectory();
+        assertTrue(subdir.resolve("..").toRealPath(true).equals(dir.toRealPath(true)));
+        assertTrue(subdir.resolve("..").toRealPath(false).equals(dir.toRealPath(false)));
+        subdir.delete();
+
+        // clean-up
+        file.delete();
+    }
+
+    /**
+     * Exercise isSameFile method
+     */
+    static void isSameFileTests(Path dir) throws IOException {
+        Path thisFile = dir.resolve("thisFile");
+        Path thatFile = dir.resolve("thatFile");
+
+        /**
+         * Test: isSameFile for self and null
+         */
+        assertTrue(thisFile.isSameFile(thisFile));
+        assertTrue(!thisFile.isSameFile(null));
+
+        /**
+         * Test: Neither files exist
+         */
+        try {
+            thisFile.isSameFile(thatFile);
+            throw new RuntimeException("IOException not thrown");
+        } catch (IOException x) {
+        }
+        try {
+            thatFile.isSameFile(thisFile);
+            throw new RuntimeException("IOException not thrown");
+        } catch (IOException x) {
+        }
+
+        thisFile.createFile();
+        try {
+            /**
+             * Test: One file exists
+             */
+            try {
+                thisFile.isSameFile(thatFile);
+                throw new RuntimeException("IOException not thrown");
+            } catch (IOException x) {
+            }
+            try {
+                thatFile.isSameFile(thisFile);
+                throw new RuntimeException("IOException not thrown");
+            } catch (IOException x) {
+            }
+
+            thatFile.createFile();
+
+            /**
+             * Test: Both file exists
+             */
+            try {
+                assertTrue(!thisFile.isSameFile(thatFile));
+                assertTrue(!thatFile.isSameFile(thisFile));
+            } finally {
+                thatFile.delete(false);
+            }
+
+            /**
+             * Test: Symbolic links
+             */
+            if (supportsLinks) {
+                thatFile.createSymbolicLink(thisFile);
+                try {
+                    assertTrue(thisFile.isSameFile(thatFile));
+                    assertTrue(thatFile.isSameFile(thisFile));
+                } finally {
+                    thatFile.delete(false);
+                }
+            }
+        } finally {
+            thisFile.delete(false);
+        }
+    }
+
+    /**
+     * Exercise isHidden method
+     */
+    static void isHiddenTests(Path dir) throws IOException {
+        assertTrue(!dir.isHidden());
+
+        Path file = dir.resolve(".foo");
+        if (isWindows) {
+            file.createFile();
+            try {
+                Attributes.setAttribute(file, "dos:hidden", true);
+                assertTrue(file.isHidden());
+            } finally {
+                file.delete();
+            }
+        } else {
+            assertTrue(file.isHidden());
+        }
+    }
+
+    static void assertTrue(boolean okay) {
+        if (!okay)
+            throw new RuntimeException("Assertion Failed");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Path/PathOps.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,646 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.Path path operations
+ */
+
+import java.nio.file.*;
+
+public class PathOps {
+
+    static final java.io.PrintStream out = System.out;
+
+    private String input;
+    private Path path;
+    private Exception exc;
+
+    private PathOps(String s) {
+        out.println();
+        input = s;
+        try {
+            path = FileSystems.getDefault().getPath(s);
+            out.format("%s -> %s", s, path);
+        } catch (Exception x) {
+            exc = x;
+            out.format("%s -> %s", s, x);
+        }
+        out.println();
+    }
+
+    Path path() {
+        return path;
+    }
+
+    void fail() {
+        throw new RuntimeException("PathOps failed");
+    }
+
+    void checkPath() {
+        if (path == null) {
+            throw new InternalError("path is null");
+        }
+    }
+
+    void check(Object result, String expected) {
+        out.format("\tExpected: %s\n", expected);
+        out.format("\tActual: %s\n",  result);
+        if (result == null) {
+            if (expected == null) return;
+        } else {
+            // compare string representations
+            if (expected != null && result.toString().equals(expected.toString()))
+                return;
+        }
+        fail();
+    }
+
+    void check(Object result, boolean expected) {
+        check(result, Boolean.toString(expected));
+    }
+
+    PathOps root(String expected) {
+        out.println("check root");
+        checkPath();
+        check(path.getRoot(), expected);
+        return this;
+    }
+
+    PathOps parent(String expected) {
+        out.println("check parent");
+        checkPath();
+        check(path.getParent(), expected);
+        return this;
+    }
+
+    PathOps name(String expected) {
+        out.println("check name");
+        checkPath();
+        check(path.getName(), expected);
+        return this;
+    }
+
+    PathOps element(int index, String expected) {
+        out.format("check element %d\n", index);
+        checkPath();
+        check(path.getName(index), expected);
+        return this;
+    }
+
+    PathOps subpath(int startIndex, int endIndex, String expected) {
+        out.format("test subpath(%d,%d)\n", startIndex, endIndex);
+        checkPath();
+        check(path.subpath(startIndex, endIndex), expected);
+        return this;
+    }
+
+    PathOps starts(String prefix) {
+        out.format("test startsWith with %s\n", prefix);
+        checkPath();
+        Path s = FileSystems.getDefault().getPath(prefix);
+        check(path.startsWith(s), true);
+        return this;
+    }
+
+    PathOps notStarts(String prefix) {
+        out.format("test not startsWith with %s\n", prefix);
+        checkPath();
+        Path s = FileSystems.getDefault().getPath(prefix);
+        check(path.startsWith(s), false);
+        return this;
+    }
+
+    PathOps ends(String suffix) {
+        out.format("test endsWith %s\n", suffix);
+        checkPath();
+        Path s = FileSystems.getDefault().getPath(suffix);
+        check(path.endsWith(s), true);
+        return this;
+    }
+
+    PathOps notEnds(String suffix) {
+        out.format("test not endsWith %s\n", suffix);
+        checkPath();
+        Path s = FileSystems.getDefault().getPath(suffix);
+        check(path.endsWith(s), false);
+        return this;
+    }
+
+    PathOps absolute() {
+        out.println("check path is absolute");
+        checkPath();
+        check(path.isAbsolute(), true);
+        return this;
+    }
+
+    PathOps notAbsolute() {
+        out.println("check path is not absolute");
+        checkPath();
+        check(path.isAbsolute(), false);
+        return this;
+    }
+
+    PathOps resolve(String other, String expected) {
+        out.format("test resolve %s\n", other);
+        checkPath();
+        check(path.resolve(other), expected);
+        return this;
+    }
+
+    PathOps relativize(String other, String expected) {
+        out.format("test relativize %s\n", other);
+        checkPath();
+        Path that = FileSystems.getDefault().getPath(other);
+        check(path.relativize(that), expected);
+        return this;
+    }
+
+    PathOps normalize(String expected) {
+        out.println("check normalized path");
+        checkPath();
+        check(path.normalize(), expected);
+        return this;
+    }
+
+    PathOps string(String expected) {
+        out.println("check string representation");
+        checkPath();
+        check(path, expected);
+        return this;
+    }
+
+    PathOps invalid() {
+        if (!(exc instanceof InvalidPathException)) {
+            out.println("InvalidPathException not thrown as expected");
+            fail();
+        }
+        return this;
+    }
+
+    static PathOps test(String s) {
+        return new PathOps(s);
+    }
+
+    // -- PathOpss --
+
+    static void header(String s) {
+        out.println();
+        out.println();
+        out.println("-- " + s + " --");
+    }
+
+    static void doWindowsTests() {
+        header("Windows specific tests");
+
+        // all components present
+        test("C:\\a\\b\\c")
+            .root("C:\\")
+            .parent("C:\\a\\b")
+            .name("c");
+        test("C:a\\b\\c")
+            .root("C:")
+            .parent("C:a\\b")
+            .name("c");
+        test("\\\\server\\share\\a")
+            .root("\\\\server\\share\\")
+            .parent("\\\\server\\share\\")
+            .name("a");
+
+        // root component only
+        test("C:\\")
+            .root("C:\\")
+            .parent(null)
+            .name(null);
+        test("C:")
+            .root("C:")
+            .parent(null)
+            .name(null);
+        test("\\\\server\\share\\")
+            .root("\\\\server\\share\\")
+            .parent(null)
+            .name(null);
+
+        // no root component
+        test("a\\b")
+            .root(null)
+            .parent("a")
+            .name("b");
+
+        // name component only
+        test("foo")
+            .root(null)
+            .parent(null)
+            .name("foo");
+
+        // startsWith and endsWith
+        test("C:\\foo\\bar")
+            .starts("C:\\")
+            .starts("C:\\foo")
+            .starts("C:\\foo\\bar")
+            .notStarts("C:\\f")
+            .notStarts("C:foo")
+            .notStarts("D:")
+            .notStarts("\\foo\\bar")
+            .ends("bar")
+            .ends("foo\\bar")
+            .ends("C:\\foo\\bar")
+            .notEnds("r")
+            .notEnds("C:foo\\bar")
+            .notEnds("o\\bar");
+
+        // elements
+        test("C:\\a\\b\\c")
+            .element(0, "a")
+            .element(1, "b")
+            .element(2, "c");
+        test("foo.bar\\gus.alice")
+            .element(0, "foo.bar")
+            .element(1, "gus.alice");
+
+        // subpath
+        test("C:\\foo")
+            .subpath(0, 1, "foo");
+        test("C:foo")
+            .subpath(0, 1, "foo");
+        test("foo")
+            .subpath(0, 1, "foo");
+        test("C:\\foo\\bar\\gus")
+            .subpath(0, 1, "foo")
+            .subpath(0, 2, "foo\\bar")
+            .subpath(0, 3, "foo\\bar\\gus")
+            .subpath(1, 2, "bar")
+            .subpath(1, 3, "bar\\gus")
+            .subpath(2, 3, "gus");
+        test("\\\\server\\share\\foo")
+            .subpath(0, 1, "foo");
+
+        // isAbsolute
+        test("foo").notAbsolute();
+        test("C:").notAbsolute();
+        test("C:\\").absolute();
+        test("C:\\abc").absolute();
+        test("\\\\server\\share\\").absolute();
+
+        // resolve
+        test("C:\\")
+            .resolve("foo", "C:\\foo")
+            .resolve("D:\\bar", "D:\\bar")
+            .resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar")
+            .resolve("C:foo", "C:\\foo")
+            .resolve("D:foo", "D:foo");
+        test("\\")
+            .resolve("foo", "\\foo")
+            .resolve("D:bar", "D:bar")
+            .resolve("C:\\bar", "C:\\bar")
+            .resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar")
+            .resolve("\\foo", "\\foo");
+        test("\\foo")
+            .resolve("bar", "\\foo\\bar")
+            .resolve("D:bar", "D:bar")
+            .resolve("C:\\bar", "C:\\bar")
+            .resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar")
+            .resolve("\\bar", "\\bar");
+        test("foo")
+            .resolve("bar", "foo\\bar")
+            .resolve("D:\\bar", "D:\\bar")
+            .resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar")
+            .resolve("C:bar", "C:bar")
+            .resolve("D:foo", "D:foo");
+        test("C:")
+            .resolve("foo", "C:foo");
+        test("\\\\server\\share\\foo")
+            .resolve("bar", "\\\\server\\share\\foo\\bar")
+            .resolve("\\bar", "\\\\server\\share\\bar")
+            .resolve("D:\\bar", "D:\\bar")
+            .resolve("\\\\other\\share\\bar", "\\\\other\\share\\bar")
+            .resolve("D:bar", "D:bar");
+
+        // relativize
+        test("foo\\bar")
+            .relativize("foo\\bar", null)
+            .relativize("foo", "..");
+        test("C:\\a\\b\\c")
+            .relativize("C:\\a", "..\\..");
+        test("\\\\server\\share\\foo")
+            .relativize("\\\\server\\share\\bar", "..\\bar");
+
+        // normalize
+        test("C:\\")
+            .normalize("C:\\");
+        test("C:\\.")
+            .normalize("C:\\");
+        test("C:\\..")
+            .normalize("C:\\");
+        test("\\\\server\\share")
+            .normalize("\\\\server\\share\\");
+        test("\\\\server\\share\\.")
+            .normalize("\\\\server\\share\\");
+        test("\\\\server\\share\\..")
+            .normalize("\\\\server\\share\\");
+        test("C:")
+            .normalize("C:");
+        test("C:.")
+            .normalize("C:");
+        test("C:..")
+            .normalize("C:..");
+        test("\\")
+            .normalize("\\");
+        test("\\.")
+            .normalize("\\");
+        test("\\..")
+            .normalize("\\");
+        test("foo")
+            .normalize("foo");
+        test("foo\\.")
+            .normalize("foo");
+        test("foo\\..")
+            .normalize(null);
+        test("C:\\foo")
+            .normalize("C:\\foo");
+        test("C:\\foo\\.")
+            .normalize("C:\\foo");
+        test("C:\\.\\foo")
+            .normalize("C:\\foo");
+        test("C:\\foo\\..")
+            .normalize("C:\\");
+        test("C:\\..\\foo")
+            .normalize("C:\\foo");
+        test("\\\\server\\share\\foo")
+            .normalize("\\\\server\\share\\foo");
+        test("\\\\server\\share\\foo\\.")
+            .normalize("\\\\server\\share\\foo");
+        test("\\\\server\\share\\.\\foo")
+            .normalize("\\\\server\\share\\foo");
+        test("\\\\server\\share\\foo\\..")
+            .normalize("\\\\server\\share\\");
+        test("\\\\server\\share\\..\\foo")
+            .normalize("\\\\server\\share\\foo");
+        test("C:foo")
+            .normalize("C:foo");
+        test("C:foo\\.")
+            .normalize("C:foo");
+        test("C:.\\foo")
+            .normalize("C:foo");
+        test("C:foo\\..")
+            .normalize("C:");
+        test("C:..\\foo")
+            .normalize("C:..\\foo");
+        test("\\foo")
+            .normalize("\\foo");
+        test("\\foo\\.")
+            .normalize("\\foo");
+        test("\\.\\foo")
+            .normalize("\\foo");
+        test("\\foo\\..")
+            .normalize("\\");
+        test("\\..\\foo")
+            .normalize("\\foo");
+        test(".")
+            .normalize(null);
+        test("..")
+            .normalize("..");
+        test("\\..\\..")
+            .normalize("\\");
+        test("..\\..\\foo")
+            .normalize("..\\..\\foo");
+        test("foo\\bar\\..")
+            .normalize("foo");
+        test("foo\\bar\\.\\..")
+            .normalize("foo");
+        test("foo\\bar\\gus\\..\\..")
+            .normalize("foo");
+        test(".\\foo\\.\\bar\\.\\gus\\..\\.\\..")
+            .normalize("foo");
+
+        // UNC corner cases
+        test("\\\\server\\share\\")
+            .root("\\\\server\\share\\")
+            .parent(null)
+            .name(null);
+        test("\\\\server")
+            .invalid();
+        test("\\\\server\\")
+            .invalid();
+        test("\\\\server\\share")
+            .root("\\\\server\\share\\")
+            .parent(null)
+            .name(null);
+
+        // invalid
+        test(":\\foo")
+            .invalid();
+        test("C::")
+            .invalid();
+        test("C:\\?")           // invalid character
+            .invalid();
+        test("C:\\*")           // invalid character
+            .invalid();
+        test("C:\\abc\u0001\\foo")
+            .invalid();
+        test("C:\\\u0019\\foo")
+            .invalid();
+        test("\\\\server\u0019\\share")
+            .invalid();
+        test("\\\\server\\share\u0019")
+            .invalid();
+        test("foo\u0000\bar")
+            .invalid();
+        test("C:\\foo ")                // trailing space
+             .invalid();
+        test("C:\\foo \\bar")
+            .invalid();
+        //test("C:\\foo.")              // trailing dot
+            //.invalid();
+        //test("C:\\foo...\\bar")
+            //.invalid();
+
+        // normalization at construction time (remove redundant and replace slashes)
+        test("C:/a/b/c")
+            .string("C:\\a\\b\\c")
+            .root("C:\\")
+            .parent("C:\\a\\b");
+        test("C://a//b//c")
+            .string("C:\\a\\b\\c")
+            .root("C:\\")
+            .parent("C:\\a\\b");
+
+        // hashCode
+        header("hashCode");
+        int h1 = test("C:\\foo").path().hashCode();
+        int h2 = test("c:\\FOO").path().hashCode();
+        if (h1 != h2)
+            throw new RuntimeException("PathOps failed");
+    }
+
+    static void doUnixTests() {
+        header("Unix specific tests");
+
+        // all components
+        test("/a/b/c")
+            .root("/")
+            .parent("/a/b")
+            .name("c");
+
+        // root component only
+        test("/")
+            .root("/")
+            .parent(null)
+            .name(null);
+
+        // no root component
+        test("a/b")
+            .root(null)
+            .parent("a")
+            .name("b");
+
+        // name component only
+        test("foo")
+            .root(null)
+            .parent(null)
+            .name("foo");
+
+        // elements
+        test("a/b/c")
+            .element(0,"a")
+            .element(1,"b")
+            .element(2,"c");
+
+        // isAbsolute
+        test("/")
+            .absolute();
+        test("/tmp")
+            .absolute();
+        test("tmp")
+            .notAbsolute();
+
+        // resolve
+        test("/tmp")
+            .resolve("foo", "/tmp/foo")
+            .resolve("/foo", "/foo");
+        test("tmp")
+            .resolve("foo", "tmp/foo")
+            .resolve("/foo", "/foo");
+
+        // relativize
+        test("/a/b/c")
+            .relativize("/a/b/c", null)
+            .relativize("/a/b/c/d/e", "d/e")
+            .relativize("/a/x", "../../x");
+
+        // normalize
+        test("/")
+            .normalize("/");
+        test("foo")
+            .normalize("foo");
+        test("/foo")
+            .normalize("/foo");
+        test(".")
+            .normalize(null);
+        test("..")
+            .normalize("..");
+        test("/..")
+            .normalize("/");
+        test("/../..")
+            .normalize("/");
+        test("foo/.")
+            .normalize("foo");
+        test("./foo")
+            .normalize("foo");
+        test("foo/..")
+            .normalize(null);
+        test("../foo")
+            .normalize("../foo");
+        test("../../foo")
+            .normalize("../../foo");
+        test("foo/bar/..")
+            .normalize("foo");
+        test("foo/bar/gus/../..")
+            .normalize("foo");
+        test("/foo/bar/gus/../..")
+            .normalize("/foo");
+
+        // invalid
+        test("foo\u0000\bar")
+            .invalid();
+
+        // normalization
+        test("//foo//bar")
+            .string("/foo/bar")
+            .root("/")
+            .parent("/foo")
+            .name("bar");
+    }
+
+    static void npes() {
+        header("NullPointerException");
+
+        Path path = FileSystems.getDefault().getPath("foo");
+
+        try {
+            path.resolve((String)null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException npe) {
+        }
+
+        try {
+            path.relativize(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException npe) {
+        }
+
+        try {
+            path.compareTo(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException npe) {
+        }
+
+        try {
+            path.startsWith(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException npe) {
+        }
+
+        try {
+            path.endsWith(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException npe) {
+        }
+
+    }
+
+    public static void main(String[] args) {
+        // all platforms
+        npes();
+
+        // operating system specific
+        String osname = System.getProperty("os.name");
+        if (osname.startsWith("Windows")) {
+            doWindowsTests();
+        }
+        if (osname.equals("SunOS") || osname.equals("Linux")) {
+            doUnixTests();
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Path/SBC.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,468 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.Path.newByteChannel
+ * @library ..
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.file.*;
+import static java.nio.file.StandardOpenOption.*;
+import static com.sun.nio.file.ExtendedOpenOption.*;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.channels.*;
+import java.io.IOException;
+import java.util.*;
+
+public class SBC {
+
+    static boolean supportsLinks;
+
+    public static void main(String[] args) throws Exception {
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            supportsLinks = TestUtil.supportsLinks(dir);
+
+            // open options
+            createTests(dir);
+            appendTests(dir);
+            truncateExistingTests(dir);
+            noFollowLinksTests(dir);
+
+            // SeekableByteChannel methods
+            sizeTruncatePositionTests(dir);
+
+            // platform specific
+            if (System.getProperty("os.name").startsWith("Windows"))
+                dosSharingOptionTests(dir);
+
+            // misc. tests
+            badCombinations(dir);
+            unsupportedOptions(dir);
+            nullTests(dir);
+
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+
+    // test CREATE and CREATE_NEW options
+    static void createTests(Path dir) throws Exception {
+        Path file = dir.resolve("foo");
+
+        // CREATE
+        try {
+            // create file (no existing file)
+            file.newByteChannel(CREATE, WRITE).close();
+            if (file.notExists())
+                throw new RuntimeException("File not created");
+
+            // create file (existing file)
+            file.newByteChannel(CREATE, WRITE).close();
+
+            // create file where existing file is a sym link
+            if (supportsLinks) {
+                Path link = dir.resolve("link").createSymbolicLink(file);
+                try {
+                    // file already exists
+                    link.newByteChannel(CREATE, WRITE).close();
+
+                    // file does not exist
+                    file.delete();
+                    link.newByteChannel(CREATE, WRITE).close();
+                    if (file.notExists())
+                        throw new RuntimeException("File not created");
+
+                } finally {
+                    link.delete();
+                }
+            }
+
+        } finally {
+            file.delete(false);
+        }
+
+        // CREATE_NEW
+        try {
+            // create file
+            file.newByteChannel(CREATE_NEW, WRITE).close();
+            if (file.notExists())
+                throw new RuntimeException("File not created");
+
+            // create should fail
+            try {
+                SeekableByteChannel sbc =
+                    file.newByteChannel(CREATE_NEW, WRITE);
+                sbc.close();
+                throw new RuntimeException("FileAlreadyExistsException not thrown");
+            } catch (FileAlreadyExistsException x) { }
+
+            // create should fail
+            if (supportsLinks) {
+                Path link = dir.resolve("link");
+                Path target = dir.resolve("thisDoesNotExist");
+                link.createSymbolicLink(target);
+                try {
+
+                    try {
+                        SeekableByteChannel sbc =
+                            file.newByteChannel(CREATE_NEW, WRITE);
+                        sbc.close();
+                        throw new RuntimeException("FileAlreadyExistsException not thrown");
+                    } catch (FileAlreadyExistsException x) { }
+
+                } finally {
+                    link.delete();
+                }
+            }
+
+
+        } finally {
+            file.delete(false);
+        }
+
+        // CREATE_NEW + SPARSE
+        try {
+            SeekableByteChannel sbc = file
+                .newByteChannel(CREATE_NEW, WRITE, SPARSE);
+            try {
+                final long hole = 2L * 1024L * 1024L * 1024L;
+                sbc.position(hole);
+                write(sbc, "hello");
+                long size = sbc.size();
+                if (size != (hole + 5))
+                    throw new RuntimeException("Unexpected size");
+            } finally {
+                sbc.close();
+            }
+        } finally {
+            file.delete(false);
+        }
+    }
+
+    // test APPEND option
+    static void appendTests(Path dir) throws Exception {
+        Path file = dir.resolve("foo");
+        try {
+            // "hello there" should be written to file
+            SeekableByteChannel sbc = file
+                .newByteChannel(CREATE_NEW, WRITE, APPEND);
+            try {
+                write(sbc, "hello ");
+                sbc.position(0L);
+                write(sbc, "there");
+            } finally {
+                sbc.close();
+            }
+
+            // check file
+            Scanner s = new Scanner(file);
+            try {
+                String line = s.nextLine();
+                if (!line.equals("hello there"))
+                    throw new RuntimeException("Unexpected file contents");
+            } finally {
+                s.close();
+            }
+
+            // check that read is not allowed
+            sbc = file.newByteChannel(APPEND);
+            try {
+                sbc.read(ByteBuffer.allocate(100));
+            } catch (NonReadableChannelException x) {
+            } finally {
+                sbc.close();
+            }
+        } finally {
+            // clean-up
+            file.delete(false);
+        }
+    }
+
+    // test TRUNCATE_EXISTING option
+    static void truncateExistingTests(Path dir) throws Exception {
+        Path file = dir.resolve("foo");
+        try {
+            SeekableByteChannel sbc =
+                file.newByteChannel(CREATE_NEW, WRITE);
+            try {
+                write(sbc, "Have a nice day!");
+            } finally {
+                sbc.close();
+            }
+
+            // re-open with truncate option
+            // write short message and check
+            sbc = file.newByteChannel(WRITE, TRUNCATE_EXISTING);
+            try {
+                write(sbc, "Hello there!");
+            } finally {
+                sbc.close();
+            }
+            Scanner s = new Scanner(file);
+            try {
+                String line = s.nextLine();
+                if (!line.equals("Hello there!"))
+                    throw new RuntimeException("Unexpected file contents");
+            } finally {
+                s.close();
+            }
+
+            // re-open with create + truncate option
+            // check file is of size 0L
+            sbc = file.newByteChannel(WRITE, CREATE, TRUNCATE_EXISTING);
+            try {
+                long size = ((FileChannel)sbc).size();
+                if (size != 0L)
+                    throw new RuntimeException("File not truncated");
+            } finally {
+                sbc.close();
+            }
+
+        } finally {
+            // clean-up
+            file.delete(false);
+        }
+
+    }
+
+    // test NOFOLLOW_LINKS option
+    static void noFollowLinksTests(Path dir) throws Exception {
+        if (!supportsLinks)
+            return;
+        Path file = dir.resolve("foo").createFile();
+        try {
+            // ln -s foo link
+            Path link = dir.resolve("link").createSymbolicLink(file);
+
+            // open with NOFOLLOW_LINKS option
+            try {
+                link.newByteChannel(READ, LinkOption.NOFOLLOW_LINKS);
+                throw new RuntimeException();
+            } catch (IOException x) {
+            } finally {
+                link.delete();
+            }
+
+        } finally {
+            // clean-up
+            file.delete();
+        }
+    }
+
+    // test size/truncate/position methods
+    static void sizeTruncatePositionTests(Path dir) throws Exception {
+        Path file = dir.resolve("foo");
+        try {
+            SeekableByteChannel sbc = file
+                .newByteChannel(CREATE_NEW, READ, WRITE);
+            try {
+                if (sbc.size() != 0L)
+                    throw new RuntimeException("Unexpected size");
+
+                // check size
+                write(sbc, "hello");
+                if (sbc.size() != 5L)
+                    throw new RuntimeException("Unexpected size");
+
+                // truncate (size and position should change)
+                sbc.truncate(4L);
+                if (sbc.size() != 4L)
+                    throw new RuntimeException("Unexpected size");
+                if (sbc.position() != 4L)
+                    throw new RuntimeException("Unexpected position");
+
+                // truncate (position should not change)
+                sbc.position(2L).truncate(3L);
+                if (sbc.size() != 3L)
+                    throw new RuntimeException("Unexpected size");
+                if (sbc.position() != 2L)
+                    throw new RuntimeException("Unexpected position");
+            } finally {
+                sbc.close();
+            }
+        } finally {
+            file.delete(false);
+        }
+    }
+
+    // Windows specific options for the use by applications that really want
+    // to use legacy DOS sharing options
+    static void dosSharingOptionTests(Path dir) throws Exception {
+        Path file = dir.resolve("foo").createFile();
+        try {
+            SeekableByteChannel ch;
+
+            // no sharing
+            ch = file.newByteChannel(READ,
+                NOSHARE_READ, NOSHARE_WRITE, NOSHARE_DELETE);
+            try {
+                try {
+                    file.newByteChannel(READ);
+                    throw new RuntimeException("Sharing violation expected");
+                } catch (IOException ignore) { }
+                try {
+                    file.newByteChannel(WRITE);
+                    throw new RuntimeException("Sharing violation expected");
+                } catch (IOException ignore) { }
+                try {
+                    file.delete();
+                    throw new RuntimeException("Sharing violation expected");
+                } catch (IOException ignore) { }
+            } finally {
+                ch.close();
+            }
+
+            // read allowed
+            ch = file.newByteChannel(READ, NOSHARE_WRITE, NOSHARE_DELETE);
+            try {
+                file.newByteChannel(READ).close();
+                try {
+                    file.newByteChannel(WRITE);
+                    throw new RuntimeException("Sharing violation expected");
+                } catch (IOException ignore) { }
+                try {
+                    file.delete();
+                    throw new RuntimeException("Sharing violation expected");
+                } catch (IOException ignore) { }
+            } finally {
+                ch.close();
+            }
+
+            // write allowed
+            ch = file.newByteChannel(READ, NOSHARE_READ, NOSHARE_DELETE);
+            try {
+                try {
+                    file.newByteChannel(READ);
+                    throw new RuntimeException("Sharing violation expected");
+                } catch (IOException ignore) { }
+                file.newByteChannel(WRITE).close();
+                try {
+                    file.delete();
+                    throw new RuntimeException("Sharing violation expected");
+                } catch (IOException ignore) { }
+            } finally {
+                ch.close();
+            }
+
+            // delete allowed
+            ch = file.newByteChannel(READ, NOSHARE_READ, NOSHARE_WRITE);
+            try {
+                try {
+                    file.newByteChannel(READ);
+                    throw new RuntimeException("Sharing violation expected");
+                } catch (IOException ignore) { }
+                try {
+                    file.newByteChannel(WRITE);
+                    throw new RuntimeException("Sharing violation expected");
+                } catch (IOException ignore) { }
+                file.delete();
+            } finally {
+                ch.close();
+            }
+
+        } finally {
+            file.delete(false);
+        }
+    }
+
+    // invalid combinations of options
+    static void badCombinations(Path dir) throws Exception {
+        Path file = dir.resolve("bad");
+
+        try {
+            file.newByteChannel(READ, APPEND);
+            throw new RuntimeException("IllegalArgumentException expected");
+        } catch (IllegalArgumentException x) { }
+
+        try {
+            file.newByteChannel(WRITE, APPEND, TRUNCATE_EXISTING);
+            throw new RuntimeException("IllegalArgumentException expected");
+        } catch (IllegalArgumentException x) { }
+    }
+
+    // unsupported operations
+    static void unsupportedOptions(Path dir) throws Exception {
+        Path file = dir.resolve("bad");
+
+        OpenOption badOption = new OpenOption() { };
+        try {
+            file.newByteChannel(badOption);
+            throw new RuntimeException("UnsupportedOperationException expected");
+        } catch (UnsupportedOperationException e) { }
+        try {
+            file.newByteChannel(READ, WRITE, badOption);
+            throw new RuntimeException("UnsupportedOperationException expected");
+        } catch (UnsupportedOperationException e) { }
+    }
+
+    // null handling
+    static void nullTests(Path dir) throws Exception {
+        Path file = dir.resolve("foo");
+
+        try {
+            file.newByteChannel((OpenOption[])null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException x) { }
+
+        try {
+            OpenOption[] opts = { READ, null };
+            file.newByteChannel(opts);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException x) { }
+
+        try {
+            file.newByteChannel((Set<OpenOption>)null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException x) { }
+
+        try {
+            Set<OpenOption> opts = new HashSet<OpenOption>();
+            opts.add(READ);
+            opts.add(null);
+            file.newByteChannel(opts);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException x) { }
+
+        try {
+            EnumSet<StandardOpenOption> opts = EnumSet.of(READ);
+            file.newByteChannel(opts, (FileAttribute[])null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException x) { }
+
+        try {
+            EnumSet<StandardOpenOption> opts = EnumSet.of(READ);
+            FileAttribute[] attrs = { null };
+            file.newByteChannel(opts, attrs);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException x) { }
+    }
+
+    static void write(WritableByteChannel wbc, String msg) throws IOException {
+        ByteBuffer buf = ByteBuffer.wrap(msg.getBytes());
+        while (buf.hasRemaining())
+            wbc.write(buf);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Path/TemporaryFiles.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.nio.file.*;
+import static java.nio.file.StandardOpenOption.*;
+import java.nio.file.attribute.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Set;
+
+public class TemporaryFiles {
+
+    static void checkFile(Path file) throws IOException {
+        // check file is in temporary directory
+        Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir"));
+        if (!file.getParent().equals(tmpdir))
+            throw new RuntimeException("Not in temporary directory");
+
+        // check that file can be opened for reading and writing
+        file.newByteChannel(READ).close();
+        file.newByteChannel(WRITE).close();
+        file.newByteChannel(READ,WRITE).close();
+
+        // check file permissions are 0600 or more secure
+        if (file.getFileStore().supportsFileAttributeView("posix")) {
+            Set<PosixFilePermission> perms = Attributes
+                .readPosixFileAttributes(file).permissions();
+            perms.remove(PosixFilePermission.OWNER_READ);
+            perms.remove(PosixFilePermission.OWNER_WRITE);
+            if (!perms.isEmpty())
+                throw new RuntimeException("Temporary file is not secure");
+        }
+    }
+
+    public static void main(String[] args) throws IOException {
+        Path file = File.createTempFile("blah", null, false).toPath();
+        try {
+            checkFile(file);
+        } finally {
+            file.delete();
+        }
+
+        // temporary file with deleteOnExit
+        file = File.createTempFile("blah", "tmp", true).toPath();
+        checkFile(file);
+        // write path to temporary file to file so that calling script can
+        // check that it is deleted
+        OutputStream out = Paths.get(args[0]).newOutputStream();
+        try {
+            out.write(file.toString().getBytes());
+        } finally {
+            out.close();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Path/UriImportExport.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.Path
+ */
+
+import java.nio.file.*;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.io.PrintStream;
+
+public class UriImportExport {
+
+    static final PrintStream log = System.out;
+    static int failures = 0;
+
+    static void test(String fn, String expected) {
+        log.println();
+        Path p = Paths.get(fn);
+        log.println(p);
+        URI u = p.toUri();
+        log.println("  --> " + u);
+        if (expected != null && !(u.toString().equals(expected))) {
+            log.println("FAIL: Expected " + expected);
+            failures++;
+            return;
+        }
+        Path q = Paths.get(u);
+        log.println("  --> " + q);
+        if (!p.toAbsolutePath().equals(q)) {
+            log.println("FAIL: Expected " + p + ", got " + q);
+            failures++;
+            return;
+        }
+    }
+
+    static void test(String fn) {
+        test(fn, null);
+    }
+
+    public static void main(String[] args) throws Exception {
+        test("foo");
+        test("/foo");
+        test("/foo bar");
+
+        String osname = System.getProperty("os.name");
+        if (osname.startsWith("Windows")) {
+            test("C:\\foo");
+            test("C:foo");
+            test("\\\\rialto.dublin.com\\share\\");
+            test("\\\\fe80--203-baff-fe5a-749ds1.ipv6-literal.net\\share\\missing",
+                "file://[fe80::203:baff:fe5a:749d%1]/share/missing");
+        }
+
+        if (failures > 0)
+            throw new RuntimeException(failures + " test(s) failed");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Path/delete_on_close.sh	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,61 @@
+#
+# 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.
+#
+# 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.
+#
+
+# @test
+# @bug 4313887
+# @summary Unit test for DELETE_ON_CLOSE open option
+# @library ..
+# @build DeleteOnClose
+# @run shell delete_on_close.sh
+
+# if TESTJAVA isn't set then we assume an interactive run.
+
+if [ -z "$TESTJAVA" ]; then
+    TESTSRC=.
+    TESTCLASSES=.
+    JAVA=java
+else
+    JAVA="${TESTJAVA}/bin/java"
+fi
+
+OS=`uname -s`
+case "$OS" in
+    Windows_* )
+        CLASSPATH="${TESTCLASSES};${TESTSRC}"
+        ;;
+    * )
+        CLASSPATH=${TESTCLASSES}:${TESTSRC}
+        ;;
+esac
+export CLASSPATH
+
+TMPFILE="$$.tmp"
+touch $TMPFILE
+$JAVA DeleteOnClose $TMPFILE 2>&1
+if [ $? != 0 ]; then exit 1; fi
+if [ -f $TMPFILE ]; then
+    echo "$TMPFILE was not deleted"
+    exit 1
+fi
+
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/Path/temporary_files.sh	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,65 @@
+#
+# 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.
+#
+# 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.
+#
+
+# @test
+# @bug 4313887
+# @summary Unit test for File.createTempFile (to be be moved to test/java/io/File)
+# @library ..
+# @build TemporaryFiles
+# @run shell temporary_files.sh
+
+# if TESTJAVA isn't set then we assume an interactive run.
+
+if [ -z "$TESTJAVA" ]; then
+    TESTSRC=.
+    TESTCLASSES=.
+    JAVA=java
+else
+    JAVA="${TESTJAVA}/bin/java"
+fi
+
+OS=`uname -s`
+case "$OS" in
+    Windows_* )
+        CLASSPATH="${TESTCLASSES};${TESTSRC}"
+        ;;
+    * )
+        CLASSPATH=${TESTCLASSES}:${TESTSRC}
+        ;;
+esac
+export CLASSPATH
+
+TMPFILENAME="$$.tmp"
+$JAVA TemporaryFiles $TMPFILENAME 2>&1
+if [ $? != 0 ]; then exit 1; fi
+if [ ! -f $TMPFILENAME ]; then
+    echo "$TMPFILENAME not found"
+    exit 1
+fi
+TMPFILE=`cat $TMPFILENAME`
+if [ -f $TMPFILE ]; then
+    echo "$TMPFILE not deleted"
+    exit 1
+fi
+
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/PathMatcher/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,163 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.PathMatcher
+ */
+
+import java.nio.file.*;
+import java.util.regex.PatternSyntaxException;
+
+public class Basic {
+    static int failures;
+
+    static void match(String name, String pattern, boolean expectedToMatch) {
+        System.out.format("%s -> %s", name, pattern);
+        Path file = Paths.get(name);
+        boolean matched =  file.getFileSystem()
+            .getNameMatcher("glob", pattern).matches(file);
+        if (matched)
+            System.out.print(" (matched)");
+        else
+            System.out.print(" (no match)");
+        if (matched != expectedToMatch) {
+            System.out.println(" ==> UNEXPECTED RESULT!");
+            failures++;
+        } else {
+            System.out.println(" OKAY");
+        }
+    }
+
+    static void assertMatch(String path, String pattern) {
+        match(path, pattern, true);
+    }
+
+    static void assertNotMatch(String path, String pattern) {
+        match(path, pattern, false);
+    }
+
+    static void assertBadPattern(String path, String pattern) {
+        System.out.format("Compile bad pattern %s\t", pattern);
+        try {
+            FileSystems.getDefault().getNameMatcher("glob", pattern);
+            System.out.println("Compiled ==> UNEXPECTED RESULT!");
+            failures++;
+        } catch (PatternSyntaxException e) {
+            System.out.println("Failed to compile ==> OKAY");
+        }
+    }
+
+    public static void main(String[] args) {
+        // basic
+        assertMatch("foo.html", "foo.html");
+        assertNotMatch("foo.html", "foo.htm");
+        assertNotMatch("foo.html", "bar.html");
+
+        // match zero or more characters
+        assertMatch("foo.html", "f*");
+        assertMatch("foo.html", "*.html");
+        assertMatch("foo.html", "foo.html*");
+        assertMatch("foo.html", "*foo.html");
+        assertMatch("foo.html", "*foo.html*");
+        assertNotMatch("foo.html", "*.htm");
+        assertNotMatch("foo.html", "f.*");
+
+        // match one character
+        assertMatch("foo.html", "?oo.html");
+        assertMatch("foo.html", "??o.html");
+        assertMatch("foo.html", "???.html");
+        assertMatch("foo.html", "???.htm?");
+        assertNotMatch("foo.html", "foo.???");
+
+        // group of subpatterns
+        assertMatch("foo.html", "foo{.html,.class}");
+        assertMatch("foo.html", "foo.{class,html}");
+        assertNotMatch("foo.html", "foo{.htm,.class}");
+
+        // bracket expressions
+        assertMatch("foo.html", "[f]oo.html");
+        assertMatch("foo.html", "[e-g]oo.html");
+        assertMatch("foo.html", "[abcde-g]oo.html");
+        assertMatch("foo.html", "[abcdefx-z]oo.html");
+        assertMatch("foo.html", "[!a]oo.html");
+        assertMatch("foo.html", "[!a-e]oo.html");
+        assertMatch("foo-bar", "foo[-a-z]bar");     // match dash
+        assertMatch("foo.html", "foo[!-]html");     // match !dash
+
+        // groups of subpattern with bracket expressions
+        assertMatch("foo.html", "[f]oo.{[h]tml,class}");
+        assertMatch("foo.html", "foo.{[a-z]tml,class}");
+        assertMatch("foo.html", "foo.{[!a-e]tml,.class}");
+
+        // assume special characters are allowed in file names
+        assertMatch("{foo}.html", "\\{foo*");
+        assertMatch("{foo}.html", "*\\}.html");
+        assertMatch("[foo].html", "\\[foo*");
+        assertMatch("[foo].html", "*\\].html");
+
+        // some special characters not allowed on Windows
+        if (!System.getProperty("os.name").startsWith("Windows")) {
+            assertMatch("myfile?", "myfile\\?");
+            assertMatch("one\\two", "one\\\\two");
+            assertMatch("one*two", "one\\*two");
+        }
+
+        // errors
+        assertBadPattern("foo.html", "*[a--z]");            // bad range
+        assertBadPattern("foo.html", "*[a--]");             // bad range
+        assertBadPattern("foo.html", "*[a-z");              // missing ]
+        assertBadPattern("foo.html", "*{class,java");       // missing }
+        assertBadPattern("foo.html", "*.{class,{.java}}");  // nested group
+        assertBadPattern("foo.html", "*.html\\");           // nothing to escape
+
+        // regex syntax
+        {
+            String pattern = ".*\\.html";
+            System.out.format("Test regex pattern: %s", pattern);
+            Path file = Paths.get("foo.html");
+            boolean matched =  file.getFileSystem()
+                .getNameMatcher("regex", pattern).matches(file);
+            if (matched) {
+                System.out.println(" OKAY");
+            } else {
+                System.out.println(" ==> UNEXPECTED RESULT!");
+                failures++;
+            }
+        }
+
+        // unknown syntax
+        try {
+            System.out.format("Test unknown syntax");
+            FileSystems.getDefault().getNameMatcher("grep", "foo");
+            System.out.println(" ==> NOT EXPECTED TO COMPILE");
+            failures++;
+        } catch (UnsupportedOperationException e) {
+            System.out.println(" OKAY");
+        }
+
+        if (failures > 0)
+            throw new RuntimeException(failures +
+                " sub-test(s) failed - see log for details");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/TestUtil.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,117 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.Random;
+import java.io.IOException;
+
+public class TestUtil {
+    private TestUtil() {
+    }
+
+    public static Path createTemporaryDirectory() throws IOException {
+        Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir"));
+        Random r = new Random();
+
+        Path dir;
+        do {
+            dir = tmpdir.resolve("name" + r.nextInt());
+        } while (dir.exists());
+        return dir.createDirectory();
+    }
+
+    static void removeAll(Path dir) {
+        Files.walkFileTree(dir, new FileVisitor<Path>() {
+
+            public FileVisitResult preVisitDirectory(Path dir) {
+                return FileVisitResult.CONTINUE;
+            }
+
+            public FileVisitResult preVisitDirectoryFailed(Path dir, IOException exc) {
+                System.err.format("Error occured accessing directory %s\n", dir, exc);
+                return FileVisitResult.CONTINUE;
+            }
+
+            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
+                try {
+                    file.delete(false);
+                } catch (IOException x) {
+                    System.err.format("Unable to delete %s: %s\n", file, x);
+                }
+                return FileVisitResult.CONTINUE;
+            }
+
+            public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
+                try {
+                    dir.delete(false);
+                } catch (IOException x) {
+                    System.err.format("Unable to delete %s: %s\n", dir, x);
+                }
+                return FileVisitResult.CONTINUE;
+            }
+
+            public FileVisitResult visitFileFailed(Path file, IOException exc) {
+                System.err.format("Unable to visit %s: %s\n", file, exc);
+                return FileVisitResult.CONTINUE;
+            }
+        });
+    }
+
+    /**
+     * Creates a directory tree in the given directory so that the total
+     * size of the path is more than 2k in size. This is used for long
+     * path tests on Windows.
+     */
+    static Path createDirectoryWithLongPath(Path dir)
+        throws IOException
+    {
+        StringBuilder sb = new StringBuilder();
+        for (int i=0; i<240; i++) {
+            sb.append('A');
+        }
+        String name = sb.toString();
+        do {
+            dir = dir.resolve(name).resolve(".");
+            dir.createDirectory();
+        } while (dir.toString().length() < 2048);
+        return dir;
+    }
+
+    /**
+     * Returns true if symbolic links are supported
+     */
+    static boolean supportsLinks(Path dir) {
+        Path link = dir.resolve("testlink");
+        Path target = dir.resolve("testtarget");
+        try {
+            link.createSymbolicLink(target);
+            target.delete(false);
+            return true;
+        } catch (UnsupportedOperationException x) {
+            return false;
+        } catch (IOException x) {
+            return false;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,493 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.WatchService
+ * @library ..
+ * @run main/timeout=120 Basic
+ */
+
+import java.nio.file.*;
+import static java.nio.file.StandardWatchEventKind.*;
+import java.nio.file.attribute.*;
+import java.io.*;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Unit test for WatchService that exercises all methods in various scenarios.
+ */
+
+public class Basic {
+
+    static void createFile(Path file) throws IOException {
+        file.newOutputStream().close();
+    }
+
+    static void takeExpectedKey(WatchService watcher, WatchKey expected) {
+        System.out.println("take events...");
+        WatchKey key;
+        try {
+            key = watcher.take();
+        } catch (InterruptedException x) {
+            // not expected
+            throw new RuntimeException(x);
+        }
+        if (key != expected)
+            throw new RuntimeException("removed unexpected key");
+    }
+
+    static void checkExpectedEvent(Iterable<WatchEvent<?>> events,
+                                   WatchEvent.Kind<?> expectedKind,
+                                   Object expectedContext)
+    {
+        WatchEvent<?> event = events.iterator().next();
+        System.out.format("got event: type=%s, count=%d, context=%s\n",
+            event.kind(), event.count(), event.context());
+        if (event.kind() != expectedKind)
+            throw new RuntimeException("unexpected event");
+        if (!expectedContext.equals(event.context()))
+            throw new RuntimeException("unexpected context");
+    }
+
+    /**
+     * Simple test of each of the standard events
+     */
+    static void testEvents(Path dir) throws IOException {
+        System.out.println("-- Standard Events --");
+
+        FileSystem fs = FileSystems.getDefault();
+        Path name = fs.getPath("foo");
+
+        WatchService watcher = fs.newWatchService();
+        try {
+            // --- ENTRY_CREATE ---
+
+            // register for event
+            System.out.format("register %s for ENTRY_CREATE\n", dir);
+            WatchKey myKey = dir.register(watcher,
+                new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
+
+            // create file
+            Path file = dir.resolve("foo");
+            System.out.format("create %s\n", file);
+            createFile(file);
+
+            // remove key and check that we got the ENTRY_CREATE event
+            takeExpectedKey(watcher, myKey);
+            checkExpectedEvent(myKey.pollEvents(),
+                StandardWatchEventKind.ENTRY_CREATE, name);
+
+            System.out.println("reset key");
+            if (!myKey.reset())
+                throw new RuntimeException("key has been cancalled");
+
+            System.out.println("OKAY");
+
+            // --- ENTRY_DELETE ---
+
+            System.out.format("register %s for ENTRY_DELETE\n", dir);
+            WatchKey deleteKey = dir.register(watcher,
+                new WatchEvent.Kind<?>[]{ ENTRY_DELETE });
+            if (deleteKey != myKey)
+                throw new RuntimeException("register did not return existing key");
+
+            System.out.format("delete %s\n", file);
+            file.delete(false);
+            takeExpectedKey(watcher, myKey);
+            checkExpectedEvent(myKey.pollEvents(),
+                StandardWatchEventKind.ENTRY_DELETE, name);
+
+            System.out.println("reset key");
+            if (!myKey.reset())
+                throw new RuntimeException("key has been cancalled");
+
+            System.out.println("OKAY");
+
+            // create the file for the next test
+            createFile(file);
+
+            // --- ENTRY_MODIFY ---
+
+            System.out.format("register %s for ENTRY_MODIFY\n", dir);
+            WatchKey newKey = dir.register(watcher,
+                new WatchEvent.Kind<?>[]{ ENTRY_MODIFY });
+            if (newKey != myKey)
+                throw new RuntimeException("register did not return existing key");
+
+            System.out.format("update: %s\n", file);
+            OutputStream out = file.newOutputStream(EnumSet.of(StandardOpenOption.APPEND));
+            try {
+                out.write("I am a small file".getBytes("UTF-8"));
+            } finally {
+                out.close();
+            }
+
+            // remove key and check that we got the ENTRY_MODIFY event
+            takeExpectedKey(watcher, myKey);
+            checkExpectedEvent(myKey.pollEvents(),
+                StandardWatchEventKind.ENTRY_MODIFY, name);
+            System.out.println("OKAY");
+
+            // done
+            file.delete(false);
+
+        } finally {
+            watcher.close();
+        }
+    }
+
+    /**
+     * Check that a cancelled key will never be queued
+     */
+    static void testCancel(Path dir) throws IOException {
+        System.out.println("-- Cancel --");
+
+        WatchService watcher = FileSystems.getDefault().newWatchService();
+        try {
+
+            System.out.format("register %s for events\n", dir);
+            WatchKey myKey = dir.register(watcher,
+                new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
+
+            System.out.println("cancel key");
+            myKey.cancel();
+
+            // create a file in the directory
+            Path file = dir.resolve("mars");
+            System.out.format("create: %s\n", file);
+            createFile(file);
+
+            // poll for keys - there will be none
+            System.out.println("poll...");
+            try {
+                WatchKey key = watcher.poll(3000, TimeUnit.MILLISECONDS);
+                if (key != null)
+                    throw new RuntimeException("key should not be queued");
+            } catch (InterruptedException x) {
+                throw new RuntimeException(x);
+            }
+
+            // done
+            file.delete(false);
+
+            System.out.println("OKAY");
+
+        } finally {
+            watcher.close();
+        }
+    }
+
+    /**
+     * Check that deleting a registered directory causes the key to be
+     * cancelled and queued.
+     */
+    static void testAutomaticCancel(Path dir) throws IOException {
+        System.out.println("-- Automatic Cancel --");
+
+        Path subdir = dir.resolve("bar").createDirectory();
+
+        WatchService watcher = FileSystems.getDefault().newWatchService();
+        try {
+
+            System.out.format("register %s for events\n", subdir);
+            WatchKey myKey = subdir.register(watcher,
+                new WatchEvent.Kind<?>[]{ ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY });
+
+            System.out.format("delete: %s\n", subdir);
+            subdir.delete(false);
+            takeExpectedKey(watcher, myKey);
+
+            System.out.println("reset key");
+            if (myKey.reset())
+                throw new RuntimeException("Key was not cancelled");
+            if (myKey.isValid())
+                throw new RuntimeException("Key is still valid");
+
+            System.out.println("OKAY");
+
+        } finally {
+            watcher.close();
+        }
+    }
+
+    /**
+     * Asynchronous close of watcher causes blocked threads to wakeup
+     */
+    static void testWakeup(Path dir) throws IOException {
+        System.out.println("-- Wakeup Tests --");
+        final WatchService watcher = FileSystems.getDefault().newWatchService();
+        Runnable r = new Runnable() {
+            public void run() {
+                try {
+                    Thread.sleep(5000);
+                    System.out.println("close WatchService...");
+                    watcher.close();
+                } catch (InterruptedException x) {
+                    x.printStackTrace();
+                } catch (IOException x) {
+                    x.printStackTrace();
+                }
+            }
+        };
+
+        // start thread to close watch service after delay
+        new Thread(r).start();
+
+        try {
+            System.out.println("take...");
+            watcher.take();
+            throw new RuntimeException("ClosedWatchServiceException not thrown");
+        } catch (InterruptedException x) {
+            throw new RuntimeException(x);
+        } catch (ClosedWatchServiceException  x) {
+            System.out.println("ClosedWatchServiceException thrown");
+        }
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Simple test to check exceptions and other cases
+     */
+    @SuppressWarnings("unchecked")
+    static void testExceptions(Path dir) throws IOException {
+        System.out.println("-- Exceptions and other simple tests --");
+
+        WatchService watcher = FileSystems.getDefault().newWatchService();
+        try {
+
+            // Poll tests
+
+            WatchKey key;
+            System.out.println("poll...");
+            key = watcher.poll();
+            if (key != null)
+                throw new RuntimeException("no keys registered");
+
+            System.out.println("poll with timeout...");
+            try {
+                long start = System.currentTimeMillis();
+                key = watcher.poll(3000, TimeUnit.MILLISECONDS);
+                if (key != null)
+                    throw new RuntimeException("no keys registered");
+                long waited = System.currentTimeMillis() - start;
+                if (waited < 2900)
+                    throw new RuntimeException("poll was too short");
+            } catch (InterruptedException x) {
+                throw new RuntimeException(x);
+            }
+
+            // IllegalArgumentException
+            System.out.println("IllegalArgumentException tests...");
+            try {
+                dir.register(watcher, new WatchEvent.Kind<?>[]{ } );
+                throw new RuntimeException("IllegalArgumentException not thrown");
+            } catch (IllegalArgumentException x) {
+            }
+            try {
+                // OVERFLOW is ignored so this is equivalent to the empty set
+                dir.register(watcher, new WatchEvent.Kind<?>[]{ OVERFLOW });
+                throw new RuntimeException("IllegalArgumentException not thrown");
+            } catch (IllegalArgumentException x) {
+            }
+
+            // UnsupportedOperationException
+            try {
+                dir.register(watcher, new WatchEvent.Kind<?>[]{
+                             new WatchEvent.Kind<Object>() {
+ public String name() { return "custom"; }
+ public Class<Object> type() { return Object.class; }
+                             }});
+            } catch (UnsupportedOperationException x) {
+            }
+            try {
+                dir.register(watcher,
+                             new WatchEvent.Kind<?>[]{ ENTRY_CREATE },
+                             new WatchEvent.Modifier() {
+ public String name() { return "custom"; }
+                             });
+                throw new RuntimeException("UnsupportedOperationException not thrown");
+            } catch (UnsupportedOperationException x) {
+            }
+
+            // NullPointerException
+            System.out.println("NullPointerException tests...");
+            try {
+                dir.register(null, new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
+                throw new RuntimeException("NullPointerException not thrown");
+            } catch (NullPointerException x) {
+            }
+            try {
+                dir.register(watcher, new WatchEvent.Kind<?>[]{ null });
+                throw new RuntimeException("NullPointerException not thrown");
+            } catch (NullPointerException x) {
+            }
+            try {
+                dir.register(watcher, new WatchEvent.Kind<?>[]{ ENTRY_CREATE },
+                    (WatchEvent.Modifier)null);
+                throw new RuntimeException("NullPointerException not thrown");
+            } catch (NullPointerException x) {
+            }
+        } finally {
+            watcher.close();
+        }
+
+        // -- ClosedWatchServiceException --
+
+        System.out.println("ClosedWatchServiceException tests...");
+
+        try {
+            watcher.poll();
+            throw new RuntimeException("ClosedWatchServiceException not thrown");
+        } catch (ClosedWatchServiceException  x) {
+        }
+
+        // assume that poll throws exception immediately
+        long start = System.currentTimeMillis();
+        try {
+            watcher.poll(10000, TimeUnit.MILLISECONDS);
+            throw new RuntimeException("ClosedWatchServiceException not thrown");
+        } catch (InterruptedException x) {
+            throw new RuntimeException(x);
+        } catch (ClosedWatchServiceException  x) {
+            long waited = System.currentTimeMillis() - start;
+            if (waited > 5000)
+                throw new RuntimeException("poll was too long");
+        }
+
+        try {
+            watcher.take();
+            throw new RuntimeException("ClosedWatchServiceException not thrown");
+        } catch (InterruptedException x) {
+            throw new RuntimeException(x);
+        } catch (ClosedWatchServiceException  x) {
+        }
+
+        try {
+            dir.register(watcher, new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
+             throw new RuntimeException("ClosedWatchServiceException not thrown");
+        } catch (ClosedWatchServiceException  x) {
+        }
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Test that directory can be registered with more than one watch service
+     * and that events don't interfere with each other
+     */
+    static void testTwoWatchers(Path dir) throws IOException {
+        System.out.println("-- Two watchers test --");
+
+        FileSystem fs = FileSystems.getDefault();
+        WatchService watcher1 = fs.newWatchService();
+        WatchService watcher2 = fs.newWatchService();
+        try {
+            Path name1 = fs.getPath("gus1");
+            Path name2 = fs.getPath("gus2");
+
+            // create gus1
+            Path file1 = dir.resolve(name1);
+            System.out.format("create %s\n", file1);
+            createFile(file1);
+
+            // register with both watch services (different events)
+            System.out.println("register for different events");
+            WatchKey key1 = dir.register(watcher1,
+                new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
+            WatchKey key2 = dir.register(watcher2,
+                new WatchEvent.Kind<?>[]{ ENTRY_DELETE });
+
+            if (key1 == key2)
+                throw new RuntimeException("keys should be different");
+
+            // create gus2
+            Path file2 = dir.resolve(name2);
+            System.out.format("create %s\n", file2);
+            createFile(file2);
+
+            // check that key1 got ENTRY_CREATE
+            takeExpectedKey(watcher1, key1);
+            checkExpectedEvent(key1.pollEvents(),
+                StandardWatchEventKind.ENTRY_CREATE, name2);
+
+            // check that key2 got zero events
+            WatchKey key = watcher2.poll();
+            if (key != null)
+                throw new RuntimeException("key not expected");
+
+            // delete gus1
+            file1.delete(false);
+
+            // check that key2 got ENTRY_DELETE
+            takeExpectedKey(watcher2, key2);
+            checkExpectedEvent(key2.pollEvents(),
+                StandardWatchEventKind.ENTRY_DELETE, name1);
+
+            // check that key1 got zero events
+            key = watcher1.poll();
+            if (key != null)
+                throw new RuntimeException("key not expected");
+
+            // reset for next test
+            key1.reset();
+            key2.reset();
+
+            // change registration with watcher2 so that they are both
+            // registered for the same event
+            System.out.println("register for same event");
+            key2 = dir.register(watcher2, new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
+
+            // create file and key2 should be queued
+            System.out.format("create %s\n", file1);
+            createFile(file1);
+            takeExpectedKey(watcher2, key2);
+            checkExpectedEvent(key2.pollEvents(),
+                StandardWatchEventKind.ENTRY_CREATE, name1);
+
+            System.out.println("OKAY");
+
+        } finally {
+            watcher2.close();
+            watcher1.close();
+        }
+    }
+
+    public static void main(String[] args) throws IOException {
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+
+            testEvents(dir);
+            testCancel(dir);
+            testAutomaticCancel(dir);
+            testWakeup(dir);
+            testExceptions(dir);
+            testTwoWatchers(dir);
+
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/FileTreeModifier.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Sanity test for Sun-specific FILE_TREE watch event modifier
+ * @library ..
+ */
+
+import java.nio.file.*;
+import static java.nio.file.StandardWatchEventKind.*;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import java.util.concurrent.*;
+import static com.sun.nio.file.ExtendedWatchEventModifier.*;
+
+public class FileTreeModifier {
+
+    static void checkExpectedEvent(WatchService watcher,
+                                   WatchEvent.Kind<?> expectedType,
+                                   Object expectedContext)
+    {
+        WatchKey key;
+        try {
+            key = watcher.take();
+        } catch (InterruptedException x) {
+            // should not happen
+            throw new RuntimeException(x);
+        }
+        WatchEvent<?> event = key.pollEvents().iterator().next();
+        System.out.format("Event: type=%s, count=%d, context=%s\n",
+            event.kind(), event.count(), event.context());
+        if (event.kind() != expectedType)
+            throw new RuntimeException("unexpected event");
+        if (!expectedContext.equals(event.context()))
+            throw new RuntimeException("unexpected context");
+    }
+
+    static void doTest(Path top) throws IOException {
+        FileSystem fs = top.getFileSystem();
+        WatchService watcher = fs.newWatchService();
+
+        // create directories
+        Path subdir = top
+           .resolve("a").createDirectory()
+           .resolve("b").createDirectory()
+           .resolve("c").createDirectory();
+
+        // Test ENTRY_CREATE with FILE_TREE modifier.
+
+        WatchKey key = top.register(watcher,
+            new WatchEvent.Kind<?>[]{ ENTRY_CREATE }, FILE_TREE);
+
+        // create file in a/b/c and check we get create event
+        Path file = subdir.resolve("foo").createFile();
+        checkExpectedEvent(watcher, ENTRY_CREATE, top.relativize(file));
+        key.reset();
+
+        // Test ENTRY_DELETE with FILE_TREE modifier.
+
+        WatchKey k = top.register(watcher,
+            new WatchEvent.Kind<?>[]{ ENTRY_DELETE }, FILE_TREE);
+        if (k != key)
+            throw new RuntimeException("Existing key not returned");
+
+        // delete a/b/c/foo and check we get delete event
+        file.delete(false);
+        checkExpectedEvent(watcher, ENTRY_DELETE, top.relativize(file));
+        key.reset();
+
+        // Test changing registration to ENTRY_CREATE without modifier
+
+        k = top.register(watcher, new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
+        if (k != key)
+            throw new RuntimeException("Existing key not returned");
+
+        // create a/b/c/foo
+        file.createFile();
+
+        // check that key is not queued
+        try {
+            k = watcher.poll(3, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+            throw new RuntimeException();
+        }
+        if (k != null)
+            throw new RuntimeException("WatchKey not expected to be polled");
+
+        // create bar and check we get create event
+        file = top.resolve("bar").createFile();
+        checkExpectedEvent(watcher, ENTRY_CREATE, top.relativize(file));
+        key.reset();
+
+        // Test changing registration to <all> with FILE_TREE modifier
+
+        k = top.register(watcher,
+            new WatchEvent.Kind<?>[]{ ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY },
+            FILE_TREE);
+        if (k != key)
+            throw new RuntimeException("Existing key not returned");
+
+        // modify bar and check we get modify event
+        OutputStream out = file.newOutputStream();
+        try {
+            out.write("Double shot expresso please".getBytes("UTF-8"));
+        } finally {
+            out.close();
+        }
+        checkExpectedEvent(watcher, ENTRY_MODIFY, top.relativize(file));
+        key.reset();
+    }
+
+
+    public static void main(String[] args) throws IOException {
+        if (!System.getProperty("os.name").startsWith("Windows")) {
+            System.out.println("This is Windows-only test at this time!");
+            return;
+        }
+
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            doTest(dir);
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/WithSecurityManager.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for Watchable#register's permission checks
+ * @build WithSecurityManager
+ * @run main/othervm WithSecurityManager denyAll.policy - fail
+ * @run main/othervm WithSecurityManager denyAll.policy tree fail
+ * @run main/othervm WithSecurityManager grantDirOnly.policy - pass
+ * @run main/othervm WithSecurityManager grantDirOnly.policy tree fail
+ * @run main/othervm WithSecurityManager grantDirAndOneLevel.policy - pass
+ * @run main/othervm WithSecurityManager grantDirAndOneLevel.policy tree fail
+ * @run main/othervm WithSecurityManager grantDirAndTree.policy - pass
+ * @run main/othervm WithSecurityManager grantDirAndTree.policy tree pass
+ */
+
+import java.nio.file.*;
+import java.io.IOException;
+import com.sun.nio.file.ExtendedWatchEventModifier;
+
+public class WithSecurityManager {
+
+    public static void main(String[] args) throws IOException {
+        String policyFile = args[0];
+        boolean recursive = args[1].equals("tree");
+        boolean expectedToFail = args[2].equals("fail");
+
+        // install security manager with the given policy file
+        String testSrc = System.getProperty("test.src");
+        if (testSrc == null)
+            throw new RuntimeException("This test must be run by jtreg");
+        Path dir = Paths.get(testSrc);
+        System.setProperty("java.security.policy", dir.resolve(policyFile).toString());
+        System.setSecurityManager(new SecurityManager());
+
+        // initialize optional modifier
+        WatchEvent.Modifier[] modifiers;
+        if (recursive) {
+            modifiers = new WatchEvent.Modifier[1];
+            modifiers[0] = ExtendedWatchEventModifier.FILE_TREE;
+        } else {
+            modifiers = new WatchEvent.Modifier[0];
+        }
+
+        // attempt to register directory
+        try {
+            dir.register(dir.getFileSystem().newWatchService(),
+                         new WatchEvent.Kind<?>[]{ StandardWatchEventKind.ENTRY_CREATE },
+                         modifiers);
+            if (expectedToFail)
+                throw new RuntimeException("SecurityException not thrown");
+        } catch (SecurityException e) {
+            if (!expectedToFail)
+                throw e;
+        } catch (UnsupportedOperationException e) {
+            // FILE_TREE modifier only supported on some platforms
+            if (!recursive)
+                throw new RuntimeException(e);
+            System.out.println("FILE_TREE option not supported");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/denyAll.policy	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,3 @@
+// policy file that does not grant any permissions
+grant {
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/grantDirAndOneLevel.policy	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,5 @@
+// policy file that grants read access to source directory and its entries
+grant {
+    permission java.io.FilePermission "${test.src}", "read";
+    permission java.io.FilePermission "${test.src}${file.separator}*", "read";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/grantDirAndTree.policy	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,5 @@
+// policy file that grants read access to source directory and all descendants
+grant {
+    permission java.io.FilePermission "${test.src}", "read";
+    permission java.io.FilePermission "${test.src}${file.separator}-", "read";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/WatchService/grantDirOnly.policy	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,4 @@
+// policy file that grants read access to source directory
+grant {
+    permission java.io.FilePermission "${test.src}", "read";
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/AclFileAttributeView/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,166 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.attribute.AclFileAttribueView
+ * @library ../..
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.io.IOException;
+import java.util.*;
+
+import static java.nio.file.attribute.AclEntryType.*;
+import static java.nio.file.attribute.AclEntryPermission.*;
+import static java.nio.file.attribute.AclEntryFlag.*;
+
+public class Basic {
+
+    static void printAcl(List<AclEntry> acl) {
+        for (AclEntry entry: acl) {
+            System.out.format("  %s%n", entry);
+        }
+    }
+
+    // sanity check read and writing ACL
+    static void testReadWrite(Path dir) throws IOException {
+        Path file = dir.resolve("foo");
+        if (file.notExists())
+            file.createFile();
+
+        AclFileAttributeView view = file
+            .getFileAttributeView(AclFileAttributeView.class);
+
+        // print existing ACL
+        List<AclEntry> acl = view.getAcl();
+        System.out.println(" -- current ACL --");
+        printAcl(acl);
+
+        // insert entry to grant owner read access
+        UserPrincipal owner = view.getOwner();
+        AclEntry entry = AclEntry.newBuilder()
+            .setType(ALLOW)
+            .setPrincipal(owner)
+            .setPermissions(READ_DATA, READ_ATTRIBUTES)
+            .build();
+        System.out.println(" -- insert (entry 0) --");
+        System.out.format("  %s%n", entry);
+        acl.add(0, entry);
+        view.setAcl(acl);
+
+        // re-ACL and check entry
+        List<AclEntry> newacl = view.getAcl();
+        System.out.println(" -- current ACL --");
+        printAcl(acl);
+        if (!newacl.get(0).equals(entry)) {
+            throw new RuntimeException("Entry 0 is not expected");
+        }
+
+        // if PosixFileAttributeView then repeat test with OWNER@
+        if (file.getFileStore().supportsFileAttributeView("posix")) {
+            owner = file.getFileSystem().getUserPrincipalLookupService()
+                .lookupPrincipalByName("OWNER@");
+            entry = AclEntry.newBuilder(entry).setPrincipal(owner).build();
+
+            System.out.println(" -- replace (entry 0) --");
+            System.out.format("  %s%n", entry);
+
+            acl.set(0, entry);
+            view.setAcl(acl);
+            newacl = view.getAcl();
+            System.out.println(" -- current ACL --");
+            printAcl(acl);
+            if (!newacl.get(0).equals(entry)) {
+                throw new RuntimeException("Entry 0 is not expected");
+            }
+        }
+    }
+
+    static FileAttribute<List<AclEntry>> asAclAttribute(final List<AclEntry> acl) {
+        return new FileAttribute<List<AclEntry>>() {
+            public String name() { return "acl:acl"; }
+            public List<AclEntry> value() { return acl; }
+        };
+    }
+
+    static void assertEquals(List<AclEntry> actual, List<AclEntry> expected) {
+        if (!actual.equals(expected)) {
+            System.err.format("Actual: %s\n", actual);
+            System.err.format("Expected: %s\n", expected);
+            throw new RuntimeException("ACL not expected");
+        }
+    }
+
+    // sanity check create a file or directory with initial ACL
+    static void testCreateFile(Path dir) throws IOException {
+        UserPrincipal user = Attributes.getOwner(dir);
+
+        // create file with initial ACL
+        System.out.println("-- create file with initial ACL --");
+        Path file = dir.resolve("gus");
+        List<AclEntry> fileAcl = Arrays.asList(
+            AclEntry.newBuilder()
+                .setType(AclEntryType.ALLOW)
+                .setPrincipal(user)
+                .setPermissions(SYNCHRONIZE, READ_DATA, WRITE_DATA,
+                    READ_ATTRIBUTES, READ_ACL, WRITE_ATTRIBUTES, DELETE)
+                .build());
+        file.createFile(asAclAttribute(fileAcl));
+        assertEquals(Attributes.getAcl(file), fileAcl);
+
+        // create directory with initial ACL
+        System.out.println("-- create directory with initial ACL --");
+        Path subdir = dir.resolve("stuff");
+        List<AclEntry> dirAcl = Arrays.asList(
+            AclEntry.newBuilder()
+                .setType(AclEntryType.ALLOW)
+                .setPrincipal(user)
+                .setPermissions(SYNCHRONIZE, ADD_FILE, DELETE)
+                .build(),
+            AclEntry.newBuilder(fileAcl.get(0))
+                .setFlags(FILE_INHERIT)
+                .build());
+        subdir.createDirectory(asAclAttribute(dirAcl));
+        assertEquals(Attributes.getAcl(subdir), dirAcl);
+    }
+
+    public static void main(String[] args) throws IOException {
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            if (!dir.getFileStore().supportsFileAttributeView("acl")) {
+                System.out.println("ACLs not supported - test skipped!");
+                return;
+            }
+            testReadWrite(dir);
+
+            // only currently feasible on Windows
+            if (System.getProperty("os.name").startsWith("Windows"))
+                testCreateFile(dir);
+
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/Attributes/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,254 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.attribute.Attributes
+ * @library ../..
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Exercises getAttribute/setAttribute/readAttributes methods.
+ */
+
+public class Basic {
+
+    static void assertTrue(boolean okay) {
+        if (!okay)
+            throw new RuntimeException("Assertion Failed");
+    }
+
+    static void checkEqual(Object o1, Object o2) {
+        if (o1 == null) {
+            assertTrue(o2 == null);
+        } else {
+            assertTrue (o1.equals(o2));
+        }
+    }
+
+    // Exercise getAttribute/setAttribute/readAttributes on basic attributes
+    static void checkBasicAttributes(FileRef file, BasicFileAttributes attrs)
+        throws IOException
+    {
+        // getAttribute
+        checkEqual(attrs.size(), Attributes.getAttribute(file, "size"));
+        checkEqual(attrs.lastModifiedTime(),
+                   Attributes.getAttribute(file, "basic:lastModifiedTime"));
+        checkEqual(attrs.lastAccessTime(),
+                   Attributes.getAttribute(file, "lastAccessTime"));
+        checkEqual(attrs.creationTime(),
+                   Attributes.getAttribute(file, "basic:creationTime"));
+        assertTrue((Boolean)Attributes.getAttribute(file, "isRegularFile"));
+        assertTrue(!(Boolean)Attributes.getAttribute(file, "basic:isDirectory"));
+        assertTrue(!(Boolean)Attributes.getAttribute(file, "isSymbolicLink"));
+        assertTrue(!(Boolean)Attributes.getAttribute(file, "basic:isOther"));
+        checkEqual(attrs.linkCount(),
+                   (Integer)Attributes.getAttribute(file, "linkCount"));
+        checkEqual(attrs.fileKey(), Attributes.getAttribute(file, "basic:fileKey"));
+
+        // setAttribute
+        if (attrs.resolution() == TimeUnit.MILLISECONDS) {
+            long modTime = attrs.lastModifiedTime();
+            Attributes.setAttribute(file, "basic:lastModifiedTime", 0L);
+            assertTrue(Attributes.readBasicFileAttributes(file).lastModifiedTime() == 0L);
+            Attributes.setAttribute(file, "lastModifiedTime", modTime);
+            assertTrue(Attributes.readBasicFileAttributes(file).lastModifiedTime() == modTime);
+        }
+
+        // readAttributes
+        Map<String,?> map;
+        map = Attributes.readAttributes(file, "*");
+        assertTrue(map.size() >= 11);
+        checkEqual(attrs.isRegularFile(), map.get("isRegularFile")); // check one
+
+        map = Attributes.readAttributes(file, "basic:*");
+        assertTrue(map.size() >= 11);
+        checkEqual(attrs.lastAccessTime(), map.get("lastAccessTime")); // check one
+
+        map = Attributes.readAttributes(file, "size,lastModifiedTime");
+        assertTrue(map.size() == 2);
+        checkEqual(attrs.size(), map.get("size"));
+        checkEqual(attrs.lastModifiedTime(), map.get("lastModifiedTime"));
+
+        map = Attributes.readAttributes(file,
+            "basic:lastModifiedTime,lastAccessTime,linkCount,ShouldNotExist");
+        assertTrue(map.size() == 3);
+        checkEqual(attrs.lastModifiedTime(), map.get("lastModifiedTime"));
+        checkEqual(attrs.lastAccessTime(), map.get("lastAccessTime"));
+        checkEqual(attrs.lastAccessTime(), map.get("lastAccessTime"));
+    }
+
+    // Exercise getAttribute/setAttribute/readAttributes on posix attributes
+    static void checkPosixAttributes(FileRef file, PosixFileAttributes attrs)
+        throws IOException
+    {
+        checkBasicAttributes(file, attrs);
+
+        // getAttribute
+        checkEqual(attrs.permissions(),
+                   Attributes.getAttribute(file, "posix:permissions"));
+        checkEqual(attrs.owner(),
+                   Attributes.getAttribute(file, "posix:owner"));
+        checkEqual(attrs.group(),
+                   Attributes.getAttribute(file, "posix:group"));
+
+        // setAttribute
+        Set<PosixFilePermission> orig = attrs.permissions();
+        Set<PosixFilePermission> newPerms = new HashSet<PosixFilePermission>(orig);
+        newPerms.remove(PosixFilePermission.OTHERS_READ);
+        newPerms.remove(PosixFilePermission.OTHERS_WRITE);
+        newPerms.remove(PosixFilePermission.OTHERS_EXECUTE);
+        Attributes.setAttribute(file, "posix:permissions", newPerms);
+        checkEqual(Attributes.readPosixFileAttributes(file).permissions(), newPerms);
+        Attributes.setAttribute(file, "posix:permissions", orig);
+        checkEqual(Attributes.readPosixFileAttributes(file).permissions(), orig);
+        Attributes.setAttribute(file, "posix:owner", attrs.owner());
+        Attributes.setAttribute(file, "posix:group", attrs.group());
+
+        // readAttributes
+        Map<String,?> map;
+        map = Attributes.readAttributes(file, "posix:*");
+        assertTrue(map.size() >= 14);
+        checkEqual(attrs.permissions(), map.get("permissions")); // check one
+
+        map = Attributes.readAttributes(file, "posix:size,owner,ShouldNotExist");
+        assertTrue(map.size() == 2);
+        checkEqual(attrs.size(), map.get("size"));
+        checkEqual(attrs.owner(), map.get("owner"));
+    }
+
+    // Exercise getAttribute/setAttribute/readAttributes on unix attributes
+    static void checkUnixAttributes(FileRef file) throws IOException {
+        // getAttribute
+        int mode = (Integer)Attributes.getAttribute(file, "unix:mode");
+        long ino = (Long)Attributes.getAttribute(file, "unix:ino");
+        long dev = (Long)Attributes.getAttribute(file, "unix:dev");
+        long rdev = (Long)Attributes.getAttribute(file, "unix:rdev");
+        int uid = (Integer)Attributes.getAttribute(file, "unix:uid");
+        int gid = (Integer)Attributes.getAttribute(file, "unix:gid");
+        long ctime = (Long)Attributes.getAttribute(file, "unix:ctime");
+
+        // readAttributes
+        Map<String,?> map;
+        map = Attributes.readAttributes(file, "unix:*");
+        assertTrue(map.size() >= 21);
+
+        map = Attributes.readAttributes(file, "unix:size,uid,gid,ShouldNotExist");
+        assertTrue(map.size() == 3);
+        checkEqual(map.get("size"),
+                   Attributes.readBasicFileAttributes(file).size());
+    }
+
+    // Exercise getAttribute/setAttribute/readAttributes on dos attributes
+    static void checkDosAttributes(FileRef file, DosFileAttributes attrs)
+        throws IOException
+    {
+        checkBasicAttributes(file, attrs);
+
+        // getAttribute
+        checkEqual(attrs.isReadOnly(),
+                   Attributes.getAttribute(file, "dos:readonly"));
+        checkEqual(attrs.isHidden(),
+                   Attributes.getAttribute(file, "dos:hidden"));
+        checkEqual(attrs.isSystem(),
+                   Attributes.getAttribute(file, "dos:system"));
+        checkEqual(attrs.isArchive(),
+                   Attributes.getAttribute(file, "dos:archive"));
+
+        // setAttribute
+        boolean value;
+
+        value = attrs.isReadOnly();
+        Attributes.setAttribute(file, "dos:readonly", !value);
+        checkEqual(Attributes.readDosFileAttributes(file).isReadOnly(), !value);
+        Attributes.setAttribute(file, "dos:readonly", value);
+        checkEqual(Attributes.readDosFileAttributes(file).isReadOnly(), value);
+
+        value = attrs.isHidden();
+        Attributes.setAttribute(file, "dos:hidden", !value);
+        checkEqual(Attributes.readDosFileAttributes(file).isHidden(), !value);
+        Attributes.setAttribute(file, "dos:hidden", value);
+        checkEqual(Attributes.readDosFileAttributes(file).isHidden(), value);
+
+        value = attrs.isSystem();
+        Attributes.setAttribute(file, "dos:system", !value);
+        checkEqual(Attributes.readDosFileAttributes(file).isSystem(), !value);
+        Attributes.setAttribute(file, "dos:system", value);
+        checkEqual(Attributes.readDosFileAttributes(file).isSystem(), value);
+
+        value = attrs.isArchive();
+        Attributes.setAttribute(file, "dos:archive", !value);
+        checkEqual(Attributes.readDosFileAttributes(file).isArchive(), !value);
+        Attributes.setAttribute(file, "dos:archive", value);
+        checkEqual(Attributes.readDosFileAttributes(file).isArchive(), value);
+
+        // readAttributes
+        Map<String,?> map;
+        map = Attributes.readAttributes(file, "dos:*");
+        assertTrue(map.size() >= 15);
+        checkEqual(attrs.isReadOnly(), map.get("readonly")); // check one
+
+        map = Attributes.readAttributes(file, "dos:size,hidden,ShouldNotExist");
+        assertTrue(map.size() == 2);
+        checkEqual(attrs.size(), map.get("size"));
+        checkEqual(attrs.isHidden(), map.get("hidden"));
+    }
+
+    static void doTests(Path dir) throws IOException {
+        Path file = dir.resolve("foo").createFile();
+        FileStore store = file.getFileStore();
+        try {
+            checkBasicAttributes(file,
+                Attributes.readBasicFileAttributes(file));
+
+            if (store.supportsFileAttributeView("posix"))
+                checkPosixAttributes(file,
+                    Attributes.readPosixFileAttributes(file));
+
+            if (store.supportsFileAttributeView("unix"))
+                checkUnixAttributes(file);
+
+            if (store.supportsFileAttributeView("dos"))
+                checkDosAttributes(file,
+                    Attributes.readDosFileAttributes(file));
+        } finally {
+            file.delete();
+        }
+    }
+
+
+    public static void main(String[] args) throws IOException {
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            doTests(dir);
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/BasicFileAttributeView/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,150 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.attribute.BasicFileAttributeView
+ * @library ../..
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.io.*;
+
+public class Basic {
+
+    static void check(boolean okay, String msg) {
+        if (!okay)
+            throw new RuntimeException(msg);
+    }
+
+    static void checkAttributesOfDirectory(Path dir)
+        throws IOException
+    {
+        BasicFileAttributes attrs = Attributes.readBasicFileAttributes(dir);
+        check(attrs.isDirectory(), "is a directory");
+        check(!attrs.isRegularFile(), "is not a regular file");
+        check(!attrs.isSymbolicLink(), "is not a link");
+        check(!attrs.isOther(), "is not other");
+        check(attrs.linkCount() >= 1, "should be at least 1");
+
+        // last-modified-time should match java.io.File
+        if (attrs.resolution() == TimeUnit.MILLISECONDS) {
+            File f = new File(dir.toString());
+            check(f.lastModified() == attrs.lastModifiedTime(),
+                "last-modified time should be the same");
+        }
+    }
+
+    static void checkAttributesOfFile(Path dir, Path file)
+        throws IOException
+    {
+        BasicFileAttributes attrs = Attributes.readBasicFileAttributes(file);
+        check(attrs.isRegularFile(), "is a regular file");
+        check(!attrs.isDirectory(), "is not a directory");
+        check(!attrs.isSymbolicLink(), "is not a link");
+        check(!attrs.isOther(), "is not other");
+        check(attrs.linkCount() >= 1, "should be at least 1");
+
+        // size and last-modified-time should match java.io.File
+        File f = new File(file.toString());
+        check(f.length() == attrs.size(), "size should be the same");
+        if (attrs.resolution() == TimeUnit.MILLISECONDS) {
+            check(f.lastModified() == attrs.lastModifiedTime(),
+                "last-modified time should be the same");
+        }
+
+        // copy last-modified time and file create time from directory to file,
+        // re-read attribtues, and check they match
+        BasicFileAttributeView view =
+            file.getFileAttributeView(BasicFileAttributeView.class);
+        BasicFileAttributes dirAttrs = Attributes.readBasicFileAttributes(dir);
+        view.setTimes(dirAttrs.lastModifiedTime(), null, null, dirAttrs.resolution());
+        if (dirAttrs.creationTime() != -1L) {
+            view.setTimes(null, null, dirAttrs.creationTime(), dirAttrs.resolution());
+        }
+        attrs = view.readAttributes();
+        check(attrs.lastModifiedTime() == dirAttrs.lastModifiedTime(),
+            "last-modified time should be equal");
+        if (dirAttrs.creationTime() != -1L) {
+            check(attrs.creationTime() == dirAttrs.creationTime(),
+                "create time should be the same");
+        }
+
+        // security tests
+        check (!(attrs instanceof PosixFileAttributes),
+            "should not be able to cast to PosixFileAttributes");
+    }
+
+    static void checkAttributesOfLink(Path link)
+        throws IOException
+    {
+        BasicFileAttributes attrs = Attributes
+            .readBasicFileAttributes(link, LinkOption.NOFOLLOW_LINKS);
+        check(attrs.isSymbolicLink(), "is a link");
+        check(!attrs.isDirectory(), "is a directory");
+        check(!attrs.isRegularFile(), "is not a regular file");
+        check(!attrs.isOther(), "is not other");
+        check(attrs.linkCount() >= 1, "should be at least 1");
+    }
+
+    static void attributeReadWriteTests(Path dir)
+        throws IOException
+    {
+        // create file
+        Path file = dir.resolve("foo");
+        OutputStream out = file.newOutputStream();
+        try {
+            out.write("this is not an empty file".getBytes("UTF-8"));
+        } finally {
+            out.close();
+        }
+
+        // check attributes of directory and file
+        checkAttributesOfDirectory(dir);
+        checkAttributesOfFile(dir, file);
+
+        // symbolic links may be supported
+        Path link = dir.resolve("link");
+        try {
+            link.createSymbolicLink( file );
+        } catch (UnsupportedOperationException x) {
+            return;
+        } catch (IOException x) {
+            return;
+        }
+        checkAttributesOfLink(link);
+    }
+
+    public static void main(String[] args) throws IOException {
+        // create temporary directory to run tests
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            attributeReadWriteTests(dir);
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/DosFileAttributeView/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.attribute.DosFileAttributeView
+ * @library ../..
+ */
+
+import java.nio.file.*;
+import static java.nio.file.LinkOption.*;
+import java.nio.file.attribute.*;
+import java.util.*;
+import java.io.IOException;
+
+public class Basic {
+
+    static void check(boolean okay) {
+        if (!okay)
+            throw new RuntimeException("Test failed");
+    }
+
+    // exercise each setter/getter method, leaving all attributes unset
+    static void testAttributes(DosFileAttributeView view) throws IOException {
+        view.setReadOnly(true);
+        check(view.readAttributes().isReadOnly());
+        view.setReadOnly(false);
+        check(!view.readAttributes().isReadOnly());
+        view.setHidden(true);
+        check(view.readAttributes().isHidden());
+        view.setHidden(false);
+        check(!view.readAttributes().isHidden());
+        view.setArchive(true);
+        check(view.readAttributes().isArchive());
+        view.setArchive(false);
+        check(!view.readAttributes().isArchive());
+        view.setSystem(true);
+        check(view.readAttributes().isSystem());
+        view.setSystem(false);
+        check(!view.readAttributes().isSystem());
+    }
+
+    // set the value of all attributes
+    static void setAll(DosFileAttributeView view, boolean value)
+        throws IOException
+    {
+        view.setReadOnly(value);
+        view.setHidden(value);
+        view.setArchive(value);
+        view.setSystem(value);
+    }
+
+    // read and write FAT attributes
+    static void readWriteTests(Path dir) throws IOException {
+
+        // create "foo" and test that we can read/write each FAT attribute
+        Path file = dir.resolve("foo");
+        file.newOutputStream().close();
+        try {
+            testAttributes(file
+                .getFileAttributeView(DosFileAttributeView.class));
+
+            // Following tests use a symbolic link so skip if not supported
+            if (!TestUtil.supportsLinks(dir))
+                return;
+
+            Path link = dir.resolve("link").createSymbolicLink(file);
+
+            // test following links
+            testAttributes(link
+                .getFileAttributeView(DosFileAttributeView.class));
+
+            // test not following links
+            try {
+                try {
+                    testAttributes(link
+                        .getFileAttributeView(DosFileAttributeView.class, NOFOLLOW_LINKS));
+                } catch (IOException x) {
+                    // access to link attributes not supported
+                    return;
+                }
+
+                // set all attributes on link
+                // run test on target of link (which leaves them all un-set)
+                // check that attributes of link remain all set
+                setAll(link
+                    .getFileAttributeView(DosFileAttributeView.class, NOFOLLOW_LINKS), true);
+                testAttributes(link
+                    .getFileAttributeView(DosFileAttributeView.class));
+                DosFileAttributes attrs = Attributes.readDosFileAttributes(link, NOFOLLOW_LINKS);
+                check(attrs.isReadOnly());
+                check(attrs.isHidden());
+                check(attrs.isArchive());
+                check(attrs.isSystem());
+                setAll(link
+                    .getFileAttributeView(DosFileAttributeView.class, NOFOLLOW_LINKS), false);
+
+                // set all attributes on target
+                // run test on link (which leaves them all un-set)
+                // check that attributes of target remain all set
+                setAll(link
+                    .getFileAttributeView(DosFileAttributeView.class), true);
+                testAttributes(link
+                    .getFileAttributeView(DosFileAttributeView.class, NOFOLLOW_LINKS));
+                attrs = Attributes.readDosFileAttributes(link, NOFOLLOW_LINKS);
+                check(attrs.isReadOnly());
+                check(attrs.isHidden());
+                check(attrs.isArchive());
+                check(attrs.isSystem());
+                setAll(link
+                    .getFileAttributeView(DosFileAttributeView.class), false);
+            } finally {
+                link.delete(false);
+            }
+        } finally {
+            file.delete(false);
+        }
+    }
+
+    public static void main(String[] args) throws IOException {
+        // create temporary directory to run tests
+        Path dir = TestUtil.createTemporaryDirectory();
+
+        try {
+            // skip test if DOS file attributes not supported
+            if (!dir.getFileStore().supportsFileAttributeView("dos")) {
+                System.out.println("DOS file attribute not supported.");
+                return;
+            }
+            readWriteTests(dir);
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/FileStoreAttributeView/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,170 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.attribute.FileStoreAttributeView
+ * @library ../..
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * Simple unit test for FileStoreAttributeView that checks that the disk space
+ * attribtues are "close" to the equivalent values reported by java.io.File.
+ */
+
+public class Basic {
+
+    static final long K = 1024L;
+    static final long G = 1024L * 1024L * 1024L;
+
+    /**
+     * Print out the disk space information for the given file system
+     */
+    static void printFileStore(FileStore fs) throws IOException {
+        FileStoreSpaceAttributeView view =
+            fs.getFileStoreAttributeView(FileStoreSpaceAttributeView.class);
+        FileStoreSpaceAttributes attrs = view.readAttributes();
+
+        long total = attrs.totalSpace() / K;
+        long used = (attrs.totalSpace() - attrs.unallocatedSpace()) / K;
+        long avail = attrs.usableSpace() / K;
+
+        String s = fs.toString();
+        if (s.length() > 20) {
+            System.out.println(s);
+            s = "";
+        }
+        System.out.format("%-20s %12d %12d %12d\n", s, total, used, avail);
+    }
+
+    /**
+     * Check that two values are within 1GB of each other
+     */
+    static void checkWithin1GB(long value1, long value2) {
+        long diff = Math.abs(value1 - value2);
+        if (diff > G)
+            throw new RuntimeException("values differ by more than 1GB");
+    }
+
+    /**
+     * Check disk space on the file system of the given file
+     */
+    static void checkSpace(Path file) throws IOException {
+        System.out.println(" -- check space -- ");
+        System.out.println(file);
+
+        FileStore fs = file.getFileStore();
+        System.out.format("Filesystem: %s\n", fs);
+
+        // get values reported by java.io.File
+        File f = new File(file.toString());
+        long total = f.getTotalSpace();
+        long free = f.getFreeSpace();
+        long usable = f.getUsableSpace();
+        System.out.println("java.io.File");
+        System.out.format("    Total: %d\n", total);
+        System.out.format("     Free: %d\n", free);
+        System.out.format("   Usable: %d\n", usable);
+
+        // get values reported by the FileStoreSpaceAttributeView
+        FileStoreSpaceAttributes attrs = fs
+            .getFileStoreAttributeView(FileStoreSpaceAttributeView.class)
+            .readAttributes();
+        System.out.println("java.nio.file.FileStoreSpaceAttributeView:");
+        System.out.format("    Total: %d\n", attrs.totalSpace());
+        System.out.format("     Free: %d\n", attrs.unallocatedSpace());
+        System.out.format("   Usable: %d\n", attrs.usableSpace());
+
+        // check values are "close"
+        checkWithin1GB(total, attrs.totalSpace());
+        checkWithin1GB(free, attrs.unallocatedSpace());
+        checkWithin1GB(usable, attrs.usableSpace());
+
+        // get values by name (and in bulk)
+        FileStoreAttributeView view = fs.getFileStoreAttributeView("space");
+        checkWithin1GB(total, (Long)view.getAttribute("totalSpace"));
+        checkWithin1GB(free, (Long)view.getAttribute("unallocatedSpace"));
+        checkWithin1GB(usable, (Long)view.getAttribute("usableSpace"));
+        Map<String,?> map = view.readAttributes("*");
+        checkWithin1GB(total, (Long)map.get("totalSpace"));
+        checkWithin1GB(free, (Long)map.get("unallocatedSpace"));
+        checkWithin1GB(usable, (Long)map.get("usableSpace"));
+        map = view.readAttributes("totalSpace", "unallocatedSpace", "usableSpace");
+        checkWithin1GB(total, (Long)map.get("totalSpace"));
+        checkWithin1GB(free, (Long)map.get("unallocatedSpace"));
+        checkWithin1GB(usable, (Long)map.get("usableSpace"));
+    }
+
+    /**
+     * Check (Windows-specific) volume attributes
+     */
+    static void checkVolumeAttributes() throws IOException {
+        System.out.println(" -- volumes -- ");
+        for (FileStore store: FileSystems.getDefault().getFileStores()) {
+            FileStoreAttributeView view = store.getFileStoreAttributeView("volume");
+            if (view == null)
+                continue;
+            Map<String,?> attrs = view.readAttributes("*");
+            int vsn = (Integer)attrs.get("vsn");
+            boolean compressed = (Boolean)attrs.get("compressed");
+            System.out.format("%s vsn:%x compressed:%b%n", store.name(),
+                vsn, compressed);
+        }
+
+    }
+
+    public static void main(String[] args) throws IOException {
+        // print out the disk space information for all file systems
+        FileSystem fs = FileSystems.getDefault();
+        for (FileStore store: fs.getFileStores()) {
+            printFileStore(store);
+        }
+
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            // check space using directory
+            checkSpace(dir);
+
+            // check space using file
+            Path file = dir.resolve("foo");
+            file.newOutputStream().close();
+            try {
+                checkSpace(file);
+            } finally {
+                file.delete(false);
+            }
+
+            // volume attributes (Windows specific)
+            checkVolumeAttributes();
+
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/NamedAttributeView/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,273 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.attribute.NamedAttributeView
+ * @library ../..
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.nio.file.*;
+import static java.nio.file.LinkOption.*;
+import java.nio.file.attribute.*;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Random;
+import java.io.IOException;
+
+public class Basic {
+
+    private static Random rand = new Random();
+
+    private static final String ATTR_NAME = "user.mime_type";
+    private static final String ATTR_VALUE = "text/plain";
+    private static final String ATTR_VALUE2 = "text/html";
+
+    static interface Task {
+        void run() throws Exception;
+    }
+
+    static void tryCatch(Class<? extends Throwable> ex, Task task) {
+        boolean caught = false;
+        try {
+            task.run();
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass())) {
+                caught = true;
+            } else {
+                throw new RuntimeException(x);
+            }
+        }
+        if (!caught)
+            throw new RuntimeException(ex.getName() + " expected");
+    }
+
+    static void expectNullPointerException(Task task) {
+        tryCatch(NullPointerException.class, task);
+    }
+
+    static boolean hasAttribute(NamedAttributeView view, String attr)
+        throws IOException
+    {
+        for (String name: view.list()) {
+            if (name.equals(ATTR_NAME))
+                return true;
+        }
+        return false;
+    }
+
+    static void test(Path file, LinkOption... options) throws IOException {
+        final NamedAttributeView view = file
+            .getFileAttributeView(NamedAttributeView.class, options);
+        ByteBuffer buf = rand.nextBoolean() ?
+            ByteBuffer.allocate(100) : ByteBuffer.allocateDirect(100);
+
+        // Test: write
+        buf.put(ATTR_VALUE.getBytes()).flip();
+        int size = buf.remaining();
+        int nwrote = view.write(ATTR_NAME, buf);
+        if (nwrote != size)
+            throw new RuntimeException("Unexpected number of bytes written");
+
+        // Test: size
+        if (view.size(ATTR_NAME) != size)
+            throw new RuntimeException("Unexpected size");
+
+        // Test: read
+        buf.clear();
+        int nread = view.read(ATTR_NAME, buf);
+        if (nread != size)
+            throw new RuntimeException("Unexpected number of bytes read");
+        buf.flip();
+        String value = Charset.defaultCharset().decode(buf).toString();
+        if (!value.equals(ATTR_VALUE))
+            throw new RuntimeException("Unexpected attribute value");
+
+        // Test: read with insufficient space
+        tryCatch(IOException.class, new Task() {
+            public void run() throws IOException {
+                view.read(ATTR_NAME, ByteBuffer.allocateDirect(1));
+            }});
+
+        // Test: replace value
+        buf.clear();
+        buf.put(ATTR_VALUE2.getBytes()).flip();
+        size = buf.remaining();
+        view.write(ATTR_NAME, buf);
+        if (view.size(ATTR_NAME) != size)
+            throw new RuntimeException("Unexpected size");
+
+        // Test: list
+        if (!hasAttribute(view, ATTR_NAME))
+            throw new RuntimeException("Attribute name not in list");
+
+        // Test: delete
+        view.delete(ATTR_NAME);
+        if (hasAttribute(view, ATTR_NAME))
+            throw new RuntimeException("Attribute name in list");
+
+        // Test: dynamic access
+        byte[] valueAsBytes = ATTR_VALUE.getBytes();
+        view.setAttribute(ATTR_NAME, valueAsBytes);
+        byte[] actualAsBytes = (byte[])view.getAttribute(ATTR_NAME);
+        if (!Arrays.equals(valueAsBytes, actualAsBytes))
+            throw new RuntimeException("Unexpected attribute value");
+        Map<String,?> map = view.readAttributes(ATTR_NAME);
+        if (!Arrays.equals(valueAsBytes, (byte[])map.get(ATTR_NAME)))
+            throw new RuntimeException("Unexpected attribute value");
+        map = view.readAttributes(ATTR_NAME, "*");
+        if (!Arrays.equals(valueAsBytes, (byte[])map.get(ATTR_NAME)))
+            throw new RuntimeException("Unexpected attribute value");
+        map = view.readAttributes("DoesNotExist");
+        if (!map.isEmpty())
+            throw new RuntimeException("Map expected to be empty");
+    }
+
+    static void miscTests(Path file) throws IOException {
+        final NamedAttributeView view = file
+            .getFileAttributeView(NamedAttributeView.class);
+        view.write(ATTR_NAME, ByteBuffer.wrap(ATTR_VALUE.getBytes()));
+
+        // NullPointerException
+        final ByteBuffer buf = ByteBuffer.allocate(100);
+
+        expectNullPointerException(new Task() {
+            public void run() throws IOException {
+                view.read(null, buf);
+            }});
+        expectNullPointerException(new Task() {
+            public void run() throws IOException {
+                view.read(ATTR_NAME, null);
+            }});
+        expectNullPointerException(new Task() {
+            public void run() throws IOException {
+                view.write(null, buf);
+            }});
+        expectNullPointerException(new Task() {
+            public void run() throws IOException {
+               view.write(ATTR_NAME, null);
+            }});
+        expectNullPointerException(new Task() {
+            public void run() throws IOException {
+                view.size(null);
+            }});
+        expectNullPointerException(new Task() {
+            public void run() throws IOException {
+                view.delete(null);
+            }});
+        expectNullPointerException(new Task() {
+            public void run() throws IOException {
+                view.getAttribute(null);
+            }});
+        expectNullPointerException(new Task() {
+            public void run() throws IOException {
+                view.setAttribute(ATTR_NAME, null);
+            }});
+        expectNullPointerException(new Task() {
+            public void run() throws IOException {
+                view.setAttribute(null, new byte[0]);
+            }});
+         expectNullPointerException(new Task() {
+            public void run() throws IOException {
+               view.readAttributes(null);
+            }});
+        expectNullPointerException(new Task() {
+            public void run() throws IOException {
+                view.readAttributes("*", (String[])null);
+            }});
+        expectNullPointerException(new Task() {
+            public void run() throws IOException {
+                view.readAttributes("*", ATTR_NAME, null);
+            }});
+
+        // Read-only buffer
+        tryCatch(IllegalArgumentException.class, new Task() {
+            public void run() throws IOException {
+                ByteBuffer buf = ByteBuffer.wrap(ATTR_VALUE.getBytes()).asReadOnlyBuffer();
+                view.write(ATTR_NAME, buf);
+                buf.flip();
+                view.read(ATTR_NAME, buf);
+            }});
+
+        // Zero bytes remaining
+        tryCatch(IOException.class, new Task() {
+            public void run() throws IOException {
+                ByteBuffer buf = buf = ByteBuffer.allocateDirect(100);
+                buf.position(buf.capacity());
+                view.read(ATTR_NAME, buf);
+            }});
+    }
+
+    public static void main(String[] args) throws IOException {
+        // create temporary directory to run tests
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            if (!dir.getFileStore().supportsFileAttributeView("xattr")) {
+                System.out.println("NamedAttributeView not supported - skip test");
+                return;
+            }
+
+            // test access to named attributes of regular file
+            Path file = dir.resolve("foo.html").createFile();
+            try {
+                test(file);
+            } finally {
+                file.delete();
+            }
+
+            // test access to named attributes of directory
+            file = dir.resolve("foo").createDirectory();
+            try {
+                test(file);
+            } finally {
+                file.delete();
+            }
+
+            // test access to named attributes of sym link
+            if (TestUtil.supportsLinks(dir)) {
+                Path target = dir.resolve("doesnotexist");
+                Path link = dir.resolve("link").createSymbolicLink(target);
+                try {
+                    test(link, NOFOLLOW_LINKS);
+                } catch (IOException x) {
+                    // access to attributes of sym link may not be supported
+                } finally {
+                    link.delete();
+                }
+            }
+
+            // misc. tests
+            try {
+                file = dir.resolve("foo.txt").createFile();
+                miscTests(dir);
+            } finally {
+                file.delete();
+            }
+
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/attribute/PosixFileAttributeView/Basic.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,398 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.attribute.PosixFileAttributeView
+ * @library ../..
+ */
+
+import java.nio.file.*;
+import static java.nio.file.LinkOption.*;
+import java.nio.file.attribute.*;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * Unit test for PosixFileAttributeView, passing silently if this attribute
+ * view is not available.
+ */
+
+public class Basic {
+
+    /**
+     * Use view to update permission to the given mode and check that the
+     * permissions have been updated.
+     */
+    static void testPermissions(PosixFileAttributeView view, String mode)
+        throws IOException
+    {
+        System.out.format("change mode: %s\n", mode);
+        Set<PosixFilePermission> perms = PosixFilePermissions.fromString(mode);
+
+        // change permissions and re-read them.
+        view.setPermissions(perms);
+        Set<PosixFilePermission> current = view.readAttributes().permissions();
+        if (!current.equals(perms)) {
+            throw new RuntimeException("Actual permissions: " +
+                PosixFilePermissions.toString(current) + ", expected: " +
+                PosixFilePermissions.toString(perms));
+        }
+
+        // repeat test using setAttribute/getAttribute
+        view.setAttribute("permissions", perms);
+        current = (Set<PosixFilePermission>)view.getAttribute("permissions");
+        if (!current.equals(perms)) {
+            throw new RuntimeException("Actual permissions: " +
+                PosixFilePermissions.toString(current) + ", expected: " +
+                PosixFilePermissions.toString(perms));
+        }
+    }
+
+    /**
+     * Check that the actual permissions of a file match or make it more
+     * secure than requested
+     */
+    static void checkSecure(Set<PosixFilePermission> requested,
+                            Set<PosixFilePermission> actual)
+    {
+        for (PosixFilePermission perm: actual) {
+            if (!requested.contains(perm)) {
+                throw new RuntimeException("Actual permissions: " +
+                    PosixFilePermissions.toString(actual) + ", requested: " +
+                    PosixFilePermissions.toString(requested) +
+                    " - file is less secure than requested");
+            }
+        }
+    }
+
+    /**
+     * Create file with given mode and check that the file is created with a
+     * mode that is not less secure
+     */
+    static void createWithPermissions(Path file,
+                                      String mode)
+        throws IOException
+    {
+        Set<PosixFilePermission> requested = PosixFilePermissions.fromString(mode);
+        FileAttribute<Set<PosixFilePermission>> attr =
+            PosixFilePermissions.asFileAttribute(requested);
+        System.out.format("create file with mode: %s\n", mode);
+
+        EnumSet<StandardOpenOption> options = EnumSet.of(StandardOpenOption.CREATE_NEW,
+            StandardOpenOption.WRITE);
+        file.newOutputStream(options, attr).close();
+        try {
+            checkSecure(requested,  file
+                .getFileAttributeView(PosixFileAttributeView.class)
+                .readAttributes()
+                .permissions());
+        } finally {
+            file.delete(false);
+        }
+
+        System.out.format("create directory with mode: %s\n", mode);
+        file.createDirectory(attr);
+        try {
+            checkSecure(requested,  file
+                .getFileAttributeView(PosixFileAttributeView.class)
+                .readAttributes()
+                .permissions());
+        } finally {
+            file.delete(false);
+        }
+    }
+
+    /**
+     * Test the setPermissions/permissions methods.
+     */
+    static void permissionTests(Path dir)
+        throws IOException
+    {
+        System.out.println("-- Permission Tests  --");
+
+        // create file and test updating and reading its permissions
+        Path file = dir.resolve("foo");
+        System.out.format("create %s\n", file);
+        file.newOutputStream().close();
+        try {
+            // get initial permissions so that we can restore them later
+            PosixFileAttributeView view = file
+                .getFileAttributeView(PosixFileAttributeView.class);
+            Set<PosixFilePermission> save = view.readAttributes()
+                .permissions();
+
+            // test various modes
+            try {
+                testPermissions(view, "---------");
+                testPermissions(view, "r--------");
+                testPermissions(view, "-w-------");
+                testPermissions(view, "--x------");
+                testPermissions(view, "rwx------");
+                testPermissions(view, "---r-----");
+                testPermissions(view, "----w----");
+                testPermissions(view, "-----x---");
+                testPermissions(view, "---rwx---");
+                testPermissions(view, "------r--");
+                testPermissions(view, "-------w-");
+                testPermissions(view, "--------x");
+                testPermissions(view, "------rwx");
+                testPermissions(view, "r--r-----");
+                testPermissions(view, "r--r--r--");
+                testPermissions(view, "rw-rw----");
+                testPermissions(view, "rwxrwx---");
+                testPermissions(view, "rw-rw-r--");
+                testPermissions(view, "r-xr-x---");
+                testPermissions(view, "r-xr-xr-x");
+                testPermissions(view, "rwxrwxrwx");
+            } finally {
+                view.setPermissions(save);
+            }
+        } finally {
+            file.delete(false);
+        }
+
+        // create link (to file that doesn't exist) and test reading of
+        // permissions
+        if (TestUtil.supportsLinks(dir)) {
+            Path link = dir.resolve("link");
+            System.out.format("create link %s\n", link);
+            link.createSymbolicLink(file);
+            try {
+                PosixFileAttributes attrs = Attributes
+                    .readPosixFileAttributes(link, NOFOLLOW_LINKS);
+                if (!attrs.isSymbolicLink()) {
+                    throw new RuntimeException("not a link");
+                }
+            } finally {
+                link.delete(false);
+            }
+        }
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Test creating a file and directory with initial permissios
+     */
+    static void createTests(Path dir)
+        throws IOException
+    {
+        System.out.println("-- Create Tests  --");
+
+        Path file = dir.resolve("foo");
+
+        createWithPermissions(file, "---------");
+        createWithPermissions(file, "r--------");
+        createWithPermissions(file, "-w-------");
+        createWithPermissions(file, "--x------");
+        createWithPermissions(file, "rwx------");
+        createWithPermissions(file, "---r-----");
+        createWithPermissions(file, "----w----");
+        createWithPermissions(file, "-----x---");
+        createWithPermissions(file, "---rwx---");
+        createWithPermissions(file, "------r--");
+        createWithPermissions(file, "-------w-");
+        createWithPermissions(file, "--------x");
+        createWithPermissions(file, "------rwx");
+        createWithPermissions(file, "r--r-----");
+        createWithPermissions(file, "r--r--r--");
+        createWithPermissions(file, "rw-rw----");
+        createWithPermissions(file, "rwxrwx---");
+        createWithPermissions(file, "rw-rw-r--");
+        createWithPermissions(file, "r-xr-x---");
+        createWithPermissions(file, "r-xr-xr-x");
+        createWithPermissions(file, "rwxrwxrwx");
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Test setOwner/setGroup methods - this test simply exercises the
+     * methods to avoid configuration.
+     */
+    static void ownerTests(Path dir)
+        throws IOException
+    {
+        System.out.println("-- Owner Tests  --");
+
+        Path file = dir.resolve("gus");
+        System.out.format("create %s\n", file);
+
+        file.newOutputStream().close();
+        try {
+
+            // read attributes of directory to get owner/group
+            PosixFileAttributeView view = file
+                .getFileAttributeView(PosixFileAttributeView.class);
+            PosixFileAttributes attrs = view.readAttributes();
+
+            // set to existing owner/group
+            view.setOwner(attrs.owner());
+            view.setGroup(attrs.group());
+
+            // repeat test using setAttribute
+            Map<String,?> map = view.readAttributes("owner","group");
+            view.setAttribute("owner", map.get("owner"));
+            view.setAttribute("group", map.get("group"));
+
+        } finally {
+            file.delete(false);
+        }
+
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Test the lookupPrincipalByName/lookupPrincipalByGroupName methods
+     */
+    static void lookupPrincipalTests(Path dir)
+        throws IOException
+    {
+        System.out.println("-- Lookup UserPrincipal Tests --");
+
+        UserPrincipalLookupService lookupService = dir.getFileSystem()
+            .getUserPrincipalLookupService();
+
+        // read attributes of directory to get owner/group
+        PosixFileAttributes attrs = Attributes.readPosixFileAttributes(dir);
+
+        // lookup owner and check it matches file's owner
+        System.out.format("lookup: %s\n", attrs.owner().getName());
+        try {
+            UserPrincipal owner = lookupService.lookupPrincipalByName(attrs.owner().getName());
+            if (owner instanceof GroupPrincipal)
+                throw new RuntimeException("owner is a group?");
+            if (!owner.equals(attrs.owner()))
+                throw new RuntimeException("owner different from file owner");
+        } catch (UserPrincipalNotFoundException x) {
+            System.out.println("user not found - test skipped");
+        }
+
+        // lookup group and check it matches file's group-owner
+        System.out.format("lookup group: %s\n", attrs.group().getName());
+        try {
+            GroupPrincipal group = lookupService.lookupPrincipalByGroupName(attrs.group().getName());
+            if (!group.equals(attrs.group()))
+                throw new RuntimeException("group different from file group-owner");
+        } catch (UserPrincipalNotFoundException x) {
+            System.out.println("group not found - test skipped");
+        }
+
+        // test that UserPrincipalNotFoundException is thrown
+        String invalidPrincipal = "scumbag99";
+        try {
+            System.out.format("lookup: %s\n", invalidPrincipal);
+            lookupService.lookupPrincipalByName(invalidPrincipal);
+            throw new RuntimeException("'" + invalidPrincipal + "' is a valid user?");
+        } catch (UserPrincipalNotFoundException x) {
+        }
+        try {
+            System.out.format("lookup group: %s\n", invalidPrincipal);
+            lookupService.lookupPrincipalByGroupName("idonotexist");
+            throw new RuntimeException("'" + invalidPrincipal + "' is a valid group?");
+        } catch (UserPrincipalNotFoundException x) {
+        }
+        System.out.println("OKAY");
+    }
+
+    /**
+     * Test various exceptions are thrown as expected
+     */
+    @SuppressWarnings("unchecked")
+    static void exceptionsTests(Path dir)
+        throws IOException
+    {
+        System.out.println("-- Exceptions --");
+
+        PosixFileAttributeView view = dir
+            .getFileAttributeView(PosixFileAttributeView.class);
+
+        // NullPointerException
+        try {
+            view.setOwner(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException x) {
+        }
+        try {
+            view.setGroup(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException x) {
+        }
+
+        UserPrincipalLookupService lookupService = dir.getFileSystem()
+            .getUserPrincipalLookupService();
+        try {
+            lookupService.lookupPrincipalByName(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException x) {
+        }
+        try {
+            lookupService.lookupPrincipalByGroupName(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException x) {
+        }
+        try {
+            view.setPermissions(null);
+            throw new RuntimeException("NullPointerException not thrown");
+        } catch (NullPointerException x) {
+        }
+        try {
+            Set<PosixFilePermission> perms = new HashSet<PosixFilePermission>();
+            perms.add(null);
+            view.setPermissions(perms);
+            throw new RuntimeException("NullPointerException not thrown");
+        }  catch (NullPointerException x) {
+        }
+
+        // ClassCastException
+        try {
+            Set perms = new HashSet();  // raw type
+            perms.add(new Object());
+            view.setPermissions(perms);
+            throw new RuntimeException("ClassCastException not thrown");
+        }  catch (ClassCastException x) {
+        }
+
+        System.out.println("OKAY");
+    }
+
+    public static void main(String[] args) throws IOException {
+        Path dir = TestUtil.createTemporaryDirectory();
+        try {
+            if (!dir.getFileStore().supportsFileAttributeView("posix")) {
+                System.out.println("PosixFileAttributeView not supported");
+                return;
+            }
+
+            permissionTests(dir);
+            createTests(dir);
+            ownerTests(dir);
+            lookupPrincipalTests(dir);
+            exceptionsTests(dir);
+
+        } finally {
+            TestUtil.removeAll(dir);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/spi/SetDefaultProvider.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 4313887
+ * @summary Unit test for java.nio.file.spi.FileSystemProvider
+ * @build TestProvider SetDefaultProvider
+ * @run main/othervm -Djava.nio.file.spi.DefaultFileSystemProvider=TestProvider SetDefaultProvider
+ */
+
+import java.nio.file.*;
+import java.nio.file.spi.*;
+
+public class SetDefaultProvider {
+    public static void main(String[] args) throws Exception {
+        Class<?> c = FileSystems.getDefault().provider().getClass();
+
+        Class<?> expected = Class.forName("TestProvider", false,
+            ClassLoader.getSystemClassLoader());
+
+        if (c != expected)
+            throw new RuntimeException();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/nio2/openjdk/jdk/test/java/nio/file/spi/TestProvider.java	Fri Mar 06 12:26:40 2009 +0000
@@ -0,0 +1,128 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+import java.nio.file.spi.FileSystemProvider;
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.net.URI;
+import java.util.*;
+import java.io.IOException;
+
+public class TestProvider extends FileSystemProvider {
+
+    private final FileSystem theFileSystem;
+
+    public TestProvider(FileSystemProvider defaultProvider) {
+        theFileSystem = new TestFileSystem(this);
+
+    }
+
+
+    public String getScheme() {
+        return "file";
+    }
+
+
+    public FileSystem newFileSystem(URI uri, Map<String,?> env) {
+        throw new RuntimeException("not implemented");
+    }
+
+
+    public FileSystem getFileSystem(URI uri) {
+        return theFileSystem;
+    }
+
+
+    public Path getPath(URI uri) {
+        throw new RuntimeException("not implemented");
+    }
+
+    static class TestFileSystem extends FileSystem {
+        private final TestProvider provider;
+
+        TestFileSystem(TestProvider provider) {
+            this.provider = provider;
+        }
+
+
+        public FileSystemProvider provider() {
+            return provider;
+        }
+
+
+        public void close() throws IOException {
+            throw new RuntimeException("not implemented");
+        }
+
+
+        public boolean isOpen() {
+            throw new RuntimeException("not implemented");
+        }
+
+
+        public boolean isReadOnly() {
+            throw new RuntimeException("not implemented");
+        }
+
+
+        public String getSeparator() {
+            throw new RuntimeException("not implemented");
+        }
+
+
+        public Iterable<Path> getRootDirectories() {
+            throw new RuntimeException("not implemented");
+        }
+
+
+        public Iterable<FileStore> getFileStores() {
+            throw new RuntimeException("not implemented");
+        }
+
+
+        public Set<String> supportedFileAttributeViews() {
+            throw new RuntimeException("not implemented");
+        }
+
+
+        public Path getPath(String path) {
+            throw new RuntimeException("not implemented");
+        }
+
+
+        public PathMatcher getNameMatcher(String syntax, String pattern) {
+            throw new RuntimeException("not implemented");
+        }
+
+
+        public UserPrincipalLookupService getUserPrincipalLookupService() {
+            throw new RuntimeException("not implemented");
+        }
+
+
+        public WatchService newWatchService() throws IOException {
+            throw new RuntimeException("not implemented");
+        }
+    }
+
+}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/io/Inputs/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,218 +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.
- *
- * 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.
- */
-
-/* @test
- * @summary Basic unit test for java.io.Inputs class
- */
-
-import java.io.*;
-import java.util.*;
-import java.nio.charset.UnsupportedCharsetException;
-import java.nio.charset.MalformedInputException;
-
-import java.io.Inputs;
-
-import java.nio.file.Path;
-
-public class Basic {
-    static final Random rand = new Random();
-
-    public static void main(String[] args) throws IOException {
-        Path dir = createTempDir();
-        try {
-            testReadAllBytesMethods(dir);
-            testReadAllLinesMethods(dir);
-        } finally {
-            dir.delete();
-        }
-    }
-
-    static void testReadAllBytesMethods(Path dir) throws IOException {
-        // create file with random bytes
-        byte[] bytes = new byte[1 + rand.nextInt(64*1024)];
-        rand.nextBytes(bytes);
-        Path file = dir.resolve("foo");
-        Outputs.write(file, bytes);
-
-        try {
-            byte[] result;
-
-            // check all bytes are read
-            result = Inputs.readAllBytes(file);
-            if (!Arrays.equals(bytes, result))
-                throw new RuntimeException("Unexpected bytes");
-            result = Inputs.readAllBytes(new File(file.toString()));
-            if (!Arrays.equals(bytes, result))
-                throw new RuntimeException("Unexpected bytes");
-
-            // via URL connection
-            InputStream in = file.toUri().toURL().openConnection().getInputStream();
-            try {
-                result = Inputs.readAllBytes(in);
-            if (!Arrays.equals(bytes, result))
-                throw new RuntimeException("Unexpected bytes");
-            } finally {
-                in.close();
-            }
-
-            // test zero-length file
-            Outputs.write(file, new byte[0]);
-            if (Inputs.readAllBytes(file).length != 0)
-                throw new RuntimeException("Unexpected bytes");
-
-            // NullPointerException
-            try {
-                Inputs.readAllBytes((FileRef)null);
-                throw new RuntimeException("NullPointerException expected");
-            } catch (NullPointerException npe) { }
-
-            try {
-                Inputs.readAllBytes((File)null);
-                throw new RuntimeException("NullPointerException expected");
-            } catch (NullPointerException npe) { }
-
-            try {
-                Inputs.readAllBytes((InputStream)null);
-                throw new RuntimeException("NullPointerException expected");
-            } catch (NullPointerException npe) { }
-
-        } finally {
-            file.delete();
-        }
-    }
-
-    static void testReadAllLinesMethods(Path dir) throws IOException {
-        String[] poem = { "I met a traveler from an antique land",
-                          "Who said: Two vast and trunkless legs of stone",
-                          "Stand in the desert. Near them, on the sand",
-                          "Half sunk, a shattered visage lies, whose frown,",
-                          "And wrinkled lip, and sneer of cold command,",
-                          "Tell that its sculptor well those passions read",
-                          "Which yet survive, stamped on these lifeless things,",
-                          "The hand that mocked them, and the heart that fed;",
-                          "And on the pedestal these words appear:",
-                          "My name is Ozymandias, king of kings:",
-                          "Look upon my works, ye Mighty, and despair!",
-                          "Nothing beside remains. Round the decay",
-                          "Of that colossal wreck, boundless and bare",
-                          "The lone and level sands stretch far away." };
-        List<String> poemAsList = Arrays.asList(poem);
-
-        Path file = dir.resolve("Shelley");
-        try {
-            Outputs.writeLines(file, poem);
-
-            checkEquals(poemAsList, Inputs.readAllLines(file));
-            checkEquals(poemAsList, Inputs.readAllLines(file, "UTF-8"));
-            checkEquals(poemAsList, Inputs.readAllLines(new File(file.toString())));
-            checkEquals(poemAsList,
-                Inputs.readAllLines(new File(file.toString()), "UTF-8"));
-            InputStream in = file.newInputStream();
-            try {
-                checkEquals(poemAsList, Inputs.readAllLines(in));
-            } finally {
-                in.close();
-            }
-            InputStreamReader reader = new InputStreamReader(file.newInputStream());
-            try {
-                checkEquals(poemAsList, Inputs.readAllLines(reader));
-            } finally {
-                reader.close();
-            }
-
-            // IOException
-            try {
-                Inputs.readAllLines(dir.resolve("doesNotExist"));
-                throw new RuntimeException("IOException expected");
-            } catch (IOException ignore) { }
-
-            // MalformedInputException
-            OutputStream out = file.newOutputStream();
-            try {
-                out.write((byte)0xC2);  // malformed 2-byte sequence
-                out.write((byte)0x00);
-            } finally {
-                out.close();
-            }
-            try {
-                Inputs.readAllLines(file, "UTF-8");
-                throw new RuntimeException("MalformedInputException expected");
-            } catch (MalformedInputException ignore) { }
-
-            // UnsupportedCharsetException
-            try {
-                Inputs.readAllLines(file, "BAD-CHARSET");
-                throw new RuntimeException("UnsupportedCharsetException expected");
-            } catch (UnsupportedCharsetException ignore) { }
-
-            try {
-                Inputs.readAllLines(new File(file.toString()), "BAD-CHARSET");
-                throw new RuntimeException("UnsupportedCharsetException expected");
-            } catch (UnsupportedCharsetException ignore) { }
-            in = file.newInputStream();
-            try {
-                try {
-                    Inputs.readAllLines(in, "BAD-CHARSET");
-                    throw new RuntimeException("UnsupportedCharsetException expected");
-                } catch (UnsupportedCharsetException ignore) { }
-            } finally {
-                in.close();
-            }
-
-            // NulPointerException
-            try {
-                Inputs.readAllLines((FileRef)null);
-                throw new RuntimeException("NullPointerException expected");
-            } catch (NullPointerException npe) { }
-            try {
-                Inputs.readAllLines((FileRef)null, "UTF-8");
-                throw new RuntimeException("NullPointerException expected");
-            } catch (NullPointerException npe) { }
-
-            try {
-                Inputs.readAllLines(file, null);
-                throw new RuntimeException("NullPointerException expected");
-            } catch (NullPointerException npe) { }
-
-        } finally {
-            file.delete();
-        }
-    }
-
-    static void checkEquals(List<String> expected, List<String> actual) {
-        if (!actual.equals(expected))
-            throw new RuntimeException();
-    }
-
-
-    static Path createTempDir() throws IOException {
-        Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir"));
-        Random r = new Random();
-
-        Path dir;
-        do {
-            dir = tmpdir.resolve("name" + r.nextInt());
-        } while (dir.exists());
-        return dir.createDirectory();
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +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.
- *
- * 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.
- */
-
-import java.util.concurrent.*;
-
-import java.nio.channels.AsynchronousChannelGroup;
-
-/**
- * Test that arbitrary tasks can be submitted to a channel group's thread pool.
- */
-
-public class AsExecutor {
-
-    public static void main(String[] args) throws Exception {
-        // create channel groups
-        ThreadFactory factory = new PrivilegedThreadFactory();
-        int nThreads = 5;
-        ExecutorService pool = Executors.newFixedThreadPool(5, factory);
-        AsynchronousChannelGroup group1 = AsynchronousChannelGroup
-            .withFixedThreadPool(pool, nThreads);
-        AsynchronousChannelGroup group2 = AsynchronousChannelGroup
-            .withCachedThreadPool(Executors.newCachedThreadPool(factory), 0);
-
-        try {
-            // execute simple tasks
-            testSimpleTask(group1);
-            testSimpleTask(group2);
-
-            // install security manager and test again
-            System.setSecurityManager( new SecurityManager() );
-            testSimpleTask(group1);
-            testSimpleTask(group2);
-
-            // attempt to execute tasks that run with only frames from boot
-            // class loader on the stack.
-            testAttackingTask(group1);
-            testAttackingTask(group2);
-        } finally {
-            group1.shutdown();
-            group2.shutdown();
-        }
-    }
-
-    static void testSimpleTask(AsynchronousChannelGroup group) throws Exception {
-        Executor executor = (Executor)group;
-        final CountDownLatch latch = new CountDownLatch(1);
-        executor.execute(new Runnable() {
-            public void run() {
-                latch.countDown();
-            }
-        });
-        latch.await();
-    }
-
-    static void testAttackingTask(AsynchronousChannelGroup group) throws Exception {
-        Executor executor = (Executor)group;
-        Attack task = new Attack();
-        executor.execute(task);
-        task.waitUntilDone();
-        if (!task.failedDueToSecurityException())
-            throw new RuntimeException("SecurityException expected");
-    }
-
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Attack.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +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.
- *
- * 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.
- */
-
-import java.net.*;
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * A task that attempts to attack the current host.
- */
-
-public class Attack implements Runnable {
-    private final CountDownLatch latch = new CountDownLatch(1);
-    private volatile boolean failedDueToSecurityException;
-
-    public void Attack() {
-        // check class is on boot class path
-        if (Attack.class.getClassLoader() != null)
-            throw new RuntimeException("Attack class not on boot class path");
-    }
-
-
-    public void run() {
-        try {
-            new Socket("127.0.0.1", 9999).close();
-            throw new RuntimeException("Connected (not expected)");
-        } catch (IOException e) {
-            throw new RuntimeException("IOException (not expected)");
-        } catch (SecurityException e) {
-            failedDueToSecurityException = true;
-        } finally {
-            latch.countDown();
-        }
-    }
-
-    public void waitUntilDone() throws InterruptedException {
-        latch.await();
-    }
-
-    public boolean failedDueToSecurityException() {
-        return failedDueToSecurityException;
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,261 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4607272
- * @summary Unit test for AsynchronousChannelGroup
- * @build Basic
- * @run main/othervm -XX:-UseVMInterruptibleIO Basic
- */
-
-import java.nio.ByteBuffer;
-import java.nio.channels.*;
-import java.net.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.io.IOException;
-
-import java.nio.channels.AsynchronousChannelGroup;
-
-public class Basic {
-    static final Random rand = new Random();
-
-    public static void main(String[] args) throws Exception {
-        shutdownTests();
-        shutdownNowTests();
-        afterShutdownTests();
-        miscTests();
-    }
-
-    static void shutdownTests() throws Exception {
-        System.out.println("-- test shutdown --");
-
-        // test shutdown with no channels in groups
-        for (int i=0; i<500; i++) {
-            ExecutorService pool;
-            AsynchronousChannelGroup group;
-            if (rand.nextBoolean()) {
-                pool = Executors.newCachedThreadPool();
-                group = AsynchronousChannelGroup.withCachedThreadPool(pool, rand.nextInt(5));
-            } else {
-                int nThreads = 1 + rand.nextInt(8);
-                pool = Executors.newFixedThreadPool(nThreads);
-                group = AsynchronousChannelGroup.withFixedThreadPool(pool, nThreads);
-            }
-            group.shutdown();
-            if (!group.isShutdown())
-                throw new RuntimeException("Group should be shutdown");
-            // group should terminate quickly
-            boolean terminated = group.awaitTermination(3, TimeUnit.SECONDS);
-            if (!terminated)
-                throw new RuntimeException("Group should have terminated");
-            if (!pool.isTerminated())
-                throw new RuntimeException("Executor should have terminated");
-        }
-
-        // shutdown with channel in group
-        for (int i=0; i<500; i++) {
-            ExecutorService pool;
-            AsynchronousChannelGroup group;
-            if (rand.nextBoolean()) {
-                pool = Executors.newCachedThreadPool();
-                group = AsynchronousChannelGroup.withCachedThreadPool(pool, rand.nextInt(10));
-            } else {
-                int nThreads = 1 + rand.nextInt(8);
-                pool = Executors.newFixedThreadPool(nThreads);
-                group = AsynchronousChannelGroup.withFixedThreadPool(pool, nThreads);
-            }
-            // create channel that is bound to group
-            AsynchronousChannel ch;
-            switch (rand.nextInt(3)) {
-                case 0 : ch = AsynchronousSocketChannel.open(group); break;
-                case 1 : ch = AsynchronousServerSocketChannel.open(group); break;
-                case 2 : ch = AsynchronousDatagramChannel.open(null, group); break;
-                default : throw new AssertionError();
-            }
-            group.shutdown();
-            if (!group.isShutdown())
-                throw new RuntimeException("Group should be shutdown");
-
-            // last channel so should terminate after this channel is closed
-            ch.close();
-
-            // group should terminate quickly
-            boolean terminated = group.awaitTermination(3, TimeUnit.SECONDS);
-            if (!terminated)
-                throw new RuntimeException("Group should have terminated");
-            if (!pool.isTerminated())
-                throw new RuntimeException("Executor should have terminated");
-        }
-    }
-
-    static void shutdownNowTests() throws Exception {
-        System.out.println("-- test shutdownNow --");
-
-        for (int i=0; i< 10; i++) {
-            ExecutorService pool;
-            AsynchronousChannelGroup group;
-            if (rand.nextBoolean()) {
-                pool = Executors.newCachedThreadPool();
-                group = AsynchronousChannelGroup
-                    .withCachedThreadPool(pool, rand.nextInt(5));
-            } else {
-                int nThreads = 1 + rand.nextInt(8);
-                pool = Executors.newFixedThreadPool(nThreads);
-                group = AsynchronousChannelGroup.withFixedThreadPool(pool, nThreads);
-            }
-
-            // I/O in progress
-            AsynchronousChannel ch;
-            if (rand.nextBoolean()) {
-                AsynchronousServerSocketChannel listener = AsynchronousServerSocketChannel
-                    .open(group).bind(new InetSocketAddress(0));
-                listener.accept();
-                ch = listener;
-            } else {
-                AsynchronousDatagramChannel adc =
-                    AsynchronousDatagramChannel.open(null, group);
-                adc.receive(ByteBuffer.allocate(100));
-                ch = adc;
-            }
-
-            // forceful shutdown
-            group.shutdownNow();
-
-            // shutdownNow is required to close all channels
-            if (ch.isOpen())
-                throw new RuntimeException("Channel should be closed");
-
-            boolean terminated = group.awaitTermination(3, TimeUnit.SECONDS);
-            if (!terminated)
-                throw new RuntimeException("Group should have terminated");
-            if (!pool.isTerminated())
-                throw new RuntimeException("Executor should have terminated");
-        }
-    }
-
-    // test creating channels in group after group is shutdown
-    static void afterShutdownTests() throws Exception {
-        System.out.println("-- test operations after group is shutdown  --");
-        ExecutorService pool = Executors.newFixedThreadPool(1);
-        AsynchronousChannelGroup group =
-            AsynchronousChannelGroup.withFixedThreadPool(pool, 1);
-
-        AsynchronousSocketChannel ch = AsynchronousSocketChannel.open(group);
-        AsynchronousServerSocketChannel listener = AsynchronousServerSocketChannel.open(group);
-
-        // initiate accept
-        listener.bind(new InetSocketAddress(0));
-        Future<AsynchronousSocketChannel> result = listener.accept();
-
-        // shutdown group
-        group.shutdown();
-        if (!group.isShutdown())
-            throw new RuntimeException("Group should be shutdown");
-
-        // attempt to create another channel
-        try {
-            AsynchronousSocketChannel.open(group);
-            throw new RuntimeException("ShutdownChannelGroupException expected");
-        } catch (ShutdownChannelGroupException x) {
-        }
-        try {
-            AsynchronousServerSocketChannel.open(group);
-            throw new RuntimeException("ShutdownChannelGroupException expected");
-        } catch (ShutdownChannelGroupException x) {
-        }
-
-        // attempt to create another channel by connecting. This should cause
-        // the accept operation to fail.
-        InetAddress lh = InetAddress.getLocalHost();
-        int port = ((InetSocketAddress)listener.getLocalAddress()).getPort();
-        InetSocketAddress isa = new InetSocketAddress(lh, port);
-        ch.connect(isa).get();
-        try {
-            result.get();
-            throw new RuntimeException("Connection was accepted");
-        } catch (ExecutionException x) {
-            Throwable cause = x.getCause();
-            if (!(cause instanceof IOException))
-                throw new RuntimeException("Cause should be IOException");
-            cause = cause.getCause();
-            if (!(cause instanceof ShutdownChannelGroupException))
-                throw new RuntimeException("IOException cause should be ShutdownChannelGroupException");
-        }
-
-        // initiate another accept even though channel group is shutdown.
-        Future<AsynchronousSocketChannel> res = listener.accept();
-        try {
-            res.get(3, TimeUnit.SECONDS);
-            throw new RuntimeException("TimeoutException expected");
-        } catch (TimeoutException x) {
-        }
-        // connect to the listener which should cause the accept to complete
-        AsynchronousSocketChannel.open().connect(isa);
-        try {
-            res.get();
-            throw new RuntimeException("Connection was accepted");
-        } catch (ExecutionException x) {
-            Throwable cause = x.getCause();
-            if (!(cause instanceof IOException))
-                throw new RuntimeException("Cause should be IOException");
-            cause = cause.getCause();
-            if (!(cause instanceof ShutdownChannelGroupException))
-                throw new RuntimeException("IOException cause should be ShutdownChannelGroupException");
-        }
-
-        // group should *not* terminate as channels are open
-        boolean terminated = group.awaitTermination(3, TimeUnit.SECONDS);
-        if (terminated)
-            throw new RuntimeException("Group should not have terminated");
-
-        // close channel; group should terminate quickly
-        ch.close();
-        listener.close();
-        terminated = group.awaitTermination(3, TimeUnit.SECONDS);
-        if (!terminated)
-            throw new RuntimeException("Group should have terminated");
-    }
-
-    static void miscTests() throws Exception {
-        System.out.println("-- miscellenous tests --");
-        try {
-            AsynchronousChannelGroup.withFixedThreadPool(null, 1);
-            throw new RuntimeException("NPE expected");
-        } catch (NullPointerException x) {
-        }
-        ExecutorService pool = Executors.newCachedThreadPool();
-        try {
-            AsynchronousChannelGroup.withFixedThreadPool(pool, 0);
-            throw new RuntimeException("IAE expected");
-        } catch (IllegalArgumentException e) {
-        } finally {
-            pool.shutdown();
-        }
-        try {
-            AsynchronousChannelGroup.withCachedThreadPool(null, 0);
-            throw new RuntimeException("NPE expected");
-        } catch (NullPointerException x) {
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4607272
- * @summary Unit test for AsynchronousChannelGroup
- */
-
-import java.nio.ByteBuffer;
-import java.nio.channels.*;
-import java.net.*;
-import java.util.concurrent.*;
-import java.io.IOException;
-
-/**
- * This test verifies that a channel or channel group can be closed from a
- * completion handler when there are no threads available to handle I/O events.
- */
-
-public class GroupOfOne {
-
-    public static void main(String[] args) throws Exception {
-        // create listener to accept connections
-        final AsynchronousServerSocketChannel listener =
-            AsynchronousServerSocketChannel.open()
-                .bind(new InetSocketAddress(0));
-        listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
-            public void completed(AsynchronousSocketChannel ch, Void att) {
-                listener.accept(null, this);
-            }
-            public void failed(Throwable exc, Void att) {
-            }
-            public void cancelled(Void att) {
-            }
-        });
-
-        int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
-        SocketAddress sa = new InetSocketAddress(InetAddress.getLocalHost(), port);
-
-        test(sa, true, false);
-        test(sa, false, true);
-        test(sa, true, true);
-    }
-
-    static void test(SocketAddress sa,
-                     final boolean closeChannel,
-                     final boolean shutdownGroup)
-        throws Exception
-    {
-        // group with 1 thread
-        ExecutorService pool = Executors.newFixedThreadPool(1);
-        final AsynchronousChannelGroup group =
-            AsynchronousChannelGroup.withFixedThreadPool(pool, 1);
-        final AsynchronousSocketChannel ch = AsynchronousSocketChannel.open(group);
-
-        // the latch counts down when:
-        // 1. The read operation fails (expected)
-        // 2. the close/shutdown completes
-        final CountDownLatch latch = new CountDownLatch(2);
-
-        ch.connect(sa, null, new CompletionHandler<Void,Void>() {
-            public void completed(Void result, Void att)  {
-                System.out.println("Connected");
-
-                // initiate I/O operation that does not complete (successfully)
-                ByteBuffer buf = ByteBuffer.allocate(100);
-                ch.read(buf, null, new CompletionHandler<Integer,Void>() {
-                    public void completed(Integer bytesRead, Void att)  {
-                        throw new RuntimeException();
-                    }
-                    public void failed(Throwable exc, Void att) {
-                        if (!(exc instanceof AsynchronousCloseException))
-                            throw new RuntimeException(exc);
-                        System.out.println("Read failed (expected)");
-                        latch.countDown();
-                    }
-                    public void cancelled(Void att) {
-                        throw new RuntimeException();
-                    }
-                });
-
-                // close channel or shutdown group
-                try {
-                    if (closeChannel) {
-                        System.out.print("Close channel ...");
-                        ch.close();
-                        System.out.println(" done.");
-                    }
-                    if (shutdownGroup) {
-                        System.out.print("Shutdown group ...");
-                        group.shutdownNow();
-                        System.out.println(" done.");
-                    }
-                    latch.countDown();
-                } catch (IOException e) {
-                    throw new RuntimeException();
-                }
-            }
-            public void failed(Throwable exc, Void att) {
-                throw new RuntimeException(exc);
-            }
-            public void cancelled(Void att) {
-                throw new RuntimeException();
-            }
-        });
-
-        latch.await();
-
-        // clean-up
-        group.shutdown();
-        boolean terminated = group.awaitTermination(5, TimeUnit.SECONDS);
-        if (!terminated)
-            throw new RuntimeException("Group did not terminate");
-
-        System.out.println("TEST OKAY");
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Identity.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4607272
- * @summary Unit test for AsynchronousChannelGroup
- */
-
-import java.nio.ByteBuffer;
-import java.nio.channels.*;
-import java.net.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-/**
- * Tests that the completion handler is invoked by a thread with
- * the expected identity.
- */
-
-public class Identity {
-    static final Random rand = new Random();
-    static final CountDownLatch done = new CountDownLatch(1);
-    static final AtomicBoolean failed = new AtomicBoolean(false);
-
-    static void fail(String msg) {
-        failed.set(true);
-        done.countDown();
-        throw new RuntimeException(msg);
-    }
-
-    // thread-local identifies the thread
-    private static final ThreadLocal<Integer> myGroup =
-        new ThreadLocal<Integer>() {
- protected Integer initialValue() {
-                return Integer.valueOf(-1);
-            }
-        };
-
-    // creates a ThreadFactory that constructs groups with the given identity
-    static final ThreadFactory createThreadFactory(final int groupId) {
-        return new ThreadFactory() {
-
-            public Thread newThread(final Runnable r) {
-                Thread t = new Thread(new Runnable() {
-                    public void run() {
-                        myGroup.set(groupId);
-                        r.run();
-                    }});
-                t.setDaemon(true);
-                return t;
-            }
-        };
-    }
-
-    public static void main(String[] args) throws Exception {
-        // create listener to accept connections
-        final AsynchronousServerSocketChannel listener =
-            AsynchronousServerSocketChannel.open()
-                .bind(new InetSocketAddress(0));
-        listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
-            public void completed(final AsynchronousSocketChannel ch, Void att) {
-                listener.accept(null, this);
-
-                final ByteBuffer buf = ByteBuffer.allocate(100);
-                ch.read(buf, null, new CompletionHandler<Integer,Void>() {
-                    public void completed(Integer bytesRead, Void att) {
-                        buf.clear();
-                        ch.read(buf, null, this);
-                    }
-                    public void failed(Throwable exc, Void att) {
-                    }
-                    public void cancelled(Void att) {
-                    }
-                });
-            }
-            public void failed(Throwable exc, Void att) {
-            }
-            public void cancelled(Void att) {
-            }
-        });
-        int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
-        SocketAddress sa = new InetSocketAddress(InetAddress.getLocalHost(), port);
-
-        // create 3-10 channels, each in its own group
-        final int groupCount = 3 + rand.nextInt(8);
-        final AsynchronousSocketChannel[] channel = new AsynchronousSocketChannel[groupCount];
-        for (int i=0; i<groupCount; i++) {
-            ThreadFactory factory = createThreadFactory(i);
-            AsynchronousChannelGroup group;
-            if (rand.nextBoolean()) {
-                int nThreads = 1 + rand.nextInt(10);
-                ExecutorService pool = Executors.newFixedThreadPool(nThreads, factory);
-                group = AsynchronousChannelGroup.withFixedThreadPool(pool, nThreads);
-            } else {
-                ExecutorService pool = Executors.newCachedThreadPool(factory);
-                group = AsynchronousChannelGroup.withCachedThreadPool(pool, rand.nextInt(5));
-            }
-
-            // create channel in group and connect it to the server
-            AsynchronousSocketChannel ch = AsynchronousSocketChannel.open(group);
-            ch.connect(sa).get();
-            channel[i] = ch;
-        }
-
-        // randomly write to each channel, ensuring that the completion handler
-        // is always invoked by a thread with the right identity.
-        final AtomicInteger writeCount = new AtomicInteger(100);
-        channel[0].write(getBuffer(), 0, new CompletionHandler<Integer,Integer>() {
-            public void completed(Integer bytesWritten, Integer groupId) {
-                if (bytesWritten != 1)
-                    fail("Expected 1 byte to be written");
-                if (!myGroup.get().equals(groupId))
-                    fail("Handler invoked by thread with the wrong identity");
-                if (writeCount.decrementAndGet() > 0) {
-                    int id = rand.nextInt(groupCount);
-                    channel[id].write(getBuffer(), id, this);
-                } else {
-                    done.countDown();
-                }
-            }
-            public void failed(Throwable exc, Integer groupId) {
-                fail(exc.getMessage());
-            }
-            public void cancelled(Integer groupId) {
-                fail("I/O operation was cancelled");
-            }
-        });
-
-        // wait until
-        done.await();
-        if (failed.get())
-            throw new RuntimeException("Test failed - see log for details");
-    }
-
-    static ByteBuffer getBuffer() {
-        ByteBuffer buf;
-        if (rand.nextBoolean()) {
-            buf = ByteBuffer.allocateDirect(1);
-        } else {
-            buf = ByteBuffer.allocate(1);
-        }
-        buf.put((byte)0);
-        buf.flip();
-        return buf;
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/PrivilegedThreadFactory.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +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.
- *
- * 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.
- */
-
-import java.util.concurrent.ThreadFactory;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * The "privileged" ThreadFactory used by the AsExecutor test.
- */
-
-public class PrivilegedThreadFactory implements ThreadFactory {
-    public void PrivilegedThreadPoolFactory() {
-        // check class is on boot class path
-        if (PrivilegedThreadFactory.class.getClassLoader() != null)
-            throw new RuntimeException("PrivilegedThreadFactory class not on boot class path");
-    }
-
-
-    public Thread newThread(final Runnable r) {
-        return AccessController.doPrivileged(new PrivilegedAction<Thread>() {
-
-            public Thread run() {
-                Thread t = new Thread(r);
-                t.setDaemon(true);
-                return t;
-            }
-        });
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Restart.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4607272
- * @summary Unit test for AsynchronousChannelGroup
- * @build Restart
- * @run main/othervm -XX:-UseVMInterruptibleIO Restart
- */
-
-import java.nio.channels.*;
-import java.net.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-import java.io.IOException;
-
-/**
- * Exercise replacement of threads in the thread pool when completion handlers
- * terminate due to errors or runtime exceptions.
- */
-
-public class Restart {
-    static final Random rand = new Random();
-
-    public static void main(String[] args) throws Exception {
-        // thread group for thread pools
-        final ThreadGroup tg = new ThreadGroup("test");
-
-        // keep track of the number of threads that terminate
-        final AtomicInteger exceptionCount = new AtomicInteger(0);
-        final Thread.UncaughtExceptionHandler ueh =
-            new Thread.UncaughtExceptionHandler() {
-                public void uncaughtException(Thread t, Throwable e) {
-                    exceptionCount.incrementAndGet();
-                }
-            };
-        ThreadFactory factory = new ThreadFactory() {
-
-            public Thread newThread(Runnable r) {
-                Thread t = new Thread(tg, r);
-                t.setUncaughtExceptionHandler(ueh);
-                return t;
-            }
-        };
-
-        // group with fixed thread pool
-        int nThreads = 1 + rand.nextInt(4);
-        ExecutorService pool = Executors.newFixedThreadPool(nThreads, factory);
-        AsynchronousChannelGroup group =
-            AsynchronousChannelGroup.withFixedThreadPool(pool, nThreads);
-        testRestart(group, 100);
-        group.shutdown();
-
-        // group with thread pool created automatically
-        pool = Executors.newCachedThreadPool(factory);
-        group = AsynchronousChannelGroup.withCachedThreadPool(pool, rand.nextInt(5));
-        testRestart(group, 100);
-        group.shutdown();
-
-        // give time for threads to terminate
-        Thread.sleep(3000);
-        int actual = exceptionCount.get();
-        if (actual != 200)
-            throw new RuntimeException(actual + " exceptions, expected: " + 200);
-    }
-
-    static void testRestart(AsynchronousChannelGroup group, int count)
-        throws Exception
-    {
-        AsynchronousServerSocketChannel listener =
-            AsynchronousServerSocketChannel.open(group)
-                .bind(new InetSocketAddress(0));
-
-        for (int i=0; i<count; i++) {
-            final CountDownLatch latch = new CountDownLatch(1);
-
-            listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
-                public void completed(AsynchronousSocketChannel ch, Void att) {
-                    try {
-                        ch.close();
-                    } catch (IOException ignore) { }
-
-                    latch.countDown();
-
-                    // throw error or runtime exception
-                    if (rand.nextBoolean()) {
-                        throw new Error();
-                    } else {
-                        throw new RuntimeException();
-                    }
-                }
-                public void failed(Throwable exc, Void att) {
-                }
-                public void cancelled(Void att) {
-                }
-            });
-
-            // establish loopback connection which should cause completion
-            // handler to be invoked.
-            int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
-            AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
-            InetAddress lh = InetAddress.getLocalHost();
-            ch.connect(new InetSocketAddress(lh, port)).get();
-            ch.close();
-
-            // wait for handler to be invoked
-            latch.await();
-        }
-
-        // clean-up
-        listener.close();
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/Unbounded.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4607272
- * @summary Unit test for AsynchronousChannelGroup
- */
-
-import java.nio.ByteBuffer;
-import java.nio.channels.*;
-import java.net.*;
-import java.util.concurrent.*;
-import java.io.IOException;
-
-public class Unbounded {
-    // number of concurrent completion handlers
-    static final int CONCURRENCY_COUNT = 512;
-
-    public static void main(String[] args) throws Exception {
-        // all accepted connections are added to a queue
-        final ArrayBlockingQueue<AsynchronousSocketChannel> queue =
-            new ArrayBlockingQueue<AsynchronousSocketChannel>(CONCURRENCY_COUNT);
-
-        // create listener to accept connections
-        final AsynchronousServerSocketChannel listener =
-            AsynchronousServerSocketChannel.open()
-                .bind(new InetSocketAddress(0));
-        listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
-            public void completed(AsynchronousSocketChannel ch, Void att) {
-                queue.add(ch);
-                listener.accept(null, this);
-            }
-            public void failed(Throwable exc, Void att) {
-            }
-            public void cancelled(Void att) {
-            }
-        });
-        System.out.println("Listener created.");
-
-        // establish lots of connections
-        int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
-        SocketAddress sa = new InetSocketAddress(InetAddress.getLocalHost(), port);
-        AsynchronousSocketChannel[] channels =
-            new AsynchronousSocketChannel[CONCURRENCY_COUNT];
-        for (int i=0; i<CONCURRENCY_COUNT; i++) {
-            int attempts = 0;
-            for (;;) {
-                try {
-                    channels[i] = AsynchronousSocketChannel.open();
-                    channels[i].connect(sa).get();
-                    break;
-                } catch (IOException x) {
-                    // probably resource issue so back off and retry
-                    if (++attempts >= 3)
-                        throw x;
-                    Thread.sleep(50);
-                }
-            }
-        }
-        System.out.println("All connection established.");
-
-        // the barrier where all threads (plus the main thread) wait
-        final CyclicBarrier barrier = new CyclicBarrier(CONCURRENCY_COUNT+1);
-
-        // initiate a read operation on each channel.
-        for (int i=0; i<CONCURRENCY_COUNT; i++) {
-            ByteBuffer buf = ByteBuffer.allocateDirect(100);
-            channels[i].read( buf, channels[i],
-                new CompletionHandler<Integer,AsynchronousSocketChannel>() {
-                    public void completed(Integer bytesRead, AsynchronousSocketChannel ch) {
-                        try {
-                            ch.close();
-                            barrier.await();
-                        } catch (Exception x) {
-                            throw new AssertionError(x);
-                        }
-                    }
-                    public void failed(Throwable exc, AsynchronousSocketChannel ch) {
-                    }
-                    public void cancelled(AsynchronousSocketChannel ch) {
-                    }
-                });
-        }
-        System.out.println("All read operations outstanding.");
-
-        // write data to each of the accepted connections
-        int remaining = CONCURRENCY_COUNT;
-        while (remaining > 0) {
-            AsynchronousSocketChannel ch = queue.take();
-            ch.write(ByteBuffer.wrap("welcome".getBytes())).get();
-            ch.close();
-            remaining--;
-        }
-
-        // wait for all threads to reach the barrier
-        System.out.println("Waiting for all threads to reach barrier");
-        barrier.await();
-        listener.close();
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +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.
-#
-# 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.
-#
-
-# @test
-# @bug 4607272
-# @summary Unit test for AsynchronousChannelGrou#execute
-# @build AsExecutor PrivilegedThreadFactory Attack
-# @run shell run_any_task.sh
-
-# if TESTJAVA isn't set then we assume an interactive run.
-
-if [ -z "$TESTJAVA" ]; then
-    TESTSRC=.
-    TESTCLASSES=.
-    JAVA=java
-    JAR=jar
-else
-    JAVA="${TESTJAVA}/bin/java"
-    JAR="${TESTJAVA}/bin/jar"
-fi
-
-echo "Creating JAR file ..."
-$JAR -cf "${TESTCLASSES}/Privileged.jar" \
-    -C "${TESTCLASSES}" PrivilegedThreadFactory.class \
-    -C "${TESTCLASSES}" PrivilegedThreadFactory\$1.class \
-    -C "${TESTCLASSES}" Attack.class
-
-echo "Running test ..."
-$JAVA -XX:-UseVMInterruptibleIO \
-    -Xbootclasspath/a:"${TESTCLASSES}/Privileged.jar" \
-    -classpath "${TESTCLASSES}" \
-    AsExecutor
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousDatagramChannel/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,377 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4527345
- * @summary Unit test for AsynchronousDatagramChannel
- */
-
-import java.nio.ByteBuffer;
-import java.nio.channels.*;
-import java.net.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-public class Basic {
-
-    public static void main(String[] args) throws Exception {
-        doReceiveTests();
-        doReadTests();
-        doSendTests();
-        doWriteTests();
-        doMulticastTests();
-    }
-
-    // basic receive tests
-    static void doReceiveTests() throws Exception {
-        final byte[] msg = "hello".getBytes();
-
-        AsynchronousDatagramChannel ch = AsynchronousDatagramChannel.open()
-            .bind(new InetSocketAddress(0));
-        int port = ((InetSocketAddress)(ch.getLocalAddress())).getPort();
-        InetAddress rh = InetAddress.getLocalHost();
-        final SocketAddress sa = new InetSocketAddress(rh, port);
-
-        DatagramChannel sender = DatagramChannel.open();
-        ByteBuffer dst = ByteBuffer.allocateDirect(100);
-
-        // Test: datagram packet received immediately
-        sender.send(ByteBuffer.wrap(msg), sa);
-        dst.clear();
-        ch.receive(dst).get(1, TimeUnit.SECONDS);
-        if (dst.flip().remaining() != msg.length)
-            throw new RuntimeException("Unexpected number of bytes read");
-
-        // Test: datagram packet not received immediately
-        dst.clear();
-        final CountDownLatch latch = new CountDownLatch(1);
-        ch.receive(dst, null, new CompletionHandler<SocketAddress,Void>() {
-            public void completed(SocketAddress source, Void att) {
-                latch.countDown();
-            }
-            public void failed (Throwable exc, Void att) {
-            }
-            public void cancelled(Void att) {
-            }
-        });
-        Thread.sleep(2000);
-        sender.send(ByteBuffer.wrap(msg), sa);
-        latch.await(2, TimeUnit.SECONDS);  // wait for completion handler
-
-        // Test: timeout
-        dst.clear();
-        final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
-        ch.receive(dst, 2, TimeUnit.SECONDS, null, new CompletionHandler<SocketAddress,Void>() {
-            public void completed(SocketAddress source, Void att) {
-            }
-            public void failed (Throwable exc, Void att) {
-                exception.set(exc);
-            }
-            public void cancelled(Void att) {
-            }
-        });
-        Throwable result;
-        while ((result = exception.get()) == null) {
-            Thread.sleep(100);
-        }
-        if (!(result instanceof InterruptedByTimeoutException))
-            throw new RuntimeException("InterruptedByTimeoutException expected");
-
-        // AsynchronousCloseException
-        dst = ByteBuffer.allocateDirect(100);
-        exception.set(null);
-        ch.receive(dst, null, new CompletionHandler<SocketAddress,Void>() {
-            public void completed(SocketAddress source, Void att) {
-            }
-            public void failed (Throwable exc, Void att) {
-                exception.set(exc);
-            }
-            public void cancelled(Void att) {
-            }
-        });
-        ch.close();
-        while ((result = exception.get()) == null) {
-            Thread.sleep(100);
-        }
-        if (!(result instanceof AsynchronousCloseException))
-            throw new RuntimeException("AsynchronousCloseException expected");
-
-        // done
-        sender.close();
-    }
-
-    // basic read tests
-    static void doReadTests() throws Exception {
-        final byte[] msg = "hello".getBytes();
-
-        AsynchronousDatagramChannel ch = AsynchronousDatagramChannel.open()
-            .bind(new InetSocketAddress(0));
-        int port = ((InetSocketAddress)(ch.getLocalAddress())).getPort();
-        InetAddress lh = InetAddress.getLocalHost();
-        final SocketAddress sa = new InetSocketAddress(lh, port);
-
-        DatagramChannel sender = DatagramChannel.open();
-        ByteBuffer dst = ByteBuffer.allocateDirect(100);
-
-        // Test: not connected
-        try {
-            ch.read(dst);
-            throw new RuntimeException("NotYetConnectedException expected");
-        } catch (NotYetConnectedException e) {
-        }
-
-        // connect the channel
-        sender.bind(new InetSocketAddress(0));
-        ch.connect(new InetSocketAddress(lh,
-                ((InetSocketAddress)(sender.getLocalAddress())).getPort()));
-
-        // Test: datagram packet received immediately
-        sender.send(ByteBuffer.wrap(msg), sa);
-        dst.clear();
-        ch.read(dst).get(1, TimeUnit.SECONDS);
-        if (dst.flip().remaining() != msg.length)
-            throw new RuntimeException("Unexpected number of bytes read");
-
-        // Test: datagram packet not received immediately
-        dst.clear();
-        final CountDownLatch l1 = new CountDownLatch(1);
-        ch.read(dst, null, new CompletionHandler<Integer,Void>() {
-            public void completed(Integer bytesRead, Void att) {
-                l1.countDown();
-            }
-            public void failed (Throwable exc, Void att) {
-            }
-            public void cancelled(Void att) {
-            }
-        });
-        Thread.sleep(2000);
-        sender.send(ByteBuffer.wrap(msg), sa);
-        l1.await(2, TimeUnit.SECONDS);
-
-        // Test: timeout
-        dst.clear();
-        final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
-        ch.read(dst, 2, TimeUnit.SECONDS, null, new CompletionHandler<Integer,Void>() {
-            public void completed(Integer bytesRead, Void att) {
-            }
-            public void failed (Throwable exc, Void att) {
-                exception.set(exc);
-            }
-            public void cancelled(Void att) {
-            }
-        });
-        Throwable result;
-        while ((result = exception.get()) == null) {
-            Thread.sleep(100);
-        }
-        if (!(result instanceof InterruptedByTimeoutException))
-            throw new RuntimeException("InterruptedByTimeoutException expected");
-
-        // AsynchronousCloseException
-        dst.clear();
-        exception.set(null);
-        ch.read(dst, null, new CompletionHandler<Integer,Void>() {
-            public void completed(Integer bytesRead, Void att) {
-            }
-            public void failed (Throwable exc, Void att) {
-                exception.set(exc);
-            }
-            public void cancelled(Void att) {
-            }
-        });
-        ch.close();
-        while ((result = exception.get()) == null) {
-            Thread.sleep(100);
-        }
-        if (!(result instanceof AsynchronousCloseException))
-            throw new RuntimeException("AsynchronousCloseException expected");
-
-        // done
-        sender.close();
-    }
-
-    // basic send tests
-    static void doSendTests() throws Exception {
-        final byte[] msg = "hello".getBytes();
-
-        DatagramChannel reader = DatagramChannel.open()
-            .bind(new InetSocketAddress(0));
-        int port = ((InetSocketAddress)(reader.getLocalAddress())).getPort();
-        InetAddress rh = InetAddress.getLocalHost();
-        SocketAddress sa = new InetSocketAddress(rh, port);
-
-        AsynchronousDatagramChannel ch = AsynchronousDatagramChannel.open();
-
-        // Test: send datagram packet to reader
-        int bytesSent = ch.send(ByteBuffer.wrap(msg), sa).get();
-        if (bytesSent != msg.length)
-            throw new RuntimeException("Unexpected number of bytes sent");
-
-        // check received
-        ByteBuffer dst = ByteBuffer.allocateDirect(100);
-        reader.receive(dst);
-        dst.flip();
-        if (dst.remaining() != msg.length)
-            throw new RuntimeException("Unexpected number of bytes received");
-
-        // Test: send datagram packet to reader and check completion handler
-        // is invoked
-        final CountDownLatch l2 = new CountDownLatch(1);
-        ch.send(ByteBuffer.wrap(msg), sa, null, new CompletionHandler<Integer,Void>() {
-            public void completed(Integer bytesSent, Void att) {
-                if (bytesSent != msg.length)
-                    throw new RuntimeException("Unexpected number of bytes received");
-                l2.countDown();
-            }
-            public void failed (Throwable exc, Void att) {
-            }
-            public void cancelled(Void att) {
-            }
-        });
-        l2.await(5, TimeUnit.SECONDS);
-
-        // check received
-        dst.clear();
-        reader.receive(dst);
-        dst.flip();
-        if (dst.remaining() != msg.length)
-            throw new RuntimeException("Unexpected number of bytes received");
-
-        // Test: check that failed method is invoked
-        ch.close();
-        final CountDownLatch l3 = new CountDownLatch(1);
-        ch.send(ByteBuffer.wrap(msg), sa, null, new CompletionHandler<Integer,Void>() {
-            public void completed(Integer bytesSent, Void att) {
-                throw new RuntimeException("completed method invoked");
-            }
-            public void failed (Throwable exc, Void att) {
-                if (exc instanceof ClosedChannelException) {
-                    l3.countDown();
-                } else {
-                    throw new RuntimeException(exc);
-                }
-            }
-            public void cancelled(Void att) {
-            }
-        });
-        l3.await(5, TimeUnit.SECONDS);
-
-        // done
-        reader.close();
-    }
-
-    // basic write tests
-    static void doWriteTests() throws Exception {
-        final byte[] msg = "hello".getBytes();
-
-        DatagramChannel reader = DatagramChannel.open()
-            .bind(new InetSocketAddress(0));
-        int port = ((InetSocketAddress)(reader.getLocalAddress())).getPort();
-        InetAddress rh = InetAddress.getLocalHost();
-        SocketAddress sa = new InetSocketAddress(rh, port);
-
-        AsynchronousDatagramChannel ch = AsynchronousDatagramChannel.open();
-
-        // Test: unconnected
-        try {
-            ch.write(ByteBuffer.wrap(msg)).get();
-            throw new RuntimeException("NotYetConnectedException expected");
-        } catch (NotYetConnectedException e) {
-        }
-
-        // Test: connect, and write datagram
-        ch.connect(sa);
-        int bytesSent = ch.write(ByteBuffer.wrap(msg)).get();
-        if (bytesSent != msg.length)
-            throw new RuntimeException("Unexpected number of bytes sent");
-
-        // check received
-        ByteBuffer dst = ByteBuffer.allocateDirect(100);
-        reader.receive(dst);
-        dst.flip();
-        if (dst.remaining() != msg.length)
-            throw new RuntimeException("Unexpected number of bytes received");
-
-        // Test: write datagram and check completion handler is invoked
-        final CountDownLatch l2 = new CountDownLatch(1);
-        ch.write(ByteBuffer.wrap(msg), null, new CompletionHandler<Integer,Void>() {
-            public void completed(Integer bytesSent, Void att) {
-                if (bytesSent != msg.length)
-                    throw new RuntimeException("Unexpected number of bytes received");
-                l2.countDown();
-            }
-            public void failed (Throwable exc, Void att) {
-            }
-            public void cancelled(Void att) {
-            }
-        });
-        l2.await(5, TimeUnit.SECONDS);
-
-        // check received
-        dst.clear();
-        reader.receive(dst);
-        dst.flip();
-        if (dst.remaining() != msg.length)
-            throw new RuntimeException("Unexpected number of bytes received");
-
-        // done
-        ch.close();
-        reader.close();
-    }
-
-    // basic multicast test
-    static void doMulticastTests() throws Exception {
-        final byte[] msg = "hello".getBytes();
-
-        AsynchronousDatagramChannel ch = AsynchronousDatagramChannel
-            .open(StandardProtocolFamily.INET, null)
-            .setOption(StandardSocketOption.SO_REUSEADDR, true)
-            .bind(new InetSocketAddress(0));
-
-        InetAddress lh = InetAddress.getLocalHost();
-        int port = ((InetSocketAddress)(ch.getLocalAddress())).getPort();
-
-        // join group
-        InetAddress group = InetAddress.getByName("225.4.5.6");
-        NetworkInterface interf = NetworkInterface.getByInetAddress(lh);
-        MembershipKey key = ch.join(group, interf);
-
-        // check key
-        if (key.channel() != ch)
-            throw new RuntimeException("Not the expected channel");
-
-        // send message to group
-        DatagramChannel sender = DatagramChannel.open();
-        sender.send(ByteBuffer.wrap(msg), new InetSocketAddress(group, port));
-        sender.close();
-
-        // check message received
-        ByteBuffer dst = ByteBuffer.allocate(200);
-        SocketAddress source = ch.receive(dst).get(2, TimeUnit.SECONDS);
-        if (!((InetSocketAddress)source).getAddress().equals(lh))
-            throw new RuntimeException("Unexpected source");
-
-        // done
-        ch.close();
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,585 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4607272
- * @summary Unit test for AsynchronousFileChannel
- */
-
-import java.nio.file.*;
-import java.nio.channels.*;
-import java.nio.ByteBuffer;
-import java.io.File;
-import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicReference;
-import static java.nio.file.StandardOpenOption.*;
-
-public class Basic {
-
-    private static final Random rand = new Random();
-
-    public static void main(String[] args) throws IOException {
-        // create temporary file
-        File blah = File.createTempFile("blah", null);
-        blah.deleteOnExit();
-
-        final AsynchronousFileChannel ch = AsynchronousFileChannel
-            .open(blah.toPath(), READ, WRITE);
-
-        // run tests
-        testUsingCompletionHandlers(ch);
-        testUsingWaitOnResult(ch);
-        testLocking(ch);
-        testInterruptHandlerThread(ch);
-
-        // close channel and invoke test that expects channel to be closed
-        ch.close();
-        testClosedChannel(ch);
-
-        // these tests open the file themselves
-        testCustomThreadPool(blah.toPath());
-        testAsynchronousClose(blah.toPath());
-        testCancel(blah.toPath());
-        testTruncate(blah.toPath());
-    }
-
-    /*
-     * Generate buffer with random contents
-     * Writes buffer to file using a CompletionHandler to consume the result
-     *    of each write operation
-     * Reads file to EOF to a new buffer using a CompletionHandler to consume
-     *    the result of each read operation
-     * Compares buffer contents
-     */
-    static void testUsingCompletionHandlers(AsynchronousFileChannel ch)
-        throws IOException
-    {
-        System.out.println("testUsingCompletionHandlers");
-
-        ch.truncate(0L);
-
-        // generate buffer with random elements and write it to file
-        ByteBuffer src = genBuffer();
-        writeFully(ch, src, 0L);
-
-        // read to EOF or buffer is full
-        ByteBuffer dst = (rand.nextBoolean()) ?
-            ByteBuffer.allocateDirect(src.capacity()) :
-            ByteBuffer.allocate(src.capacity());
-        readAll(ch, dst, 0L);
-
-        // check buffers are the same
-        src.flip();
-        dst.flip();
-        if (!src.equals(dst)) {
-            throw new RuntimeException("Contents differ");
-        }
-    }
-
-    /*
-     * Generate buffer with random contents
-     * Writes buffer to file, invoking the Future's get method to wait for
-     *    each write operation to complete
-     * Reads file to EOF to a new buffer, invoking the Future's get method to
-     *    wait for each write operation to complete
-     * Compares buffer contents
-     */
-    static void testUsingWaitOnResult(AsynchronousFileChannel ch)
-        throws IOException
-    {
-        System.out.println("testUsingWaitOnResult");
-
-        ch.truncate(0L);
-
-        // generate buffer
-        ByteBuffer src = genBuffer();
-
-        // write buffer completely to file
-        long position = 0L;
-        while (src.hasRemaining()) {
-            Future<Integer> result = ch.write(src, position);
-            try {
-                int n = result.get();
-                // update position
-                position += n;
-            } catch (ExecutionException x) {
-                throw new RuntimeException(x.getCause());
-            } catch (InterruptedException x) {
-                throw new RuntimeException(x);
-            }
-        }
-
-        // read file into new buffer
-        ByteBuffer dst = (rand.nextBoolean()) ?
-            ByteBuffer.allocateDirect(src.capacity()) :
-            ByteBuffer.allocate(src.capacity());
-        position = 0L;
-        int n;
-        do {
-            Future<Integer> result = ch.read(dst, position);
-            try {
-                n = result.get();
-
-                // update position
-                if (n > 0) position += n;
-            } catch (ExecutionException x) {
-                throw new RuntimeException(x.getCause());
-            } catch (InterruptedException x) {
-                throw new RuntimeException(x);
-            }
-        } while (n > 0);
-
-        // check buffers are the same
-        src.flip();
-        dst.flip();
-        if (!src.equals(dst)) {
-            throw new RuntimeException("Contents differ");
-        }
-    }
-
-    // exercise lock methods
-    static void testLocking(AsynchronousFileChannel ch)
-        throws IOException
-    {
-        System.out.println("testLocking");
-
-        // test 1 - acquire lock and check that tryLock throws
-        // OverlappingFileLockException
-        FileLock fl;
-        try {
-            fl = ch.lock().get();
-        } catch (ExecutionException x) {
-            throw new RuntimeException(x);
-        } catch (InterruptedException x) {
-            throw new RuntimeException("Should not be interrupted");
-        }
-        if (!fl.acquiredBy().equals(ch))
-            throw new RuntimeException("FileLock#acquiredBy returned incorrect channel");
-        try {
-            ch.tryLock();
-            throw new RuntimeException("OverlappingFileLockException expected");
-        } catch (OverlappingFileLockException x) {
-        }
-        fl.release();
-
-        // test 2 - acquire try and check that lock throws OverlappingFileLockException
-        fl = ch.tryLock();
-        if (fl == null)
-            throw new RuntimeException("Unable to acquire lock");
-        try {
-            ch.lock(null, new CompletionHandler<FileLock,Void> () {
-                public void completed(FileLock result, Void att) {
-                }
-                public void failed(Throwable exc, Void att) {
-                }
-                public void cancelled(Void att) {
-                }
-            });
-            throw new RuntimeException("OverlappingFileLockException expected");
-        } catch (OverlappingFileLockException x) {
-        }
-        fl.release();
-    }
-
-    // interrupt should not close channel
-    static void testInterruptHandlerThread(final AsynchronousFileChannel ch) {
-        System.out.println("testInterruptHandlerThread");
-
-        ByteBuffer buf = ByteBuffer.allocateDirect(100);
-        final CountDownLatch latch = new CountDownLatch(1);
-
-        ch.read(buf, 0L, null, new CompletionHandler<Integer,Void>() {
-            public void completed(Integer result, Void att) {
-                try {
-                    Thread.currentThread().interrupt();
-                    long size = ch.size();
-                    latch.countDown();
-                } catch (IOException x) {
-                    x.printStackTrace();
-                }
-            }
-            public void failed(Throwable exc, Void att) {
-            }
-            public void cancelled(Void att) {
-            }
-        });
-
-        // wait for handler to complete
-        await(latch);
-    }
-
-    // invoke method on closed channel
-    static void testClosedChannel(AsynchronousFileChannel ch) {
-        System.out.println("testClosedChannel");
-
-        if (ch.isOpen())
-            throw new RuntimeException("Channel should be closed");
-
-        ByteBuffer buf = ByteBuffer.allocateDirect(100);
-
-        // check read fails with ClosedChannelException
-        try {
-            ch.read(buf, 0L).get();
-            throw new RuntimeException("ExecutionException expected");
-        } catch (ExecutionException x) {
-            if (!(x.getCause() instanceof ClosedChannelException))
-                throw new RuntimeException("Cause of ClosedChannelException expected");
-        } catch (InterruptedException x) {
-        }
-
-        // check write fails with ClosedChannelException
-        try {
-            ch.write(buf, 0L).get();
-            throw new RuntimeException("ExecutionException expected");
-        } catch (ExecutionException x) {
-            if (!(x.getCause() instanceof ClosedChannelException))
-                throw new RuntimeException("Cause of ClosedChannelException expected");
-        } catch (InterruptedException x) {
-        }
-
-        // check lock fails with ClosedChannelException
-        try {
-            ch.lock().get();
-            throw new RuntimeException("ExecutionException expected");
-        } catch (ExecutionException x) {
-            if (!(x.getCause() instanceof ClosedChannelException))
-                throw new RuntimeException("Cause of ClosedChannelException expected");
-        } catch (InterruptedException x) {
-        }
-    }
-
-
-    // exercise custom thread pool
-    static void testCustomThreadPool(Path file) throws IOException {
-        System.out.println("testCustomThreadPool");
-
-        // records threads that are created
-        final List<Thread> threads = new ArrayList<Thread>();
-
-        ThreadFactory threadFactory = new ThreadFactory() {
-
-             public Thread newThread(Runnable r) {
-                 Thread t = new Thread(r);
-                 t.setDaemon(true);
-                 synchronized (threads) {
-                     threads.add(t);
-                 }
-                 return t;
-             }
-        };
-
-        // exercise tests with varied number of threads
-        for (int nThreads=1; nThreads<=5; nThreads++) {
-            synchronized (threads) {
-                threads.clear();
-            }
-            ExecutorService executor = Executors.newFixedThreadPool(nThreads, threadFactory);
-            Set<StandardOpenOption> opts = EnumSet.of(WRITE);
-            AsynchronousFileChannel ch = AsynchronousFileChannel.open(file, opts, executor);
-            try {
-                for (int i=0; i<10; i++) {
-                    // do I/O operation to see which thread invokes the completion handler
-                    final AtomicReference<Thread> invoker = new AtomicReference<Thread>();
-                    final CountDownLatch latch = new CountDownLatch(1);
-
-                    ch.write(genBuffer(), 0L, null, new CompletionHandler<Integer,Void>() {
-                        public void completed(Integer result, Void att) {
-                            invoker.set(Thread.currentThread());
-                            latch.countDown();
-                        }
-                        public void failed(Throwable exc, Void att) {
-                        }
-                        public void cancelled(Void att) {
-                        }
-                    });
-                    await(latch);
-
-                    // check invoker
-                    boolean found = false;
-                    synchronized (threads) {
-                        for (Thread t: threads) {
-                            if (t == invoker.get()) {
-                                found = true;
-                                break;
-                            }
-                        }
-                    }
-                    if (!found)
-                        throw new RuntimeException("Invoker thread not found");
-                }
-            } finally {
-                ch.close();
-            }
-        }
-    }
-
-    // exercise asynchronous close
-    static void testAsynchronousClose(Path file) throws IOException {
-        System.out.println("testAsynchronousClose");
-
-        // create file
-        AsynchronousFileChannel ch = AsynchronousFileChannel
-            .open(file, WRITE, TRUNCATE_EXISTING);
-        long size = 0L;
-        do {
-            ByteBuffer buf = genBuffer();
-            int n = buf.remaining();
-            writeFully(ch, buf, size);
-            size += n;
-        } while (size < (50L * 1024L * 1024L));
-
-        ch.close();
-
-        ch = AsynchronousFileChannel.open(file, WRITE, SYNC);
-
-        // randomize number of writers, buffer size, and positions
-
-        int nwriters = 1 + rand.nextInt(8);
-        ByteBuffer[] buf = new ByteBuffer[nwriters];
-        long[] position = new long[nwriters];
-        for (int i=0; i<nwriters; i++) {
-            buf[i] = genBuffer();
-            position[i] = rand.nextInt((int)size);
-        }
-
-        // initiate I/O
-        Future[] result = new Future[nwriters];
-        for (int i=0; i<nwriters; i++) {
-            result[i] = ch.write(buf[i], position[i]);
-        }
-
-        // close file
-        ch.close();
-
-        // write operations should complete or fail with AsynchronousCloseException
-        for (int i=0; i<nwriters; i++) {
-            try {
-                result[i].get();
-            } catch (ExecutionException x) {
-                Throwable cause = x.getCause();
-                if (!(cause instanceof AsynchronousCloseException))
-                    throw new RuntimeException(cause);
-            } catch (CancellationException  x) {
-                throw new RuntimeException(x);   // should not happen
-            } catch (InterruptedException x) {
-                throw new RuntimeException(x);   // should not happen
-            }
-        }
-    }
-
-    // exercise cancel method
-    static void testCancel(Path file) throws IOException {
-        System.out.println("testCancel");
-
-        for (int i=0; i<2; i++) {
-            boolean mayInterruptIfRunning = (i == 0) ? false : true;
-
-            // open with SYNC option to improve chances that write will not
-            // complete immediately
-            AsynchronousFileChannel ch = AsynchronousFileChannel
-                .open(file, WRITE, SYNC);
-
-            // start write operation
-            final CountDownLatch latch = new CountDownLatch(1);
-            Future<Integer> res = ch.write(genBuffer(), 0L, null,
-                new CompletionHandler<Integer,Void>() {
-                    public void completed(Integer result, Void att) {
-                    }
-                    public void failed(Throwable exc, Void att) {
-                    }
-                    public void cancelled(Void att) {
-                        latch.countDown();
-                    }
-            });
-
-            // cancel operation
-            boolean cancelled = res.cancel(mayInterruptIfRunning);
-
-            // check post-conditions
-            if (!res.isDone())
-                throw new RuntimeException("isDone should return true");
-            if (res.isCancelled() != cancelled)
-                throw new RuntimeException("isCancelled not consistent");
-            try {
-                res.get();
-                if (!cancelled)
-                    throw new RuntimeException("CancellationException expected");
-            } catch (CancellationException x) {
-                // expected
-            } catch (ExecutionException x) {
-                throw new RuntimeException(x);
-            } catch (InterruptedException x) {
-                throw new RuntimeException(x);
-            }
-            try {
-                res.get(1, TimeUnit.SECONDS);
-                throw new RuntimeException("CancellationException expected");
-            } catch (CancellationException x) {
-                // expected
-            } catch (ExecutionException x) {
-                throw new RuntimeException(x);
-            } catch (TimeoutException x) {
-                throw new RuntimeException(x);
-            } catch (InterruptedException x) {
-                throw new RuntimeException(x);
-            }
-
-            // check that cancelled method is invoked
-            if (cancelled)
-                await(latch);
-
-            ch.close();
-        }
-    }
-
-    // exercise truncate method
-    static void testTruncate(Path file) throws IOException {
-        System.out.println("testTruncate");
-
-        // basic tests
-        AsynchronousFileChannel ch = AsynchronousFileChannel
-            .open(file, CREATE, WRITE, TRUNCATE_EXISTING);
-        try {
-            writeFully(ch, genBuffer(), 0L);
-            long size = ch.size();
-
-            // attempt to truncate to a size greater than the current size
-            if (ch.truncate(size + 1L).size() != size)
-                throw new RuntimeException("Unexpected size after truncation");
-
-            // truncate file
-            if (ch.truncate(size - 1L).size() != (size - 1L))
-                throw new RuntimeException("Unexpected size after truncation");
-
-            // invalid size
-            try {
-                ch.truncate(-1L);
-                throw new RuntimeException("IllegalArgumentException expected");
-            } catch (IllegalArgumentException e) { }
-
-        } finally {
-            ch.close();
-        }
-
-        // channel is closed
-        try {
-            ch.truncate(0L);
-            throw new RuntimeException("ClosedChannelException expected");
-        } catch (ClosedChannelException  e) { }
-
-        // channel is read-only
-        ch = AsynchronousFileChannel.open(file, READ);
-        try {
-            try {
-            ch.truncate(0L);
-                throw new RuntimeException("NonWritableChannelException expected");
-            } catch (NonWritableChannelException  e) { }
-        } finally {
-            ch.close();
-        }
-    }
-
-    // returns ByteBuffer with random bytes
-    static ByteBuffer genBuffer() {
-        int size = 1024 + rand.nextInt(16000);
-        byte[] buf = new byte[size];
-        boolean useDirect = rand.nextBoolean();
-        if (useDirect) {
-            ByteBuffer bb = ByteBuffer.allocateDirect(buf.length);
-            bb.put(buf);
-            bb.flip();
-            return bb;
-        } else {
-            return ByteBuffer.wrap(buf);
-        }
-    }
-
-    // writes all remaining bytes in the buffer to the given channel at the
-    // given position
-    static void writeFully(final AsynchronousFileChannel ch,
-                           final ByteBuffer src,
-                           long position)
-    {
-        final CountDownLatch latch = new CountDownLatch(1);
-
-        // use position as attachment
-        ch.write(src, position, position, new CompletionHandler<Integer,Long>() {
-            public void completed(Integer result, Long position) {
-                int n = result;
-                if (src.hasRemaining()) {
-                    long p = position + n;
-                    ch.write(src, p, p, this);
-                } else {
-                    latch.countDown();
-                }
-            }
-            public void failed(Throwable exc, Long position) {
-            }
-            public void cancelled(Long position) {
-            }
-        });
-
-        // wait for writes to complete
-        await(latch);
-    }
-
-    static void readAll(final AsynchronousFileChannel ch,
-                        final ByteBuffer dst,
-                       long position)
-    {
-        final CountDownLatch latch = new CountDownLatch(1);
-
-        // use position as attachment
-        ch.read(dst, position, position, new CompletionHandler<Integer,Long>() {
-            public void completed(Integer result, Long position) {
-                int n = result;
-                if (n > 0) {
-                    long p = position + n;
-                    ch.read(dst, p, p, this);
-                } else {
-                    latch.countDown();
-                }
-            }
-            public void failed(Throwable exc, Long position) {
-            }
-            public void cancelled(Long position) {
-            }
-        });
-
-        // wait for reads to complete
-        await(latch);
-    }
-
-    static void await(CountDownLatch latch) {
-        // wait until done
-        boolean done = false;
-        while (!done) {
-            try {
-                latch.await();
-                done = true;
-            } catch (InterruptedException x) { }
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/CustomThreadPool.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4607272
- * @summary Unit test for java.nio.channels.AsynchronousFileChannel
- * @build CustomThreadPool MyThreadFactory
- * @run main/othervm -Djava.nio.channels.DefaultThreadPool.threadFactory=MyThreadFactory CustomThreadPool
- */
-
-import java.io.File;
-import static java.nio.file.StandardOpenOption.*;
-import java.nio.ByteBuffer;
-import java.nio.channels.*;
-import java.util.concurrent.atomic.AtomicReference;
-
-public class CustomThreadPool {
-
-    public static void main(String[] args) throws Exception {
-        File blah = File.createTempFile("blah", null);
-        blah.deleteOnExit();
-        AsynchronousFileChannel ch =
-            AsynchronousFileChannel.open(blah.toPath(), READ, WRITE);
-        ByteBuffer src = ByteBuffer.wrap("Scooby Snacks".getBytes());
-
-        final AtomicReference<Thread> invoker = new AtomicReference<Thread>();
-        ch.write(src, 0, invoker,
-            new CompletionHandler<Integer,AtomicReference<Thread>>() {
-                public void completed(Integer result, AtomicReference<Thread> invoker) {
-                    invoker.set(Thread.currentThread());
-                }
-                public void failed(Throwable exc, AtomicReference<Thread> invoker) {
-                }
-                public void cancelled(AtomicReference<Thread> invoker) {
-                }
-            });
-        Thread t;
-        while ((t = invoker.get()) == null) {
-            Thread.sleep(100);
-        }
-        ch.close();
-
-        // check handler was run by known thread
-        if (!MyThreadFactory.created(t))
-            throw new RuntimeException("Handler invoked by unknown thread");
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/Lock.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,340 +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.
- *
- * 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.
- */
-
-
-/* @test
- * @bug 4607272
- * @summary Unit test for AsynchronousFileChannel#lock method
- */
-
-import java.net.*;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.nio.file.*;
-import static java.nio.file.StandardOpenOption.*;
-import java.nio.channels.*;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Random;
-import java.util.concurrent.*;
-
-public class Lock {
-
-    static final Random rand = new Random();
-
-    public static void main(String[] args) throws Exception {
-        if (args.length > 0 && args[0].equals("-lockslave")) {
-            int port = Integer.parseInt(args[1]);
-            runLockSlave(port);
-            System.exit(0);
-        }
-
-        LockSlaveMirror slave = startLockSlave();
-        try {
-
-             // create temporary file
-            File blah = File.createTempFile("blah", null);
-            blah.deleteOnExit();
-
-            testLockProtocol(blah, slave);
-            testAsyncClose(blah, slave);
-
-        } finally {
-            slave.shutdown();
-        }
-    }
-
-    // test locking protocol
-    static void testLockProtocol(File file, LockSlaveMirror slave)
-        throws Exception
-    {
-        FileLock fl;
-
-        // slave VM opens file and acquires exclusive lock
-        slave.open(file.getPath()).lock();
-
-        AsynchronousFileChannel ch = AsynchronousFileChannel
-            .open(file.toPath(), READ, WRITE);
-
-        // this VM tries to acquire lock
-        // (lock should not be acquire until released by slave VM)
-        Future<FileLock> result = ch.lock();
-        try {
-            result.get(2, TimeUnit.SECONDS);
-            throw new RuntimeException("Timeout expected");
-        } catch (TimeoutException x) {
-        }
-
-        // slave VM releases lock
-        slave.unlock();
-
-        // this VM should now acquire lock
-        fl = result.get();
-        fl.release();
-
-        // slave VM acquires lock on range
-        slave.lock(0, 10, false);
-
-        // this VM acquires lock on non-overlapping range
-        fl = ch.lock(10, 10, false, null, null).get();
-        fl.release();
-
-        // done
-        ch.close();
-        slave.close();
-    }
-
-    // test close of channel with outstanding lock operation
-    static void testAsyncClose(File file, LockSlaveMirror slave) throws Exception {
-        // slave VM opens file and acquires exclusive lock
-        slave.open(file.getPath()).lock();
-
-        for (int i=0; i<100; i++) {
-            AsynchronousFileChannel ch = AsynchronousFileChannel
-                .open(file.toPath(), READ, WRITE);
-
-            // try to lock file (should not complete because file is locked by slave)
-            Future<FileLock> result = ch.lock();
-            try {
-                result.get(rand.nextInt(100), TimeUnit.MILLISECONDS);
-                throw new RuntimeException("Timeout expected");
-            } catch (TimeoutException x) {
-            }
-
-            // close channel with lock operation outstanding
-            ch.close();
-
-            // operation should complete with AsynchronousCloseException
-            try {
-                result.get();
-                throw new RuntimeException("ExecutionException expected");
-            } catch (ExecutionException x) {
-                if (!(x.getCause() instanceof AsynchronousCloseException)) {
-                    x.getCause().printStackTrace();
-                    throw new RuntimeException("AsynchronousCloseException expected");
-                }
-            }
-        }
-
-        slave.close();
-    }
-
-    // starts a "lock slave" in another process, returning a mirror object to
-    // control the slave
-    static LockSlaveMirror startLockSlave() throws Exception {
-        ServerSocketChannel ssc = ServerSocketChannel.open()
-            .bind(new InetSocketAddress(0));
-        int port = ((InetSocketAddress)(ssc.getLocalAddress())).getPort();
-
-        String sep = FileSystems.getDefault().getSeparator();
-
-        String command = System.getProperty("java.home") +
-            sep + "bin" + sep + "java Lock -lockslave " + port;
-        Process p = Runtime.getRuntime().exec(command);
-        IOHandler.handle(p.getInputStream());
-        IOHandler.handle(p.getErrorStream());
-
-        // wait for slave to connect
-        SocketChannel sc = ssc.accept();
-        return new LockSlaveMirror(sc);
-    }
-
-    // commands that the slave understands
-    static final String OPEN_CMD    = "open";
-    static final String CLOSE_CMD   = "close";
-    static final String LOCK_CMD    = "lock";
-    static final String UNLOCK_CMD  = "unlock";
-    static final char TERMINATOR    = ';';
-
-    // provides a proxy to a "lock slave"
-    static class LockSlaveMirror {
-        private final SocketChannel sc;
-
-        LockSlaveMirror(SocketChannel sc) {
-            this.sc = sc;
-        }
-
-        private void sendCommand(String cmd, String... params)
-            throws IOException
-        {
-            for (String s: params) {
-                cmd += " " + s;
-            }
-            cmd += TERMINATOR;
-
-            ByteBuffer buf = Charset.defaultCharset().encode(cmd);
-            while (buf.hasRemaining()) {
-                sc.write(buf);
-            }
-
-            // wait for ack
-            buf = ByteBuffer.allocate(1);
-            int n = sc.read(buf);
-            if (n != 1)
-                throw new RuntimeException("Reply expected");
-            if (buf.get(0) != TERMINATOR)
-                throw new RuntimeException("Terminated expected");
-        }
-
-        LockSlaveMirror open(String file) throws IOException {
-            sendCommand(OPEN_CMD, file);
-            return this;
-        }
-
-        void close() throws IOException {
-            sendCommand(CLOSE_CMD);
-        }
-
-        LockSlaveMirror lock() throws IOException {
-            sendCommand(LOCK_CMD);
-            return this;
-        }
-
-
-        LockSlaveMirror lock(long position, long size, boolean shared)
-            throws IOException
-        {
-            sendCommand(LOCK_CMD, position + "," + size + "," + shared);
-            return this;
-        }
-
-        LockSlaveMirror unlock() throws IOException {
-            sendCommand(UNLOCK_CMD);
-            return this;
-        }
-
-        void shutdown() throws IOException {
-            sc.close();
-        }
-    }
-
-    // Helper class to direct process output to the parent System.out
-    static class IOHandler implements Runnable {
-        private final InputStream in;
-
-        IOHandler(InputStream in) {
-            this.in = in;
-        }
-
-        static void handle(InputStream in) {
-            IOHandler handler = new IOHandler(in);
-            Thread thr = new Thread(handler);
-            thr.setDaemon(true);
-            thr.start();
-        }
-
-        public void run() {
-            try {
-                byte b[] = new byte[100];
-                for (;;) {
-                    int n = in.read(b);
-                    if (n < 0) return;
-                    for (int i=0; i<n; i++) {
-                        System.out.print((char)b[i]);
-                    }
-                }
-            } catch (IOException ioe) { }
-        }
-    }
-
-    // slave process that responds to simple commands a socket connection
-    static void runLockSlave(int port) throws Exception {
-
-        // establish connection to parent
-        SocketChannel sc = SocketChannel.open(new InetSocketAddress(port));
-        ByteBuffer buf = ByteBuffer.allocateDirect(1024);
-
-        FileChannel fc = null;
-        FileLock fl = null;
-        try {
-            for (;;) {
-
-                // read command (ends with ";")
-                buf.clear();
-                int n, last = 0;
-                do {
-                    n = sc.read(buf);
-                    if (n < 0)
-                        return;
-                    if (n == 0)
-                        throw new AssertionError();
-                    last += n;
-                } while (buf.get(last-1) != TERMINATOR);
-
-                // decode into command and optional parameter
-                buf.flip();
-                String s = Charset.defaultCharset().decode(buf).toString();
-                int sp = s.indexOf(" ");
-                String cmd = (sp < 0) ? s.substring(0, s.length()-1) :
-                    s.substring(0, sp);
-                String param = (sp < 0) ? "" : s.substring(sp+1, s.length()-1);
-
-                // execute
-                if (cmd.equals(OPEN_CMD)) {
-                    if (fc != null)
-                        throw new RuntimeException("File already open");
-                    fc = FileChannel.open(Paths.get(param),READ, WRITE);
-                }
-                if (cmd.equals(CLOSE_CMD)) {
-                    if (fc == null)
-                        throw new RuntimeException("No file open");
-                    fc.close();
-                    fc = null;
-                    fl = null;
-                }
-                if (cmd.equals(LOCK_CMD)) {
-                    if (fl != null)
-                        throw new RuntimeException("Already holding lock");
-
-                    if (param.length() == 0) {
-                        fl = fc.lock();
-                    } else {
-                        String[] values = param.split(",");
-                        if (values.length != 3)
-                            throw new RuntimeException("Lock parameter invalid");
-                        long position = Long.parseLong(values[0]);
-                        long size = Long.parseLong(values[1]);
-                        boolean shared = Boolean.parseBoolean(values[2]);
-                        fl = fc.lock(position, size, shared);
-                    }
-                }
-
-                if (cmd.equals(UNLOCK_CMD)) {
-                    if (fl == null)
-                        throw new RuntimeException("Not holding lock");
-                    fl.release();
-                    fl = null;
-                }
-
-                // send reply
-                byte[] reply = { TERMINATOR };
-                n = sc.write(ByteBuffer.wrap(reply));
-            }
-
-        } finally {
-            sc.close();
-            if (fc != null) fc.close();
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousFileChannel/MyThreadFactory.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +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.
- *
- * 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.
- */
-
-import java.util.concurrent.ThreadFactory;
-import java.util.*;
-
-public class MyThreadFactory implements ThreadFactory {
-
-    private static final Set<Thread> threads = new HashSet<Thread>();
-
-    static boolean created(Thread t) {
-        synchronized (threads) {
-            return threads.contains(t);
-        }
-    }
-
-    public MyThreadFactory() {
-    }
-
-
-    public Thread newThread(Runnable r) {
-        Thread t = new Thread(r);
-        t.setDaemon(true);
-        synchronized (threads) {
-            threads.add(t);
-        }
-        return t;
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4607272
- * @summary Unit test for AsynchronousServerSocketChannel
- * @run main/timeout=180 Basic
- */
-
-import java.nio.channels.*;
-import java.net.*;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicReference;
-
-public class Basic {
-
-    public static void main(String[] args) throws Exception {
-        testBind();
-        testAccept();
-    }
-
-    static void testBind() throws Exception {
-        System.out.println("-- bind --");
-
-        AsynchronousServerSocketChannel ch = AsynchronousServerSocketChannel.open();
-        if (ch.getLocalAddress() != null)
-            throw new RuntimeException("Local address should be 'null'");
-        ch.bind(new InetSocketAddress(0), 20);
-
-        // check local address after binding
-        InetSocketAddress local = (InetSocketAddress)ch.getLocalAddress();
-        if (local.getPort() == 0)
-            throw new RuntimeException("Unexpected port");
-        if (!local.getAddress().isAnyLocalAddress())
-            throw new RuntimeException("Not bound to a wildcard address");
-
-        // try to re-bind
-        try {
-            ch.bind(new InetSocketAddress(0));
-            throw new RuntimeException("AlreadyBoundException expected");
-        } catch (AlreadyBoundException x) {
-        }
-        ch.close();
-
-        // check ClosedChannelException
-        ch = AsynchronousServerSocketChannel.open();
-        ch.close();
-        try {
-            ch.bind(new InetSocketAddress(0));
-            throw new RuntimeException("ClosedChannelException  expected");
-        } catch (ClosedChannelException  x) {
-        }
-    }
-
-    static void testAccept() throws Exception {
-        System.out.println("-- accept --");
-
-        final AsynchronousServerSocketChannel listener =
-            AsynchronousServerSocketChannel.open().bind(new InetSocketAddress(0));
-
-        InetAddress lh = InetAddress.getLocalHost();
-        int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
-        final InetSocketAddress isa = new InetSocketAddress(lh, port);
-
-        // establish a few loopback connections
-        for (int i=0; i<100; i++) {
-            SocketChannel sc = SocketChannel.open(isa);
-            AsynchronousSocketChannel ch = listener.accept().get();
-            sc.close();
-            ch.close();
-        }
-
-       final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
-
-        // start accepting
-        listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
-            public void completed(AsynchronousSocketChannel ch, Void att) {
-                try {
-                    ch.close();
-                } catch (IOException ignore) { }
-            }
-            public void failed(Throwable exc, Void att) {
-                exception.set(exc);
-            }
-            public void cancelled(Void att) {
-            }
-        });
-
-        // check AcceptPendingException
-        try {
-            listener.accept();
-            throw new RuntimeException("AcceptPendingException expected");
-        } catch (AcceptPendingException x) {
-        }
-
-        // asynchronous close
-        listener.close();
-        while (exception.get() == null)
-            Thread.sleep(100);
-        if (!(exception.get() instanceof AsynchronousCloseException))
-            throw new RuntimeException("AsynchronousCloseException expected");
-
-        // once closed when a further attemt should throw ClosedChannelException
-        try {
-            listener.accept().get();
-            throw new RuntimeException("ExecutionException expected");
-        } catch (ExecutionException x) {
-            if (!(x.getCause() instanceof ClosedChannelException))
-                throw new RuntimeException("Cause of ClosedChannelException expected");
-        } catch (InterruptedException x) {
-        }
-
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Copyright 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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4607272
- * @summary Unit test for AsynchronousServerServerSocketChannel
- * @build WithSecurityManager
- * @run main/othervm WithSecurityManager allow
- * @run main/othervm WithSecurityManager deny
- */
-
-import java.nio.file.Paths;
-import java.nio.channels.*;
-import java.net.*;
-import java.util.concurrent.*;
-
-public class WithSecurityManager {
-    public static void main(String[] args) throws Exception {
-        boolean allow = false;
-        String policy = (args[0].equals("allow")) ? "java.policy.allow" :
-            "java.policy.deny";
-
-        String testSrc = System.getProperty("test.src");
-        if (testSrc == null)
-            testSrc = ".";
-
-        System.setProperty("java.security.policy",
-            Paths.get(testSrc).resolve(policy).toString());
-        System.setSecurityManager(new SecurityManager());
-
-        AsynchronousServerSocketChannel listener =
-            AsynchronousServerSocketChannel.open().bind(new InetSocketAddress(0));
-
-        InetAddress lh = InetAddress.getLocalHost();
-        int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
-
-        // establish and accept connection
-        SocketChannel sc = SocketChannel.open(new InetSocketAddress(lh, port));
-        Future<AsynchronousSocketChannel> result = listener.accept();
-
-        if (allow) {
-            // no security exception
-            result.get().close();
-        } else {
-            try {
-                result.get();
-            } catch (ExecutionException x) {
-                if (!(x.getCause() instanceof SecurityException))
-                    throw new RuntimeException("SecurityException expected");
-            }
-        }
-
-        sc.close();
-        listener.close();
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/java.policy.allow	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-grant {
-    permission java.net.SocketPermission "*:1024-", "accept,connect,resolve";
-};
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousServerSocketChannel/java.policy.deny	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-grant {
-    permission java.net.SocketPermission "*:1024-", "connect,resolve";
-};
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousSocketChannel/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,805 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4607272
- * @summary Unit test for AsynchronousSocketChannel
- * @run main/timeout=600 Basic
- */
-
-import java.nio.ByteBuffer;
-import java.nio.channels.*;
-import static java.net.StandardSocketOption.*;
-import java.net.*;
-import java.util.Random;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-import java.io.IOException;
-
-public class Basic {
-    static final Random rand = new Random();
-
-    public static void main(String[] args) throws Exception {
-        testBind();
-        testSocketOptions();
-        testConnect();
-        testCloseWhenPending();
-        testCancel();
-        testRead1();
-        testRead2();
-        testRead3();
-        testWrite1();
-        testWrite2();
-        testTimeout();
-        testShutdown();
-    }
-
-    static class Server {
-        private final ServerSocketChannel ssc;
-        private final InetSocketAddress address;
-
-        Server() throws IOException {
-            ssc = ServerSocketChannel.open().bind(new InetSocketAddress(0));
-
-            InetAddress lh = InetAddress.getLocalHost();
-            int port = ((InetSocketAddress)(ssc.getLocalAddress())).getPort();
-            address = new InetSocketAddress(lh, port);
-        }
-
-        InetSocketAddress address() {
-            return address;
-        }
-
-        SocketChannel accept() throws IOException {
-            return ssc.accept();
-        }
-
-        void close() {
-            try {
-                ssc.close();
-            } catch (IOException ignore) { }
-        }
-
-    }
-
-    static void testBind() throws Exception {
-        System.out.println("-- bind --");
-
-        AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
-        if (ch.getLocalAddress() != null)
-            throw new RuntimeException("Local address should be 'null'");
-        ch.bind(new InetSocketAddress(0));
-
-        // check local address after binding
-        InetSocketAddress local = (InetSocketAddress)ch.getLocalAddress();
-        if (local.getPort() == 0)
-            throw new RuntimeException("Unexpected port");
-        if (!local.getAddress().isAnyLocalAddress())
-            throw new RuntimeException("Not bound to a wildcard address");
-
-        // try to re-bind
-        try {
-            ch.bind(new InetSocketAddress(0));
-            throw new RuntimeException("AlreadyBoundException expected");
-        } catch (AlreadyBoundException x) {
-        }
-        ch.close();
-
-        // check ClosedChannelException
-        ch = AsynchronousSocketChannel.open();
-        ch.close();
-        try {
-            ch.bind(new InetSocketAddress(0));
-            throw new RuntimeException("ClosedChannelException  expected");
-        } catch (ClosedChannelException  x) {
-        }
-    }
-
-    static void testSocketOptions() throws Exception {
-        System.out.println("-- socket options --");
-
-        AsynchronousSocketChannel ch = AsynchronousSocketChannel.open()
-            .setOption(SO_RCVBUF, 128*1024)
-            .setOption(SO_SNDBUF, 128*1024)
-            .setOption(SO_REUSEADDR, true)
-            .bind(new InetSocketAddress(0));
-
-        // default values
-        if ((Boolean)ch.getOption(SO_KEEPALIVE))
-            throw new RuntimeException("Default of SO_KEEPALIVE should be 'false'");
-        if ((Boolean)ch.getOption(TCP_NODELAY))
-            throw new RuntimeException("Default of TCP_NODELAY should be 'false'");
-
-        // set and check
-        if (!(Boolean)ch.setOption(SO_KEEPALIVE, true).getOption(SO_KEEPALIVE))
-            throw new RuntimeException("SO_KEEPALIVE did not change");
-        if (!(Boolean)ch.setOption(TCP_NODELAY, true).getOption(TCP_NODELAY))
-            throw new RuntimeException("SO_KEEPALIVE did not change");
-
-        // read others (can't check as actual value is implementation dependent)
-        ch.getOption(SO_RCVBUF);
-        ch.getOption(SO_SNDBUF);
-
-        ch.close();
-    }
-
-    static void testConnect() throws Exception {
-        System.out.println("-- connect --");
-
-        Server server = new Server();
-        AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
-        ch.connect(server.address()).get();
-
-        // check local address
-        if (ch.getLocalAddress() == null)
-            throw new RuntimeException("Not bound to local address");
-
-        // check remote address
-        InetSocketAddress remote = (InetSocketAddress)ch.getRemoteAddress();
-        if (remote.getPort() != server.address().getPort())
-            throw new RuntimeException("Connected to unexpected port");
-        if (!remote.getAddress().equals(server.address().getAddress()))
-            throw new RuntimeException("Connected to unexpected address");
-
-        // try to connect again
-        try {
-            ch.connect(server.address()).get();
-            throw new RuntimeException("AlreadyConnectedException expected");
-        } catch (AlreadyConnectedException x) {
-        }
-        ch.close();
-
-        // check that connect fails with ClosedChannelException)
-        ch = AsynchronousSocketChannel.open();
-        ch.close();
-        try {
-            ch.connect(server.address()).get();
-            throw new RuntimeException("ExecutionException expected");
-        } catch (ExecutionException x) {
-            if (!(x.getCause() instanceof ClosedChannelException))
-                throw new RuntimeException("Cause of ClosedChannelException expected");
-        }
-        final AtomicReference<Throwable> connectException =
-            new AtomicReference<Throwable>();
-        ch.connect(server.address(), null, new CompletionHandler<Void,Void>() {
-            public void completed(Void result, Void att) {
-            }
-            public void failed(Throwable exc, Void att) {
-                connectException.set(exc);
-            }
-            public void cancelled(Void att) {
-            }
-        });
-        while (connectException.get() == null) {
-            Thread.sleep(100);
-        }
-        if (!(connectException.get() instanceof ClosedChannelException))
-            throw new RuntimeException("ClosedChannelException expected");
-
-        System.out.println("-- connect to non-existent host --");
-
-        // test failure
-        InetAddress badHost = InetAddress.getByName("1.2.3.4");
-        if (!badHost.isReachable(10*1000)) {
-
-            ch = AsynchronousSocketChannel.open();
-            try {
-                ch.connect(new InetSocketAddress(badHost, 9876)).get();
-                throw new RuntimeException("Connection should not be established");
-            } catch (ExecutionException x) {
-            }
-            if (ch.isOpen())
-                throw new RuntimeException("Channel should be closed");
-        }
-
-        server.close();
-    }
-
-    static void testCloseWhenPending() throws Exception {
-        System.out.println("-- asynchronous close when connecting --");
-
-        AsynchronousSocketChannel ch;
-
-        // asynchronous close while connecting
-        InetAddress rh = InetAddress.getByName("1.2.3.4");
-        if (!rh.isReachable(3000)) {
-            InetSocketAddress isa = new InetSocketAddress(rh, 1234);
-
-            ch = AsynchronousSocketChannel.open();
-            Future<Void> result = ch.connect(isa);
-
-            // give time to initiate the connect (SYN)
-            Thread.sleep(50);
-
-            // close
-            ch.close();
-
-            // check that AsynchronousCloseException is thrown
-            try {
-                result.get();
-                throw new RuntimeException("Should not connect");
-            } catch (ExecutionException x) {
-                if (!(x.getCause() instanceof AsynchronousCloseException))
-                    throw new RuntimeException(x);
-            }
-        }
-
-        System.out.println("-- asynchronous close when reading --");
-
-        Server server = new Server();
-        ch = AsynchronousSocketChannel.open();
-        ch.connect(server.address()).get();
-
-        ByteBuffer dst = ByteBuffer.allocateDirect(100);
-        Future<Integer> result = ch.read(dst);
-
-        // attempt a second read - should fail with ReadPendingException
-        ByteBuffer buf = ByteBuffer.allocateDirect(100);
-        try {
-            ch.read(buf);
-            throw new RuntimeException("ReadPendingException expected");
-        } catch (ReadPendingException x) {
-        }
-
-        // close channel (should cause initial read to complete)
-        ch.close();
-
-        // check that AsynchronousCloseException is thrown
-        try {
-            result.get();
-            throw new RuntimeException("Should not read");
-        } catch (ExecutionException x) {
-            if (!(x.getCause() instanceof AsynchronousCloseException))
-                throw new RuntimeException(x);
-        }
-
-        System.out.println("-- asynchronous close when writing --");
-
-        ch = AsynchronousSocketChannel.open();
-        ch.connect(server.address()).get();
-
-        final AtomicReference<Throwable> writeException =
-            new AtomicReference<Throwable>();
-
-        // write bytes to fill socket buffer
-        ch.write(genBuffer(), ch, new CompletionHandler<Integer,AsynchronousSocketChannel>() {
-            public void completed(Integer result, AsynchronousSocketChannel ch) {
-                ch.write(genBuffer(), ch, this);
-            }
-            public void failed(Throwable x, AsynchronousSocketChannel ch) {
-                writeException.set(x);
-            }
-            public void cancelled(AsynchronousSocketChannel ch) {
-            }
-        });
-
-        // give time for socket buffer to fill up.
-        Thread.sleep(5*1000);
-
-        //  attempt a concurrent write - should fail with WritePendingException
-        try {
-            ch.write(genBuffer());
-            throw new RuntimeException("WritePendingException expected");
-        } catch (WritePendingException x) {
-        }
-
-        // close channel - should cause initial write to complete
-        ch.close();
-
-        // wait for exception
-        while (writeException.get() == null) {
-            Thread.sleep(100);
-        }
-        if (!(writeException.get() instanceof AsynchronousCloseException))
-            throw new RuntimeException("AsynchronousCloseException expected");
-
-        server.close();
-    }
-
-    static void testCancel() throws Exception {
-        System.out.println("-- cancel --");
-
-        Server server = new Server();
-
-        for (int i=0; i<2; i++) {
-            boolean mayInterruptIfRunning = (i == 0) ? false : true;
-
-            // establish loopback connection
-            AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
-            ch.connect(server.address()).get();
-            SocketChannel peer = server.accept();
-
-            // start read operation
-            final CountDownLatch latch = new CountDownLatch(1);
-            ByteBuffer buf = ByteBuffer.allocate(1);
-            Future<Integer> res = ch.read(buf, null,
-                new CompletionHandler<Integer,Void>() {
-                    public void completed(Integer result, Void att) {
-                    }
-                    public void failed(Throwable exc, Void att) {
-                    }
-                    public void cancelled(Void att) {
-                        latch.countDown();
-                    }
-            });
-
-            // cancel operation
-            boolean cancelled = res.cancel(mayInterruptIfRunning);
-
-            // check post-conditions
-            if (!res.isDone())
-                throw new RuntimeException("isDone should return true");
-            if (res.isCancelled() != cancelled)
-                throw new RuntimeException("isCancelled not consistent");
-            try {
-                res.get();
-                throw new RuntimeException("CancellationException expected");
-            } catch (CancellationException x) {
-            }
-            try {
-                res.get(1, TimeUnit.SECONDS);
-                throw new RuntimeException("CancellationException expected");
-            } catch (CancellationException x) {
-            }
-
-            // check that completion handler executed.
-            latch.await();
-
-            ch.close();
-            peer.close();
-        }
-
-        server.close();
-    }
-
-    static void testRead1() throws Exception {
-        System.out.println("-- read (1) --");
-
-        Server server = new Server();
-        final AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
-        ch.connect(server.address()).get();
-
-        // read with 0 bytes remaining should complete immediately
-        ByteBuffer buf = ByteBuffer.allocate(1);
-        buf.put((byte)0);
-        int n = ch.read(buf).get();
-        if (n != 0)
-            throw new RuntimeException("0 expected");
-
-        // write bytes and close connection
-        SocketChannel sc = server.accept();
-        ByteBuffer src = genBuffer();
-        sc.setOption(StandardSocketOption.SO_SNDBUF, src.remaining());
-        while (src.hasRemaining())
-            sc.write(src);
-        sc.close();
-
-        // reads should complete immediately
-        final ByteBuffer dst = ByteBuffer.allocateDirect(src.capacity() + 100);
-        final CountDownLatch latch = new CountDownLatch(1);
-        ch.read(dst, null, new CompletionHandler<Integer,Void>() {
-            public void completed(Integer result, Void att) {
-                int n = result;
-                if (n > 0) {
-                    ch.read(dst, null, this);
-                } else {
-                    latch.countDown();
-                }
-            }
-            public void failed(Throwable exc, Void att) {
-            }
-            public void cancelled(Void att) {
-            }
-        });
-
-        latch.await();
-
-        // check buffers
-        src.flip();
-        dst.flip();
-        if (!src.equals(dst)) {
-            throw new RuntimeException("Contents differ");
-        }
-
-        // close channel
-        ch.close();
-
-        // check read fails with ClosedChannelException
-        try {
-            ch.read(dst).get();
-            throw new RuntimeException("ExecutionException expected");
-        } catch (ExecutionException x) {
-            if (!(x.getCause() instanceof ClosedChannelException))
-                throw new RuntimeException("Cause of ClosedChannelException expected");
-        }
-
-        server.close();
-    }
-
-    static void testRead2() throws Exception {
-        System.out.println("-- read (2) --");
-
-        Server server = new Server();
-
-        final AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
-        ch.connect(server.address()).get();
-        SocketChannel sc = server.accept();
-
-        ByteBuffer src = genBuffer();
-
-        // read until the buffer is full
-        final ByteBuffer dst = ByteBuffer.allocateDirect(src.capacity());
-        final CountDownLatch latch = new CountDownLatch(1);
-        ch.read(dst, null, new CompletionHandler<Integer,Void>() {
-            public void completed(Integer result, Void att) {
-                if (dst.hasRemaining()) {
-                    ch.read(dst, null, this);
-                } else {
-                    latch.countDown();
-                }
-            }
-            public void failed(Throwable exc, Void att) {
-            }
-            public void cancelled(Void att) {
-            }
-        });
-
-        // trickle the writing
-        do {
-            int rem = src.remaining();
-            int size = (rem <= 100) ? rem : 50 + rand.nextInt(rem - 100);
-            ByteBuffer buf = ByteBuffer.allocate(size);
-            for (int i=0; i<size; i++)
-                buf.put(src.get());
-            buf.flip();
-            Thread.sleep(50 + rand.nextInt(1500));
-            while (buf.hasRemaining())
-                sc.write(buf);
-        } while (src.hasRemaining());
-
-        // wait until ascynrhonous reading has completed
-        latch.await();
-
-        // check buffers
-        src.flip();
-        dst.flip();
-        if (!src.equals(dst)) {
-           throw new RuntimeException("Contents differ");
-        }
-
-        sc.close();
-        ch.close();
-        server.close();
-    }
-
-    // exercise scattering read
-    static void testRead3() throws Exception {
-        System.out.println("-- read (3) --");
-
-        Server server = new Server();
-        final AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
-        ch.connect(server.address()).get();
-        SocketChannel sc = server.accept();
-
-        ByteBuffer[] dsts = new ByteBuffer[3];
-        for (int i=0; i<dsts.length; i++) {
-            dsts[i] = ByteBuffer.allocateDirect(100);
-        }
-
-        // scattering read that completes ascynhronously
-        final CountDownLatch latch = new CountDownLatch(1);
-        ch.read(dsts, 0, dsts.length, 0L, TimeUnit.SECONDS, null,
-            new CompletionHandler<Long,Void>() {
-                public void completed(Long result, Void att) {
-                    long n = result;
-                    if (n <= 0)
-                        throw new RuntimeException("No bytes read");
-                    latch.countDown();
-                }
-                public void failed(Throwable exc, Void att) {
-                }
-                public void cancelled(Void att) {
-                }
-        });
-
-        // write some bytes
-        sc.write(genBuffer());
-
-        // read should now complete
-        latch.await();
-
-        // write more bytes
-        sc.write(genBuffer());
-
-        // read should complete immediately
-        for (int i=0; i<dsts.length; i++) {
-            dsts[i].rewind();
-        }
-        long n = ch
-            .read(dsts, 0, dsts.length, 0L, TimeUnit.SECONDS, null, null).get();
-        if (n <= 0)
-            throw new RuntimeException("No bytes read");
-
-        ch.close();
-        sc.close();
-        server.close();
-    }
-
-    static void testWrite1() throws Exception {
-        System.out.println("-- write (1) --");
-
-        Server server = new Server();
-        final AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
-        ch.connect(server.address()).get();
-        SocketChannel sc = server.accept();
-
-        // write with 0 bytes remaining should complete immediately
-        ByteBuffer buf = ByteBuffer.allocate(1);
-        buf.put((byte)0);
-        int n = ch.write(buf).get();
-        if (n != 0)
-            throw new RuntimeException("0 expected");
-
-        // write all bytes and close connection when done
-        final ByteBuffer src = genBuffer();
-        ch.write(src, null, new CompletionHandler<Integer,Void>() {
-            public void completed(Integer result, Void att) {
-                if (src.hasRemaining()) {
-                    ch.write(src, null, this);
-                } else {
-                    try {
-                        ch.close();
-                    } catch (IOException ignore) { }
-                }
-            }
-            public void failed(Throwable exc, Void att) {
-            }
-            public void cancelled(Void att) {
-            }
-        });
-
-        // read to EOF or buffer full
-        ByteBuffer dst = ByteBuffer.allocateDirect(src.capacity() + 100);
-        do {
-            n = sc.read(dst);
-        } while (n > 0);
-        sc.close();
-
-        // check buffers
-        src.flip();
-        dst.flip();
-        if (!src.equals(dst)) {
-            throw new RuntimeException("Contents differ");
-        }
-
-        // check write fails with ClosedChannelException
-        try {
-            ch.read(dst).get();
-            throw new RuntimeException("ExecutionException expected");
-        } catch (ExecutionException x) {
-            if (!(x.getCause() instanceof ClosedChannelException))
-                throw new RuntimeException("Cause of ClosedChannelException expected");
-        }
-
-        server.close();
-    }
-
-    // exercise gathering write
-    static void testWrite2() throws Exception {
-        System.out.println("-- write (2) --");
-
-        Server server = new Server();
-        final AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
-        ch.connect(server.address()).get();
-        SocketChannel sc = server.accept();
-
-        // write buffers (should complete immediately)
-        ByteBuffer[] srcs = genBuffers(1);
-        long n = ch
-            .write(srcs, 0, srcs.length, 0L, TimeUnit.SECONDS, null, null).get();
-        if (n <= 0)
-            throw new RuntimeException("No bytes written");
-
-        // set to true to signal that no more buffers should be written
-        final AtomicBoolean continueWriting = new AtomicBoolean(true);
-
-        // number of bytes written
-        final AtomicLong bytesWritten = new AtomicLong(n);
-
-        // write until socket buffer is full so as to create the conditions
-        // for when a write does not complete immediately
-        srcs = genBuffers(1);
-        ch.write(srcs, 0, srcs.length, 0L, TimeUnit.SECONDS, null,
-            new CompletionHandler<Long,Void>() {
-                public void completed(Long result, Void att) {
-                    long n = result;
-                    if (n <= 0)
-                        throw new RuntimeException("No bytes written");
-                    bytesWritten.addAndGet(n);
-                    if (continueWriting.get()) {
-                        ByteBuffer[] srcs = genBuffers(8);
-                        ch.write(srcs, 0, srcs.length, 0L, TimeUnit.SECONDS,
-                            null, this);
-                    }
-                }
-                public void failed(Throwable exc, Void att) {
-                }
-                public void cancelled(Void att) {
-                }
-        });
-
-        // give time for socket buffer to fill up.
-        Thread.sleep(5*1000);
-
-        // signal handler to stop further writing
-        continueWriting.set(false);
-
-        // read until done
-        ByteBuffer buf = ByteBuffer.allocateDirect(4096);
-        long total = 0L;
-        do {
-            n = sc.read(buf);
-            if (n <= 0)
-                throw new RuntimeException("No bytes read");
-            buf.rewind();
-            total += n;
-        } while (total < bytesWritten.get());
-
-        ch.close();
-        sc.close();
-        server.close();
-    }
-
-    static void testShutdown() throws Exception {
-        System.out.println("-- shutdown--");
-
-        Server server = new Server();
-        AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
-        ch.connect(server.address()).get();
-        SocketChannel sc = server.accept();
-
-        ByteBuffer buf = ByteBuffer.allocateDirect(1000);
-        int n;
-
-        // check read
-        ch.shutdownInput();
-        n = ch.read(buf).get();
-        if (n != -1)
-            throw new RuntimeException("-1 expected");
-        // check full with full buffer
-        buf.put(new byte[100]);
-        n = ch.read(buf).get();
-        if (n != -1)
-            throw new RuntimeException("-1 expected");
-
-        // check write
-        ch.shutdownOutput();
-        try {
-            ch.write(buf).get();
-            throw new RuntimeException("ClosedChannelException expected");
-        } catch (ExecutionException x) {
-            if (!(x.getCause() instanceof ClosedChannelException))
-                throw new RuntimeException("ClosedChannelException expected");
-        }
-
-        sc.close();
-        ch.close();
-        server.close();
-    }
-
-    static void testTimeout() throws Exception {
-        Server server = new Server();
-        AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
-        ch.connect(server.address()).get();
-
-        System.out.println("-- timeout when reading --");
-
-        // this read should timeout
-        ByteBuffer dst = ByteBuffer.allocate(512);
-        try {
-            ch.read(dst, 3, TimeUnit.SECONDS, null, null).get();
-            throw new RuntimeException("Read did not timeout");
-        } catch (ExecutionException x) {
-            if (!(x.getCause() instanceof InterruptedByTimeoutException))
-                throw new RuntimeException("InterruptedByTimeoutException expected");
-        }
-
-        // after a timeout then further reading should throw unspecified runtime exception
-        boolean exceptionThrown = false;
-        try {
-            ch.read(dst);
-        } catch (RuntimeException x) {
-            exceptionThrown = true;
-        }
-        if (!exceptionThrown)
-            throw new RuntimeException("RuntimeException expected after timeout.");
-
-
-        System.out.println("-- timeout when writing --");
-
-        final AtomicReference<Throwable> writeException = new AtomicReference<Throwable>();
-
-        final long timeout = 5;
-        final TimeUnit unit = TimeUnit.SECONDS;
-
-        // write bytes to fill socket buffer
-        ch.write(genBuffer(), timeout, unit, ch,
-            new CompletionHandler<Integer,AsynchronousSocketChannel>()
-        {
-            public void completed(Integer result, AsynchronousSocketChannel ch) {
-                ch.write(genBuffer(), timeout, unit, ch, this);
-            }
-            public void failed(Throwable exc, AsynchronousSocketChannel ch) {
-                writeException.set(exc);
-            }
-            public void cancelled(AsynchronousSocketChannel ch) {
-            }
-        });
-
-        // wait for exception
-        while (writeException.get() == null) {
-            Thread.sleep(100);
-        }
-        if (!(writeException.get() instanceof InterruptedByTimeoutException))
-            throw new RuntimeException("InterruptedByTimeoutException expected");
-
-        // after a timeout then further writing should throw unspecified runtime exception
-        exceptionThrown = false;
-        try {
-            ch.write(genBuffer());
-        } catch (RuntimeException x) {
-            exceptionThrown = true;
-        }
-        if (!exceptionThrown)
-            throw new RuntimeException("RuntimeException expected after timeout.");
-
-        ch.close();
-    }
-
-   // returns ByteBuffer with random bytes
-   static ByteBuffer genBuffer() {
-       int size = 1024 + rand.nextInt(16000);
-       byte[] buf = new byte[size];
-       rand.nextBytes(buf);
-       boolean useDirect = rand.nextBoolean();
-       if (useDirect) {
-           ByteBuffer bb = ByteBuffer.allocateDirect(buf.length);
-           bb.put(buf);
-           bb.flip();
-           return bb;
-       } else {
-           return ByteBuffer.wrap(buf);
-       }
-   }
-
-   // return ByteBuffer[] with random bytes
-   static ByteBuffer[] genBuffers(int max) {
-       int len = 1;
-       if (max > 1)
-           len += rand.nextInt(max);
-       ByteBuffer[] bufs = new ByteBuffer[len];
-       for (int i=0; i<len; i++)
-           bufs[i] = genBuffer();
-       return bufs;
-   }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/AsynchronousSocketChannel/Leaky.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4607272
- * @summary Unit test for AsynchronousSocketChannel
- * @run main/othervm -XX:+DisableExplicitGC -mx64m Leaky
- */
-
-import java.nio.ByteBuffer;
-import java.nio.channels.*;
-import java.net.*;
-import java.util.concurrent.Future;
-
-/**
- * Heap buffers must be substituted with direct buffers when doing I/O. This
- * test creates a scenario on Windows that challenges the per-thread buffer
- * cache and quickly leads to an OutOfMemoryError if temporary buffers are
- * not returned to the native heap.
- */
-
-public class Leaky {
-
-    static final int K = 1024;
-
-    static class Connection {
-        private final AsynchronousSocketChannel client;
-        private final SocketChannel peer;
-        private final ByteBuffer dst;
-        private Future<Integer> readResult;
-
-        Connection() throws Exception {
-            ServerSocketChannel ssc =
-                ServerSocketChannel.open().bind(new InetSocketAddress(0));
-            InetAddress lh = InetAddress.getLocalHost();
-            int port = ((InetSocketAddress)(ssc.getLocalAddress())).getPort();
-            SocketAddress remote = new InetSocketAddress(lh, port);
-            client = AsynchronousSocketChannel.open();
-            client.connect(remote).get();
-            peer = ssc.accept();
-            ssc.close();
-            dst = ByteBuffer.allocate(K*K);
-        }
-
-        void startRead() {
-            dst.clear();
-            readResult = client.read(dst);
-        }
-
-        void write() throws Exception {
-            peer.write(ByteBuffer.wrap("X".getBytes()));
-        }
-
-        void finishRead() throws Exception {
-            readResult.get();
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-
-        final int CONNECTION_COUNT = 10;
-        Connection[] connections = new Connection[CONNECTION_COUNT];
-        for (int i=0; i<CONNECTION_COUNT; i++) {
-            connections[i] = new Connection();
-        }
-
-        for (int i=0; i<1024; i++) {
-            // initiate reads
-            for (Connection conn: connections) {
-                conn.startRead();
-            }
-
-            // write data so that the read can complete
-            for (Connection conn: connections) {
-                conn.write();
-            }
-
-            // complete read
-            for (Connection conn: connections) {
-                conn.finishRead();
-            }
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/Channels/Basic2.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4607272
- * @summary Test Channels methods for interoperability between streams and
- *     asynchronous byte channels
- */
-
-import java.net.*;
-import java.io.*;
-import java.nio.channels.*;
-import java.util.Random;
-
-public class Basic2 {
-
-    static final Random rand = new Random();
-
-    public static void main(String[] args) throws Exception {
-        // establish loopback connection
-        AsynchronousServerSocketChannel listener =
-            AsynchronousServerSocketChannel.open().bind(new InetSocketAddress(0));
-        int port = ((InetSocketAddress)(listener.getLocalAddress())).getPort();
-        InetSocketAddress isa =
-            new InetSocketAddress(InetAddress.getLocalHost(), port);
-        AsynchronousSocketChannel ch1 = AsynchronousSocketChannel.open();
-        ch1.connect(isa).get();
-        AsynchronousSocketChannel ch2 = listener.accept().get();
-
-        // start thread to write to stream
-        Writer writer = new Writer(Channels.newOutputStream(ch1));
-        Thread writerThread = new Thread(writer);
-        writerThread.start();
-
-        // start thread to read from stream
-        Reader reader = new Reader(Channels.newInputStream(ch2));
-        Thread readerThread = new Thread(reader);
-        readerThread.start();
-
-        // wait for threads to complete
-        writerThread.join();
-        readerThread.join();
-
-        // check that reader received what we expected
-        if (reader.total() != writer.total())
-            throw new RuntimeException("Unexpected number of bytes read");
-        if (reader.hash() != writer.hash())
-            throw new RuntimeException("Hash incorrect for bytes read");
-
-        // channels should be closed
-        if (ch1.isOpen() || ch2.isOpen())
-            throw new RuntimeException("Channels should be closed");
-    }
-
-    static class Reader implements Runnable {
-        private final InputStream in;
-        private volatile int total;
-        private volatile int hash;
-
-        Reader(InputStream in) {
-            this.in = in;
-        }
-
-        public void run() {
-            try {
-                int n;
-                do {
-                    // random offset/len
-                    byte[] buf = new byte[128 + rand.nextInt(128)];
-                    int len, off;
-                    if (rand.nextBoolean()) {
-                        len = buf.length;
-                        off = 0;
-                        n = in.read(buf);
-                    } else {
-                        len = 1 + rand.nextInt(64);
-                        off = rand.nextInt(64);
-                        n = in.read(buf, off, len);
-                    }
-                    if (n > len)
-                        throw new RuntimeException("Too many bytes read");
-                    if (n > 0) {
-                        total += n;
-                        for (int i=0; i<n; i++) {
-                            int value = buf[off + i];
-                            hash = hash ^ value;
-                        }
-                    }
-                } while (n > 0);
-                in.close();
-
-            } catch (IOException x) {
-                x.printStackTrace();
-            }
-        }
-
-        int total() { return total; }
-        int hash() { return hash; }
-    }
-
-    static class Writer implements Runnable {
-        private final OutputStream out;
-        private final int total;
-        private volatile int hash;
-
-        Writer(OutputStream out) {
-            this.out = out;
-            this.total = 50*1000 + rand.nextInt(50*1000);
-        }
-
-        public void run() {
-            hash = 0;
-            int rem = total;
-            try {
-                do {
-                    byte[] buf = new byte[1 + rand.nextInt(rem)];
-                    int off, len;
-
-                    // write random bytes
-                    if (rand.nextBoolean()) {
-                        off = 0;
-                        len = buf.length;
-                    } else {
-                        off = rand.nextInt(buf.length);
-                        int r = buf.length - off;
-                        len = (r <= 1) ? 1 : (1 + rand.nextInt(r));
-                    }
-                    for (int i=0; i<len; i++) {
-                        byte value = (byte)rand.nextInt(256);
-                        buf[off + i] = value;
-                        hash = hash ^ value;
-                    }
-                    if ((off == 0) && (len == buf.length)) {
-                        out.write(buf);
-                    } else {
-                        out.write(buf, off, len);
-                    }
-                    rem -= len;
-                } while (rem > 0);
-
-                // close stream when done
-                out.close();
-
-            } catch (IOException x) {
-                x.printStackTrace();
-            }
-        }
-
-        int total() { return total; }
-        int hash() { return hash; }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright 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.
- *
- * 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.
- */
-
-import java.nio.channels.spi.AsynchronousChannelProvider;
-
-public class CheckProvider {
-    public static void main(String[] args) {
-        Class<?> c = AsynchronousChannelProvider.provider().getClass();
-
-        String expected = args[0];
-        String actual = c.getName();
-
-        if (!actual.equals(expected))
-            throw new RuntimeException("Provider is of type '" + actual +
-                "', expected '" + expected + "'");
-
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/META-INF/services/java.nio.channels.spi.AsynchronousChannelProvider	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-Provider1
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright 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.
- *
- * 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.
- */
-
-import java.nio.channels.spi.AsynchronousChannelProvider;
-import java.nio.channels.spi.AsynchronousChannelProvider.ThreadPoolType;
-import java.nio.channels.*;
-import java.net.ProtocolFamily;
-import java.util.concurrent.ExecutorService;
-import java.io.IOException;
-
-public class Provider1 extends AsynchronousChannelProvider {
-    public Provider1() {
-    }
-
-
-    public AsynchronousChannelGroup openAsynchronousChannelGroup
-        (ThreadPoolType poolType, ExecutorService executor, int n) throws IOException
-    {
-        throw new RuntimeException();
-    }
-
-
-    public AsynchronousSocketChannel openAsynchronousSocketChannel
-        (AsynchronousChannelGroup group) throws IOException
-    {
-        throw new RuntimeException();
-    }
-
-
-    public AsynchronousServerSocketChannel openAsynchronousServerSocketChannel
-        (AsynchronousChannelGroup group) throws IOException
-    {
-        throw new RuntimeException();
-    }
-
-
-    public AsynchronousDatagramChannel openAsynchronousDatagramChannel
-        (ProtocolFamily family, AsynchronousChannelGroup group) throws IOException
-    {
-        throw new RuntimeException();
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright 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.
- *
- * 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.
- */
-
-import java.nio.channels.spi.AsynchronousChannelProvider;
-import java.nio.channels.spi.AsynchronousChannelProvider.ThreadPoolType;
-import java.nio.channels.*;
-import java.net.ProtocolFamily;
-import java.util.concurrent.ExecutorService;
-import java.io.IOException;
-
-public class Provider2 extends AsynchronousChannelProvider {
-    public Provider2() {
-    }
-
-
-    public AsynchronousChannelGroup openAsynchronousChannelGroup
-        (ThreadPoolType poolType, ExecutorService executor, int n) throws IOException
-    {
-        throw new RuntimeException();
-    }
-
-
-    public AsynchronousSocketChannel openAsynchronousSocketChannel
-        (AsynchronousChannelGroup group) throws IOException
-    {
-        throw new RuntimeException();
-    }
-
-
-    public AsynchronousServerSocketChannel openAsynchronousServerSocketChannel
-        (AsynchronousChannelGroup group) throws IOException
-    {
-        throw new RuntimeException();
-    }
-
-
-    public AsynchronousDatagramChannel openAsynchronousDatagramChannel
-        (ProtocolFamily family, AsynchronousChannelGroup group) throws IOException
-    {
-        throw new RuntimeException();
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-#
-# Copyright 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.
-#
-# 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.
-#
-
-# @test
-# @summary Unit test for java.nio.channels.spi.AsynchronousChannelProvider
-# @build Provider1 Provider2 CheckProvider
-# @run shell custom_provider.sh
-
-# if TESTJAVA isn't set then we assume an interactive run.
-
-if [ -z "$TESTJAVA" ]; then
-    TESTSRC=.
-    TESTCLASSES=.
-    JAVA=java
-else
-    JAVA="${TESTJAVA}/bin/java"
-fi
-
-OS=`uname -s`
-case "$OS" in
-    Windows_* )
-        CLASSPATH="${TESTCLASSES};${TESTSRC}"
-        ;;
-    * )
-        CLASSPATH=${TESTCLASSES}:${TESTSRC}
-        ;;
-esac
-export CLASSPATH
-
-failures=0
-
-go() {
-    echo ''
-    $JAVA $1 $2 $3 2>&1
-    if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
-}
-
-# Run the tests
-
-go CheckProvider Provider1
-go -Djava.nio.channels.spi.AsynchronousChannelProvider=Provider2 CheckProvider \
-  Provider2
-
-#
-# Results
-#
-echo ''
-if [ $failures -gt 0 ];
-  then echo "$failures test(s) failed";
-  else echo "All test(s) passed"; fi
-exit $failures
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/DirectoryStream/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.DirectoryStream
- * @library ..
- */
-
-import java.nio.file.*;
-import java.util.*;
-import java.io.IOException;
-
-public class Basic {
-    static boolean found;
-
-    static void doTest(final Path dir) throws IOException {
-        // test that directory is empty
-        Files.withDirectory(dir, new FileAction<FileRef>() {
-            public void invoke(FileRef entry) {
-                throw new RuntimeException("directory not empty");
-            }
-        });
-
-        // create file in directory
-        final Path foo = Paths.get("foo");
-        dir.resolve(foo).createFile();
-
-        // iterate over directory and check there is one entry
-        found = false;
-        Files.withDirectory(dir, new FileAction<Path>() {
-            public void invoke(Path entry) {
-                if (entry.getName().equals(foo)) {
-                    if (found)
-                        throw new RuntimeException("entry already found");
-                    found = true;
-                } else {
-                    throw new RuntimeException("entry " + entry.getName() +
-                        " not expected");
-                }
-            }
-        });
-        if (!found)
-            throw new RuntimeException("entry not found");
-
-        // check filtering: f* should match foo
-        DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
-            private PathMatcher matcher =
-                dir.getFileSystem().getNameMatcher("glob", "f*");
-            public boolean accept(Path file) {
-                return matcher.matches(file);
-            }
-        };
-        Files.withDirectory(dir, filter, new FileAction<Path>() {
-            public void invoke(Path entry) {
-                if (!entry.getName().equals(foo))
-                    throw new RuntimeException("entry not expected");
-            }
-        });
-
-        // check filtering: z* should not match any files
-        filter = new DirectoryStream.Filter<Path>() {
-            private PathMatcher matcher =
-                dir.getFileSystem().getNameMatcher("glob", "z*");
-            public boolean accept(Path file) {
-                return matcher.matches(file);
-            }
-        };
-        Files.withDirectory(dir, filter, new FileAction<FileRef>() {
-            public void invoke(FileRef entry) {
-                throw new RuntimeException("no matching entries expected");
-            }
-        });
-
-        // test NotDirectoryException
-        try {
-            dir.resolve(foo).newDirectoryStream();
-            throw new RuntimeException("NotDirectoryException not thrown");
-        } catch (NotDirectoryException x) {
-        }
-
-        // test iterator remove method
-        DirectoryStream<Path> stream = dir.newDirectoryStream();
-        Iterator<Path> i = stream.iterator();
-        while (i.hasNext()) {
-            Path entry = i.next();
-            if (!entry.getName().equals(foo))
-                throw new RuntimeException("entry not expected");
-            i.remove();
-        }
-        stream.close();
-
-        // test IllegalStateException
-        stream =  dir.newDirectoryStream();
-        i = stream.iterator();
-        try {
-            stream.iterator();
-            throw new RuntimeException("IllegalStateException not thrown as expected");
-        } catch (IllegalStateException x) {
-        }
-        stream.close();
-        try {
-            stream.iterator();
-            throw new RuntimeException("IllegalStateException not thrown as expected");
-        } catch (IllegalStateException x) {
-        }
-        try {
-            i.hasNext();
-            throw new RuntimeException("ConcurrentModificationException not thrown as expected");
-        } catch (ConcurrentModificationException x) {
-            Throwable t = x.getCause();
-            if (!(t instanceof IllegalStateException))
-                throw new RuntimeException("Cause is not IllegalStateException as expected");
-        }
-        try {
-            i.next();
-            throw new RuntimeException("IllegalStateException not thrown as expected");
-        } catch (ConcurrentModificationException x) {
-            Throwable t = x.getCause();
-            if (!(t instanceof IllegalStateException))
-                throw new RuntimeException("Cause is not IllegalStateException as expected");
-        }
-    }
-
-    public static void main(String[] args) throws IOException {
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            doTest(dir);
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/DirectoryStream/Filters.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,241 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.DirectoryStreamFilters
- * @library ..
- */
-
-import java.nio.file.*;
-import static java.nio.file.DirectoryStreamFilters.*;
-import java.nio.file.attribute.Attributes;
-import java.io.*;
-import java.util.*;
-
-public class Filters {
-    static final Random rand = new Random();
-
-    // returns a filter that only accepts files that are larger than a given size
-    static DirectoryStream.Filter<FileRef> newMinimumSizeFilter(final long min) {
-        return new DirectoryStream.Filter<FileRef>() {
-            public boolean accept(FileRef file) {
-                try {
-                    long size = Attributes.readBasicFileAttributes(file).size();
-                    return size >= min;
-                } catch (IOException e) {
-                    throw new IOError(e);
-                }
-            }
-        };
-    }
-
-    // returns a filter that only accepts files that are matched by a given glob
-    static DirectoryStream.Filter<Path> newGlobFilter(final String glob) {
-        return new DirectoryStream.Filter<Path>() {
-            PathMatcher matcher = FileSystems.getDefault().getNameMatcher("glob", glob);
-            public boolean accept(Path file) {
-                return matcher.matches(file);
-            }
-        };
-    }
-
-    static final int BIG_FILE_THRESHOLD = 8192;
-
-    static int totalCount;
-    static int htmlCount;
-    static int bigAndHtmlCount;
-    static int bigOrHtmlCount;
-
-    // generates random files in the test directory and initializes the counts
-    static void setup(Path dir) throws IOException {
-        // create 10-26 files.
-        totalCount = 10 + rand.nextInt(17);
-        char firstChar = 'A';
-        for (int i=0; i<totalCount; i++) {
-            boolean isHtml = rand.nextBoolean();
-            boolean isBig = rand.nextBoolean();
-            if (isHtml) {
-                htmlCount++;
-                if (isBig) bigAndHtmlCount++;
-            }
-            if (isHtml || isBig)
-                bigOrHtmlCount++;
-            String name;
-            if (isHtml) {
-                name = firstChar + ".html";
-            } else {
-                name = firstChar + ".tmp";
-            }
-            firstChar++;
-            int size = rand.nextInt(BIG_FILE_THRESHOLD);
-            if (isBig)
-                size += BIG_FILE_THRESHOLD;
-            Path file = dir.resolve(name);
-            OutputStream out = file.newOutputStream();
-            try {
-                if (size > 0)
-                    out.write(new byte[size]);
-            } finally {
-                out.close();
-            }
-            System.out.format("Created %s, size %d byte(s)\n", name, size);
-        }
-    }
-
-    static boolean isHtml(Path file) {
-        return file.toString().endsWith(".html");
-    }
-
-    static boolean isBig(Path file) throws IOException {
-        long size = Attributes.readBasicFileAttributes(file).size();
-        return size >= BIG_FILE_THRESHOLD;
-    }
-
-    static void checkCount(int expected, int actual) {
-        if (actual != expected)
-            throw new RuntimeException("'" + expected +
-                "' entries expected, actual: " + actual);
-    }
-
-    static void doTests(Path dir) throws IOException {
-        final List<DirectoryStream.Filter<Path>> emptyList = Collections.emptyList();
-
-        // list containing two filters
-        List<DirectoryStream.Filter<? super Path>> filters =
-            new ArrayList<DirectoryStream.Filter<? super Path>>();
-        filters.add(newMinimumSizeFilter(BIG_FILE_THRESHOLD));
-        filters.add(newGlobFilter("*.html"));
-
-        int accepted;
-        DirectoryStream<Path> stream;
-
-        System.out.println("Test: newContentTypeFilter");
-        accepted = 0;
-        stream = dir.newDirectoryStream(newContentTypeFilter("text/html"));
-        try {
-            for (Path entry: stream) {
-                if (!isHtml(entry))
-                    throw new RuntimeException("html file expected");
-                accepted++;
-            }
-        } finally {
-            stream.close();
-        }
-        checkCount(htmlCount, accepted);
-
-        System.out.println("Test: allOf with list of filters");
-        accepted = 0;
-        stream = dir.newDirectoryStream(allOf(filters));
-        try {
-            for (Path entry: stream) {
-                if (!isHtml(entry))
-                    throw new RuntimeException("html file expected");
-                if (!isBig(entry))
-                    throw new RuntimeException("big file expected");
-                accepted++;
-            }
-        } finally {
-            stream.close();
-        }
-        checkCount(bigAndHtmlCount, accepted);
-
-        System.out.println("Test: allOf with empty list");
-        accepted = 0;
-        stream = dir.newDirectoryStream(allOf(emptyList));
-        try {
-            for (Path entry: stream) {
-                accepted++;
-            }
-        } finally {
-            stream.close();
-        }
-        checkCount(totalCount, accepted);
-
-        System.out.println("Test: anyOf with list of filters");
-        accepted = 0;
-        stream = dir.newDirectoryStream(anyOf(filters));
-        try {
-            for (Path entry: stream) {
-                if (!isHtml(entry) && !isBig(entry))
-                    throw new RuntimeException("html or big file expected");
-                accepted++;
-            }
-        } finally {
-            stream.close();
-        }
-        checkCount(bigOrHtmlCount, accepted);
-
-        System.out.println("Test: anyOf with empty list");
-        accepted = 0;
-        stream = dir.newDirectoryStream(anyOf(emptyList));
-        try {
-            for (Path entry: stream) {
-                accepted++;
-            }
-        } finally {
-            stream.close();
-        }
-        checkCount(0, accepted);
-
-        System.out.println("Test: complementOf");
-        accepted = 0;
-        stream = dir.newDirectoryStream(complementOf(newGlobFilter("*.html")));
-        try {
-            for (Path entry: stream) {
-                accepted++;
-            }
-        } finally {
-            stream.close();
-        }
-        checkCount(totalCount-htmlCount, accepted);
-
-        System.out.println("Test: nulls");
-        try {
-            newContentTypeFilter(null);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException npe) { }
-        try {
-            allOf(null);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException npe) { }
-        try {
-            anyOf(null);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException npe) { }
-        try {
-            complementOf(null);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException npe) { }
-    }
-
-    public static void main(String[] args) throws IOException {
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            setup(dir);
-            doTests(dir);
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/DirectoryStream/SecureDS.java	Thu Mar 05 09:41:58 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.
- * 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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.SecureDirectoryStream
- * @library ..
- */
-
-import java.nio.file.*;
-import static java.nio.file.StandardOpenOption.*;
-import static java.nio.file.LinkOption.*;
-import java.nio.file.attribute.*;
-import java.nio.channels.*;
-import java.io.IOException;
-import java.util.*;
-
-public class SecureDS {
-    static boolean supportsLinks;
-
-    public static void main(String[] args) throws IOException {
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            DirectoryStream stream = dir.newDirectoryStream();
-            stream.close();
-            if (!(stream instanceof SecureDirectoryStream)) {
-                System.out.println("SecureDirectoryStream not supported.");
-                return;
-            }
-
-            supportsLinks = TestUtil.supportsLinks(dir);
-
-            // run tests
-            doBasicTests(dir);
-            doMoveTests(dir);
-            miscTests(dir);
-
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-
-    // Exercise each of SecureDirectoryStream's method (except move)
-    static void doBasicTests(Path dir) throws IOException {
-        Path dir1 = dir.resolve("dir1").createDirectory();
-        Path dir2 = dir.resolve("dir2");
-
-        // create a file, directory, and two sym links in the directory
-        Path fileEntry = Paths.get("myfile");
-        dir1.resolve(fileEntry).createFile();
-        Path dirEntry = Paths.get("mydir");
-        dir1.resolve(dirEntry).createDirectory();
-        // myfilelink -> myfile
-        Path link1Entry = Paths.get("myfilelink");
-        if (supportsLinks)
-            dir1.resolve(link1Entry).createSymbolicLink(fileEntry);
-        // mydirlink -> mydir
-        Path link2Entry = Paths.get("mydirlink");
-        if (supportsLinks)
-            dir1.resolve(link2Entry).createSymbolicLink(dirEntry);
-
-        // open directory and then move it so that it is no longer accessible
-        // via its original path.
-        SecureDirectoryStream stream =
-            (SecureDirectoryStream)dir1.newDirectoryStream();
-        dir1.moveTo(dir2);
-
-        // Test: iterate over all entries
-        int count = 0;
-        for (Path entry: stream) { count++; }
-        assertTrue(count == (supportsLinks ? 4 : 2));
-
-        // Test: getFileAttributeView to access directory's attributes
-        assertTrue(stream
-            .getFileAttributeView(BasicFileAttributeView.class)
-                .readAttributes()
-                    .isDirectory());
-
-        // Test: dynamic access to directory's attributes
-        BasicFileAttributeView view = stream.
-            getFileAttributeView(BasicFileAttributeView.class);
-        Map<String,?> attrs = view.readAttributes("*");
-        assertTrue((Boolean)attrs.get("isDirectory"));
-        attrs = view.readAttributes("isRegularFile", "size");
-        assertTrue(!(Boolean)attrs.get("isRegularFile"));
-        assertTrue((Long)attrs.get("size") >= 0);
-        int linkCount = (Integer)view.getAttribute("linkCount");
-        assertTrue(linkCount > 0);
-        view.setAttribute("lastModifiedTime", 0L);
-
-        // Test: getFileAttributeView to access attributes of entries
-        assertTrue(stream
-            .getFileAttributeView(fileEntry, BasicFileAttributeView.class)
-                .readAttributes()
-                    .isRegularFile());
-        assertTrue(stream
-            .getFileAttributeView(fileEntry, BasicFileAttributeView.class, NOFOLLOW_LINKS)
-                .readAttributes()
-                    .isRegularFile());
-        assertTrue(stream
-            .getFileAttributeView(dirEntry, BasicFileAttributeView.class)
-                .readAttributes()
-                    .isDirectory());
-        assertTrue(stream
-            .getFileAttributeView(dirEntry, BasicFileAttributeView.class, NOFOLLOW_LINKS)
-                .readAttributes()
-                    .isDirectory());
-        if (supportsLinks) {
-            assertTrue(stream
-                .getFileAttributeView(link1Entry, BasicFileAttributeView.class)
-                    .readAttributes()
-                        .isRegularFile());
-            assertTrue(stream
-                .getFileAttributeView(link1Entry, BasicFileAttributeView.class, NOFOLLOW_LINKS)
-                    .readAttributes()
-                        .isSymbolicLink());
-            assertTrue(stream
-                .getFileAttributeView(link2Entry, BasicFileAttributeView.class)
-                    .readAttributes()
-                        .isDirectory());
-            assertTrue(stream
-                .getFileAttributeView(link2Entry, BasicFileAttributeView.class, NOFOLLOW_LINKS)
-                    .readAttributes()
-                        .isSymbolicLink());
-        }
-
-        // Test: dynamic access to entry attributes
-        view = stream
-             .getFileAttributeView(fileEntry, PosixFileAttributeView.class, NOFOLLOW_LINKS);
-        if (view != null) {
-            attrs = view.readAttributes("owner", "size");
-            UserPrincipal owner = (UserPrincipal)attrs.get("owner");
-            assertTrue(owner != null);
-            assertTrue((Long)attrs.get("size") >= 0L);
-            view.setAttribute("lastAccessTime", 0L);
-        }
-
-        // Test: newByteChannel
-        Set<StandardOpenOption> opts = Collections.emptySet();
-        stream.newByteChannel(fileEntry, opts).close();
-        if (supportsLinks) {
-            stream.newByteChannel(link1Entry, opts).close();
-            try {
-                Set<OpenOption> mixed = new HashSet<OpenOption>();
-                mixed.add(READ);
-                mixed.add(NOFOLLOW_LINKS);
-                stream.newByteChannel(link1Entry, mixed).close();
-                shouldNotGetHere();
-            } catch (IOException x) { }
-        }
-
-        // Test: newDirectoryStream
-        stream.newDirectoryStream(dirEntry, true, null).close();
-        stream.newDirectoryStream(dirEntry, false, null).close();
-        if (supportsLinks) {
-            stream.newDirectoryStream(link2Entry, true, null).close();
-            try {
-                stream.newDirectoryStream(link2Entry, false, null).close();
-                shouldNotGetHere();
-            } catch (IOException x) { }
-        }
-
-        // Test: delete
-        if (supportsLinks) {
-            stream.deleteFile(link1Entry);
-            stream.deleteFile(link2Entry);
-        }
-        stream.deleteDirectory(dirEntry);
-        stream.deleteFile(fileEntry);
-
-        // Test: remove
-        // (requires resetting environment to get new iterator)
-        stream.close();
-        dir2.moveTo(dir1);
-        dir1.resolve(fileEntry).createFile();
-        stream = (SecureDirectoryStream)dir1.newDirectoryStream();
-        dir1.moveTo(dir2);
-        Iterator<Path> iter = stream.iterator();
-        int removed = 0;
-        while (iter.hasNext()) {
-            iter.next();
-            iter.remove();
-            removed++;
-        }
-        assertTrue(removed == 1);
-
-        // clean-up
-        stream.close();
-        dir2.delete();
-    }
-
-    // Exercise SecureDirectoryStream's move method
-    static void doMoveTests(Path dir) throws IOException {
-        Path dir1 = dir.resolve("dir1").createDirectory();
-        Path dir2 = dir.resolve("dir2").createDirectory();
-
-        // create dir1/myfile, dir1/mydir, dir1/mylink
-        Path fileEntry = Paths.get("myfile");
-        dir1.resolve(fileEntry).createFile();
-        Path dirEntry = Paths.get("mydir");
-        dir1.resolve(dirEntry).createDirectory();
-        Path linkEntry = Paths.get("mylink");
-        if (supportsLinks)
-            dir1.resolve(linkEntry).createSymbolicLink(Paths.get("missing"));
-
-        // target name
-        Path target = Paths.get("newfile");
-
-        // open stream to both directories
-        SecureDirectoryStream stream1 =
-            (SecureDirectoryStream)dir1.newDirectoryStream();
-        SecureDirectoryStream stream2 =
-            (SecureDirectoryStream)dir2.newDirectoryStream();
-
-        // Test: move dir1/myfile -> dir2/newfile
-        stream1.move(fileEntry, stream2, target);
-        assertTrue(dir1.resolve(fileEntry).notExists());
-        assertTrue(dir2.resolve(target).exists());
-        stream2.deleteFile(target);
-
-        // Test: move dir1/mydir -> dir2/newfile
-        stream1.move(dirEntry, stream2, target);
-        assertTrue(dir1.resolve(dirEntry).notExists());
-        assertTrue(dir2.resolve(target).exists());
-        stream2.deleteDirectory(target);
-
-        // Test: move dir1/mylink -> dir2/newfile
-        if (supportsLinks) {
-            stream1.move(linkEntry, stream2, target);
-            assertTrue(dir2.resolve(target)
-                .getFileAttributeView(BasicFileAttributeView.class, NOFOLLOW_LINKS)
-                .readAttributes()
-                .isSymbolicLink());
-            stream2.deleteFile(target);
-        }
-
-        // Test: move between devices
-        String testDirAsString = System.getProperty("test.dir");
-        if (testDirAsString != null) {
-            Path testDir = Paths.get(testDirAsString);
-            if (!dir1.getFileStore().equals(testDir.getFileStore())) {
-                SecureDirectoryStream ts =
-                    (SecureDirectoryStream)testDir.newDirectoryStream();
-                dir1.resolve(fileEntry).createFile();
-                try {
-                    stream1.move(fileEntry, ts, target);
-                    shouldNotGetHere();
-                } catch (AtomicMoveNotSupportedException x) { }
-                ts.close();
-                stream1.deleteFile(fileEntry);
-            }
-        }
-
-        // clean-up
-        dir1.delete();
-        dir2.delete();
-    }
-
-    // null and ClosedDirectoryStreamException
-    static void miscTests(Path dir) throws IOException {
-        Path file = Paths.get("file");
-        dir.resolve(file).createFile();
-
-        SecureDirectoryStream stream =
-            (SecureDirectoryStream)dir.newDirectoryStream();
-
-        // NullPointerException
-        try {
-            stream.getFileAttributeView(null);
-            shouldNotGetHere();
-        } catch (NullPointerException x) { }
-        try {
-            stream.getFileAttributeView(null, BasicFileAttributeView.class);
-            shouldNotGetHere();
-        } catch (NullPointerException x) { }
-        try {
-            stream.getFileAttributeView(file, null);
-            shouldNotGetHere();
-        } catch (NullPointerException x) { }
-        try {
-            stream.newByteChannel(null, EnumSet.of(CREATE,WRITE));
-            shouldNotGetHere();
-        } catch (NullPointerException x) { }
-        try {
-            stream.newByteChannel(null, EnumSet.of(CREATE,WRITE,null));
-            shouldNotGetHere();
-        } catch (NullPointerException x) { }
-        try {
-            stream.newByteChannel(file, null);
-            shouldNotGetHere();
-        } catch (NullPointerException x) { }
-        try {
-            stream.move(null, stream, file);
-            shouldNotGetHere();
-        } catch (NullPointerException x) { }
-        try {
-            stream.move(file, null, file);
-            shouldNotGetHere();
-        } catch (NullPointerException x) { }
-        try {
-            stream.move(file, stream, null);
-            shouldNotGetHere();
-        } catch (NullPointerException x) { }
-        try {
-            stream.newDirectoryStream(null, true, null);
-            shouldNotGetHere();
-        } catch (NullPointerException x) { }
-        try {
-            stream.deleteFile(null);
-            shouldNotGetHere();
-        } catch (NullPointerException x) { }
-        try {
-            stream.deleteDirectory(null);
-            shouldNotGetHere();
-        } catch (NullPointerException x) { }
-
-        // close stream
-        stream.close();
-        stream.close();     // should be no-op
-
-        // ClosedDirectoryStreamException
-        try {
-            stream.newDirectoryStream(file, true, null);
-            shouldNotGetHere();
-        } catch (ClosedDirectoryStreamException x) { }
-        try {
-            stream.newByteChannel(file, EnumSet.of(READ));
-            shouldNotGetHere();
-        } catch (ClosedDirectoryStreamException x) { }
-        try {
-            stream.move(file, stream, file);
-            shouldNotGetHere();
-        } catch (ClosedDirectoryStreamException x) { }
-        try {
-            stream.deleteFile(file);
-            shouldNotGetHere();
-        } catch (ClosedDirectoryStreamException x) { }
-
-        // clean-up
-        dir.resolve(file).delete();
-    }
-
-    static void assertTrue(boolean b) {
-        if (!b) throw new RuntimeException("Assertion failed");
-    }
-
-    static void shouldNotGetHere() {
-        assertTrue(false);
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/FileStore/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.FileStore
- * @library ..
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
-
-public class Basic {
-
-    public static void main(String[] args) throws IOException {
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            doTests(dir);
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-
-    static void assertTrue(boolean okay) {
-        if (!okay)
-            throw new RuntimeException("Assertion failed");
-    }
-
-    static void doTests(Path dir) throws IOException {
-        /**
-         * Test: Directory should be on FileStore that is writable
-         */
-        assertTrue(!dir.getFileStore().isReadOnly());
-
-        /**
-         * Test: Two files should have the same FileStore
-         */
-        FileStore store1 = dir.resolve("foo").createFile().getFileStore();
-        FileStore store2 = dir.resolve("bar").createFile().getFileStore();
-        assertTrue(store1.equals(store2));
-        assertTrue(store2.equals(store1));
-        assertTrue(store1.hashCode() == store2.hashCode());
-
-        /**
-         * Test: File and FileStore attributes
-         */
-        assertTrue(store1.supportsFileAttributeView("basic"));
-
-        /**
-         * Test: Enumerate all FileStores
-         */
-        for (FileStore store: FileSystems.getDefault().getFileStores()) {
-            System.out.format("%s (name=%s type=%s)\n", store, store.name(),
-                store.type());
-            Attributes.readFileStoreSpaceAttributes(store);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/FileSystem/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.FileSystem
- * @library ..
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
-
-/**
- * Simple santity checks for java.nio.file.FileSystem
- */
-public class Basic {
-
-    static void check(boolean okay, String msg) {
-        if (!okay)
-            throw new RuntimeException(msg);
-    }
-
-    static void checkSupported(FileSystem fs, String... views) {
-        for (String view: views) {
-            check(fs.supportedFileAttributeViews().contains(view),
-                "support for '" + view + "' expected");
-        }
-    }
-
-    public static void main(String[] args) throws IOException {
-        FileSystem fs = FileSystems.getDefault();
-
-        // close should throw UOE
-        try {
-            fs.close();
-            throw new RuntimeException("UnsupportedOperationException expected");
-        } catch (UnsupportedOperationException e) { }
-        check(fs.isOpen(), "should be open");
-
-        check(!fs.isReadOnly(), "should provide read-write access");
-
-        check(fs.provider().getScheme().equals("file"),
-            "should use 'file' scheme");
-
-        // santity check method - need to re-visit this in future as I/O errors
-        // are possible
-        for (FileStore store: fs.getFileStores()) {
-            System.out.println(store);
-        }
-
-        // sanity check supportedFileAttributeViews
-        checkSupported(fs, "basic");
-        String os = System.getProperty("os.name");
-        if (os.equals("SunOS"))
-            checkSupported(fs, "posix", "unix", "owner", "acl", "xattr");
-        if (os.equals("Linux"))
-            checkSupported(fs, "posix", "unix", "owner", "dos", "xattr");
-        if (os.equals("Windows"))
-            checkSupported(fs, "owner", "dos", "acl", "xattr");
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/ContentType.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +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.
- *
- * 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.
- */
-
-import java.nio.file.*;
-import java.io.*;
-
-/**
- * Uses Files.probeContentType to probe html file and custom file type.
- */
-
-public class ContentType {
-
-    static FileRef createHtmlFile() throws IOException {
-        Path file = File.createTempFile("foo", ".html").toPath();
-        OutputStream out = file.newOutputStream();
-        try {
-            out.write("<html><body>foo</body></html>".getBytes());
-        } finally {
-            out.close();
-        }
-
-        return file;
-    }
-
-    static FileRef createUnknownFile() throws IOException {
-        return File.createTempFile("unknown", "unknown-file-type-789").toPath();
-    }
-
-    static FileRef createGrapeFile() throws IOException {
-        return File.createTempFile("red", ".grape").toPath();
-    }
-
-    public static void main(String[] args) throws IOException {
-
-        // exercise default file type detector
-        FileRef file = createHtmlFile();
-        try {
-            String type = Files.probeContentType(file);
-            if (type == null) {
-                System.err.println("Content type cannot be determined - test skipped");
-            } else {
-                if (!type.equals("text/html"))
-                    throw new RuntimeException("Unexpected type: " + type);
-            }
-        } finally {
-            file.delete();
-        }
-        file = createUnknownFile();
-        try {
-            String type = Files.probeContentType(file);
-            if (type != null)
-                 throw new RuntimeException(file + " should not be recognized as:" +
-                     type);
-        } finally {
-            file.delete();
-        }
-
-        // exercise custom file type detector
-        file = createGrapeFile();
-        try {
-            String type = Files.probeContentType(file);
-            if (type == null)
-                throw new RuntimeException("Custom file type detector not installed?");
-            if (!type.equals("grape/unknown"))
-                throw new RuntimeException("Unexpected type: " + type);
-        } finally {
-            file.delete();
-        }
-
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/CreateFileTree.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +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.
- *
- * 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.
- */
-
-import java.nio.file.*;
-import java.io.IOException;
-import java.util.*;
-
-/**
- * Creates a file tree with possible cycles caused by symbolic links
- * to ancestor directories.
- */
-
-public class CreateFileTree {
-
-    static final Random rand = new Random();
-
-    public static Path createTemporaryDirectory() throws IOException {
-        Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir"));
-        Path dir;
-        do {
-            dir = tmpdir.resolve("name" + rand.nextInt());
-        } while (dir.exists());
-        dir.createDirectory();
-        return dir;
-    }
-
-    public static void main(String[] args) throws IOException {
-        Path top = createTemporaryDirectory();
-        if (!top.isAbsolute())
-            top = top.toAbsolutePath();
-
-        List<Path> dirs = new ArrayList<Path>();
-
-        // create tree
-        Queue<Path> queue = new ArrayDeque<Path>();
-        queue.add(top);
-        int total = 1 + rand.nextInt(20);
-        int n = 0;
-        Path dir;
-        while (((dir = queue.poll()) != null) && (n < total)) {
-            int r = Math.min((total-n), (1+rand.nextInt(3)));
-            for (int i=0; i<r; i++) {
-                String name = "dir" + (++n);
-                Path subdir = dir.resolve(name).createDirectory();
-                queue.offer(subdir);
-                dirs.add(subdir);
-            }
-        }
-        assert dirs.size() >= 2;
-
-        // create a few regular files in the file tree
-        int files = dirs.size() * 3;
-        for (int i=0; i<files; i++) {
-            String name = "file" + (i+1);
-            int x = rand.nextInt(dirs.size());
-            dirs.get(x).resolve(name).createFile();
-        }
-
-        // create a few sym links in the file tree so as to create cycles
-        int links = 1 + rand.nextInt(5);
-        for (int i=0; i<links; i++) {
-            int x = rand.nextInt(dirs.size());
-            int y;
-            do {
-                y = rand.nextInt(dirs.size());
-            } while (y != x);
-            String name = "link" + (i+1);
-            Path link = dirs.get(x).resolve(name);
-            Path target = dirs.get(y);
-            link.createSymbolicLink(target);
-        }
-
-        // done
-        System.out.println(top);
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/ForceLoad.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Test library dependencies by invoking Files.probeContentType
- *     before other methods that would cause nio.dll to be loaded.
- */
-
-import java.nio.file.*;
-import java.io.IOException;
-
-public class ForceLoad {
-
-    public static void main(String[] args) throws IOException {
-        Files.probeContentType(Paths.get("."));
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/META-INF/services/java.nio.file.spi.FileTypeDetector	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-SimpleFileTypeDetector
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/Misc.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.Files for miscellenous cases not
- *   covered by other tests
- * @library ..
- */
-
-import java.nio.file.*;
-import java.io.IOException;
-import java.util.*;
-
-public class Misc {
-
-    static void npeExpected() {
-        throw new RuntimeException("NullPointerException expected");
-    }
-
-    public static void main(String[] args) throws IOException {
-        try {
-            Files.probeContentType(null);
-            npeExpected();
-        } catch (NullPointerException e) {
-        }
-
-        try {
-            Files.withDirectory(null, "*", new FileAction<Path>() {
-                public void invoke(Path entry) {
-                }
-            });
-            npeExpected();
-        } catch (NullPointerException e) {
-        }
-
-       try {
-            Files.withDirectory(Paths.get("."), (String)null, new FileAction<Path>() {
-                public void invoke(Path entry) {
-                }
-            });
-            npeExpected();
-        } catch (NullPointerException e) {
-        }
-
-        try {
-            Files.withDirectory(Paths.get("."), "*", null);
-            npeExpected();
-        } catch (NullPointerException e) {
-        }
-
-        // test propogation of IOException
-        Path tmpdir = TestUtil.createTemporaryDirectory();
-        try {
-            tmpdir.resolve("foo").createFile();
-            try {
-                Files.withDirectory(tmpdir, new FileAction<Path>() {
-                    public void invoke(Path entry) throws IOException {
-                        throw new IOException();
-                    }
-                });
-                throw new RuntimeException("IOException expected");
-            } catch (IOException e) {
-            }
-        } finally {
-            TestUtil.removeAll(tmpdir);
-        }
-
-        try {
-            Files.walkFileTree(null, EnumSet.noneOf(FileVisitOption.class),
-                Integer.MAX_VALUE, new SimpleFileVisitor<Path>(){});
-            npeExpected();
-        } catch (NullPointerException e) {
-        }
-
-        try {
-            Files.walkFileTree(Paths.get("."), null, Integer.MAX_VALUE,
-                new SimpleFileVisitor<Path>(){});
-            npeExpected();
-        } catch (NullPointerException e) {
-        }
-
-        try {
-            Files.walkFileTree(Paths.get("."), EnumSet.noneOf(FileVisitOption.class),
-                -1, new SimpleFileVisitor<Path>(){});
-            throw new RuntimeException("IllegalArgumentExpected expected");
-        } catch (IllegalArgumentException e) {
-        }
-
-        try {
-            Set<FileVisitOption> opts = new HashSet<FileVisitOption>(1);
-            opts.add(null);
-            Files.walkFileTree(Paths.get("."), opts, Integer.MAX_VALUE,
-                new SimpleFileVisitor<Path>(){});
-            npeExpected();
-        } catch (NullPointerException e) {
-        }
-
-        try {
-            Files.walkFileTree(Paths.get("."), EnumSet.noneOf(FileVisitOption.class),
-                Integer.MAX_VALUE, null);
-            npeExpected();
-        } catch (NullPointerException e) {
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/PrintFileTree.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +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.
- *
- * 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.
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
-import java.util.*;
-
-/**
- * Invokes Files.walkFileTree to traverse a file tree and prints
- * each of the directories and files. The -L option causes symbolic
- * links to be followed.
- */
-
-public class PrintFileTree {
-
-    public static void main(String[] args) throws Exception {
-        boolean followLinks = false;
-        Path dir;
-
-        if (args[0].equals("-L")) {
-            followLinks = true;
-            dir = Paths.get(args[1]);
-        } else {
-            dir = Paths.get(args[0]);
-        }
-
-        Set<FileVisitOption> options = new HashSet<FileVisitOption>();
-        if (followLinks)
-            options.add(FileVisitOption.FOLLOW_LINKS);
-
-        Files.walkFileTree(dir, options, Integer.MAX_VALUE, new FileVisitor<FileRef>() {
-            public FileVisitResult preVisitDirectory(FileRef dir) {
-                System.out.println(dir);
-                return FileVisitResult.CONTINUE;
-            }
-            public FileVisitResult preVisitDirectoryFailed(FileRef dir, IOException exc) {
-                exc.printStackTrace();
-                return FileVisitResult.CONTINUE;
-            }
-            public FileVisitResult visitFile(FileRef file, BasicFileAttributes attrs) {
-                System.out.println(file);
-                return FileVisitResult.CONTINUE;
-            }
-            public FileVisitResult postVisitDirectory(FileRef dir, IOException exc) {
-                if (exc != null) {
-                    exc.printStackTrace();
-                    return FileVisitResult.TERMINATE;
-                }
-                return FileVisitResult.CONTINUE;
-            }
-            public FileVisitResult visitFileFailed(FileRef file, IOException exc) {
-                exc.printStackTrace();
-                return FileVisitResult.TERMINATE;
-            }
-        });
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/SimpleFileTypeDetector.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +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.
- *
- * 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.
- */
-
-import java.nio.file.*;
-import java.nio.file.spi.FileTypeDetector;
-import java.io.*;
-
-
-public class SimpleFileTypeDetector extends FileTypeDetector {
-    public SimpleFileTypeDetector() {
-    }
-
-    public String probeContentType(FileRef file) throws IOException {
-
-        System.out.println("probe " + file + "...");
-
-        if (file instanceof Path) {
-            String name = ((Path)file).toString();
-            if (name.endsWith(".grape")) {
-                return "grape/unknown";
-            }
-        }
-
-        // unknown
-        return null;
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/SkipSiblings.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +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.
- *
- * 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.
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
-import java.util.*;
-
-/**
- * Unit test for Files.walkFileTree to test SKIP_SIBLINGS return value.
- */
-
-public class SkipSiblings {
-
-    static final Random rand = new Random();
-    static final Set<Path> skipped = new HashSet<Path>();
-
-    // check if this path's directory has been skipped
-    static void check(Path path) {
-        if (skipped.contains(path.getParent()))
-            throw new RuntimeException(path + " should not have been visited");
-    }
-
-    // indicates if the siblings of this path should be skipped
-    static boolean skip(Path path) {
-        Path parent = path.getParent();
-        if (parent != null && rand.nextBoolean()) {
-            skipped.add(parent);
-            return true;
-        }
-        return false;
-    }
-
-    public static void main(String[] args) throws Exception {
-        Path dir = Paths.get(args[0]);
-
-        Files.walkFileTree(dir, new FileVisitor<Path>() {
-            public FileVisitResult preVisitDirectory(Path dir) {
-                check(dir);
-                if (skip(dir))
-                    return FileVisitResult.SKIP_SIBLINGS;
-                return FileVisitResult.CONTINUE;
-            }
-            public FileVisitResult preVisitDirectoryFailed(Path dir, IOException exc) {
-                throw new RuntimeException(exc);
-            }
-
-            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
-                check(file);
-                if (skip(file))
-                    return FileVisitResult.SKIP_SIBLINGS;
-                return FileVisitResult.CONTINUE;
-            }
-            public FileVisitResult postVisitDirectory(Path dir, IOException x) {
-                if (x != null)
-                    throw new RuntimeException(x);
-                check(dir);
-                return FileVisitResult.CONTINUE;
-            }
-            public FileVisitResult visitFileFailed(Path file, IOException x) {
-                throw new RuntimeException(x);
-            }
-        });
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/TerminateWalk.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +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.
- *
- * 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.
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
-import java.util.*;
-
-/**
- * Unit test for Files.walkFileTree to test TERMINATE return value
- */
-
-public class TerminateWalk {
-
-    static final Random rand = new Random();
-    static boolean terminated;
-
-    static FileVisitResult maybeTerminate() {
-        if (terminated)
-            throw new RuntimeException("FileVisitor invoked after termination");
-        if (rand.nextInt(10) == 0) {
-            terminated = true;
-            return FileVisitResult.TERMINATE;
-        } else {
-            return FileVisitResult.CONTINUE;
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        Path dir = Paths.get(args[0]);
-
-        Files.walkFileTree(dir, new FileVisitor<Path>() {
-            public FileVisitResult preVisitDirectory(Path dir) {
-                return maybeTerminate();
-            }
-            public FileVisitResult preVisitDirectoryFailed(Path dir, IOException exc) {
-                return maybeTerminate();
-            }
-            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
-                return maybeTerminate();
-            }
-            public FileVisitResult postVisitDirectory(Path dir, IOException x) {
-                return maybeTerminate();
-            }
-            public FileVisitResult visitFileFailed(Path file, IOException x) {
-                return maybeTerminate();
-            }
-        });
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/content_type.sh	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +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.
-#
-# 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.
-#
-
-# @test
-# @bug 4313887
-# @summary Unit test for probeContentType method
-# @build ContentType SimpleFileTypeDetector
-# @run shell content_type.sh
-
-# if TESTJAVA isn't set then we assume an interactive run.
-
-if [ -z "$TESTJAVA" ]; then
-    TESTSRC=.
-    TESTCLASSES=.
-    JAVA=java
-else
-    JAVA="${TESTJAVA}/bin/java"
-fi
-
-OS=`uname -s`
-case "$OS" in
-    Windows_* )
-        CLASSPATH="${TESTCLASSES};${TESTSRC}"
-        ;;
-    * )
-        CLASSPATH=${TESTCLASSES}:${TESTSRC}
-        ;;
-esac
-export CLASSPATH
-
-failures=0
-
-go() {
-    echo ''
-    $JAVA $1 $2 $3 2>&1
-    if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
-}
-
-# Run the test
-
-go ContentType
-
-#
-# Results
-#
-echo ''
-if [ $failures -gt 0 ];
-  then echo "$failures test(s) failed";
-  else echo "All test(s) passed"; fi
-exit $failures
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Files/walk_file_tree.sh	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +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.
-#
-# 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.
-#
-
-# @test
-# @bug 4313887
-# @summary Unit test for walkFileTree method
-# @build CreateFileTree PrintFileTree SkipSiblings TerminateWalk
-# @run shell walk_file_tree.sh
-
-# if TESTJAVA isn't set then we assume an interactive run.
-
-if [ -z "$TESTJAVA" ]; then
-    TESTSRC=.
-    TESTCLASSES=.
-    JAVA=java
-else
-    JAVA="${TESTJAVA}/bin/java"
-fi
-
-OS=`uname -s`
-case "$OS" in
-    Windows_* )
-        echo "This test does not run on Windows" 
-        exit 0
-        ;;
-    * )
-        CLASSPATH=${TESTCLASSES}:${TESTSRC}
-        ;;
-esac
-export CLASSPATH
-
-# create the file tree
-ROOT=`$JAVA CreateFileTree`
-if [ $? != 0 ]; then exit 1; fi
-
-failures=0
-
-# print the file tree and compare output with find(1)
-$JAVA PrintFileTree "$ROOT" > out1
-find "$ROOT" > out2
-diff out1 out2
-if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
-
-# repeat test following links (use -follow instead of -L
-# to allow running on older systems)
-$JAVA PrintFileTree -L "$ROOT" > out1
-find "$ROOT" -follow > out2
-diff out1 out2
-if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
-
-# test SKIP_SIBLINGS
-$JAVA SkipSiblings "$ROOT"
-if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
-
-# test TERMINATE
-$JAVA TerminateWalk "$ROOT"
-if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
-
-# clean-up
-rm -r "$ROOT"
-
-echo ''
-if [ $failures -gt 0 ];
-  then echo "$failures test(s) failed";
-  else echo "Test passed"; fi
-exit $failures
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/CopyAndMove.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,983 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.Path copyTo/moveTo methods
- * @library ..
- */
-
-import java.nio.ByteBuffer;
-import java.nio.file.*;
-import static java.nio.file.StandardCopyOption.*;
-import static java.nio.file.LinkOption.*;
-import java.nio.file.attribute.*;
-import java.io.*;
-import java.util.*;
-
-public class CopyAndMove {
-    static final Random rand = new Random();
-    static boolean heads() { return rand.nextBoolean(); }
-    static boolean supportsLinks;
-
-    public static void main(String[] args) throws Exception {
-        Path dir1 = TestUtil.createTemporaryDirectory();
-        try {
-            supportsLinks = TestUtil.supportsLinks(dir1);
-
-            // Exercise copyTo
-            doCopyTests(dir1);
-
-            // Exercise moveTo
-            // if test.dir differs to temporary file system then can test
-            // moving between devices
-            String testDir = System.getProperty("test.dir");
-            Path dir2 = (testDir != null) ? Paths.get(testDir) : dir1;
-            doMoveTests(dir1, dir2);
-
-        } finally {
-            TestUtil.removeAll(dir1);
-        }
-    }
-
-    static void checkBasicAttributes(BasicFileAttributes attrs1,
-                                     BasicFileAttributes attrs2)
-    {
-        // check file type
-        assertTrue(attrs1.isRegularFile() == attrs2.isRegularFile());
-        assertTrue(attrs1.isDirectory() == attrs2.isDirectory());
-        assertTrue(attrs1.isSymbolicLink() == attrs2.isSymbolicLink());
-        assertTrue(attrs1.isOther() == attrs2.isOther());
-
-        // check last modified time (assume millisecond precision)
-        long time1 = attrs1.resolution().toMillis(attrs1.lastModifiedTime());
-        long time2 = attrs1.resolution().toMillis(attrs2.lastModifiedTime());
-        assertTrue(time1 == time2);
-
-        // check size
-        if (attrs1.isRegularFile())
-            assertTrue(attrs1.size() == attrs2.size());
-    }
-
-    static void checkPosixAttributes(PosixFileAttributes attrs1,
-                                     PosixFileAttributes attrs2)
-    {
-        assertTrue(attrs1.permissions().equals(attrs2.permissions()));
-        assertTrue(attrs1.owner().equals(attrs2.owner()));
-        assertTrue(attrs1.group().equals(attrs2.group()));
-    }
-
-    static void checkDosAttributes(DosFileAttributes attrs1,
-                                   DosFileAttributes attrs2)
-    {
-        assertTrue(attrs1.isReadOnly() == attrs2.isReadOnly());
-        assertTrue(attrs1.isHidden() == attrs2.isHidden());
-        assertTrue(attrs1.isArchive() == attrs2.isArchive());
-        assertTrue(attrs1.isSystem() == attrs2.isSystem());
-    }
-
-    static void checkNamedAttributes(Map<String,ByteBuffer> attrs1,
-                                     Map<String,ByteBuffer> attrs2)
-    {
-        assert attrs1.size() == attrs2.size();
-        for (String name: attrs1.keySet()) {
-            ByteBuffer bb1 = attrs1.get(name);
-            ByteBuffer bb2 = attrs2.get(name);
-            assertTrue(bb2 != null);
-            assertTrue(bb1.equals(bb2));
-        }
-    }
-
-    static Map<String,ByteBuffer> readNamedAttributes(Path file)
-        throws IOException
-    {
-        NamedAttributeView view = file
-            .getFileAttributeView(NamedAttributeView.class);
-        Map<String,ByteBuffer> result = new HashMap<String,ByteBuffer>();
-        for (String name: view.list()) {
-            int size = view.size(name);
-            ByteBuffer bb = ByteBuffer.allocate(size);
-            int n = view.read(name, bb);
-            assertTrue(n == size);
-            bb.flip();
-            result.put(name, bb);
-        }
-        return result;
-    }
-
-    // move source to target with verification
-    static void moveAndVerify(Path source, Path target, CopyOption... options)
-        throws IOException
-    {
-        // read attributes before file is moved
-        BasicFileAttributes basicAttributes = null;
-        PosixFileAttributes posixAttributes = null;
-        DosFileAttributes dosAttributes = null;
-        Map<String,ByteBuffer> namedAttributes = null;
-
-        // get file attributes of source file
-        String os = System.getProperty("os.name");
-        if (os.equals("SunOS") || os.equals("Linux")) {
-            posixAttributes = Attributes.readPosixFileAttributes(source, NOFOLLOW_LINKS);
-            basicAttributes = posixAttributes;
-        }
-        if (os.startsWith("Windows")) {
-            dosAttributes = Attributes.readDosFileAttributes(source, NOFOLLOW_LINKS);
-            basicAttributes = dosAttributes;
-        }
-        if (basicAttributes == null)
-            basicAttributes = Attributes.readBasicFileAttributes(source, NOFOLLOW_LINKS);
-
-        // hash file contents if regular file
-        int hash = (basicAttributes.isRegularFile()) ? computeHash(source) : 0;
-
-        // record link target if symbolic link
-        Path linkTarget = null;
-        if (basicAttributes.isSymbolicLink())
-            linkTarget = source.readSymbolicLink();
-
-        // read named attributes if available (and file is not a sym link)
-        if (!basicAttributes.isSymbolicLink() &&
-            source.getFileStore().supportsFileAttributeView("xattr"))
-        {
-            namedAttributes = readNamedAttributes(source);
-        }
-
-        // move file
-        source.moveTo(target, options);
-
-        // verify source does not exist
-        assertTrue(source.notExists());
-
-        // verify file contents
-        if (basicAttributes.isRegularFile()) {
-            if (computeHash(target) != hash)
-                throw new RuntimeException("Failed to verify move of regular file");
-        }
-
-        // verify link target
-        if (basicAttributes.isSymbolicLink()) {
-            if (!target.readSymbolicLink().equals(linkTarget))
-                throw new RuntimeException("Failed to verify move of symbolic link");
-        }
-
-        // verify basic attributes
-        checkBasicAttributes(basicAttributes,
-            Attributes.readBasicFileAttributes(target, NOFOLLOW_LINKS));
-
-        // verify POSIX attributes
-        if (posixAttributes != null && !basicAttributes.isSymbolicLink()) {
-            checkPosixAttributes(posixAttributes,
-                Attributes.readPosixFileAttributes(target, NOFOLLOW_LINKS));
-        }
-
-        // verify DOS attributes
-        if (dosAttributes != null && !basicAttributes.isSymbolicLink()) {
-            checkDosAttributes(dosAttributes,
-                Attributes.readDosFileAttributes(target, NOFOLLOW_LINKS));
-        }
-
-        // verify named attributes
-        if (namedAttributes != null &&
-            target.getFileStore().supportsFileAttributeView("xattr"))
-        {
-            checkNamedAttributes(namedAttributes, readNamedAttributes(target));
-        }
-    }
-
-    /**
-     * Tests all possible ways to invoke moveTo
-     */
-    static void doMoveTests(Path dir1, Path dir2) throws IOException {
-        Path source, target, entry;
-
-        boolean sameDevice = dir1.getFileStore().equals(dir2.getFileStore());
-
-        // -- regular file --
-
-        /**
-         * Test: move regular file, target does not exist
-         */
-        source = createSourceFile(dir1);
-        target = getTargetFile(dir1);
-        moveAndVerify(source, target);
-        target.delete();
-
-        /**
-         * Test: move regular file, target exists
-         */
-        source = createSourceFile(dir1);
-        target = getTargetFile(dir1).createFile();
-        try {
-            moveAndVerify(source, target);
-            throw new RuntimeException("FileAlreadyExistsException expected");
-        } catch (FileAlreadyExistsException x) {
-        }
-        target.delete();
-        target.createDirectory();
-        try {
-            moveAndVerify(source, target);
-            throw new RuntimeException("FileAlreadyExistsException expected");
-        } catch (FileAlreadyExistsException x) {
-        }
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: move regular file, target does not exist
-         */
-        source = createSourceFile(dir1);
-        target = getTargetFile(dir1);
-        moveAndVerify(source, target, REPLACE_EXISTING);
-        target.delete();
-
-        /**
-         * Test: move regular file, target exists
-         */
-        source = createSourceFile(dir1);
-        target = getTargetFile(dir1).createFile();
-        moveAndVerify(source, target, REPLACE_EXISTING);
-        target.delete();
-
-        /**
-         * Test: move regular file, target exists and is empty directory
-         */
-        source = createSourceFile(dir1);
-        target = getTargetFile(dir1).createDirectory();
-        moveAndVerify(source, target, REPLACE_EXISTING);
-        target.delete();
-
-        /**
-         * Test: move regular file, target exists and is non-empty directory
-         */
-        source = createSourceFile(dir1);
-        target = getTargetFile(dir1).createDirectory();
-        entry = target.resolve("foo").createFile();
-        try {
-            moveAndVerify(source, target);
-            throw new RuntimeException("FileAlreadyExistsException expected");
-        } catch (FileAlreadyExistsException x) {
-        }
-        entry.delete();
-        source.delete();
-        target.delete();
-
-        /**
-         * Test atomic move of regular file (same file store)
-         */
-        source = createSourceFile(dir1);
-        target = getTargetFile(dir1);
-        moveAndVerify(source, target, ATOMIC_MOVE);
-        target.delete();
-
-        /**
-         * Test atomic move of regular file (different file store)
-         */
-        if (!sameDevice) {
-            source = createSourceFile(dir1);
-            target = getTargetFile(dir2);
-            try {
-                moveAndVerify(source, target, ATOMIC_MOVE);
-                throw new RuntimeException("AtomicMoveNotSupportedException expected");
-            } catch (AtomicMoveNotSupportedException x) {
-            }
-            source.delete();
-        }
-
-        // -- directories --
-
-        /*
-         * Test: move empty directory, target does not exist
-         */
-        source = createSourceDirectory(dir1);
-        target = getTargetFile(dir1);
-        moveAndVerify(source, target);
-        target.delete();
-
-        /**
-         * Test: move empty directory, target exists
-         */
-        source = createSourceDirectory(dir1);
-        target = getTargetFile(dir1).createFile();
-        try {
-            moveAndVerify(source, target);
-            throw new RuntimeException("FileAlreadyExistsException expected");
-        } catch (FileAlreadyExistsException x) {
-        }
-        target.delete();
-        target.createDirectory();
-        try {
-            moveAndVerify(source, target);
-            throw new RuntimeException("FileAlreadyExistsException expected");
-        } catch (FileAlreadyExistsException x) {
-        }
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: move empty directory, target does not exist
-         */
-        source = createSourceDirectory(dir1);
-        target = getTargetFile(dir1);
-        moveAndVerify(source, target, REPLACE_EXISTING);
-        target.delete();
-
-        /**
-         * Test: move empty directory, target exists
-         */
-        source = createSourceDirectory(dir1);
-        target = getTargetFile(dir1).createFile();
-        moveAndVerify(source, target, REPLACE_EXISTING);
-        target.delete();
-
-        /**
-         * Test: move empty, target exists and is empty directory
-         */
-        source = createSourceDirectory(dir1);
-        target = getTargetFile(dir1).createDirectory();
-        moveAndVerify(source, target, REPLACE_EXISTING);
-        target.delete();
-
-        /**
-         * Test: move empty directory, target exists and is non-empty directory
-         */
-        source = createSourceDirectory(dir1);
-        target = getTargetFile(dir1).createDirectory();
-        entry = target.resolve("foo").createFile();
-        try {
-            moveAndVerify(source, target, REPLACE_EXISTING);
-            throw new RuntimeException("FileAlreadyExistsException expected");
-        } catch (FileAlreadyExistsException x) {
-        }
-        entry.delete();
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: move non-empty directory (same file system)
-         */
-        source = createSourceDirectory(dir1);
-        source.resolve("foo").createFile();
-        target = getTargetFile(dir1);
-        moveAndVerify(source, target);
-        target.resolve("foo").delete();
-        target.delete();
-
-        /**
-         * Test: move non-empty directory (different file store)
-         */
-        if (!sameDevice) {
-            source = createSourceDirectory(dir1);
-            source.resolve("foo").createFile();
-            target = getTargetFile(dir2);
-            try {
-                moveAndVerify(source, target);
-                throw new RuntimeException("IOException expected");
-            } catch (IOException x) {
-            }
-            source.resolve("foo").delete();
-            source.delete();
-        }
-
-        /**
-         * Test atomic move of directory (same file store)
-         */
-        source = createSourceDirectory(dir1);
-        source.resolve("foo").createFile();
-        target = getTargetFile(dir1);
-        moveAndVerify(source, target, ATOMIC_MOVE);
-        target.resolve("foo").delete();
-        target.delete();
-
-        // -- symbolic links --
-
-        /**
-         * Test: Move symbolic link to file, target does not exist
-         */
-        if (supportsLinks) {
-            Path tmp = createSourceFile(dir1);
-            source = dir1.resolve("link").createSymbolicLink(tmp);
-            target = getTargetFile(dir1);
-            moveAndVerify(source, target);
-            target.delete();
-            tmp.delete();
-        }
-
-        /**
-         * Test: Move symbolic link to directory, target does not exist
-         */
-        if (supportsLinks) {
-            source = dir1.resolve("link").createSymbolicLink(dir2);
-            target = getTargetFile(dir1);
-            moveAndVerify(source, target);
-            target.delete();
-        }
-
-        /**
-         * Test: Move broken symbolic link, target does not exists
-         */
-        if (supportsLinks) {
-            Path tmp = Paths.get("doesnotexist");
-            source = dir1.resolve("link").createSymbolicLink(tmp);
-            target = getTargetFile(dir1);
-            moveAndVerify(source, target);
-            target.delete();
-        }
-
-        /**
-         * Test: Move symbolic link, target exists
-         */
-        if (supportsLinks) {
-            source = dir1.resolve("link").createSymbolicLink(dir2);
-            target = getTargetFile(dir1).createFile();
-            try {
-                moveAndVerify(source, target);
-                throw new RuntimeException("FileAlreadyExistsException expected");
-            } catch (FileAlreadyExistsException x) {
-            }
-            source.delete();
-            target.delete();
-        }
-
-        /**
-         * Test: Move regular file, target exists
-         */
-        if (supportsLinks) {
-            source = dir1.resolve("link").createSymbolicLink(dir2);
-            target = getTargetFile(dir1).createFile();
-            moveAndVerify(source, target, REPLACE_EXISTING);
-            target.delete();
-        }
-
-        /**
-         * Test: move symbolic link, target exists and is empty directory
-         */
-        if (supportsLinks) {
-            source = dir1.resolve("link").createSymbolicLink(dir2);
-            target = getTargetFile(dir1).createDirectory();
-            moveAndVerify(source, target, REPLACE_EXISTING);
-            target.delete();
-        }
-
-        /**
-         * Test: symbolic link, target exists and is non-empty directory
-         */
-        if (supportsLinks) {
-            source = dir1.resolve("link").createSymbolicLink(dir2);
-            target = getTargetFile(dir1).createDirectory();
-            entry = target.resolve("foo").createFile();
-            try {
-                moveAndVerify(source, target);
-                throw new RuntimeException("FileAlreadyExistsException expected");
-            } catch (FileAlreadyExistsException x) {
-            }
-            entry.delete();
-            source.delete();
-            target.delete();
-        }
-
-        /**
-         * Test atomic move of symbolic link (same file store)
-         */
-        if (supportsLinks) {
-            source = dir1.resolve("link").createSymbolicLink(dir1);
-            target = getTargetFile(dir1).createFile();
-            moveAndVerify(source, target, REPLACE_EXISTING);
-            target.delete();
-        }
-
-        // -- misc. tests --
-
-        /**
-         * Test nulls
-         */
-        source = createSourceFile(dir1);
-        target = getTargetFile(dir1);
-        try {
-            source.moveTo(null);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException x) { }
-        try {
-            source.moveTo(target, (CopyOption[])null);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException x) { }
-        try {
-            CopyOption[] opts = { REPLACE_EXISTING, null };
-            source.moveTo(target, opts);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException x) { }
-        source.delete();
-
-        /**
-         * Test UOE
-         */
-        source = createSourceFile(dir1);
-        target = getTargetFile(dir1);
-        try {
-            source.moveTo(target, new CopyOption() { });
-        } catch (UnsupportedOperationException x) { }
-        try {
-            source.moveTo(target, REPLACE_EXISTING,  new CopyOption() { });
-        } catch (UnsupportedOperationException x) { }
-        source.delete();
-    }
-
-    // copy source to target with verification
-    static void copyAndVerify(Path source, Path target, CopyOption... options)
-        throws IOException
-    {
-        source.copyTo(target, options);
-
-        // get attributes of source and target file to verify copy
-        boolean followLinks = true;
-        LinkOption[] linkOptions = new LinkOption[0];
-        boolean copyAttributes = false;
-        for (CopyOption opt : options) {
-            if (opt == NOFOLLOW_LINKS) {
-                followLinks = false;
-                linkOptions = new LinkOption[] { NOFOLLOW_LINKS };
-            }
-            if (opt == COPY_ATTRIBUTES)
-                copyAttributes = true;
-        }
-        BasicFileAttributes basicAttributes = Attributes
-            .readBasicFileAttributes(source, linkOptions);
-
-        // check hash if regular file
-        if (basicAttributes.isRegularFile())
-            assertTrue(computeHash(source) == computeHash(target));
-
-        // check link target if symbolic link
-        if (basicAttributes.isSymbolicLink())
-            assert( source.readSymbolicLink().equals(target.readSymbolicLink()));
-
-        // check that attributes are copied
-        if (copyAttributes && followLinks) {
-            checkBasicAttributes(basicAttributes,
-                Attributes.readBasicFileAttributes(source, linkOptions));
-
-            // check POSIX attributes are copied
-            String os = System.getProperty("os.name");
-            if (os.equals("SunOS") || os.equals("Linux")) {
-                checkPosixAttributes(
-                    Attributes.readPosixFileAttributes(source, linkOptions),
-                    Attributes.readPosixFileAttributes(target, linkOptions));
-            }
-
-            // check DOS attributes are copied
-            if (os.startsWith("Windows")) {
-                checkDosAttributes(
-                    Attributes.readDosFileAttributes(source, linkOptions),
-                    Attributes.readDosFileAttributes(target, linkOptions));
-            }
-
-            // check named attributes are copied
-            if (followLinks &&
-                source.getFileStore().supportsFileAttributeView("xattr") &&
-                target.getFileStore().supportsFileAttributeView("xattr"))
-            {
-                checkNamedAttributes(readNamedAttributes(source),
-                                     readNamedAttributes(target));
-            }
-        }
-    }
-
-    /**
-     * Tests all possible ways to invoke copyTo
-     */
-    static void doCopyTests(Path dir) throws IOException {
-        Path source, target, link, entry;
-
-        // -- regular file --
-
-        /**
-         * Test: move regular file, target does not exist
-         */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir);
-        copyAndVerify(source, target);
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: copy regular file, target exists
-         */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir).createFile();
-        try {
-            copyAndVerify(source, target);
-            throw new RuntimeException("FileAlreadyExistsException expected");
-        } catch (FileAlreadyExistsException x) {
-        }
-        target.delete();
-        target.createDirectory();
-        try {
-            copyAndVerify(source, target);
-            throw new RuntimeException("FileAlreadyExistsException expected");
-        } catch (FileAlreadyExistsException x) {
-        }
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: copy regular file, target does not exist
-         */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir);
-        copyAndVerify(source, target, REPLACE_EXISTING);
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: copy regular file, target exists
-         */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir).createFile();
-        copyAndVerify(source, target, REPLACE_EXISTING);
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: copy regular file, target exists and is empty directory
-         */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir).createDirectory();
-        copyAndVerify(source, target, REPLACE_EXISTING);
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: copy regular file, target exists and is non-empty directory
-         */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir).createDirectory();
-        entry = target.resolve("foo").createFile();
-        try {
-            copyAndVerify(source, target);
-            throw new RuntimeException("FileAlreadyExistsException expected");
-        } catch (FileAlreadyExistsException x) {
-        }
-        entry.delete();
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: copy regular file + attributes
-         */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir);
-        copyAndVerify(source, target, COPY_ATTRIBUTES);
-        source.delete();
-        target.delete();
-
-
-        // -- directory --
-
-        /*
-         * Test: copy directory, target does not exist
-         */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir);
-        copyAndVerify(source, target);
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: copy directory, target exists
-         */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir).createFile();
-        try {
-            copyAndVerify(source, target);
-            throw new RuntimeException("FileAlreadyExistsException expected");
-        } catch (FileAlreadyExistsException x) {
-        }
-        target.delete();
-        target.createDirectory();
-        try {
-            copyAndVerify(source, target);
-            throw new RuntimeException("FileAlreadyExistsException expected");
-        } catch (FileAlreadyExistsException x) {
-        }
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: copy directory, target does not exist
-         */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir);
-        copyAndVerify(source, target, REPLACE_EXISTING);
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: copy directory, target exists
-         */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir).createFile();
-        copyAndVerify(source, target, REPLACE_EXISTING);
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: copy directory, target exists and is empty directory
-         */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir).createDirectory();
-        copyAndVerify(source, target, REPLACE_EXISTING);
-        source.delete();
-        target.delete();
-
-        /**
-         * Test: copy directory, target exists and is non-empty directory
-         */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir).createDirectory();
-        entry = target.resolve("foo").createFile();
-        try {
-            copyAndVerify(source, target, REPLACE_EXISTING);
-            throw new RuntimeException("FileAlreadyExistsException expected");
-        } catch (FileAlreadyExistsException x) {
-        }
-        entry.delete();
-        source.delete();
-        target.delete();
-
-        /*
-         * Test: copy directory + attributes
-         */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir);
-        copyAndVerify(source, target, COPY_ATTRIBUTES);
-        source.delete();
-        target.delete();
-
-        // -- symbolic links --
-
-        /**
-         * Test: Follow link
-         */
-        if (supportsLinks) {
-            source = createSourceFile(dir);
-            link = dir.resolve("link").createSymbolicLink(source);
-            target = getTargetFile(dir);
-            copyAndVerify(link, target);
-            link.delete();
-            source.delete();
-        }
-
-        /**
-         * Test: Copy link (to file)
-         */
-        if (supportsLinks) {
-            source = createSourceFile(dir);
-            link = dir.resolve("link").createSymbolicLink(source);
-            target = getTargetFile(dir);
-            copyAndVerify(link, target, NOFOLLOW_LINKS);
-            link.delete();
-            source.delete();
-        }
-
-        /**
-         * Test: Copy link (to directory)
-         */
-        if (supportsLinks) {
-            source = dir.resolve("mydir").createDirectory();
-            link = dir.resolve("link").createSymbolicLink(source);
-            target = getTargetFile(dir);
-            copyAndVerify(link, target, NOFOLLOW_LINKS);
-            link.delete();
-            source.delete();
-        }
-
-        /**
-         * Test: Copy broken link
-         */
-        if (supportsLinks) {
-            assertTrue(source.notExists());
-            link = dir.resolve("link").createSymbolicLink(source);
-            target = getTargetFile(dir);
-            copyAndVerify(link, target, NOFOLLOW_LINKS);
-            link.delete();
-        }
-
-        /**
-         * Test: Copy link to UNC (Windows only)
-         */
-        if (supportsLinks &&
-            System.getProperty("os.name").startsWith("Windows"))
-        {
-            Path unc = Paths.get("\\\\rialto\\share\\file");
-            link = dir.resolve("link").createSymbolicLink(unc);
-            target = getTargetFile(dir);
-            copyAndVerify(link, target, NOFOLLOW_LINKS);
-            link.delete();
-        }
-
-        // -- misc. tests --
-
-        /**
-         * Test nulls
-         */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir);
-        try {
-            source.copyTo(null);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException x) { }
-        try {
-            source.copyTo(target, (CopyOption[])null);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException x) { }
-        try {
-            CopyOption[] opts = { REPLACE_EXISTING, null };
-            source.copyTo(target, opts);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException x) { }
-        source.delete();
-
-        /**
-         * Test UOE
-         */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir);
-        try {
-            source.copyTo(target, new CopyOption() { });
-        } catch (UnsupportedOperationException x) { }
-        try {
-            source.copyTo(target, REPLACE_EXISTING,  new CopyOption() { });
-        } catch (UnsupportedOperationException x) { }
-        source.delete();
-    }
-
-
-    static void assertTrue(boolean value) {
-        if (!value)
-            throw new RuntimeException("Assertion failed");
-    }
-
-    // computes simple hash of the given file
-    static int computeHash(Path file) throws IOException {
-        int h = 0;
-
-        InputStream in = file.newInputStream();
-        try {
-            byte[] buf = new byte[1024];
-            int n;
-            do {
-                n = in.read(buf);
-                for (int i=0; i<n; i++) {
-                    h = 31*h + (buf[i] & 0xff);
-                }
-            } while (n > 0);
-        } finally {
-            in.close();
-        }
-        return h;
-    }
-
-    // create file of random size in given directory
-    static Path createSourceFile(Path dir) throws IOException {
-        String name = "source" + Integer.toString(rand.nextInt());
-        Path file = dir.resolve(name).createFile();
-        byte[] bytes = new byte[rand.nextInt(128*1024)];
-        rand.nextBytes(bytes);
-        OutputStream out = file.newOutputStream();
-        try {
-            out.write(bytes);
-        } finally {
-            out.close();
-        }
-        randomizeAttributes(file);
-        return file;
-    }
-
-    // create directory in the given directory
-    static Path createSourceDirectory(Path dir) throws IOException {
-        String name = "sourcedir" + Integer.toString(rand.nextInt());
-        Path subdir = dir.resolve(name).createDirectory();
-        randomizeAttributes(subdir);
-        return subdir;
-    }
-
-    // "randomize" the file attributes of the given file.
-    static void randomizeAttributes(Path file) throws IOException {
-        String os = System.getProperty("os.name");
-        boolean isWindows = os.startsWith("Windows");
-        boolean isUnix = os.equals("SunOS") || os.equals("Linux");
-        boolean isDirectory = Attributes.readBasicFileAttributes(file, NOFOLLOW_LINKS)
-            .isDirectory();
-
-        if (isUnix) {
-            Set<PosixFilePermission> perms = Attributes
-                .readPosixFileAttributes(file, NOFOLLOW_LINKS).permissions();
-            PosixFilePermission[] toChange = {
-                PosixFilePermission.GROUP_READ,
-                PosixFilePermission.GROUP_WRITE,
-                PosixFilePermission.GROUP_EXECUTE,
-                PosixFilePermission.OTHERS_READ,
-                PosixFilePermission.OTHERS_WRITE,
-                PosixFilePermission.OTHERS_EXECUTE
-            };
-            for (PosixFilePermission perm: toChange) {
-                if (heads()) {
-                    perms.add(perm);
-                } else {
-                    perms.remove(perm);
-                }
-            }
-            Attributes.setPosixFilePermissions(file, perms);
-        }
-
-        if (isWindows) {
-            DosFileAttributeView view = file
-                .getFileAttributeView(DosFileAttributeView.class, NOFOLLOW_LINKS);
-            // only set or unset the hidden attribute
-            view.setHidden(heads());
-        }
-
-        boolean addNamedAttributes = heads() &&
-            file.getFileStore().supportsFileAttributeView("xattr");
-
-        // remove this when copying a direcory copies its named streams
-        if (isWindows && isDirectory) addNamedAttributes = false;
-
-        if (addNamedAttributes) {
-            NamedAttributeView view = file
-                .getFileAttributeView(NamedAttributeView.class);
-            int n = rand.nextInt(16);
-            while (n > 0) {
-                byte[] value = new byte[1 + rand.nextInt(100)];
-                view.write("user." + Integer.toString(n), ByteBuffer.wrap(value));
-                n--;
-            }
-        }
-    }
-
-    // create name for file in given directory
-    static Path getTargetFile(Path dir) throws IOException {
-        String name = "target" + Integer.toString(rand.nextInt());
-        return dir.resolve(name);
-    }
- }
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/DeleteOnClose.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +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.
- *
- * 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.
- */
-
-import java.nio.file.*;
-import static java.nio.file.StandardOpenOption.*;
-import java.io.*;
-import java.util.*;
-
-public class DeleteOnClose {
-
-    public static void main(String[] args) throws IOException {
-        // open file but do not close it. Its existance will be checked by
-        // the calling script.
-        Paths.get(args[0]).newByteChannel(READ, WRITE, DELETE_ON_CLOSE);
-
-        // check temporary file has been deleted after closing it
-        Path file = File.createTempFile("blah", "tmp").toPath();
-        file.newByteChannel(READ, WRITE, DELETE_ON_CLOSE).close();
-        if (file.exists())
-            throw new RuntimeException("Temporary file was not deleted");
-
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            // check that DELETE_ON_CLOSE fails when file is a sym link
-            if (TestUtil.supportsLinks(dir)) {
-                file = dir.resolve("foo").createFile();
-                Path link = dir.resolve("link").createSymbolicLink(file);
-                try {
-                    link.newByteChannel(READ, WRITE, DELETE_ON_CLOSE);
-                    throw new RuntimeException("IOException expected");
-                } catch (IOException ignore) { }
-            }
-
-            // check that DELETE_ON_CLOSE works with files created via open
-            // directories
-            DirectoryStream stream = dir.newDirectoryStream();
-            try {
-                if (stream instanceof SecureDirectoryStream) {
-                    SecureDirectoryStream secure = (SecureDirectoryStream)stream;
-                    file = Paths.get("foo");
-
-                    Set<OpenOption> opts = new HashSet<OpenOption>();
-                    opts.add(WRITE);
-                    opts.add(DELETE_ON_CLOSE);
-                    secure.newByteChannel(file, opts).close();
-
-                    if (dir.resolve(file).exists())
-                        throw new RuntimeException("File not deleted");
-                }
-            } finally {
-                stream.close();
-            }
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/InterruptCopy.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for Sun-specific ExtendedCopyOption.INTERRUPTIBLE option
- * @library ..
- * @run main/othervm -XX:-UseVMInterruptibleIO InterruptCopy
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.Attributes;
-import java.io.*;
-import java.util.concurrent.*;
-import com.sun.nio.file.ExtendedCopyOption;
-
-public class InterruptCopy {
-
-    private static final long FILE_SIZE_TO_COPY = 512 * 1024 * 1024;
-    private static final int DELAY_IN_MS = 500;
-
-    public static void main(String[] args) throws Exception {
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            FileStore store = dir.getFileStore();
-            System.out.format("Checking space (%s)\n", store);
-            long usableSpace = Attributes
-                .readFileStoreSpaceAttributes(store).usableSpace();
-            if (usableSpace < 2*FILE_SIZE_TO_COPY) {
-                System.out.println("Insufficient disk space to run test.");
-                return;
-            }
-            doTest(dir);
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-
-    static void doTest(Path dir) throws Exception {
-        final Path source = dir.resolve("foo");
-        final Path target = dir.resolve("bar");
-
-        // create source file (don't create it as sparse file because we
-        // require the copy to take a long time)
-        System.out.println("Creating source file...");
-        byte[] buf = new byte[32*1024];
-        long total = 0;
-        OutputStream out = source.newOutputStream();
-        try {
-            do {
-                out.write(buf);
-                total += buf.length;
-            } while (total < FILE_SIZE_TO_COPY);
-        } finally {
-            out.close();
-        }
-        System.out.println("Source file created.");
-
-        ScheduledExecutorService pool =
-            Executors.newSingleThreadScheduledExecutor();
-        try {
-            // copy source to target in main thread, interrupting it after a delay
-            final Thread me = Thread.currentThread();
-            pool.schedule(new Runnable() {
-                public void run() {
-                    me.interrupt();
-                }}, DELAY_IN_MS, TimeUnit.MILLISECONDS);
-            System.out.println("Copying file...");
-            try {
-                source.copyTo(target, ExtendedCopyOption.INTERRUPTIBLE);
-                throw new RuntimeException("Copy completed (this is not expected)");
-            } catch (IOException e) {
-                boolean interrupted = Thread.interrupted();
-                if (!interrupted)
-                    throw new RuntimeException("Interrupt status was not set");
-                System.out.println("Copy failed (this is expected)");
-            }
-
-            // copy source to target via task in thread pool, interrupting it after
-            // a delay using cancel(true)
-            Future<Void> result = pool.submit(new Callable<Void>() {
-                public Void call() throws IOException {
-                    System.out.println("Copying file...");
-                    source.copyTo(target, ExtendedCopyOption.INTERRUPTIBLE,
-                        StandardCopyOption.REPLACE_EXISTING);
-                    return null;
-                }
-            });
-            Thread.sleep(DELAY_IN_MS);
-            boolean cancelled = result.cancel(true);
-            if (!cancelled)
-                result.get();
-            System.out.println("Copy cancelled.");
-        } finally {
-            pool.shutdown();
-            pool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/Links.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.Path createSymbolicLink,
- *     readSymbolicLink, and createLink methods
- * @library ..
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.*;
-import java.util.*;
-
-public class Links {
-
-    static final boolean isWindows =
-        System.getProperty("os.name").startsWith("Windows");
-
-    static void assertTrue(boolean okay) {
-        if (!okay)
-            throw new RuntimeException("Assertion failed");
-    }
-
-    /**
-     * Exercise createSymbolicLink and readLink methods
-     */
-    static void testSymLinks(Path dir) throws IOException {
-        Path link = dir.resolve("link");
-
-        // Check if sym links are supported
-        try {
-            link.createSymbolicLink(Paths.get("foo"));
-            link.delete();
-        } catch (UnsupportedOperationException x) {
-            // sym links not supported
-            return;
-        } catch (IOException x) {
-            // probably insufficient privileges to create sym links (Windows)
-            return;
-        }
-
-        // Test links to various targets
-        String[] windowsTargets =
-            { "foo", "C:\\foo", "\\foo", "\\\\server\\share\\foo" };
-        String[] otherTargets = { "relative", "/absolute" };
-
-        String[] targets = (isWindows) ? windowsTargets : otherTargets;
-        for (String s: targets) {
-            Path target = Paths.get(s);
-            link.createSymbolicLink(target);
-            try {
-                assertTrue(link.readSymbolicLink().equals(target));
-            } finally {
-                link.delete();
-            }
-        }
-    }
-
-    /**
-     * Exercise createLink method
-     */
-    static void testHardLinks(Path dir) throws IOException {
-        Path foo = dir.resolve("foo").createFile();
-        try {
-            Path bar;
-            try {
-                bar = dir.resolve("bar").createLink(foo);
-            } catch (UnsupportedOperationException x) {
-                return;
-            } catch (IOException x) {
-                // probably insufficient privileges (Windows)
-                return;
-            }
-            try {
-                Object key1 = Attributes
-                    .readBasicFileAttributes(foo).fileKey();
-                Object key2 = Attributes
-                    .readBasicFileAttributes(bar).fileKey();
-                assertTrue((key1 == null) || (key1.equals(key2)));
-
-                assertTrue(Attributes
-                    .readBasicFileAttributes(foo).linkCount() >= 2);
-                assertTrue(Attributes
-                    .readBasicFileAttributes(bar).linkCount() >= 2);
-
-            } finally {
-                bar.delete();
-            }
-
-
-        } finally {
-            foo.delete();
-        }
-    }
-
-    public static void main(String[] args) throws IOException {
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            testSymLinks(dir);
-            testHardLinks(dir);
-
-            // repeat tests on Windows with long path
-            if (isWindows) {
-                Path dirWithLongPath = null;
-                try {
-                    dirWithLongPath = TestUtil.createDirectoryWithLongPath(dir);
-                } catch (IOException x) {
-                    System.out.println("Unable to create long path: " + x);
-                }
-                if (dirWithLongPath != null) {
-                    System.out.println("");
-                    System.out.println("** REPEAT TESTS WITH LONG PATH **");
-                    testSymLinks(dirWithLongPath);
-                    testHardLinks(dirWithLongPath);
-                }
-            }
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/Misc.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,349 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.Path for miscellenous methods not
- *   covered by other tests
- * @library ..
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.*;
-import java.util.*;
-
-public class Misc {
-    static final boolean isWindows =
-        System.getProperty("os.name").startsWith("Windows");
-    static boolean supportsLinks;
-
-    public static void main(String[] args) throws IOException {
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            supportsLinks = TestUtil.supportsLinks(dir);
-
-            // equals and hashCode methods
-            equalsAndHashCode();
-
-            // checkAccess method
-            checkAccessTests(dir);
-
-            // toRealPath method
-            toRealPathTests(dir);
-
-            // isSameFile method
-            isSameFileTests(dir);
-
-            // isHidden method
-            isHiddenTests(dir);
-
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-
-    /**
-     * Exercise equals and hashCode methods
-     */
-    static void equalsAndHashCode() {
-
-        Path thisFile = Paths.get("this");
-        Path thatFile = Paths.get("that");
-
-        assertTrue(thisFile.equals(thisFile));
-        assertTrue(!thisFile.equals(thatFile));
-
-        assertTrue(!thisFile.equals(null));
-        assertTrue(!thisFile.equals(new Object()));
-
-        Path likeThis = Paths.get("This");
-        if (isWindows) {
-            // case insensitive
-            assertTrue(thisFile.equals(likeThis));
-            assertTrue(thisFile.hashCode() == likeThis.hashCode());
-        } else {
-            // case senstive
-            assertTrue(!thisFile.equals(likeThis));
-        }
-    }
-
-    /**
-     * Exercise checkAccess method
-     */
-    static void checkAccessTests(Path dir) throws IOException {
-        final Path file = dir.resolve("foo").createFile();
-
-        /**
-         * Test: This directory should readable and writable
-         */
-        dir.checkAccess();
-        dir.checkAccess(AccessMode.READ);
-        dir.checkAccess(AccessMode.WRITE);
-        dir.checkAccess(AccessMode.READ, AccessMode.WRITE);
-
-        /**
-         * Test: File does not exist
-         */
-        Path doesNotExist = dir.resolve("thisDoesNotExists");
-        try {
-            doesNotExist.checkAccess();
-            throw new RuntimeException("NoSuchFileException expected");
-        } catch (NoSuchFileException x) {
-        }
-        try {
-            doesNotExist.checkAccess(AccessMode.READ);
-            throw new RuntimeException("NoSuchFileException expected");
-        } catch (NoSuchFileException x) {
-        }
-        try {
-            doesNotExist.checkAccess(AccessMode.WRITE);
-            throw new RuntimeException("NoSuchFileException expected");
-        } catch (NoSuchFileException x) {
-        }
-        try {
-            doesNotExist.checkAccess(AccessMode.EXECUTE);
-            throw new RuntimeException("NoSuchFileException expected");
-        } catch (NoSuchFileException x) {
-        }
-
-        /**
-         * Test: Edit ACL to deny WRITE and EXECUTE
-         */
-        AclFileAttributeView view = file
-            .getFileAttributeView(AclFileAttributeView.class);
-        if (view != null &&
-            file.getFileStore().supportsFileAttributeView("acl"))
-        {
-            UserPrincipal owner = view.getOwner();
-            List<AclEntry> acl = view.getAcl();
-
-            // Insert entry to deny WRITE and EXECUTE
-            AclEntry entry = AclEntry.newBuilder()
-                .setType(AclEntryType.DENY)
-                .setPrincipal(owner)
-                .setPermissions(AclEntryPermission.WRITE_DATA,
-                    AclEntryPermission.EXECUTE)
-                .build();
-            acl.add(0, entry);
-            view.setAcl(acl);
-
-            try {
-                file.checkAccess(AccessMode.WRITE);
-                throw new RuntimeException("AccessDeniedException expected");
-            } catch (AccessDeniedException x) {
-            }
-
-            try {
-                file.checkAccess(AccessMode.EXECUTE);
-                throw new RuntimeException("AccessDeniedException expected");
-            } catch (AccessDeniedException x) {
-            }
-
-
-            // Restore ACL
-            acl.remove(0);
-            view.setAcl(acl);
-        }
-
-        /**
-         * Test: Windows DOS read-only attribute
-         */
-        if (isWindows) {
-            DosFileAttributeView dview =
-                file.getFileAttributeView(DosFileAttributeView.class);
-            dview.setReadOnly(true);
-            try {
-                file.checkAccess(AccessMode.WRITE);
-                throw new RuntimeException("AccessDeniedException expected");
-            } catch (AccessDeniedException x) {
-            }
-            dview.setReadOnly(false);
-
-            // Read-only attribute does not make direcory read-only
-            dview = dir.getFileAttributeView(DosFileAttributeView.class);
-            boolean save = dview.readAttributes().isReadOnly();
-            dview.setReadOnly(true);
-            dir.checkAccess(AccessMode.WRITE);
-            dview.setReadOnly(save);
-        }
-
-        /**
-         * Test: null
-         */
-        try {
-            file.checkAccess((AccessMode)null);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException ignore) { }
-
-        // clean-up
-        file.delete();
-    }
-
-    /**
-     * Exercise toRealPath method
-     */
-    static void toRealPathTests(Path dir) throws IOException {
-        final Path file = dir.resolve("foo").createFile();
-        final Path link = dir.resolve("link");
-
-        /**
-         * Test: toRealPath(true) will access same file as toRealPath(false)
-         */
-        assertTrue(file.toRealPath(true).isSameFile(file.toRealPath(false)));
-
-        /**
-         * Test: toRealPath(true) should resolve links
-         */
-        if (supportsLinks) {
-            link.createSymbolicLink(file.toAbsolutePath());
-            assertTrue(link.toRealPath(true).equals(file.toRealPath(true)));
-            link.delete();
-        }
-
-
-        /**
-         * Test: toRealPath(false) should not resolve links
-         */
-        if (supportsLinks) {
-            link.createSymbolicLink(file.toAbsolutePath());
-            assertTrue(link.toRealPath(false).getName().equals(link.getName()));
-            link.delete();
-        }
-
-        /**
-         * Test: toRealPath should eliminate "."
-         */
-        assertTrue(dir.resolve(".").toRealPath(true).equals(dir.toRealPath(true)));
-        assertTrue(dir.resolve(".").toRealPath(false).equals(dir.toRealPath(false)));
-
-        /**
-         * Test: toRealPath should eliminate ".." when it doesn't follow a
-         *       symbolic link
-         */
-        Path subdir = dir.resolve("subdir").createDirectory();
-        assertTrue(subdir.resolve("..").toRealPath(true).equals(dir.toRealPath(true)));
-        assertTrue(subdir.resolve("..").toRealPath(false).equals(dir.toRealPath(false)));
-        subdir.delete();
-
-        // clean-up
-        file.delete();
-    }
-
-    /**
-     * Exercise isSameFile method
-     */
-    static void isSameFileTests(Path dir) throws IOException {
-        Path thisFile = dir.resolve("thisFile");
-        Path thatFile = dir.resolve("thatFile");
-
-        /**
-         * Test: isSameFile for self and null
-         */
-        assertTrue(thisFile.isSameFile(thisFile));
-        assertTrue(!thisFile.isSameFile(null));
-
-        /**
-         * Test: Neither files exist
-         */
-        try {
-            thisFile.isSameFile(thatFile);
-            throw new RuntimeException("IOException not thrown");
-        } catch (IOException x) {
-        }
-        try {
-            thatFile.isSameFile(thisFile);
-            throw new RuntimeException("IOException not thrown");
-        } catch (IOException x) {
-        }
-
-        thisFile.createFile();
-        try {
-            /**
-             * Test: One file exists
-             */
-            try {
-                thisFile.isSameFile(thatFile);
-                throw new RuntimeException("IOException not thrown");
-            } catch (IOException x) {
-            }
-            try {
-                thatFile.isSameFile(thisFile);
-                throw new RuntimeException("IOException not thrown");
-            } catch (IOException x) {
-            }
-
-            thatFile.createFile();
-
-            /**
-             * Test: Both file exists
-             */
-            try {
-                assertTrue(!thisFile.isSameFile(thatFile));
-                assertTrue(!thatFile.isSameFile(thisFile));
-            } finally {
-                thatFile.delete(false);
-            }
-
-            /**
-             * Test: Symbolic links
-             */
-            if (supportsLinks) {
-                thatFile.createSymbolicLink(thisFile);
-                try {
-                    assertTrue(thisFile.isSameFile(thatFile));
-                    assertTrue(thatFile.isSameFile(thisFile));
-                } finally {
-                    thatFile.delete(false);
-                }
-            }
-        } finally {
-            thisFile.delete(false);
-        }
-    }
-
-    /**
-     * Exercise isHidden method
-     */
-    static void isHiddenTests(Path dir) throws IOException {
-        assertTrue(!dir.isHidden());
-
-        Path file = dir.resolve(".foo");
-        if (isWindows) {
-            file.createFile();
-            try {
-                Attributes.setAttribute(file, "dos:hidden", true);
-                assertTrue(file.isHidden());
-            } finally {
-                file.delete();
-            }
-        } else {
-            assertTrue(file.isHidden());
-        }
-    }
-
-    static void assertTrue(boolean okay) {
-        if (!okay)
-            throw new RuntimeException("Assertion Failed");
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/PathOps.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,646 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.Path path operations
- */
-
-import java.nio.file.*;
-
-public class PathOps {
-
-    static final java.io.PrintStream out = System.out;
-
-    private String input;
-    private Path path;
-    private Exception exc;
-
-    private PathOps(String s) {
-        out.println();
-        input = s;
-        try {
-            path = FileSystems.getDefault().getPath(s);
-            out.format("%s -> %s", s, path);
-        } catch (Exception x) {
-            exc = x;
-            out.format("%s -> %s", s, x);
-        }
-        out.println();
-    }
-
-    Path path() {
-        return path;
-    }
-
-    void fail() {
-        throw new RuntimeException("PathOps failed");
-    }
-
-    void checkPath() {
-        if (path == null) {
-            throw new InternalError("path is null");
-        }
-    }
-
-    void check(Object result, String expected) {
-        out.format("\tExpected: %s\n", expected);
-        out.format("\tActual: %s\n",  result);
-        if (result == null) {
-            if (expected == null) return;
-        } else {
-            // compare string representations
-            if (expected != null && result.toString().equals(expected.toString()))
-                return;
-        }
-        fail();
-    }
-
-    void check(Object result, boolean expected) {
-        check(result, Boolean.toString(expected));
-    }
-
-    PathOps root(String expected) {
-        out.println("check root");
-        checkPath();
-        check(path.getRoot(), expected);
-        return this;
-    }
-
-    PathOps parent(String expected) {
-        out.println("check parent");
-        checkPath();
-        check(path.getParent(), expected);
-        return this;
-    }
-
-    PathOps name(String expected) {
-        out.println("check name");
-        checkPath();
-        check(path.getName(), expected);
-        return this;
-    }
-
-    PathOps element(int index, String expected) {
-        out.format("check element %d\n", index);
-        checkPath();
-        check(path.getName(index), expected);
-        return this;
-    }
-
-    PathOps subpath(int startIndex, int endIndex, String expected) {
-        out.format("test subpath(%d,%d)\n", startIndex, endIndex);
-        checkPath();
-        check(path.subpath(startIndex, endIndex), expected);
-        return this;
-    }
-
-    PathOps starts(String prefix) {
-        out.format("test startsWith with %s\n", prefix);
-        checkPath();
-        Path s = FileSystems.getDefault().getPath(prefix);
-        check(path.startsWith(s), true);
-        return this;
-    }
-
-    PathOps notStarts(String prefix) {
-        out.format("test not startsWith with %s\n", prefix);
-        checkPath();
-        Path s = FileSystems.getDefault().getPath(prefix);
-        check(path.startsWith(s), false);
-        return this;
-    }
-
-    PathOps ends(String suffix) {
-        out.format("test endsWith %s\n", suffix);
-        checkPath();
-        Path s = FileSystems.getDefault().getPath(suffix);
-        check(path.endsWith(s), true);
-        return this;
-    }
-
-    PathOps notEnds(String suffix) {
-        out.format("test not endsWith %s\n", suffix);
-        checkPath();
-        Path s = FileSystems.getDefault().getPath(suffix);
-        check(path.endsWith(s), false);
-        return this;
-    }
-
-    PathOps absolute() {
-        out.println("check path is absolute");
-        checkPath();
-        check(path.isAbsolute(), true);
-        return this;
-    }
-
-    PathOps notAbsolute() {
-        out.println("check path is not absolute");
-        checkPath();
-        check(path.isAbsolute(), false);
-        return this;
-    }
-
-    PathOps resolve(String other, String expected) {
-        out.format("test resolve %s\n", other);
-        checkPath();
-        check(path.resolve(other), expected);
-        return this;
-    }
-
-    PathOps relativize(String other, String expected) {
-        out.format("test relativize %s\n", other);
-        checkPath();
-        Path that = FileSystems.getDefault().getPath(other);
-        check(path.relativize(that), expected);
-        return this;
-    }
-
-    PathOps normalize(String expected) {
-        out.println("check normalized path");
-        checkPath();
-        check(path.normalize(), expected);
-        return this;
-    }
-
-    PathOps string(String expected) {
-        out.println("check string representation");
-        checkPath();
-        check(path, expected);
-        return this;
-    }
-
-    PathOps invalid() {
-        if (!(exc instanceof InvalidPathException)) {
-            out.println("InvalidPathException not thrown as expected");
-            fail();
-        }
-        return this;
-    }
-
-    static PathOps test(String s) {
-        return new PathOps(s);
-    }
-
-    // -- PathOpss --
-
-    static void header(String s) {
-        out.println();
-        out.println();
-        out.println("-- " + s + " --");
-    }
-
-    static void doWindowsTests() {
-        header("Windows specific tests");
-
-        // all components present
-        test("C:\\a\\b\\c")
-            .root("C:\\")
-            .parent("C:\\a\\b")
-            .name("c");
-        test("C:a\\b\\c")
-            .root("C:")
-            .parent("C:a\\b")
-            .name("c");
-        test("\\\\server\\share\\a")
-            .root("\\\\server\\share\\")
-            .parent("\\\\server\\share\\")
-            .name("a");
-
-        // root component only
-        test("C:\\")
-            .root("C:\\")
-            .parent(null)
-            .name(null);
-        test("C:")
-            .root("C:")
-            .parent(null)
-            .name(null);
-        test("\\\\server\\share\\")
-            .root("\\\\server\\share\\")
-            .parent(null)
-            .name(null);
-
-        // no root component
-        test("a\\b")
-            .root(null)
-            .parent("a")
-            .name("b");
-
-        // name component only
-        test("foo")
-            .root(null)
-            .parent(null)
-            .name("foo");
-
-        // startsWith and endsWith
-        test("C:\\foo\\bar")
-            .starts("C:\\")
-            .starts("C:\\foo")
-            .starts("C:\\foo\\bar")
-            .notStarts("C:\\f")
-            .notStarts("C:foo")
-            .notStarts("D:")
-            .notStarts("\\foo\\bar")
-            .ends("bar")
-            .ends("foo\\bar")
-            .ends("C:\\foo\\bar")
-            .notEnds("r")
-            .notEnds("C:foo\\bar")
-            .notEnds("o\\bar");
-
-        // elements
-        test("C:\\a\\b\\c")
-            .element(0, "a")
-            .element(1, "b")
-            .element(2, "c");
-        test("foo.bar\\gus.alice")
-            .element(0, "foo.bar")
-            .element(1, "gus.alice");
-
-        // subpath
-        test("C:\\foo")
-            .subpath(0, 1, "foo");
-        test("C:foo")
-            .subpath(0, 1, "foo");
-        test("foo")
-            .subpath(0, 1, "foo");
-        test("C:\\foo\\bar\\gus")
-            .subpath(0, 1, "foo")
-            .subpath(0, 2, "foo\\bar")
-            .subpath(0, 3, "foo\\bar\\gus")
-            .subpath(1, 2, "bar")
-            .subpath(1, 3, "bar\\gus")
-            .subpath(2, 3, "gus");
-        test("\\\\server\\share\\foo")
-            .subpath(0, 1, "foo");
-
-        // isAbsolute
-        test("foo").notAbsolute();
-        test("C:").notAbsolute();
-        test("C:\\").absolute();
-        test("C:\\abc").absolute();
-        test("\\\\server\\share\\").absolute();
-
-        // resolve
-        test("C:\\")
-            .resolve("foo", "C:\\foo")
-            .resolve("D:\\bar", "D:\\bar")
-            .resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar")
-            .resolve("C:foo", "C:\\foo")
-            .resolve("D:foo", "D:foo");
-        test("\\")
-            .resolve("foo", "\\foo")
-            .resolve("D:bar", "D:bar")
-            .resolve("C:\\bar", "C:\\bar")
-            .resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar")
-            .resolve("\\foo", "\\foo");
-        test("\\foo")
-            .resolve("bar", "\\foo\\bar")
-            .resolve("D:bar", "D:bar")
-            .resolve("C:\\bar", "C:\\bar")
-            .resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar")
-            .resolve("\\bar", "\\bar");
-        test("foo")
-            .resolve("bar", "foo\\bar")
-            .resolve("D:\\bar", "D:\\bar")
-            .resolve("\\\\server\\share\\bar", "\\\\server\\share\\bar")
-            .resolve("C:bar", "C:bar")
-            .resolve("D:foo", "D:foo");
-        test("C:")
-            .resolve("foo", "C:foo");
-        test("\\\\server\\share\\foo")
-            .resolve("bar", "\\\\server\\share\\foo\\bar")
-            .resolve("\\bar", "\\\\server\\share\\bar")
-            .resolve("D:\\bar", "D:\\bar")
-            .resolve("\\\\other\\share\\bar", "\\\\other\\share\\bar")
-            .resolve("D:bar", "D:bar");
-
-        // relativize
-        test("foo\\bar")
-            .relativize("foo\\bar", null)
-            .relativize("foo", "..");
-        test("C:\\a\\b\\c")
-            .relativize("C:\\a", "..\\..");
-        test("\\\\server\\share\\foo")
-            .relativize("\\\\server\\share\\bar", "..\\bar");
-
-        // normalize
-        test("C:\\")
-            .normalize("C:\\");
-        test("C:\\.")
-            .normalize("C:\\");
-        test("C:\\..")
-            .normalize("C:\\");
-        test("\\\\server\\share")
-            .normalize("\\\\server\\share\\");
-        test("\\\\server\\share\\.")
-            .normalize("\\\\server\\share\\");
-        test("\\\\server\\share\\..")
-            .normalize("\\\\server\\share\\");
-        test("C:")
-            .normalize("C:");
-        test("C:.")
-            .normalize("C:");
-        test("C:..")
-            .normalize("C:..");
-        test("\\")
-            .normalize("\\");
-        test("\\.")
-            .normalize("\\");
-        test("\\..")
-            .normalize("\\");
-        test("foo")
-            .normalize("foo");
-        test("foo\\.")
-            .normalize("foo");
-        test("foo\\..")
-            .normalize(null);
-        test("C:\\foo")
-            .normalize("C:\\foo");
-        test("C:\\foo\\.")
-            .normalize("C:\\foo");
-        test("C:\\.\\foo")
-            .normalize("C:\\foo");
-        test("C:\\foo\\..")
-            .normalize("C:\\");
-        test("C:\\..\\foo")
-            .normalize("C:\\foo");
-        test("\\\\server\\share\\foo")
-            .normalize("\\\\server\\share\\foo");
-        test("\\\\server\\share\\foo\\.")
-            .normalize("\\\\server\\share\\foo");
-        test("\\\\server\\share\\.\\foo")
-            .normalize("\\\\server\\share\\foo");
-        test("\\\\server\\share\\foo\\..")
-            .normalize("\\\\server\\share\\");
-        test("\\\\server\\share\\..\\foo")
-            .normalize("\\\\server\\share\\foo");
-        test("C:foo")
-            .normalize("C:foo");
-        test("C:foo\\.")
-            .normalize("C:foo");
-        test("C:.\\foo")
-            .normalize("C:foo");
-        test("C:foo\\..")
-            .normalize("C:");
-        test("C:..\\foo")
-            .normalize("C:..\\foo");
-        test("\\foo")
-            .normalize("\\foo");
-        test("\\foo\\.")
-            .normalize("\\foo");
-        test("\\.\\foo")
-            .normalize("\\foo");
-        test("\\foo\\..")
-            .normalize("\\");
-        test("\\..\\foo")
-            .normalize("\\foo");
-        test(".")
-            .normalize(null);
-        test("..")
-            .normalize("..");
-        test("\\..\\..")
-            .normalize("\\");
-        test("..\\..\\foo")
-            .normalize("..\\..\\foo");
-        test("foo\\bar\\..")
-            .normalize("foo");
-        test("foo\\bar\\.\\..")
-            .normalize("foo");
-        test("foo\\bar\\gus\\..\\..")
-            .normalize("foo");
-        test(".\\foo\\.\\bar\\.\\gus\\..\\.\\..")
-            .normalize("foo");
-
-        // UNC corner cases
-        test("\\\\server\\share\\")
-            .root("\\\\server\\share\\")
-            .parent(null)
-            .name(null);
-        test("\\\\server")
-            .invalid();
-        test("\\\\server\\")
-            .invalid();
-        test("\\\\server\\share")
-            .root("\\\\server\\share\\")
-            .parent(null)
-            .name(null);
-
-        // invalid
-        test(":\\foo")
-            .invalid();
-        test("C::")
-            .invalid();
-        test("C:\\?")           // invalid character
-            .invalid();
-        test("C:\\*")           // invalid character
-            .invalid();
-        test("C:\\abc\u0001\\foo")
-            .invalid();
-        test("C:\\\u0019\\foo")
-            .invalid();
-        test("\\\\server\u0019\\share")
-            .invalid();
-        test("\\\\server\\share\u0019")
-            .invalid();
-        test("foo\u0000\bar")
-            .invalid();
-        test("C:\\foo ")                // trailing space
-             .invalid();
-        test("C:\\foo \\bar")
-            .invalid();
-        //test("C:\\foo.")              // trailing dot
-            //.invalid();
-        //test("C:\\foo...\\bar")
-            //.invalid();
-
-        // normalization at construction time (remove redundant and replace slashes)
-        test("C:/a/b/c")
-            .string("C:\\a\\b\\c")
-            .root("C:\\")
-            .parent("C:\\a\\b");
-        test("C://a//b//c")
-            .string("C:\\a\\b\\c")
-            .root("C:\\")
-            .parent("C:\\a\\b");
-
-        // hashCode
-        header("hashCode");
-        int h1 = test("C:\\foo").path().hashCode();
-        int h2 = test("c:\\FOO").path().hashCode();
-        if (h1 != h2)
-            throw new RuntimeException("PathOps failed");
-    }
-
-    static void doUnixTests() {
-        header("Unix specific tests");
-
-        // all components
-        test("/a/b/c")
-            .root("/")
-            .parent("/a/b")
-            .name("c");
-
-        // root component only
-        test("/")
-            .root("/")
-            .parent(null)
-            .name(null);
-
-        // no root component
-        test("a/b")
-            .root(null)
-            .parent("a")
-            .name("b");
-
-        // name component only
-        test("foo")
-            .root(null)
-            .parent(null)
-            .name("foo");
-
-        // elements
-        test("a/b/c")
-            .element(0,"a")
-            .element(1,"b")
-            .element(2,"c");
-
-        // isAbsolute
-        test("/")
-            .absolute();
-        test("/tmp")
-            .absolute();
-        test("tmp")
-            .notAbsolute();
-
-        // resolve
-        test("/tmp")
-            .resolve("foo", "/tmp/foo")
-            .resolve("/foo", "/foo");
-        test("tmp")
-            .resolve("foo", "tmp/foo")
-            .resolve("/foo", "/foo");
-
-        // relativize
-        test("/a/b/c")
-            .relativize("/a/b/c", null)
-            .relativize("/a/b/c/d/e", "d/e")
-            .relativize("/a/x", "../../x");
-
-        // normalize
-        test("/")
-            .normalize("/");
-        test("foo")
-            .normalize("foo");
-        test("/foo")
-            .normalize("/foo");
-        test(".")
-            .normalize(null);
-        test("..")
-            .normalize("..");
-        test("/..")
-            .normalize("/");
-        test("/../..")
-            .normalize("/");
-        test("foo/.")
-            .normalize("foo");
-        test("./foo")
-            .normalize("foo");
-        test("foo/..")
-            .normalize(null);
-        test("../foo")
-            .normalize("../foo");
-        test("../../foo")
-            .normalize("../../foo");
-        test("foo/bar/..")
-            .normalize("foo");
-        test("foo/bar/gus/../..")
-            .normalize("foo");
-        test("/foo/bar/gus/../..")
-            .normalize("/foo");
-
-        // invalid
-        test("foo\u0000\bar")
-            .invalid();
-
-        // normalization
-        test("//foo//bar")
-            .string("/foo/bar")
-            .root("/")
-            .parent("/foo")
-            .name("bar");
-    }
-
-    static void npes() {
-        header("NullPointerException");
-
-        Path path = FileSystems.getDefault().getPath("foo");
-
-        try {
-            path.resolve((String)null);
-            throw new RuntimeException("NullPointerException not thrown");
-        } catch (NullPointerException npe) {
-        }
-
-        try {
-            path.relativize(null);
-            throw new RuntimeException("NullPointerException not thrown");
-        } catch (NullPointerException npe) {
-        }
-
-        try {
-            path.compareTo(null);
-            throw new RuntimeException("NullPointerException not thrown");
-        } catch (NullPointerException npe) {
-        }
-
-        try {
-            path.startsWith(null);
-            throw new RuntimeException("NullPointerException not thrown");
-        } catch (NullPointerException npe) {
-        }
-
-        try {
-            path.endsWith(null);
-            throw new RuntimeException("NullPointerException not thrown");
-        } catch (NullPointerException npe) {
-        }
-
-    }
-
-    public static void main(String[] args) {
-        // all platforms
-        npes();
-
-        // operating system specific
-        String osname = System.getProperty("os.name");
-        if (osname.startsWith("Windows")) {
-            doWindowsTests();
-        }
-        if (osname.equals("SunOS") || osname.equals("Linux")) {
-            doUnixTests();
-        }
-
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/SBC.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,468 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.Path.newByteChannel
- * @library ..
- */
-
-import java.nio.ByteBuffer;
-import java.nio.file.*;
-import static java.nio.file.StandardOpenOption.*;
-import static com.sun.nio.file.ExtendedOpenOption.*;
-import java.nio.file.attribute.FileAttribute;
-import java.nio.channels.*;
-import java.io.IOException;
-import java.util.*;
-
-public class SBC {
-
-    static boolean supportsLinks;
-
-    public static void main(String[] args) throws Exception {
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            supportsLinks = TestUtil.supportsLinks(dir);
-
-            // open options
-            createTests(dir);
-            appendTests(dir);
-            truncateExistingTests(dir);
-            noFollowLinksTests(dir);
-
-            // SeekableByteChannel methods
-            sizeTruncatePositionTests(dir);
-
-            // platform specific
-            if (System.getProperty("os.name").startsWith("Windows"))
-                dosSharingOptionTests(dir);
-
-            // misc. tests
-            badCombinations(dir);
-            unsupportedOptions(dir);
-            nullTests(dir);
-
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-
-    // test CREATE and CREATE_NEW options
-    static void createTests(Path dir) throws Exception {
-        Path file = dir.resolve("foo");
-
-        // CREATE
-        try {
-            // create file (no existing file)
-            file.newByteChannel(CREATE, WRITE).close();
-            if (file.notExists())
-                throw new RuntimeException("File not created");
-
-            // create file (existing file)
-            file.newByteChannel(CREATE, WRITE).close();
-
-            // create file where existing file is a sym link
-            if (supportsLinks) {
-                Path link = dir.resolve("link").createSymbolicLink(file);
-                try {
-                    // file already exists
-                    link.newByteChannel(CREATE, WRITE).close();
-
-                    // file does not exist
-                    file.delete();
-                    link.newByteChannel(CREATE, WRITE).close();
-                    if (file.notExists())
-                        throw new RuntimeException("File not created");
-
-                } finally {
-                    link.delete();
-                }
-            }
-
-        } finally {
-            file.delete(false);
-        }
-
-        // CREATE_NEW
-        try {
-            // create file
-            file.newByteChannel(CREATE_NEW, WRITE).close();
-            if (file.notExists())
-                throw new RuntimeException("File not created");
-
-            // create should fail
-            try {
-                SeekableByteChannel sbc =
-                    file.newByteChannel(CREATE_NEW, WRITE);
-                sbc.close();
-                throw new RuntimeException("FileAlreadyExistsException not thrown");
-            } catch (FileAlreadyExistsException x) { }
-
-            // create should fail
-            if (supportsLinks) {
-                Path link = dir.resolve("link");
-                Path target = dir.resolve("thisDoesNotExist");
-                link.createSymbolicLink(target);
-                try {
-
-                    try {
-                        SeekableByteChannel sbc =
-                            file.newByteChannel(CREATE_NEW, WRITE);
-                        sbc.close();
-                        throw new RuntimeException("FileAlreadyExistsException not thrown");
-                    } catch (FileAlreadyExistsException x) { }
-
-                } finally {
-                    link.delete();
-                }
-            }
-
-
-        } finally {
-            file.delete(false);
-        }
-
-        // CREATE_NEW + SPARSE
-        try {
-            SeekableByteChannel sbc = file
-                .newByteChannel(CREATE_NEW, WRITE, SPARSE);
-            try {
-                final long hole = 2L * 1024L * 1024L * 1024L;
-                sbc.position(hole);
-                write(sbc, "hello");
-                long size = sbc.size();
-                if (size != (hole + 5))
-                    throw new RuntimeException("Unexpected size");
-            } finally {
-                sbc.close();
-            }
-        } finally {
-            file.delete(false);
-        }
-    }
-
-    // test APPEND option
-    static void appendTests(Path dir) throws Exception {
-        Path file = dir.resolve("foo");
-        try {
-            // "hello there" should be written to file
-            SeekableByteChannel sbc = file
-                .newByteChannel(CREATE_NEW, WRITE, APPEND);
-            try {
-                write(sbc, "hello ");
-                sbc.position(0L);
-                write(sbc, "there");
-            } finally {
-                sbc.close();
-            }
-
-            // check file
-            Scanner s = new Scanner(file);
-            try {
-                String line = s.nextLine();
-                if (!line.equals("hello there"))
-                    throw new RuntimeException("Unexpected file contents");
-            } finally {
-                s.close();
-            }
-
-            // check that read is not allowed
-            sbc = file.newByteChannel(APPEND);
-            try {
-                sbc.read(ByteBuffer.allocate(100));
-            } catch (NonReadableChannelException x) {
-            } finally {
-                sbc.close();
-            }
-        } finally {
-            // clean-up
-            file.delete(false);
-        }
-    }
-
-    // test TRUNCATE_EXISTING option
-    static void truncateExistingTests(Path dir) throws Exception {
-        Path file = dir.resolve("foo");
-        try {
-            SeekableByteChannel sbc =
-                file.newByteChannel(CREATE_NEW, WRITE);
-            try {
-                write(sbc, "Have a nice day!");
-            } finally {
-                sbc.close();
-            }
-
-            // re-open with truncate option
-            // write short message and check
-            sbc = file.newByteChannel(WRITE, TRUNCATE_EXISTING);
-            try {
-                write(sbc, "Hello there!");
-            } finally {
-                sbc.close();
-            }
-            Scanner s = new Scanner(file);
-            try {
-                String line = s.nextLine();
-                if (!line.equals("Hello there!"))
-                    throw new RuntimeException("Unexpected file contents");
-            } finally {
-                s.close();
-            }
-
-            // re-open with create + truncate option
-            // check file is of size 0L
-            sbc = file.newByteChannel(WRITE, CREATE, TRUNCATE_EXISTING);
-            try {
-                long size = ((FileChannel)sbc).size();
-                if (size != 0L)
-                    throw new RuntimeException("File not truncated");
-            } finally {
-                sbc.close();
-            }
-
-        } finally {
-            // clean-up
-            file.delete(false);
-        }
-
-    }
-
-    // test NOFOLLOW_LINKS option
-    static void noFollowLinksTests(Path dir) throws Exception {
-        if (!supportsLinks)
-            return;
-        Path file = dir.resolve("foo").createFile();
-        try {
-            // ln -s foo link
-            Path link = dir.resolve("link").createSymbolicLink(file);
-
-            // open with NOFOLLOW_LINKS option
-            try {
-                link.newByteChannel(READ, LinkOption.NOFOLLOW_LINKS);
-                throw new RuntimeException();
-            } catch (IOException x) {
-            } finally {
-                link.delete();
-            }
-
-        } finally {
-            // clean-up
-            file.delete();
-        }
-    }
-
-    // test size/truncate/position methods
-    static void sizeTruncatePositionTests(Path dir) throws Exception {
-        Path file = dir.resolve("foo");
-        try {
-            SeekableByteChannel sbc = file
-                .newByteChannel(CREATE_NEW, READ, WRITE);
-            try {
-                if (sbc.size() != 0L)
-                    throw new RuntimeException("Unexpected size");
-
-                // check size
-                write(sbc, "hello");
-                if (sbc.size() != 5L)
-                    throw new RuntimeException("Unexpected size");
-
-                // truncate (size and position should change)
-                sbc.truncate(4L);
-                if (sbc.size() != 4L)
-                    throw new RuntimeException("Unexpected size");
-                if (sbc.position() != 4L)
-                    throw new RuntimeException("Unexpected position");
-
-                // truncate (position should not change)
-                sbc.position(2L).truncate(3L);
-                if (sbc.size() != 3L)
-                    throw new RuntimeException("Unexpected size");
-                if (sbc.position() != 2L)
-                    throw new RuntimeException("Unexpected position");
-            } finally {
-                sbc.close();
-            }
-        } finally {
-            file.delete(false);
-        }
-    }
-
-    // Windows specific options for the use by applications that really want
-    // to use legacy DOS sharing options
-    static void dosSharingOptionTests(Path dir) throws Exception {
-        Path file = dir.resolve("foo").createFile();
-        try {
-            SeekableByteChannel ch;
-
-            // no sharing
-            ch = file.newByteChannel(READ,
-                NOSHARE_READ, NOSHARE_WRITE, NOSHARE_DELETE);
-            try {
-                try {
-                    file.newByteChannel(READ);
-                    throw new RuntimeException("Sharing violation expected");
-                } catch (IOException ignore) { }
-                try {
-                    file.newByteChannel(WRITE);
-                    throw new RuntimeException("Sharing violation expected");
-                } catch (IOException ignore) { }
-                try {
-                    file.delete();
-                    throw new RuntimeException("Sharing violation expected");
-                } catch (IOException ignore) { }
-            } finally {
-                ch.close();
-            }
-
-            // read allowed
-            ch = file.newByteChannel(READ, NOSHARE_WRITE, NOSHARE_DELETE);
-            try {
-                file.newByteChannel(READ).close();
-                try {
-                    file.newByteChannel(WRITE);
-                    throw new RuntimeException("Sharing violation expected");
-                } catch (IOException ignore) { }
-                try {
-                    file.delete();
-                    throw new RuntimeException("Sharing violation expected");
-                } catch (IOException ignore) { }
-            } finally {
-                ch.close();
-            }
-
-            // write allowed
-            ch = file.newByteChannel(READ, NOSHARE_READ, NOSHARE_DELETE);
-            try {
-                try {
-                    file.newByteChannel(READ);
-                    throw new RuntimeException("Sharing violation expected");
-                } catch (IOException ignore) { }
-                file.newByteChannel(WRITE).close();
-                try {
-                    file.delete();
-                    throw new RuntimeException("Sharing violation expected");
-                } catch (IOException ignore) { }
-            } finally {
-                ch.close();
-            }
-
-            // delete allowed
-            ch = file.newByteChannel(READ, NOSHARE_READ, NOSHARE_WRITE);
-            try {
-                try {
-                    file.newByteChannel(READ);
-                    throw new RuntimeException("Sharing violation expected");
-                } catch (IOException ignore) { }
-                try {
-                    file.newByteChannel(WRITE);
-                    throw new RuntimeException("Sharing violation expected");
-                } catch (IOException ignore) { }
-                file.delete();
-            } finally {
-                ch.close();
-            }
-
-        } finally {
-            file.delete(false);
-        }
-    }
-
-    // invalid combinations of options
-    static void badCombinations(Path dir) throws Exception {
-        Path file = dir.resolve("bad");
-
-        try {
-            file.newByteChannel(READ, APPEND);
-            throw new RuntimeException("IllegalArgumentException expected");
-        } catch (IllegalArgumentException x) { }
-
-        try {
-            file.newByteChannel(WRITE, APPEND, TRUNCATE_EXISTING);
-            throw new RuntimeException("IllegalArgumentException expected");
-        } catch (IllegalArgumentException x) { }
-    }
-
-    // unsupported operations
-    static void unsupportedOptions(Path dir) throws Exception {
-        Path file = dir.resolve("bad");
-
-        OpenOption badOption = new OpenOption() { };
-        try {
-            file.newByteChannel(badOption);
-            throw new RuntimeException("UnsupportedOperationException expected");
-        } catch (UnsupportedOperationException e) { }
-        try {
-            file.newByteChannel(READ, WRITE, badOption);
-            throw new RuntimeException("UnsupportedOperationException expected");
-        } catch (UnsupportedOperationException e) { }
-    }
-
-    // null handling
-    static void nullTests(Path dir) throws Exception {
-        Path file = dir.resolve("foo");
-
-        try {
-            file.newByteChannel((OpenOption[])null);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException x) { }
-
-        try {
-            OpenOption[] opts = { READ, null };
-            file.newByteChannel(opts);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException x) { }
-
-        try {
-            file.newByteChannel((Set<OpenOption>)null);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException x) { }
-
-        try {
-            Set<OpenOption> opts = new HashSet<OpenOption>();
-            opts.add(READ);
-            opts.add(null);
-            file.newByteChannel(opts);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException x) { }
-
-        try {
-            EnumSet<StandardOpenOption> opts = EnumSet.of(READ);
-            file.newByteChannel(opts, (FileAttribute[])null);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException x) { }
-
-        try {
-            EnumSet<StandardOpenOption> opts = EnumSet.of(READ);
-            FileAttribute[] attrs = { null };
-            file.newByteChannel(opts, attrs);
-            throw new RuntimeException("NullPointerException expected");
-        } catch (NullPointerException x) { }
-    }
-
-    static void write(WritableByteChannel wbc, String msg) throws IOException {
-        ByteBuffer buf = ByteBuffer.wrap(msg.getBytes());
-        while (buf.hasRemaining())
-            wbc.write(buf);
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/TemporaryFiles.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +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.
- *
- * 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.
- */
-
-import java.nio.file.*;
-import static java.nio.file.StandardOpenOption.*;
-import java.nio.file.attribute.*;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Set;
-
-public class TemporaryFiles {
-
-    static void checkFile(Path file) throws IOException {
-        // check file is in temporary directory
-        Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir"));
-        if (!file.getParent().equals(tmpdir))
-            throw new RuntimeException("Not in temporary directory");
-
-        // check that file can be opened for reading and writing
-        file.newByteChannel(READ).close();
-        file.newByteChannel(WRITE).close();
-        file.newByteChannel(READ,WRITE).close();
-
-        // check file permissions are 0600 or more secure
-        if (file.getFileStore().supportsFileAttributeView("posix")) {
-            Set<PosixFilePermission> perms = Attributes
-                .readPosixFileAttributes(file).permissions();
-            perms.remove(PosixFilePermission.OWNER_READ);
-            perms.remove(PosixFilePermission.OWNER_WRITE);
-            if (!perms.isEmpty())
-                throw new RuntimeException("Temporary file is not secure");
-        }
-    }
-
-    public static void main(String[] args) throws IOException {
-        Path file = File.createTempFile("blah", null, false).toPath();
-        try {
-            checkFile(file);
-        } finally {
-            file.delete();
-        }
-
-        // temporary file with deleteOnExit
-        file = File.createTempFile("blah", "tmp", true).toPath();
-        checkFile(file);
-        // write path to temporary file to file so that calling script can
-        // check that it is deleted
-        OutputStream out = Paths.get(args[0]).newOutputStream();
-        try {
-            out.write(file.toString().getBytes());
-        } finally {
-            out.close();
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/UriImportExport.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.Path
- */
-
-import java.nio.file.*;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.io.PrintStream;
-
-public class UriImportExport {
-
-    static final PrintStream log = System.out;
-    static int failures = 0;
-
-    static void test(String fn, String expected) {
-        log.println();
-        Path p = Paths.get(fn);
-        log.println(p);
-        URI u = p.toUri();
-        log.println("  --> " + u);
-        if (expected != null && !(u.toString().equals(expected))) {
-            log.println("FAIL: Expected " + expected);
-            failures++;
-            return;
-        }
-        Path q = Paths.get(u);
-        log.println("  --> " + q);
-        if (!p.toAbsolutePath().equals(q)) {
-            log.println("FAIL: Expected " + p + ", got " + q);
-            failures++;
-            return;
-        }
-    }
-
-    static void test(String fn) {
-        test(fn, null);
-    }
-
-    public static void main(String[] args) throws Exception {
-        test("foo");
-        test("/foo");
-        test("/foo bar");
-
-        String osname = System.getProperty("os.name");
-        if (osname.startsWith("Windows")) {
-            test("C:\\foo");
-            test("C:foo");
-            test("\\\\rialto.dublin.com\\share\\");
-            test("\\\\fe80--203-baff-fe5a-749ds1.ipv6-literal.net\\share\\missing",
-                "file://[fe80::203:baff:fe5a:749d%1]/share/missing");
-        }
-
-        if (failures > 0)
-            throw new RuntimeException(failures + " test(s) failed");
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/delete_on_close.sh	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +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.
-#
-# 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.
-#
-
-# @test
-# @bug 4313887
-# @summary Unit test for DELETE_ON_CLOSE open option
-# @library ..
-# @build DeleteOnClose
-# @run shell delete_on_close.sh
-
-# if TESTJAVA isn't set then we assume an interactive run.
-
-if [ -z "$TESTJAVA" ]; then
-    TESTSRC=.
-    TESTCLASSES=.
-    JAVA=java
-else
-    JAVA="${TESTJAVA}/bin/java"
-fi
-
-OS=`uname -s`
-case "$OS" in
-    Windows_* )
-        CLASSPATH="${TESTCLASSES};${TESTSRC}"
-        ;;
-    * )
-        CLASSPATH=${TESTCLASSES}:${TESTSRC}
-        ;;
-esac
-export CLASSPATH
-
-TMPFILE="$$.tmp"
-touch $TMPFILE
-$JAVA DeleteOnClose $TMPFILE 2>&1
-if [ $? != 0 ]; then exit 1; fi
-if [ -f $TMPFILE ]; then
-    echo "$TMPFILE was not deleted"
-    exit 1
-fi
-
-exit 0
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/temporary_files.sh	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +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.
-#
-# 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.
-#
-
-# @test
-# @bug 4313887
-# @summary Unit test for File.createTempFile (to be be moved to test/java/io/File)
-# @library ..
-# @build TemporaryFiles
-# @run shell temporary_files.sh
-
-# if TESTJAVA isn't set then we assume an interactive run.
-
-if [ -z "$TESTJAVA" ]; then
-    TESTSRC=.
-    TESTCLASSES=.
-    JAVA=java
-else
-    JAVA="${TESTJAVA}/bin/java"
-fi
-
-OS=`uname -s`
-case "$OS" in
-    Windows_* )
-        CLASSPATH="${TESTCLASSES};${TESTSRC}"
-        ;;
-    * )
-        CLASSPATH=${TESTCLASSES}:${TESTSRC}
-        ;;
-esac
-export CLASSPATH
-
-TMPFILENAME="$$.tmp"
-$JAVA TemporaryFiles $TMPFILENAME 2>&1
-if [ $? != 0 ]; then exit 1; fi
-if [ ! -f $TMPFILENAME ]; then
-    echo "$TMPFILENAME not found"
-    exit 1
-fi
-TMPFILE=`cat $TMPFILENAME`
-if [ -f $TMPFILE ]; then
-    echo "$TMPFILE not deleted"
-    exit 1
-fi
-
-exit 0
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/PathMatcher/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.PathMatcher
- */
-
-import java.nio.file.*;
-import java.util.regex.PatternSyntaxException;
-
-public class Basic {
-    static int failures;
-
-    static void match(String name, String pattern, boolean expectedToMatch) {
-        System.out.format("%s -> %s", name, pattern);
-        Path file = Paths.get(name);
-        boolean matched =  file.getFileSystem()
-            .getNameMatcher("glob", pattern).matches(file);
-        if (matched)
-            System.out.print(" (matched)");
-        else
-            System.out.print(" (no match)");
-        if (matched != expectedToMatch) {
-            System.out.println(" ==> UNEXPECTED RESULT!");
-            failures++;
-        } else {
-            System.out.println(" OKAY");
-        }
-    }
-
-    static void assertMatch(String path, String pattern) {
-        match(path, pattern, true);
-    }
-
-    static void assertNotMatch(String path, String pattern) {
-        match(path, pattern, false);
-    }
-
-    static void assertBadPattern(String path, String pattern) {
-        System.out.format("Compile bad pattern %s\t", pattern);
-        try {
-            FileSystems.getDefault().getNameMatcher("glob", pattern);
-            System.out.println("Compiled ==> UNEXPECTED RESULT!");
-            failures++;
-        } catch (PatternSyntaxException e) {
-            System.out.println("Failed to compile ==> OKAY");
-        }
-    }
-
-    public static void main(String[] args) {
-        // basic
-        assertMatch("foo.html", "foo.html");
-        assertNotMatch("foo.html", "foo.htm");
-        assertNotMatch("foo.html", "bar.html");
-
-        // match zero or more characters
-        assertMatch("foo.html", "f*");
-        assertMatch("foo.html", "*.html");
-        assertMatch("foo.html", "foo.html*");
-        assertMatch("foo.html", "*foo.html");
-        assertMatch("foo.html", "*foo.html*");
-        assertNotMatch("foo.html", "*.htm");
-        assertNotMatch("foo.html", "f.*");
-
-        // match one character
-        assertMatch("foo.html", "?oo.html");
-        assertMatch("foo.html", "??o.html");
-        assertMatch("foo.html", "???.html");
-        assertMatch("foo.html", "???.htm?");
-        assertNotMatch("foo.html", "foo.???");
-
-        // group of subpatterns
-        assertMatch("foo.html", "foo{.html,.class}");
-        assertMatch("foo.html", "foo.{class,html}");
-        assertNotMatch("foo.html", "foo{.htm,.class}");
-
-        // bracket expressions
-        assertMatch("foo.html", "[f]oo.html");
-        assertMatch("foo.html", "[e-g]oo.html");
-        assertMatch("foo.html", "[abcde-g]oo.html");
-        assertMatch("foo.html", "[abcdefx-z]oo.html");
-        assertMatch("foo.html", "[!a]oo.html");
-        assertMatch("foo.html", "[!a-e]oo.html");
-        assertMatch("foo-bar", "foo[-a-z]bar");     // match dash
-        assertMatch("foo.html", "foo[!-]html");     // match !dash
-
-        // groups of subpattern with bracket expressions
-        assertMatch("foo.html", "[f]oo.{[h]tml,class}");
-        assertMatch("foo.html", "foo.{[a-z]tml,class}");
-        assertMatch("foo.html", "foo.{[!a-e]tml,.class}");
-
-        // assume special characters are allowed in file names
-        assertMatch("{foo}.html", "\\{foo*");
-        assertMatch("{foo}.html", "*\\}.html");
-        assertMatch("[foo].html", "\\[foo*");
-        assertMatch("[foo].html", "*\\].html");
-
-        // some special characters not allowed on Windows
-        if (!System.getProperty("os.name").startsWith("Windows")) {
-            assertMatch("myfile?", "myfile\\?");
-            assertMatch("one\\two", "one\\\\two");
-            assertMatch("one*two", "one\\*two");
-        }
-
-        // errors
-        assertBadPattern("foo.html", "*[a--z]");            // bad range
-        assertBadPattern("foo.html", "*[a--]");             // bad range
-        assertBadPattern("foo.html", "*[a-z");              // missing ]
-        assertBadPattern("foo.html", "*{class,java");       // missing }
-        assertBadPattern("foo.html", "*.{class,{.java}}");  // nested group
-        assertBadPattern("foo.html", "*.html\\");           // nothing to escape
-
-        // regex syntax
-        {
-            String pattern = ".*\\.html";
-            System.out.format("Test regex pattern: %s", pattern);
-            Path file = Paths.get("foo.html");
-            boolean matched =  file.getFileSystem()
-                .getNameMatcher("regex", pattern).matches(file);
-            if (matched) {
-                System.out.println(" OKAY");
-            } else {
-                System.out.println(" ==> UNEXPECTED RESULT!");
-                failures++;
-            }
-        }
-
-        // unknown syntax
-        try {
-            System.out.format("Test unknown syntax");
-            FileSystems.getDefault().getNameMatcher("grep", "foo");
-            System.out.println(" ==> NOT EXPECTED TO COMPILE");
-            failures++;
-        } catch (UnsupportedOperationException e) {
-            System.out.println(" OKAY");
-        }
-
-        if (failures > 0)
-            throw new RuntimeException(failures +
-                " sub-test(s) failed - see log for details");
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/TestUtil.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +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.
- *
- * 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.
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.Random;
-import java.io.IOException;
-
-public class TestUtil {
-    private TestUtil() {
-    }
-
-    public static Path createTemporaryDirectory() throws IOException {
-        Path tmpdir = Paths.get(System.getProperty("java.io.tmpdir"));
-        Random r = new Random();
-
-        Path dir;
-        do {
-            dir = tmpdir.resolve("name" + r.nextInt());
-        } while (dir.exists());
-        return dir.createDirectory();
-    }
-
-    static void removeAll(Path dir) {
-        Files.walkFileTree(dir, new FileVisitor<Path>() {
-
-            public FileVisitResult preVisitDirectory(Path dir) {
-                return FileVisitResult.CONTINUE;
-            }
-
-            public FileVisitResult preVisitDirectoryFailed(Path dir, IOException exc) {
-                System.err.format("Error occured accessing directory %s\n", dir, exc);
-                return FileVisitResult.CONTINUE;
-            }
-
-            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
-                try {
-                    file.delete(false);
-                } catch (IOException x) {
-                    System.err.format("Unable to delete %s: %s\n", file, x);
-                }
-                return FileVisitResult.CONTINUE;
-            }
-
-            public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
-                try {
-                    dir.delete(false);
-                } catch (IOException x) {
-                    System.err.format("Unable to delete %s: %s\n", dir, x);
-                }
-                return FileVisitResult.CONTINUE;
-            }
-
-            public FileVisitResult visitFileFailed(Path file, IOException exc) {
-                System.err.format("Unable to visit %s: %s\n", file, exc);
-                return FileVisitResult.CONTINUE;
-            }
-        });
-    }
-
-    /**
-     * Creates a directory tree in the given directory so that the total
-     * size of the path is more than 2k in size. This is used for long
-     * path tests on Windows.
-     */
-    static Path createDirectoryWithLongPath(Path dir)
-        throws IOException
-    {
-        StringBuilder sb = new StringBuilder();
-        for (int i=0; i<240; i++) {
-            sb.append('A');
-        }
-        String name = sb.toString();
-        do {
-            dir = dir.resolve(name).resolve(".");
-            dir.createDirectory();
-        } while (dir.toString().length() < 2048);
-        return dir;
-    }
-
-    /**
-     * Returns true if symbolic links are supported
-     */
-    static boolean supportsLinks(Path dir) {
-        Path link = dir.resolve("testlink");
-        Path target = dir.resolve("testtarget");
-        try {
-            link.createSymbolicLink(target);
-            target.delete(false);
-            return true;
-        } catch (UnsupportedOperationException x) {
-            return false;
-        } catch (IOException x) {
-            return false;
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,493 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.WatchService
- * @library ..
- * @run main/timeout=120 Basic
- */
-
-import java.nio.file.*;
-import static java.nio.file.StandardWatchEventKind.*;
-import java.nio.file.attribute.*;
-import java.io.*;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Unit test for WatchService that exercises all methods in various scenarios.
- */
-
-public class Basic {
-
-    static void createFile(Path file) throws IOException {
-        file.newOutputStream().close();
-    }
-
-    static void takeExpectedKey(WatchService watcher, WatchKey expected) {
-        System.out.println("take events...");
-        WatchKey key;
-        try {
-            key = watcher.take();
-        } catch (InterruptedException x) {
-            // not expected
-            throw new RuntimeException(x);
-        }
-        if (key != expected)
-            throw new RuntimeException("removed unexpected key");
-    }
-
-    static void checkExpectedEvent(Iterable<WatchEvent<?>> events,
-                                   WatchEvent.Kind<?> expectedKind,
-                                   Object expectedContext)
-    {
-        WatchEvent<?> event = events.iterator().next();
-        System.out.format("got event: type=%s, count=%d, context=%s\n",
-            event.kind(), event.count(), event.context());
-        if (event.kind() != expectedKind)
-            throw new RuntimeException("unexpected event");
-        if (!expectedContext.equals(event.context()))
-            throw new RuntimeException("unexpected context");
-    }
-
-    /**
-     * Simple test of each of the standard events
-     */
-    static void testEvents(Path dir) throws IOException {
-        System.out.println("-- Standard Events --");
-
-        FileSystem fs = FileSystems.getDefault();
-        Path name = fs.getPath("foo");
-
-        WatchService watcher = fs.newWatchService();
-        try {
-            // --- ENTRY_CREATE ---
-
-            // register for event
-            System.out.format("register %s for ENTRY_CREATE\n", dir);
-            WatchKey myKey = dir.register(watcher,
-                new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
-
-            // create file
-            Path file = dir.resolve("foo");
-            System.out.format("create %s\n", file);
-            createFile(file);
-
-            // remove key and check that we got the ENTRY_CREATE event
-            takeExpectedKey(watcher, myKey);
-            checkExpectedEvent(myKey.pollEvents(),
-                StandardWatchEventKind.ENTRY_CREATE, name);
-
-            System.out.println("reset key");
-            if (!myKey.reset())
-                throw new RuntimeException("key has been cancalled");
-
-            System.out.println("OKAY");
-
-            // --- ENTRY_DELETE ---
-
-            System.out.format("register %s for ENTRY_DELETE\n", dir);
-            WatchKey deleteKey = dir.register(watcher,
-                new WatchEvent.Kind<?>[]{ ENTRY_DELETE });
-            if (deleteKey != myKey)
-                throw new RuntimeException("register did not return existing key");
-
-            System.out.format("delete %s\n", file);
-            file.delete(false);
-            takeExpectedKey(watcher, myKey);
-            checkExpectedEvent(myKey.pollEvents(),
-                StandardWatchEventKind.ENTRY_DELETE, name);
-
-            System.out.println("reset key");
-            if (!myKey.reset())
-                throw new RuntimeException("key has been cancalled");
-
-            System.out.println("OKAY");
-
-            // create the file for the next test
-            createFile(file);
-
-            // --- ENTRY_MODIFY ---
-
-            System.out.format("register %s for ENTRY_MODIFY\n", dir);
-            WatchKey newKey = dir.register(watcher,
-                new WatchEvent.Kind<?>[]{ ENTRY_MODIFY });
-            if (newKey != myKey)
-                throw new RuntimeException("register did not return existing key");
-
-            System.out.format("update: %s\n", file);
-            OutputStream out = file.newOutputStream(EnumSet.of(StandardOpenOption.APPEND));
-            try {
-                out.write("I am a small file".getBytes("UTF-8"));
-            } finally {
-                out.close();
-            }
-
-            // remove key and check that we got the ENTRY_MODIFY event
-            takeExpectedKey(watcher, myKey);
-            checkExpectedEvent(myKey.pollEvents(),
-                StandardWatchEventKind.ENTRY_MODIFY, name);
-            System.out.println("OKAY");
-
-            // done
-            file.delete(false);
-
-        } finally {
-            watcher.close();
-        }
-    }
-
-    /**
-     * Check that a cancelled key will never be queued
-     */
-    static void testCancel(Path dir) throws IOException {
-        System.out.println("-- Cancel --");
-
-        WatchService watcher = FileSystems.getDefault().newWatchService();
-        try {
-
-            System.out.format("register %s for events\n", dir);
-            WatchKey myKey = dir.register(watcher,
-                new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
-
-            System.out.println("cancel key");
-            myKey.cancel();
-
-            // create a file in the directory
-            Path file = dir.resolve("mars");
-            System.out.format("create: %s\n", file);
-            createFile(file);
-
-            // poll for keys - there will be none
-            System.out.println("poll...");
-            try {
-                WatchKey key = watcher.poll(3000, TimeUnit.MILLISECONDS);
-                if (key != null)
-                    throw new RuntimeException("key should not be queued");
-            } catch (InterruptedException x) {
-                throw new RuntimeException(x);
-            }
-
-            // done
-            file.delete(false);
-
-            System.out.println("OKAY");
-
-        } finally {
-            watcher.close();
-        }
-    }
-
-    /**
-     * Check that deleting a registered directory causes the key to be
-     * cancelled and queued.
-     */
-    static void testAutomaticCancel(Path dir) throws IOException {
-        System.out.println("-- Automatic Cancel --");
-
-        Path subdir = dir.resolve("bar").createDirectory();
-
-        WatchService watcher = FileSystems.getDefault().newWatchService();
-        try {
-
-            System.out.format("register %s for events\n", subdir);
-            WatchKey myKey = subdir.register(watcher,
-                new WatchEvent.Kind<?>[]{ ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY });
-
-            System.out.format("delete: %s\n", subdir);
-            subdir.delete(false);
-            takeExpectedKey(watcher, myKey);
-
-            System.out.println("reset key");
-            if (myKey.reset())
-                throw new RuntimeException("Key was not cancelled");
-            if (myKey.isValid())
-                throw new RuntimeException("Key is still valid");
-
-            System.out.println("OKAY");
-
-        } finally {
-            watcher.close();
-        }
-    }
-
-    /**
-     * Asynchronous close of watcher causes blocked threads to wakeup
-     */
-    static void testWakeup(Path dir) throws IOException {
-        System.out.println("-- Wakeup Tests --");
-        final WatchService watcher = FileSystems.getDefault().newWatchService();
-        Runnable r = new Runnable() {
-            public void run() {
-                try {
-                    Thread.sleep(5000);
-                    System.out.println("close WatchService...");
-                    watcher.close();
-                } catch (InterruptedException x) {
-                    x.printStackTrace();
-                } catch (IOException x) {
-                    x.printStackTrace();
-                }
-            }
-        };
-
-        // start thread to close watch service after delay
-        new Thread(r).start();
-
-        try {
-            System.out.println("take...");
-            watcher.take();
-            throw new RuntimeException("ClosedWatchServiceException not thrown");
-        } catch (InterruptedException x) {
-            throw new RuntimeException(x);
-        } catch (ClosedWatchServiceException  x) {
-            System.out.println("ClosedWatchServiceException thrown");
-        }
-
-        System.out.println("OKAY");
-    }
-
-    /**
-     * Simple test to check exceptions and other cases
-     */
-    @SuppressWarnings("unchecked")
-    static void testExceptions(Path dir) throws IOException {
-        System.out.println("-- Exceptions and other simple tests --");
-
-        WatchService watcher = FileSystems.getDefault().newWatchService();
-        try {
-
-            // Poll tests
-
-            WatchKey key;
-            System.out.println("poll...");
-            key = watcher.poll();
-            if (key != null)
-                throw new RuntimeException("no keys registered");
-
-            System.out.println("poll with timeout...");
-            try {
-                long start = System.currentTimeMillis();
-                key = watcher.poll(3000, TimeUnit.MILLISECONDS);
-                if (key != null)
-                    throw new RuntimeException("no keys registered");
-                long waited = System.currentTimeMillis() - start;
-                if (waited < 2900)
-                    throw new RuntimeException("poll was too short");
-            } catch (InterruptedException x) {
-                throw new RuntimeException(x);
-            }
-
-            // IllegalArgumentException
-            System.out.println("IllegalArgumentException tests...");
-            try {
-                dir.register(watcher, new WatchEvent.Kind<?>[]{ } );
-                throw new RuntimeException("IllegalArgumentException not thrown");
-            } catch (IllegalArgumentException x) {
-            }
-            try {
-                // OVERFLOW is ignored so this is equivalent to the empty set
-                dir.register(watcher, new WatchEvent.Kind<?>[]{ OVERFLOW });
-                throw new RuntimeException("IllegalArgumentException not thrown");
-            } catch (IllegalArgumentException x) {
-            }
-
-            // UnsupportedOperationException
-            try {
-                dir.register(watcher, new WatchEvent.Kind<?>[]{
-                             new WatchEvent.Kind<Object>() {
- public String name() { return "custom"; }
- public Class<Object> type() { return Object.class; }
-                             }});
-            } catch (UnsupportedOperationException x) {
-            }
-            try {
-                dir.register(watcher,
-                             new WatchEvent.Kind<?>[]{ ENTRY_CREATE },
-                             new WatchEvent.Modifier() {
- public String name() { return "custom"; }
-                             });
-                throw new RuntimeException("UnsupportedOperationException not thrown");
-            } catch (UnsupportedOperationException x) {
-            }
-
-            // NullPointerException
-            System.out.println("NullPointerException tests...");
-            try {
-                dir.register(null, new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
-                throw new RuntimeException("NullPointerException not thrown");
-            } catch (NullPointerException x) {
-            }
-            try {
-                dir.register(watcher, new WatchEvent.Kind<?>[]{ null });
-                throw new RuntimeException("NullPointerException not thrown");
-            } catch (NullPointerException x) {
-            }
-            try {
-                dir.register(watcher, new WatchEvent.Kind<?>[]{ ENTRY_CREATE },
-                    (WatchEvent.Modifier)null);
-                throw new RuntimeException("NullPointerException not thrown");
-            } catch (NullPointerException x) {
-            }
-        } finally {
-            watcher.close();
-        }
-
-        // -- ClosedWatchServiceException --
-
-        System.out.println("ClosedWatchServiceException tests...");
-
-        try {
-            watcher.poll();
-            throw new RuntimeException("ClosedWatchServiceException not thrown");
-        } catch (ClosedWatchServiceException  x) {
-        }
-
-        // assume that poll throws exception immediately
-        long start = System.currentTimeMillis();
-        try {
-            watcher.poll(10000, TimeUnit.MILLISECONDS);
-            throw new RuntimeException("ClosedWatchServiceException not thrown");
-        } catch (InterruptedException x) {
-            throw new RuntimeException(x);
-        } catch (ClosedWatchServiceException  x) {
-            long waited = System.currentTimeMillis() - start;
-            if (waited > 5000)
-                throw new RuntimeException("poll was too long");
-        }
-
-        try {
-            watcher.take();
-            throw new RuntimeException("ClosedWatchServiceException not thrown");
-        } catch (InterruptedException x) {
-            throw new RuntimeException(x);
-        } catch (ClosedWatchServiceException  x) {
-        }
-
-        try {
-            dir.register(watcher, new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
-             throw new RuntimeException("ClosedWatchServiceException not thrown");
-        } catch (ClosedWatchServiceException  x) {
-        }
-
-        System.out.println("OKAY");
-    }
-
-    /**
-     * Test that directory can be registered with more than one watch service
-     * and that events don't interfere with each other
-     */
-    static void testTwoWatchers(Path dir) throws IOException {
-        System.out.println("-- Two watchers test --");
-
-        FileSystem fs = FileSystems.getDefault();
-        WatchService watcher1 = fs.newWatchService();
-        WatchService watcher2 = fs.newWatchService();
-        try {
-            Path name1 = fs.getPath("gus1");
-            Path name2 = fs.getPath("gus2");
-
-            // create gus1
-            Path file1 = dir.resolve(name1);
-            System.out.format("create %s\n", file1);
-            createFile(file1);
-
-            // register with both watch services (different events)
-            System.out.println("register for different events");
-            WatchKey key1 = dir.register(watcher1,
-                new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
-            WatchKey key2 = dir.register(watcher2,
-                new WatchEvent.Kind<?>[]{ ENTRY_DELETE });
-
-            if (key1 == key2)
-                throw new RuntimeException("keys should be different");
-
-            // create gus2
-            Path file2 = dir.resolve(name2);
-            System.out.format("create %s\n", file2);
-            createFile(file2);
-
-            // check that key1 got ENTRY_CREATE
-            takeExpectedKey(watcher1, key1);
-            checkExpectedEvent(key1.pollEvents(),
-                StandardWatchEventKind.ENTRY_CREATE, name2);
-
-            // check that key2 got zero events
-            WatchKey key = watcher2.poll();
-            if (key != null)
-                throw new RuntimeException("key not expected");
-
-            // delete gus1
-            file1.delete(false);
-
-            // check that key2 got ENTRY_DELETE
-            takeExpectedKey(watcher2, key2);
-            checkExpectedEvent(key2.pollEvents(),
-                StandardWatchEventKind.ENTRY_DELETE, name1);
-
-            // check that key1 got zero events
-            key = watcher1.poll();
-            if (key != null)
-                throw new RuntimeException("key not expected");
-
-            // reset for next test
-            key1.reset();
-            key2.reset();
-
-            // change registration with watcher2 so that they are both
-            // registered for the same event
-            System.out.println("register for same event");
-            key2 = dir.register(watcher2, new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
-
-            // create file and key2 should be queued
-            System.out.format("create %s\n", file1);
-            createFile(file1);
-            takeExpectedKey(watcher2, key2);
-            checkExpectedEvent(key2.pollEvents(),
-                StandardWatchEventKind.ENTRY_CREATE, name1);
-
-            System.out.println("OKAY");
-
-        } finally {
-            watcher2.close();
-            watcher1.close();
-        }
-    }
-
-    public static void main(String[] args) throws IOException {
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-
-            testEvents(dir);
-            testCancel(dir);
-            testAutomaticCancel(dir);
-            testWakeup(dir);
-            testExceptions(dir);
-            testTwoWatchers(dir);
-
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/FileTreeModifier.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Sanity test for Sun-specific FILE_TREE watch event modifier
- * @library ..
- */
-
-import java.nio.file.*;
-import static java.nio.file.StandardWatchEventKind.*;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.*;
-import java.util.concurrent.*;
-import static com.sun.nio.file.ExtendedWatchEventModifier.*;
-
-public class FileTreeModifier {
-
-    static void checkExpectedEvent(WatchService watcher,
-                                   WatchEvent.Kind<?> expectedType,
-                                   Object expectedContext)
-    {
-        WatchKey key;
-        try {
-            key = watcher.take();
-        } catch (InterruptedException x) {
-            // should not happen
-            throw new RuntimeException(x);
-        }
-        WatchEvent<?> event = key.pollEvents().iterator().next();
-        System.out.format("Event: type=%s, count=%d, context=%s\n",
-            event.kind(), event.count(), event.context());
-        if (event.kind() != expectedType)
-            throw new RuntimeException("unexpected event");
-        if (!expectedContext.equals(event.context()))
-            throw new RuntimeException("unexpected context");
-    }
-
-    static void doTest(Path top) throws IOException {
-        FileSystem fs = top.getFileSystem();
-        WatchService watcher = fs.newWatchService();
-
-        // create directories
-        Path subdir = top
-           .resolve("a").createDirectory()
-           .resolve("b").createDirectory()
-           .resolve("c").createDirectory();
-
-        // Test ENTRY_CREATE with FILE_TREE modifier.
-
-        WatchKey key = top.register(watcher,
-            new WatchEvent.Kind<?>[]{ ENTRY_CREATE }, FILE_TREE);
-
-        // create file in a/b/c and check we get create event
-        Path file = subdir.resolve("foo").createFile();
-        checkExpectedEvent(watcher, ENTRY_CREATE, top.relativize(file));
-        key.reset();
-
-        // Test ENTRY_DELETE with FILE_TREE modifier.
-
-        WatchKey k = top.register(watcher,
-            new WatchEvent.Kind<?>[]{ ENTRY_DELETE }, FILE_TREE);
-        if (k != key)
-            throw new RuntimeException("Existing key not returned");
-
-        // delete a/b/c/foo and check we get delete event
-        file.delete(false);
-        checkExpectedEvent(watcher, ENTRY_DELETE, top.relativize(file));
-        key.reset();
-
-        // Test changing registration to ENTRY_CREATE without modifier
-
-        k = top.register(watcher, new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
-        if (k != key)
-            throw new RuntimeException("Existing key not returned");
-
-        // create a/b/c/foo
-        file.createFile();
-
-        // check that key is not queued
-        try {
-            k = watcher.poll(3, TimeUnit.SECONDS);
-        } catch (InterruptedException e) {
-            throw new RuntimeException();
-        }
-        if (k != null)
-            throw new RuntimeException("WatchKey not expected to be polled");
-
-        // create bar and check we get create event
-        file = top.resolve("bar").createFile();
-        checkExpectedEvent(watcher, ENTRY_CREATE, top.relativize(file));
-        key.reset();
-
-        // Test changing registration to <all> with FILE_TREE modifier
-
-        k = top.register(watcher,
-            new WatchEvent.Kind<?>[]{ ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY },
-            FILE_TREE);
-        if (k != key)
-            throw new RuntimeException("Existing key not returned");
-
-        // modify bar and check we get modify event
-        OutputStream out = file.newOutputStream();
-        try {
-            out.write("Double shot expresso please".getBytes("UTF-8"));
-        } finally {
-            out.close();
-        }
-        checkExpectedEvent(watcher, ENTRY_MODIFY, top.relativize(file));
-        key.reset();
-    }
-
-
-    public static void main(String[] args) throws IOException {
-        if (!System.getProperty("os.name").startsWith("Windows")) {
-            System.out.println("This is Windows-only test at this time!");
-            return;
-        }
-
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            doTest(dir);
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/WithSecurityManager.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for Watchable#register's permission checks
- * @build WithSecurityManager
- * @run main/othervm WithSecurityManager denyAll.policy - fail
- * @run main/othervm WithSecurityManager denyAll.policy tree fail
- * @run main/othervm WithSecurityManager grantDirOnly.policy - pass
- * @run main/othervm WithSecurityManager grantDirOnly.policy tree fail
- * @run main/othervm WithSecurityManager grantDirAndOneLevel.policy - pass
- * @run main/othervm WithSecurityManager grantDirAndOneLevel.policy tree fail
- * @run main/othervm WithSecurityManager grantDirAndTree.policy - pass
- * @run main/othervm WithSecurityManager grantDirAndTree.policy tree pass
- */
-
-import java.nio.file.*;
-import java.io.IOException;
-import com.sun.nio.file.ExtendedWatchEventModifier;
-
-public class WithSecurityManager {
-
-    public static void main(String[] args) throws IOException {
-        String policyFile = args[0];
-        boolean recursive = args[1].equals("tree");
-        boolean expectedToFail = args[2].equals("fail");
-
-        // install security manager with the given policy file
-        String testSrc = System.getProperty("test.src");
-        if (testSrc == null)
-            throw new RuntimeException("This test must be run by jtreg");
-        Path dir = Paths.get(testSrc);
-        System.setProperty("java.security.policy", dir.resolve(policyFile).toString());
-        System.setSecurityManager(new SecurityManager());
-
-        // initialize optional modifier
-        WatchEvent.Modifier[] modifiers;
-        if (recursive) {
-            modifiers = new WatchEvent.Modifier[1];
-            modifiers[0] = ExtendedWatchEventModifier.FILE_TREE;
-        } else {
-            modifiers = new WatchEvent.Modifier[0];
-        }
-
-        // attempt to register directory
-        try {
-            dir.register(dir.getFileSystem().newWatchService(),
-                         new WatchEvent.Kind<?>[]{ StandardWatchEventKind.ENTRY_CREATE },
-                         modifiers);
-            if (expectedToFail)
-                throw new RuntimeException("SecurityException not thrown");
-        } catch (SecurityException e) {
-            if (!expectedToFail)
-                throw e;
-        } catch (UnsupportedOperationException e) {
-            // FILE_TREE modifier only supported on some platforms
-            if (!recursive)
-                throw new RuntimeException(e);
-            System.out.println("FILE_TREE option not supported");
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/denyAll.policy	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-// policy file that does not grant any permissions
-grant {
-};
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/grantDirAndOneLevel.policy	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-// policy file that grants read access to source directory and its entries
-grant {
-    permission java.io.FilePermission "${test.src}", "read";
-    permission java.io.FilePermission "${test.src}${file.separator}*", "read";
-};
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/grantDirAndTree.policy	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-// policy file that grants read access to source directory and all descendants
-grant {
-    permission java.io.FilePermission "${test.src}", "read";
-    permission java.io.FilePermission "${test.src}${file.separator}-", "read";
-};
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/WatchService/grantDirOnly.policy	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-// policy file that grants read access to source directory
-grant {
-    permission java.io.FilePermission "${test.src}", "read";
-};
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/AclFileAttributeView/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.attribute.AclFileAttribueView
- * @library ../..
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
-import java.util.*;
-
-import static java.nio.file.attribute.AclEntryType.*;
-import static java.nio.file.attribute.AclEntryPermission.*;
-import static java.nio.file.attribute.AclEntryFlag.*;
-
-public class Basic {
-
-    static void printAcl(List<AclEntry> acl) {
-        for (AclEntry entry: acl) {
-            System.out.format("  %s%n", entry);
-        }
-    }
-
-    // sanity check read and writing ACL
-    static void testReadWrite(Path dir) throws IOException {
-        Path file = dir.resolve("foo");
-        if (file.notExists())
-            file.createFile();
-
-        AclFileAttributeView view = file
-            .getFileAttributeView(AclFileAttributeView.class);
-
-        // print existing ACL
-        List<AclEntry> acl = view.getAcl();
-        System.out.println(" -- current ACL --");
-        printAcl(acl);
-
-        // insert entry to grant owner read access
-        UserPrincipal owner = view.getOwner();
-        AclEntry entry = AclEntry.newBuilder()
-            .setType(ALLOW)
-            .setPrincipal(owner)
-            .setPermissions(READ_DATA, READ_ATTRIBUTES)
-            .build();
-        System.out.println(" -- insert (entry 0) --");
-        System.out.format("  %s%n", entry);
-        acl.add(0, entry);
-        view.setAcl(acl);
-
-        // re-ACL and check entry
-        List<AclEntry> newacl = view.getAcl();
-        System.out.println(" -- current ACL --");
-        printAcl(acl);
-        if (!newacl.get(0).equals(entry)) {
-            throw new RuntimeException("Entry 0 is not expected");
-        }
-
-        // if PosixFileAttributeView then repeat test with OWNER@
-        if (file.getFileStore().supportsFileAttributeView("posix")) {
-            owner = file.getFileSystem().getUserPrincipalLookupService()
-                .lookupPrincipalByName("OWNER@");
-            entry = AclEntry.newBuilder(entry).setPrincipal(owner).build();
-
-            System.out.println(" -- replace (entry 0) --");
-            System.out.format("  %s%n", entry);
-
-            acl.set(0, entry);
-            view.setAcl(acl);
-            newacl = view.getAcl();
-            System.out.println(" -- current ACL --");
-            printAcl(acl);
-            if (!newacl.get(0).equals(entry)) {
-                throw new RuntimeException("Entry 0 is not expected");
-            }
-        }
-    }
-
-    static FileAttribute<List<AclEntry>> asAclAttribute(final List<AclEntry> acl) {
-        return new FileAttribute<List<AclEntry>>() {
-            public String name() { return "acl:acl"; }
-            public List<AclEntry> value() { return acl; }
-        };
-    }
-
-    static void assertEquals(List<AclEntry> actual, List<AclEntry> expected) {
-        if (!actual.equals(expected)) {
-            System.err.format("Actual: %s\n", actual);
-            System.err.format("Expected: %s\n", expected);
-            throw new RuntimeException("ACL not expected");
-        }
-    }
-
-    // sanity check create a file or directory with initial ACL
-    static void testCreateFile(Path dir) throws IOException {
-        UserPrincipal user = Attributes.getOwner(dir);
-
-        // create file with initial ACL
-        System.out.println("-- create file with initial ACL --");
-        Path file = dir.resolve("gus");
-        List<AclEntry> fileAcl = Arrays.asList(
-            AclEntry.newBuilder()
-                .setType(AclEntryType.ALLOW)
-                .setPrincipal(user)
-                .setPermissions(SYNCHRONIZE, READ_DATA, WRITE_DATA,
-                    READ_ATTRIBUTES, READ_ACL, WRITE_ATTRIBUTES, DELETE)
-                .build());
-        file.createFile(asAclAttribute(fileAcl));
-        assertEquals(Attributes.getAcl(file), fileAcl);
-
-        // create directory with initial ACL
-        System.out.println("-- create directory with initial ACL --");
-        Path subdir = dir.resolve("stuff");
-        List<AclEntry> dirAcl = Arrays.asList(
-            AclEntry.newBuilder()
-                .setType(AclEntryType.ALLOW)
-                .setPrincipal(user)
-                .setPermissions(SYNCHRONIZE, ADD_FILE, DELETE)
-                .build(),
-            AclEntry.newBuilder(fileAcl.get(0))
-                .setFlags(FILE_INHERIT)
-                .build());
-        subdir.createDirectory(asAclAttribute(dirAcl));
-        assertEquals(Attributes.getAcl(subdir), dirAcl);
-    }
-
-    public static void main(String[] args) throws IOException {
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            if (!dir.getFileStore().supportsFileAttributeView("acl")) {
-                System.out.println("ACLs not supported - test skipped!");
-                return;
-            }
-            testReadWrite(dir);
-
-            // only currently feasible on Windows
-            if (System.getProperty("os.name").startsWith("Windows"))
-                testCreateFile(dir);
-
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/Attributes/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,254 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.attribute.Attributes
- * @library ../..
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Exercises getAttribute/setAttribute/readAttributes methods.
- */
-
-public class Basic {
-
-    static void assertTrue(boolean okay) {
-        if (!okay)
-            throw new RuntimeException("Assertion Failed");
-    }
-
-    static void checkEqual(Object o1, Object o2) {
-        if (o1 == null) {
-            assertTrue(o2 == null);
-        } else {
-            assertTrue (o1.equals(o2));
-        }
-    }
-
-    // Exercise getAttribute/setAttribute/readAttributes on basic attributes
-    static void checkBasicAttributes(FileRef file, BasicFileAttributes attrs)
-        throws IOException
-    {
-        // getAttribute
-        checkEqual(attrs.size(), Attributes.getAttribute(file, "size"));
-        checkEqual(attrs.lastModifiedTime(),
-                   Attributes.getAttribute(file, "basic:lastModifiedTime"));
-        checkEqual(attrs.lastAccessTime(),
-                   Attributes.getAttribute(file, "lastAccessTime"));
-        checkEqual(attrs.creationTime(),
-                   Attributes.getAttribute(file, "basic:creationTime"));
-        assertTrue((Boolean)Attributes.getAttribute(file, "isRegularFile"));
-        assertTrue(!(Boolean)Attributes.getAttribute(file, "basic:isDirectory"));
-        assertTrue(!(Boolean)Attributes.getAttribute(file, "isSymbolicLink"));
-        assertTrue(!(Boolean)Attributes.getAttribute(file, "basic:isOther"));
-        checkEqual(attrs.linkCount(),
-                   (Integer)Attributes.getAttribute(file, "linkCount"));
-        checkEqual(attrs.fileKey(), Attributes.getAttribute(file, "basic:fileKey"));
-
-        // setAttribute
-        if (attrs.resolution() == TimeUnit.MILLISECONDS) {
-            long modTime = attrs.lastModifiedTime();
-            Attributes.setAttribute(file, "basic:lastModifiedTime", 0L);
-            assertTrue(Attributes.readBasicFileAttributes(file).lastModifiedTime() == 0L);
-            Attributes.setAttribute(file, "lastModifiedTime", modTime);
-            assertTrue(Attributes.readBasicFileAttributes(file).lastModifiedTime() == modTime);
-        }
-
-        // readAttributes
-        Map<String,?> map;
-        map = Attributes.readAttributes(file, "*");
-        assertTrue(map.size() >= 11);
-        checkEqual(attrs.isRegularFile(), map.get("isRegularFile")); // check one
-
-        map = Attributes.readAttributes(file, "basic:*");
-        assertTrue(map.size() >= 11);
-        checkEqual(attrs.lastAccessTime(), map.get("lastAccessTime")); // check one
-
-        map = Attributes.readAttributes(file, "size,lastModifiedTime");
-        assertTrue(map.size() == 2);
-        checkEqual(attrs.size(), map.get("size"));
-        checkEqual(attrs.lastModifiedTime(), map.get("lastModifiedTime"));
-
-        map = Attributes.readAttributes(file,
-            "basic:lastModifiedTime,lastAccessTime,linkCount,ShouldNotExist");
-        assertTrue(map.size() == 3);
-        checkEqual(attrs.lastModifiedTime(), map.get("lastModifiedTime"));
-        checkEqual(attrs.lastAccessTime(), map.get("lastAccessTime"));
-        checkEqual(attrs.lastAccessTime(), map.get("lastAccessTime"));
-    }
-
-    // Exercise getAttribute/setAttribute/readAttributes on posix attributes
-    static void checkPosixAttributes(FileRef file, PosixFileAttributes attrs)
-        throws IOException
-    {
-        checkBasicAttributes(file, attrs);
-
-        // getAttribute
-        checkEqual(attrs.permissions(),
-                   Attributes.getAttribute(file, "posix:permissions"));
-        checkEqual(attrs.owner(),
-                   Attributes.getAttribute(file, "posix:owner"));
-        checkEqual(attrs.group(),
-                   Attributes.getAttribute(file, "posix:group"));
-
-        // setAttribute
-        Set<PosixFilePermission> orig = attrs.permissions();
-        Set<PosixFilePermission> newPerms = new HashSet<PosixFilePermission>(orig);
-        newPerms.remove(PosixFilePermission.OTHERS_READ);
-        newPerms.remove(PosixFilePermission.OTHERS_WRITE);
-        newPerms.remove(PosixFilePermission.OTHERS_EXECUTE);
-        Attributes.setAttribute(file, "posix:permissions", newPerms);
-        checkEqual(Attributes.readPosixFileAttributes(file).permissions(), newPerms);
-        Attributes.setAttribute(file, "posix:permissions", orig);
-        checkEqual(Attributes.readPosixFileAttributes(file).permissions(), orig);
-        Attributes.setAttribute(file, "posix:owner", attrs.owner());
-        Attributes.setAttribute(file, "posix:group", attrs.group());
-
-        // readAttributes
-        Map<String,?> map;
-        map = Attributes.readAttributes(file, "posix:*");
-        assertTrue(map.size() >= 14);
-        checkEqual(attrs.permissions(), map.get("permissions")); // check one
-
-        map = Attributes.readAttributes(file, "posix:size,owner,ShouldNotExist");
-        assertTrue(map.size() == 2);
-        checkEqual(attrs.size(), map.get("size"));
-        checkEqual(attrs.owner(), map.get("owner"));
-    }
-
-    // Exercise getAttribute/setAttribute/readAttributes on unix attributes
-    static void checkUnixAttributes(FileRef file) throws IOException {
-        // getAttribute
-        int mode = (Integer)Attributes.getAttribute(file, "unix:mode");
-        long ino = (Long)Attributes.getAttribute(file, "unix:ino");
-        long dev = (Long)Attributes.getAttribute(file, "unix:dev");
-        long rdev = (Long)Attributes.getAttribute(file, "unix:rdev");
-        int uid = (Integer)Attributes.getAttribute(file, "unix:uid");
-        int gid = (Integer)Attributes.getAttribute(file, "unix:gid");
-        long ctime = (Long)Attributes.getAttribute(file, "unix:ctime");
-
-        // readAttributes
-        Map<String,?> map;
-        map = Attributes.readAttributes(file, "unix:*");
-        assertTrue(map.size() >= 21);
-
-        map = Attributes.readAttributes(file, "unix:size,uid,gid,ShouldNotExist");
-        assertTrue(map.size() == 3);
-        checkEqual(map.get("size"),
-                   Attributes.readBasicFileAttributes(file).size());
-    }
-
-    // Exercise getAttribute/setAttribute/readAttributes on dos attributes
-    static void checkDosAttributes(FileRef file, DosFileAttributes attrs)
-        throws IOException
-    {
-        checkBasicAttributes(file, attrs);
-
-        // getAttribute
-        checkEqual(attrs.isReadOnly(),
-                   Attributes.getAttribute(file, "dos:readonly"));
-        checkEqual(attrs.isHidden(),
-                   Attributes.getAttribute(file, "dos:hidden"));
-        checkEqual(attrs.isSystem(),
-                   Attributes.getAttribute(file, "dos:system"));
-        checkEqual(attrs.isArchive(),
-                   Attributes.getAttribute(file, "dos:archive"));
-
-        // setAttribute
-        boolean value;
-
-        value = attrs.isReadOnly();
-        Attributes.setAttribute(file, "dos:readonly", !value);
-        checkEqual(Attributes.readDosFileAttributes(file).isReadOnly(), !value);
-        Attributes.setAttribute(file, "dos:readonly", value);
-        checkEqual(Attributes.readDosFileAttributes(file).isReadOnly(), value);
-
-        value = attrs.isHidden();
-        Attributes.setAttribute(file, "dos:hidden", !value);
-        checkEqual(Attributes.readDosFileAttributes(file).isHidden(), !value);
-        Attributes.setAttribute(file, "dos:hidden", value);
-        checkEqual(Attributes.readDosFileAttributes(file).isHidden(), value);
-
-        value = attrs.isSystem();
-        Attributes.setAttribute(file, "dos:system", !value);
-        checkEqual(Attributes.readDosFileAttributes(file).isSystem(), !value);
-        Attributes.setAttribute(file, "dos:system", value);
-        checkEqual(Attributes.readDosFileAttributes(file).isSystem(), value);
-
-        value = attrs.isArchive();
-        Attributes.setAttribute(file, "dos:archive", !value);
-        checkEqual(Attributes.readDosFileAttributes(file).isArchive(), !value);
-        Attributes.setAttribute(file, "dos:archive", value);
-        checkEqual(Attributes.readDosFileAttributes(file).isArchive(), value);
-
-        // readAttributes
-        Map<String,?> map;
-        map = Attributes.readAttributes(file, "dos:*");
-        assertTrue(map.size() >= 15);
-        checkEqual(attrs.isReadOnly(), map.get("readonly")); // check one
-
-        map = Attributes.readAttributes(file, "dos:size,hidden,ShouldNotExist");
-        assertTrue(map.size() == 2);
-        checkEqual(attrs.size(), map.get("size"));
-        checkEqual(attrs.isHidden(), map.get("hidden"));
-    }
-
-    static void doTests(Path dir) throws IOException {
-        Path file = dir.resolve("foo").createFile();
-        FileStore store = file.getFileStore();
-        try {
-            checkBasicAttributes(file,
-                Attributes.readBasicFileAttributes(file));
-
-            if (store.supportsFileAttributeView("posix"))
-                checkPosixAttributes(file,
-                    Attributes.readPosixFileAttributes(file));
-
-            if (store.supportsFileAttributeView("unix"))
-                checkUnixAttributes(file);
-
-            if (store.supportsFileAttributeView("dos"))
-                checkDosAttributes(file,
-                    Attributes.readDosFileAttributes(file));
-        } finally {
-            file.delete();
-        }
-    }
-
-
-    public static void main(String[] args) throws IOException {
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            doTests(dir);
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/BasicFileAttributeView/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.attribute.BasicFileAttributeView
- * @library ../..
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-import java.io.*;
-
-public class Basic {
-
-    static void check(boolean okay, String msg) {
-        if (!okay)
-            throw new RuntimeException(msg);
-    }
-
-    static void checkAttributesOfDirectory(Path dir)
-        throws IOException
-    {
-        BasicFileAttributes attrs = Attributes.readBasicFileAttributes(dir);
-        check(attrs.isDirectory(), "is a directory");
-        check(!attrs.isRegularFile(), "is not a regular file");
-        check(!attrs.isSymbolicLink(), "is not a link");
-        check(!attrs.isOther(), "is not other");
-        check(attrs.linkCount() >= 1, "should be at least 1");
-
-        // last-modified-time should match java.io.File
-        if (attrs.resolution() == TimeUnit.MILLISECONDS) {
-            File f = new File(dir.toString());
-            check(f.lastModified() == attrs.lastModifiedTime(),
-                "last-modified time should be the same");
-        }
-    }
-
-    static void checkAttributesOfFile(Path dir, Path file)
-        throws IOException
-    {
-        BasicFileAttributes attrs = Attributes.readBasicFileAttributes(file);
-        check(attrs.isRegularFile(), "is a regular file");
-        check(!attrs.isDirectory(), "is not a directory");
-        check(!attrs.isSymbolicLink(), "is not a link");
-        check(!attrs.isOther(), "is not other");
-        check(attrs.linkCount() >= 1, "should be at least 1");
-
-        // size and last-modified-time should match java.io.File
-        File f = new File(file.toString());
-        check(f.length() == attrs.size(), "size should be the same");
-        if (attrs.resolution() == TimeUnit.MILLISECONDS) {
-            check(f.lastModified() == attrs.lastModifiedTime(),
-                "last-modified time should be the same");
-        }
-
-        // copy last-modified time and file create time from directory to file,
-        // re-read attribtues, and check they match
-        BasicFileAttributeView view =
-            file.getFileAttributeView(BasicFileAttributeView.class);
-        BasicFileAttributes dirAttrs = Attributes.readBasicFileAttributes(dir);
-        view.setTimes(dirAttrs.lastModifiedTime(), null, null, dirAttrs.resolution());
-        if (dirAttrs.creationTime() != -1L) {
-            view.setTimes(null, null, dirAttrs.creationTime(), dirAttrs.resolution());
-        }
-        attrs = view.readAttributes();
-        check(attrs.lastModifiedTime() == dirAttrs.lastModifiedTime(),
-            "last-modified time should be equal");
-        if (dirAttrs.creationTime() != -1L) {
-            check(attrs.creationTime() == dirAttrs.creationTime(),
-                "create time should be the same");
-        }
-
-        // security tests
-        check (!(attrs instanceof PosixFileAttributes),
-            "should not be able to cast to PosixFileAttributes");
-    }
-
-    static void checkAttributesOfLink(Path link)
-        throws IOException
-    {
-        BasicFileAttributes attrs = Attributes
-            .readBasicFileAttributes(link, LinkOption.NOFOLLOW_LINKS);
-        check(attrs.isSymbolicLink(), "is a link");
-        check(!attrs.isDirectory(), "is a directory");
-        check(!attrs.isRegularFile(), "is not a regular file");
-        check(!attrs.isOther(), "is not other");
-        check(attrs.linkCount() >= 1, "should be at least 1");
-    }
-
-    static void attributeReadWriteTests(Path dir)
-        throws IOException
-    {
-        // create file
-        Path file = dir.resolve("foo");
-        OutputStream out = file.newOutputStream();
-        try {
-            out.write("this is not an empty file".getBytes("UTF-8"));
-        } finally {
-            out.close();
-        }
-
-        // check attributes of directory and file
-        checkAttributesOfDirectory(dir);
-        checkAttributesOfFile(dir, file);
-
-        // symbolic links may be supported
-        Path link = dir.resolve("link");
-        try {
-            link.createSymbolicLink( file );
-        } catch (UnsupportedOperationException x) {
-            return;
-        } catch (IOException x) {
-            return;
-        }
-        checkAttributesOfLink(link);
-    }
-
-    public static void main(String[] args) throws IOException {
-        // create temporary directory to run tests
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            attributeReadWriteTests(dir);
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/DosFileAttributeView/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.attribute.DosFileAttributeView
- * @library ../..
- */
-
-import java.nio.file.*;
-import static java.nio.file.LinkOption.*;
-import java.nio.file.attribute.*;
-import java.util.*;
-import java.io.IOException;
-
-public class Basic {
-
-    static void check(boolean okay) {
-        if (!okay)
-            throw new RuntimeException("Test failed");
-    }
-
-    // exercise each setter/getter method, leaving all attributes unset
-    static void testAttributes(DosFileAttributeView view) throws IOException {
-        view.setReadOnly(true);
-        check(view.readAttributes().isReadOnly());
-        view.setReadOnly(false);
-        check(!view.readAttributes().isReadOnly());
-        view.setHidden(true);
-        check(view.readAttributes().isHidden());
-        view.setHidden(false);
-        check(!view.readAttributes().isHidden());
-        view.setArchive(true);
-        check(view.readAttributes().isArchive());
-        view.setArchive(false);
-        check(!view.readAttributes().isArchive());
-        view.setSystem(true);
-        check(view.readAttributes().isSystem());
-        view.setSystem(false);
-        check(!view.readAttributes().isSystem());
-    }
-
-    // set the value of all attributes
-    static void setAll(DosFileAttributeView view, boolean value)
-        throws IOException
-    {
-        view.setReadOnly(value);
-        view.setHidden(value);
-        view.setArchive(value);
-        view.setSystem(value);
-    }
-
-    // read and write FAT attributes
-    static void readWriteTests(Path dir) throws IOException {
-
-        // create "foo" and test that we can read/write each FAT attribute
-        Path file = dir.resolve("foo");
-        file.newOutputStream().close();
-        try {
-            testAttributes(file
-                .getFileAttributeView(DosFileAttributeView.class));
-
-            // Following tests use a symbolic link so skip if not supported
-            if (!TestUtil.supportsLinks(dir))
-                return;
-
-            Path link = dir.resolve("link").createSymbolicLink(file);
-
-            // test following links
-            testAttributes(link
-                .getFileAttributeView(DosFileAttributeView.class));
-
-            // test not following links
-            try {
-                try {
-                    testAttributes(link
-                        .getFileAttributeView(DosFileAttributeView.class, NOFOLLOW_LINKS));
-                } catch (IOException x) {
-                    // access to link attributes not supported
-                    return;
-                }
-
-                // set all attributes on link
-                // run test on target of link (which leaves them all un-set)
-                // check that attributes of link remain all set
-                setAll(link
-                    .getFileAttributeView(DosFileAttributeView.class, NOFOLLOW_LINKS), true);
-                testAttributes(link
-                    .getFileAttributeView(DosFileAttributeView.class));
-                DosFileAttributes attrs = Attributes.readDosFileAttributes(link, NOFOLLOW_LINKS);
-                check(attrs.isReadOnly());
-                check(attrs.isHidden());
-                check(attrs.isArchive());
-                check(attrs.isSystem());
-                setAll(link
-                    .getFileAttributeView(DosFileAttributeView.class, NOFOLLOW_LINKS), false);
-
-                // set all attributes on target
-                // run test on link (which leaves them all un-set)
-                // check that attributes of target remain all set
-                setAll(link
-                    .getFileAttributeView(DosFileAttributeView.class), true);
-                testAttributes(link
-                    .getFileAttributeView(DosFileAttributeView.class, NOFOLLOW_LINKS));
-                attrs = Attributes.readDosFileAttributes(link, NOFOLLOW_LINKS);
-                check(attrs.isReadOnly());
-                check(attrs.isHidden());
-                check(attrs.isArchive());
-                check(attrs.isSystem());
-                setAll(link
-                    .getFileAttributeView(DosFileAttributeView.class), false);
-            } finally {
-                link.delete(false);
-            }
-        } finally {
-            file.delete(false);
-        }
-    }
-
-    public static void main(String[] args) throws IOException {
-        // create temporary directory to run tests
-        Path dir = TestUtil.createTemporaryDirectory();
-
-        try {
-            // skip test if DOS file attributes not supported
-            if (!dir.getFileStore().supportsFileAttributeView("dos")) {
-                System.out.println("DOS file attribute not supported.");
-                return;
-            }
-            readWriteTests(dir);
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/FileStoreAttributeView/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,170 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.attribute.FileStoreAttributeView
- * @library ../..
- */
-
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.io.File;
-import java.io.IOException;
-import java.util.*;
-
-/**
- * Simple unit test for FileStoreAttributeView that checks that the disk space
- * attribtues are "close" to the equivalent values reported by java.io.File.
- */
-
-public class Basic {
-
-    static final long K = 1024L;
-    static final long G = 1024L * 1024L * 1024L;
-
-    /**
-     * Print out the disk space information for the given file system
-     */
-    static void printFileStore(FileStore fs) throws IOException {
-        FileStoreSpaceAttributeView view =
-            fs.getFileStoreAttributeView(FileStoreSpaceAttributeView.class);
-        FileStoreSpaceAttributes attrs = view.readAttributes();
-
-        long total = attrs.totalSpace() / K;
-        long used = (attrs.totalSpace() - attrs.unallocatedSpace()) / K;
-        long avail = attrs.usableSpace() / K;
-
-        String s = fs.toString();
-        if (s.length() > 20) {
-            System.out.println(s);
-            s = "";
-        }
-        System.out.format("%-20s %12d %12d %12d\n", s, total, used, avail);
-    }
-
-    /**
-     * Check that two values are within 1GB of each other
-     */
-    static void checkWithin1GB(long value1, long value2) {
-        long diff = Math.abs(value1 - value2);
-        if (diff > G)
-            throw new RuntimeException("values differ by more than 1GB");
-    }
-
-    /**
-     * Check disk space on the file system of the given file
-     */
-    static void checkSpace(Path file) throws IOException {
-        System.out.println(" -- check space -- ");
-        System.out.println(file);
-
-        FileStore fs = file.getFileStore();
-        System.out.format("Filesystem: %s\n", fs);
-
-        // get values reported by java.io.File
-        File f = new File(file.toString());
-        long total = f.getTotalSpace();
-        long free = f.getFreeSpace();
-        long usable = f.getUsableSpace();
-        System.out.println("java.io.File");
-        System.out.format("    Total: %d\n", total);
-        System.out.format("     Free: %d\n", free);
-        System.out.format("   Usable: %d\n", usable);
-
-        // get values reported by the FileStoreSpaceAttributeView
-        FileStoreSpaceAttributes attrs = fs
-            .getFileStoreAttributeView(FileStoreSpaceAttributeView.class)
-            .readAttributes();
-        System.out.println("java.nio.file.FileStoreSpaceAttributeView:");
-        System.out.format("    Total: %d\n", attrs.totalSpace());
-        System.out.format("     Free: %d\n", attrs.unallocatedSpace());
-        System.out.format("   Usable: %d\n", attrs.usableSpace());
-
-        // check values are "close"
-        checkWithin1GB(total, attrs.totalSpace());
-        checkWithin1GB(free, attrs.unallocatedSpace());
-        checkWithin1GB(usable, attrs.usableSpace());
-
-        // get values by name (and in bulk)
-        FileStoreAttributeView view = fs.getFileStoreAttributeView("space");
-        checkWithin1GB(total, (Long)view.getAttribute("totalSpace"));
-        checkWithin1GB(free, (Long)view.getAttribute("unallocatedSpace"));
-        checkWithin1GB(usable, (Long)view.getAttribute("usableSpace"));
-        Map<String,?> map = view.readAttributes("*");
-        checkWithin1GB(total, (Long)map.get("totalSpace"));
-        checkWithin1GB(free, (Long)map.get("unallocatedSpace"));
-        checkWithin1GB(usable, (Long)map.get("usableSpace"));
-        map = view.readAttributes("totalSpace", "unallocatedSpace", "usableSpace");
-        checkWithin1GB(total, (Long)map.get("totalSpace"));
-        checkWithin1GB(free, (Long)map.get("unallocatedSpace"));
-        checkWithin1GB(usable, (Long)map.get("usableSpace"));
-    }
-
-    /**
-     * Check (Windows-specific) volume attributes
-     */
-    static void checkVolumeAttributes() throws IOException {
-        System.out.println(" -- volumes -- ");
-        for (FileStore store: FileSystems.getDefault().getFileStores()) {
-            FileStoreAttributeView view = store.getFileStoreAttributeView("volume");
-            if (view == null)
-                continue;
-            Map<String,?> attrs = view.readAttributes("*");
-            int vsn = (Integer)attrs.get("vsn");
-            boolean compressed = (Boolean)attrs.get("compressed");
-            System.out.format("%s vsn:%x compressed:%b%n", store.name(),
-                vsn, compressed);
-        }
-
-    }
-
-    public static void main(String[] args) throws IOException {
-        // print out the disk space information for all file systems
-        FileSystem fs = FileSystems.getDefault();
-        for (FileStore store: fs.getFileStores()) {
-            printFileStore(store);
-        }
-
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            // check space using directory
-            checkSpace(dir);
-
-            // check space using file
-            Path file = dir.resolve("foo");
-            file.newOutputStream().close();
-            try {
-                checkSpace(file);
-            } finally {
-                file.delete(false);
-            }
-
-            // volume attributes (Windows specific)
-            checkVolumeAttributes();
-
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,273 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.attribute.NamedAttributeView
- * @library ../..
- */
-
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.nio.file.*;
-import static java.nio.file.LinkOption.*;
-import java.nio.file.attribute.*;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Random;
-import java.io.IOException;
-
-public class Basic {
-
-    private static Random rand = new Random();
-
-    private static final String ATTR_NAME = "user.mime_type";
-    private static final String ATTR_VALUE = "text/plain";
-    private static final String ATTR_VALUE2 = "text/html";
-
-    static interface Task {
-        void run() throws Exception;
-    }
-
-    static void tryCatch(Class<? extends Throwable> ex, Task task) {
-        boolean caught = false;
-        try {
-            task.run();
-        } catch (Throwable x) {
-            if (ex.isAssignableFrom(x.getClass())) {
-                caught = true;
-            } else {
-                throw new RuntimeException(x);
-            }
-        }
-        if (!caught)
-            throw new RuntimeException(ex.getName() + " expected");
-    }
-
-    static void expectNullPointerException(Task task) {
-        tryCatch(NullPointerException.class, task);
-    }
-
-    static boolean hasAttribute(NamedAttributeView view, String attr)
-        throws IOException
-    {
-        for (String name: view.list()) {
-            if (name.equals(ATTR_NAME))
-                return true;
-        }
-        return false;
-    }
-
-    static void test(Path file, LinkOption... options) throws IOException {
-        final NamedAttributeView view = file
-            .getFileAttributeView(NamedAttributeView.class, options);
-        ByteBuffer buf = rand.nextBoolean() ?
-            ByteBuffer.allocate(100) : ByteBuffer.allocateDirect(100);
-
-        // Test: write
-        buf.put(ATTR_VALUE.getBytes()).flip();
-        int size = buf.remaining();
-        int nwrote = view.write(ATTR_NAME, buf);
-        if (nwrote != size)
-            throw new RuntimeException("Unexpected number of bytes written");
-
-        // Test: size
-        if (view.size(ATTR_NAME) != size)
-            throw new RuntimeException("Unexpected size");
-
-        // Test: read
-        buf.clear();
-        int nread = view.read(ATTR_NAME, buf);
-        if (nread != size)
-            throw new RuntimeException("Unexpected number of bytes read");
-        buf.flip();
-        String value = Charset.defaultCharset().decode(buf).toString();
-        if (!value.equals(ATTR_VALUE))
-            throw new RuntimeException("Unexpected attribute value");
-
-        // Test: read with insufficient space
-        tryCatch(IOException.class, new Task() {
-            public void run() throws IOException {
-                view.read(ATTR_NAME, ByteBuffer.allocateDirect(1));
-            }});
-
-        // Test: replace value
-        buf.clear();
-        buf.put(ATTR_VALUE2.getBytes()).flip();
-        size = buf.remaining();
-        view.write(ATTR_NAME, buf);
-        if (view.size(ATTR_NAME) != size)
-            throw new RuntimeException("Unexpected size");
-
-        // Test: list
-        if (!hasAttribute(view, ATTR_NAME))
-            throw new RuntimeException("Attribute name not in list");
-
-        // Test: delete
-        view.delete(ATTR_NAME);
-        if (hasAttribute(view, ATTR_NAME))
-            throw new RuntimeException("Attribute name in list");
-
-        // Test: dynamic access
-        byte[] valueAsBytes = ATTR_VALUE.getBytes();
-        view.setAttribute(ATTR_NAME, valueAsBytes);
-        byte[] actualAsBytes = (byte[])view.getAttribute(ATTR_NAME);
-        if (!Arrays.equals(valueAsBytes, actualAsBytes))
-            throw new RuntimeException("Unexpected attribute value");
-        Map<String,?> map = view.readAttributes(ATTR_NAME);
-        if (!Arrays.equals(valueAsBytes, (byte[])map.get(ATTR_NAME)))
-            throw new RuntimeException("Unexpected attribute value");
-        map = view.readAttributes(ATTR_NAME, "*");
-        if (!Arrays.equals(valueAsBytes, (byte[])map.get(ATTR_NAME)))
-            throw new RuntimeException("Unexpected attribute value");
-        map = view.readAttributes("DoesNotExist");
-        if (!map.isEmpty())
-            throw new RuntimeException("Map expected to be empty");
-    }
-
-    static void miscTests(Path file) throws IOException {
-        final NamedAttributeView view = file
-            .getFileAttributeView(NamedAttributeView.class);
-        view.write(ATTR_NAME, ByteBuffer.wrap(ATTR_VALUE.getBytes()));
-
-        // NullPointerException
-        final ByteBuffer buf = ByteBuffer.allocate(100);
-
-        expectNullPointerException(new Task() {
-            public void run() throws IOException {
-                view.read(null, buf);
-            }});
-        expectNullPointerException(new Task() {
-            public void run() throws IOException {
-                view.read(ATTR_NAME, null);
-            }});
-        expectNullPointerException(new Task() {
-            public void run() throws IOException {
-                view.write(null, buf);
-            }});
-        expectNullPointerException(new Task() {
-            public void run() throws IOException {
-               view.write(ATTR_NAME, null);
-            }});
-        expectNullPointerException(new Task() {
-            public void run() throws IOException {
-                view.size(null);
-            }});
-        expectNullPointerException(new Task() {
-            public void run() throws IOException {
-                view.delete(null);
-            }});
-        expectNullPointerException(new Task() {
-            public void run() throws IOException {
-                view.getAttribute(null);
-            }});
-        expectNullPointerException(new Task() {
-            public void run() throws IOException {
-                view.setAttribute(ATTR_NAME, null);
-            }});
-        expectNullPointerException(new Task() {
-            public void run() throws IOException {
-                view.setAttribute(null, new byte[0]);
-            }});
-         expectNullPointerException(new Task() {
-            public void run() throws IOException {
-               view.readAttributes(null);
-            }});
-        expectNullPointerException(new Task() {
-            public void run() throws IOException {
-                view.readAttributes("*", (String[])null);
-            }});
-        expectNullPointerException(new Task() {
-            public void run() throws IOException {
-                view.readAttributes("*", ATTR_NAME, null);
-            }});
-
-        // Read-only buffer
-        tryCatch(IllegalArgumentException.class, new Task() {
-            public void run() throws IOException {
-                ByteBuffer buf = ByteBuffer.wrap(ATTR_VALUE.getBytes()).asReadOnlyBuffer();
-                view.write(ATTR_NAME, buf);
-                buf.flip();
-                view.read(ATTR_NAME, buf);
-            }});
-
-        // Zero bytes remaining
-        tryCatch(IOException.class, new Task() {
-            public void run() throws IOException {
-                ByteBuffer buf = buf = ByteBuffer.allocateDirect(100);
-                buf.position(buf.capacity());
-                view.read(ATTR_NAME, buf);
-            }});
-    }
-
-    public static void main(String[] args) throws IOException {
-        // create temporary directory to run tests
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            if (!dir.getFileStore().supportsFileAttributeView("xattr")) {
-                System.out.println("NamedAttributeView not supported - skip test");
-                return;
-            }
-
-            // test access to named attributes of regular file
-            Path file = dir.resolve("foo.html").createFile();
-            try {
-                test(file);
-            } finally {
-                file.delete();
-            }
-
-            // test access to named attributes of directory
-            file = dir.resolve("foo").createDirectory();
-            try {
-                test(file);
-            } finally {
-                file.delete();
-            }
-
-            // test access to named attributes of sym link
-            if (TestUtil.supportsLinks(dir)) {
-                Path target = dir.resolve("doesnotexist");
-                Path link = dir.resolve("link").createSymbolicLink(target);
-                try {
-                    test(link, NOFOLLOW_LINKS);
-                } catch (IOException x) {
-                    // access to attributes of sym link may not be supported
-                } finally {
-                    link.delete();
-                }
-            }
-
-            // misc. tests
-            try {
-                file = dir.resolve("foo.txt").createFile();
-                miscTests(dir);
-            } finally {
-                file.delete();
-            }
-
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
- }
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/PosixFileAttributeView/Basic.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,398 +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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.attribute.PosixFileAttributeView
- * @library ../..
- */
-
-import java.nio.file.*;
-import static java.nio.file.LinkOption.*;
-import java.nio.file.attribute.*;
-import java.io.IOException;
-import java.util.*;
-
-/**
- * Unit test for PosixFileAttributeView, passing silently if this attribute
- * view is not available.
- */
-
-public class Basic {
-
-    /**
-     * Use view to update permission to the given mode and check that the
-     * permissions have been updated.
-     */
-    static void testPermissions(PosixFileAttributeView view, String mode)
-        throws IOException
-    {
-        System.out.format("change mode: %s\n", mode);
-        Set<PosixFilePermission> perms = PosixFilePermissions.fromString(mode);
-
-        // change permissions and re-read them.
-        view.setPermissions(perms);
-        Set<PosixFilePermission> current = view.readAttributes().permissions();
-        if (!current.equals(perms)) {
-            throw new RuntimeException("Actual permissions: " +
-                PosixFilePermissions.toString(current) + ", expected: " +
-                PosixFilePermissions.toString(perms));
-        }
-
-        // repeat test using setAttribute/getAttribute
-        view.setAttribute("permissions", perms);
-        current = (Set<PosixFilePermission>)view.getAttribute("permissions");
-        if (!current.equals(perms)) {
-            throw new RuntimeException("Actual permissions: " +
-                PosixFilePermissions.toString(current) + ", expected: " +
-                PosixFilePermissions.toString(perms));
-        }
-    }
-
-    /**
-     * Check that the actual permissions of a file match or make it more
-     * secure than requested
-     */
-    static void checkSecure(Set<PosixFilePermission> requested,
-                            Set<PosixFilePermission> actual)
-    {
-        for (PosixFilePermission perm: actual) {
-            if (!requested.contains(perm)) {
-                throw new RuntimeException("Actual permissions: " +
-                    PosixFilePermissions.toString(actual) + ", requested: " +
-                    PosixFilePermissions.toString(requested) +
-                    " - file is less secure than requested");
-            }
-        }
-    }
-
-    /**
-     * Create file with given mode and check that the file is created with a
-     * mode that is not less secure
-     */
-    static void createWithPermissions(Path file,
-                                      String mode)
-        throws IOException
-    {
-        Set<PosixFilePermission> requested = PosixFilePermissions.fromString(mode);
-        FileAttribute<Set<PosixFilePermission>> attr =
-            PosixFilePermissions.asFileAttribute(requested);
-        System.out.format("create file with mode: %s\n", mode);
-
-        EnumSet<StandardOpenOption> options = EnumSet.of(StandardOpenOption.CREATE_NEW,
-            StandardOpenOption.WRITE);
-        file.newOutputStream(options, attr).close();
-        try {
-            checkSecure(requested,  file
-                .getFileAttributeView(PosixFileAttributeView.class)
-                .readAttributes()
-                .permissions());
-        } finally {
-            file.delete(false);
-        }
-
-        System.out.format("create directory with mode: %s\n", mode);
-        file.createDirectory(attr);
-        try {
-            checkSecure(requested,  file
-                .getFileAttributeView(PosixFileAttributeView.class)
-                .readAttributes()
-                .permissions());
-        } finally {
-            file.delete(false);
-        }
-    }
-
-    /**
-     * Test the setPermissions/permissions methods.
-     */
-    static void permissionTests(Path dir)
-        throws IOException
-    {
-        System.out.println("-- Permission Tests  --");
-
-        // create file and test updating and reading its permissions
-        Path file = dir.resolve("foo");
-        System.out.format("create %s\n", file);
-        file.newOutputStream().close();
-        try {
-            // get initial permissions so that we can restore them later
-            PosixFileAttributeView view = file
-                .getFileAttributeView(PosixFileAttributeView.class);
-            Set<PosixFilePermission> save = view.readAttributes()
-                .permissions();
-
-            // test various modes
-            try {
-                testPermissions(view, "---------");
-                testPermissions(view, "r--------");
-                testPermissions(view, "-w-------");
-                testPermissions(view, "--x------");
-                testPermissions(view, "rwx------");
-                testPermissions(view, "---r-----");
-                testPermissions(view, "----w----");
-                testPermissions(view, "-----x---");
-                testPermissions(view, "---rwx---");
-                testPermissions(view, "------r--");
-                testPermissions(view, "-------w-");
-                testPermissions(view, "--------x");
-                testPermissions(view, "------rwx");
-                testPermissions(view, "r--r-----");
-                testPermissions(view, "r--r--r--");
-                testPermissions(view, "rw-rw----");
-                testPermissions(view, "rwxrwx---");
-                testPermissions(view, "rw-rw-r--");
-                testPermissions(view, "r-xr-x---");
-                testPermissions(view, "r-xr-xr-x");
-                testPermissions(view, "rwxrwxrwx");
-            } finally {
-                view.setPermissions(save);
-            }
-        } finally {
-            file.delete(false);
-        }
-
-        // create link (to file that doesn't exist) and test reading of
-        // permissions
-        if (TestUtil.supportsLinks(dir)) {
-            Path link = dir.resolve("link");
-            System.out.format("create link %s\n", link);
-            link.createSymbolicLink(file);
-            try {
-                PosixFileAttributes attrs = Attributes
-                    .readPosixFileAttributes(link, NOFOLLOW_LINKS);
-                if (!attrs.isSymbolicLink()) {
-                    throw new RuntimeException("not a link");
-                }
-            } finally {
-                link.delete(false);
-            }
-        }
-
-        System.out.println("OKAY");
-    }
-
-    /**
-     * Test creating a file and directory with initial permissios
-     */
-    static void createTests(Path dir)
-        throws IOException
-    {
-        System.out.println("-- Create Tests  --");
-
-        Path file = dir.resolve("foo");
-
-        createWithPermissions(file, "---------");
-        createWithPermissions(file, "r--------");
-        createWithPermissions(file, "-w-------");
-        createWithPermissions(file, "--x------");
-        createWithPermissions(file, "rwx------");
-        createWithPermissions(file, "---r-----");
-        createWithPermissions(file, "----w----");
-        createWithPermissions(file, "-----x---");
-        createWithPermissions(file, "---rwx---");
-        createWithPermissions(file, "------r--");
-        createWithPermissions(file, "-------w-");
-        createWithPermissions(file, "--------x");
-        createWithPermissions(file, "------rwx");
-        createWithPermissions(file, "r--r-----");
-        createWithPermissions(file, "r--r--r--");
-        createWithPermissions(file, "rw-rw----");
-        createWithPermissions(file, "rwxrwx---");
-        createWithPermissions(file, "rw-rw-r--");
-        createWithPermissions(file, "r-xr-x---");
-        createWithPermissions(file, "r-xr-xr-x");
-        createWithPermissions(file, "rwxrwxrwx");
-
-        System.out.println("OKAY");
-    }
-
-    /**
-     * Test setOwner/setGroup methods - this test simply exercises the
-     * methods to avoid configuration.
-     */
-    static void ownerTests(Path dir)
-        throws IOException
-    {
-        System.out.println("-- Owner Tests  --");
-
-        Path file = dir.resolve("gus");
-        System.out.format("create %s\n", file);
-
-        file.newOutputStream().close();
-        try {
-
-            // read attributes of directory to get owner/group
-            PosixFileAttributeView view = file
-                .getFileAttributeView(PosixFileAttributeView.class);
-            PosixFileAttributes attrs = view.readAttributes();
-
-            // set to existing owner/group
-            view.setOwner(attrs.owner());
-            view.setGroup(attrs.group());
-
-            // repeat test using setAttribute
-            Map<String,?> map = view.readAttributes("owner","group");
-            view.setAttribute("owner", map.get("owner"));
-            view.setAttribute("group", map.get("group"));
-
-        } finally {
-            file.delete(false);
-        }
-
-        System.out.println("OKAY");
-    }
-
-    /**
-     * Test the lookupPrincipalByName/lookupPrincipalByGroupName methods
-     */
-    static void lookupPrincipalTests(Path dir)
-        throws IOException
-    {
-        System.out.println("-- Lookup UserPrincipal Tests --");
-
-        UserPrincipalLookupService lookupService = dir.getFileSystem()
-            .getUserPrincipalLookupService();
-
-        // read attributes of directory to get owner/group
-        PosixFileAttributes attrs = Attributes.readPosixFileAttributes(dir);
-
-        // lookup owner and check it matches file's owner
-        System.out.format("lookup: %s\n", attrs.owner().getName());
-        try {
-            UserPrincipal owner = lookupService.lookupPrincipalByName(attrs.owner().getName());
-            if (owner instanceof GroupPrincipal)
-                throw new RuntimeException("owner is a group?");
-            if (!owner.equals(attrs.owner()))
-                throw new RuntimeException("owner different from file owner");
-        } catch (UserPrincipalNotFoundException x) {
-            System.out.println("user not found - test skipped");
-        }
-
-        // lookup group and check it matches file's group-owner
-        System.out.format("lookup group: %s\n", attrs.group().getName());
-        try {
-            GroupPrincipal group = lookupService.lookupPrincipalByGroupName(attrs.group().getName());
-            if (!group.equals(attrs.group()))
-                throw new RuntimeException("group different from file group-owner");
-        } catch (UserPrincipalNotFoundException x) {
-            System.out.println("group not found - test skipped");
-        }
-
-        // test that UserPrincipalNotFoundException is thrown
-        String invalidPrincipal = "scumbag99";
-        try {
-            System.out.format("lookup: %s\n", invalidPrincipal);
-            lookupService.lookupPrincipalByName(invalidPrincipal);
-            throw new RuntimeException("'" + invalidPrincipal + "' is a valid user?");
-        } catch (UserPrincipalNotFoundException x) {
-        }
-        try {
-            System.out.format("lookup group: %s\n", invalidPrincipal);
-            lookupService.lookupPrincipalByGroupName("idonotexist");
-            throw new RuntimeException("'" + invalidPrincipal + "' is a valid group?");
-        } catch (UserPrincipalNotFoundException x) {
-        }
-        System.out.println("OKAY");
-    }
-
-    /**
-     * Test various exceptions are thrown as expected
-     */
-    @SuppressWarnings("unchecked")
-    static void exceptionsTests(Path dir)
-        throws IOException
-    {
-        System.out.println("-- Exceptions --");
-
-        PosixFileAttributeView view = dir
-            .getFileAttributeView(PosixFileAttributeView.class);
-
-        // NullPointerException
-        try {
-            view.setOwner(null);
-            throw new RuntimeException("NullPointerException not thrown");
-        } catch (NullPointerException x) {
-        }
-        try {
-            view.setGroup(null);
-            throw new RuntimeException("NullPointerException not thrown");
-        } catch (NullPointerException x) {
-        }
-
-        UserPrincipalLookupService lookupService = dir.getFileSystem()
-            .getUserPrincipalLookupService();
-        try {
-            lookupService.lookupPrincipalByName(null);
-            throw new RuntimeException("NullPointerException not thrown");
-        } catch (NullPointerException x) {
-        }
-        try {
-            lookupService.lookupPrincipalByGroupName(null);
-            throw new RuntimeException("NullPointerException not thrown");
-        } catch (NullPointerException x) {
-        }
-        try {
-            view.setPermissions(null);
-            throw new RuntimeException("NullPointerException not thrown");
-        } catch (NullPointerException x) {
-        }
-        try {
-            Set<PosixFilePermission> perms = new HashSet<PosixFilePermission>();
-            perms.add(null);
-            view.setPermissions(perms);
-            throw new RuntimeException("NullPointerException not thrown");
-        }  catch (NullPointerException x) {
-        }
-
-        // ClassCastException
-        try {
-            Set perms = new HashSet();  // raw type
-            perms.add(new Object());
-            view.setPermissions(perms);
-            throw new RuntimeException("ClassCastException not thrown");
-        }  catch (ClassCastException x) {
-        }
-
-        System.out.println("OKAY");
-    }
-
-    public static void main(String[] args) throws IOException {
-        Path dir = TestUtil.createTemporaryDirectory();
-        try {
-            if (!dir.getFileStore().supportsFileAttributeView("posix")) {
-                System.out.println("PosixFileAttributeView not supported");
-                return;
-            }
-
-            permissionTests(dir);
-            createTests(dir);
-            ownerTests(dir);
-            lookupPrincipalTests(dir);
-            exceptionsTests(dir);
-
-        } finally {
-            TestUtil.removeAll(dir);
-        }
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/spi/SetDefaultProvider.java	Thu Mar 05 09:41:58 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.
- *
- * 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.
- */
-
-/* @test
- * @bug 4313887
- * @summary Unit test for java.nio.file.spi.FileSystemProvider
- * @build TestProvider SetDefaultProvider
- * @run main/othervm -Djava.nio.file.spi.DefaultFileSystemProvider=TestProvider SetDefaultProvider
- */
-
-import java.nio.file.*;
-import java.nio.file.spi.*;
-
-public class SetDefaultProvider {
-    public static void main(String[] args) throws Exception {
-        Class<?> c = FileSystems.getDefault().provider().getClass();
-
-        Class<?> expected = Class.forName("TestProvider", false,
-            ClassLoader.getSystemClassLoader());
-
-        if (c != expected)
-            throw new RuntimeException();
-    }
-}
--- a/overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/spi/TestProvider.java	Thu Mar 05 09:41:58 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +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.
- *
- * 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.
- */
-
-import java.nio.file.spi.FileSystemProvider;
-import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.net.URI;
-import java.util.*;
-import java.io.IOException;
-
-public class TestProvider extends FileSystemProvider {
-
-    private final FileSystem theFileSystem;
-
-    public TestProvider(FileSystemProvider defaultProvider) {
-        theFileSystem = new TestFileSystem(this);
-
-    }
-
-
-    public String getScheme() {
-        return "file";
-    }
-
-
-    public FileSystem newFileSystem(URI uri, Map<String,?> env) {
-        throw new RuntimeException("not implemented");
-    }
-
-
-    public FileSystem getFileSystem(URI uri) {
-        return theFileSystem;
-    }
-
-
-    public Path getPath(URI uri) {
-        throw new RuntimeException("not implemented");
-    }
-
-    static class TestFileSystem extends FileSystem {
-        private final TestProvider provider;
-
-        TestFileSystem(TestProvider provider) {
-            this.provider = provider;
-        }
-
-
-        public FileSystemProvider provider() {
-            return provider;
-        }
-
-
-        public void close() throws IOException {
-            throw new RuntimeException("not implemented");
-        }
-
-
-        public boolean isOpen() {
-            throw new RuntimeException("not implemented");
-        }
-
-
-        public boolean isReadOnly() {
-            throw new RuntimeException("not implemented");
-        }
-
-
-        public String getSeparator() {
-            throw new RuntimeException("not implemented");
-        }
-
-
-        public Iterable<Path> getRootDirectories() {
-            throw new RuntimeException("not implemented");
-        }
-
-
-        public Iterable<FileStore> getFileStores() {
-            throw new RuntimeException("not implemented");
-        }
-
-
-        public Set<String> supportedFileAttributeViews() {
-            throw new RuntimeException("not implemented");
-        }
-
-
-        public Path getPath(String path) {
-            throw new RuntimeException("not implemented");
-        }
-
-
-        public PathMatcher getNameMatcher(String syntax, String pattern) {
-            throw new RuntimeException("not implemented");
-        }
-
-
-        public UserPrincipalLookupService getUserPrincipalLookupService() {
-            throw new RuntimeException("not implemented");
-        }
-
-
-        public WatchService newWatchService() throws IOException {
-            throw new RuntimeException("not implemented");
-        }
-    }
-
-}