Import java.nio.channels from jdk-11.0.13-ga
List of files:
ojluni/src/main/java/java/nio/channels/AsynchronousByteChannel.java
ojluni/src/main/java/java/nio/channels/AsynchronousChannelGroup.java
ojluni/src/main/java/java/nio/channels/AsynchronousFileChannel.java
ojluni/src/main/java/java/nio/channels/AsynchronousServerSocketChannel.java
ojluni/src/main/java/java/nio/channels/AsynchronousSocketChannel.java
ojluni/src/main/java/java/nio/channels/Channel.java
ojluni/src/main/java/java/nio/channels/Channels.java
ojluni/src/main/java/java/nio/channels/DatagramChannel.java
ojluni/src/main/java/java/nio/channels/FileChannel.java
ojluni/src/main/java/java/nio/channels/FileLock.java
ojluni/src/main/java/java/nio/channels/GatheringByteChannel.java
ojluni/src/main/java/java/nio/channels/InterruptibleChannel.java
ojluni/src/main/java/java/nio/channels/MulticastChannel.java
ojluni/src/main/java/java/nio/channels/Pipe.java
ojluni/src/main/java/java/nio/channels/ReadableByteChannel.java
ojluni/src/main/java/java/nio/channels/ScatteringByteChannel.java
ojluni/src/main/java/java/nio/channels/SelectableChannel.java
ojluni/src/main/java/java/nio/channels/ServerSocketChannel.java
ojluni/src/main/java/java/nio/channels/SocketChannel.java
ojluni/src/main/java/java/nio/channels/WritableByteChannel.java
ojluni/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java
ojluni/src/main/java/java/nio/channels/package-info.java
Generated by tools/expected_upstream/ojluni_merge_to_master.py
Bug: 266401706
Test: N/A
Change-Id: I515bc1401d449a8a115c67b7fffee106c1761720
diff --git a/EXPECTED_UPSTREAM b/EXPECTED_UPSTREAM
index 5f1f94a..6367746 100644
--- a/EXPECTED_UPSTREAM
+++ b/EXPECTED_UPSTREAM
@@ -383,36 +383,36 @@
ojluni/src/main/java/java/nio/CharBufferSpliterator.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/CharBufferSpliterator.java
ojluni/src/main/java/java/nio/MappedByteBuffer.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/MappedByteBuffer.java
ojluni/src/main/java/java/nio/StringCharBuffer.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/StringCharBuffer.java
-ojluni/src/main/java/java/nio/channels/AsynchronousByteChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/AsynchronousByteChannel.java
+ojluni/src/main/java/java/nio/channels/AsynchronousByteChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/AsynchronousByteChannel.java
ojluni/src/main/java/java/nio/channels/AsynchronousChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/AsynchronousChannel.java
-ojluni/src/main/java/java/nio/channels/AsynchronousChannelGroup.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/AsynchronousChannelGroup.java
-ojluni/src/main/java/java/nio/channels/AsynchronousFileChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java
-ojluni/src/main/java/java/nio/channels/AsynchronousServerSocketChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java
-ojluni/src/main/java/java/nio/channels/AsynchronousSocketChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java
+ojluni/src/main/java/java/nio/channels/AsynchronousChannelGroup.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/AsynchronousChannelGroup.java
+ojluni/src/main/java/java/nio/channels/AsynchronousFileChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/AsynchronousFileChannel.java
+ojluni/src/main/java/java/nio/channels/AsynchronousServerSocketChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java
+ojluni/src/main/java/java/nio/channels/AsynchronousSocketChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/AsynchronousSocketChannel.java
ojluni/src/main/java/java/nio/channels/ByteChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/ByteChannel.java
-ojluni/src/main/java/java/nio/channels/Channel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/Channel.java
-ojluni/src/main/java/java/nio/channels/Channels.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/Channels.java
+ojluni/src/main/java/java/nio/channels/Channel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/Channel.java
+ojluni/src/main/java/java/nio/channels/Channels.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/Channels.java
ojluni/src/main/java/java/nio/channels/CompletionHandler.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/CompletionHandler.java
-ojluni/src/main/java/java/nio/channels/DatagramChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/DatagramChannel.java
-ojluni/src/main/java/java/nio/channels/FileChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/FileChannel.java
-ojluni/src/main/java/java/nio/channels/FileLock.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/FileLock.java
-ojluni/src/main/java/java/nio/channels/GatheringByteChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/GatheringByteChannel.java
-ojluni/src/main/java/java/nio/channels/InterruptibleChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/InterruptibleChannel.java
+ojluni/src/main/java/java/nio/channels/DatagramChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/DatagramChannel.java
+ojluni/src/main/java/java/nio/channels/FileChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/FileChannel.java
+ojluni/src/main/java/java/nio/channels/FileLock.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/FileLock.java
+ojluni/src/main/java/java/nio/channels/GatheringByteChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/GatheringByteChannel.java
+ojluni/src/main/java/java/nio/channels/InterruptibleChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/InterruptibleChannel.java
ojluni/src/main/java/java/nio/channels/MembershipKey.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/MembershipKey.java
-ojluni/src/main/java/java/nio/channels/MulticastChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/MulticastChannel.java
+ojluni/src/main/java/java/nio/channels/MulticastChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/MulticastChannel.java
ojluni/src/main/java/java/nio/channels/NetworkChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/NetworkChannel.java
-ojluni/src/main/java/java/nio/channels/Pipe.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/Pipe.java
-ojluni/src/main/java/java/nio/channels/ReadableByteChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/ReadableByteChannel.java
-ojluni/src/main/java/java/nio/channels/ScatteringByteChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/ScatteringByteChannel.java
+ojluni/src/main/java/java/nio/channels/Pipe.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/Pipe.java
+ojluni/src/main/java/java/nio/channels/ReadableByteChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/ReadableByteChannel.java
+ojluni/src/main/java/java/nio/channels/ScatteringByteChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/ScatteringByteChannel.java
ojluni/src/main/java/java/nio/channels/SeekableByteChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/SeekableByteChannel.java
-ojluni/src/main/java/java/nio/channels/SelectableChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/SelectableChannel.java
+ojluni/src/main/java/java/nio/channels/SelectableChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/SelectableChannel.java
ojluni/src/main/java/java/nio/channels/SelectionKey.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/SelectionKey.java
ojluni/src/main/java/java/nio/channels/Selector.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/Selector.java
-ojluni/src/main/java/java/nio/channels/ServerSocketChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/ServerSocketChannel.java
-ojluni/src/main/java/java/nio/channels/SocketChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/SocketChannel.java
-ojluni/src/main/java/java/nio/channels/WritableByteChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/WritableByteChannel.java
-ojluni/src/main/java/java/nio/channels/package-info.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/package-info.java
-ojluni/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java,jdk8u/jdk8u121-b13,jdk/src/share/classes/java/nio/channels/spi/AbstractInterruptibleChannel.java
+ojluni/src/main/java/java/nio/channels/ServerSocketChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/ServerSocketChannel.java
+ojluni/src/main/java/java/nio/channels/SocketChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/SocketChannel.java
+ojluni/src/main/java/java/nio/channels/WritableByteChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/WritableByteChannel.java
+ojluni/src/main/java/java/nio/channels/package-info.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/package-info.java
+ojluni/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/spi/AbstractInterruptibleChannel.java
ojluni/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/spi/AbstractSelectableChannel.java
ojluni/src/main/java/java/nio/channels/spi/AbstractSelectionKey.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/spi/AbstractSelectionKey.java
ojluni/src/main/java/java/nio/channels/spi/AbstractSelector.java,jdk11u/jdk-11.0.13-ga,src/java.base/share/classes/java/nio/channels/spi/AbstractSelector.java
diff --git a/ojluni/src/main/java/java/nio/channels/AsynchronousByteChannel.java b/ojluni/src/main/java/java/nio/channels/AsynchronousByteChannel.java
index b96a239..56003d5 100644
--- a/ojluni/src/main/java/java/nio/channels/AsynchronousByteChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/AsynchronousByteChannel.java
@@ -70,13 +70,13 @@
* {@code 0} without initiating an I/O operation.
*
* <p> Suppose that a byte sequence of length <i>n</i> is read, where
- * <tt>0</tt> <tt><</tt> <i>n</i> <tt><=</tt> <i>r</i>.
+ * {@code 0} {@code <} <i>n</i> {@code <=} <i>r</i>.
* This byte sequence will be transferred into the buffer so that the first
* byte in the sequence is at index <i>p</i> and the last byte is at index
- * <i>p</i> <tt>+</tt> <i>n</i> <tt>-</tt> <tt>1</tt>,
+ * <i>p</i> {@code +} <i>n</i> {@code -} {@code 1},
* where <i>p</i> is the buffer's position at the moment the read is
* performed. Upon completion the buffer's position will be equal to
- * <i>p</i> <tt>+</tt> <i>n</i>; its limit will not have changed.
+ * <i>p</i> {@code +} <i>n</i>; its limit will not have changed.
*
* <p> Buffers are not safe for use by multiple concurrent threads so care
* should be taken to not access the buffer until the operation has
@@ -151,13 +151,13 @@
* {@code 0} without initiating an I/O operation.
*
* <p> Suppose that a byte sequence of length <i>n</i> is written, where
- * <tt>0</tt> <tt><</tt> <i>n</i> <tt><=</tt> <i>r</i>.
+ * {@code 0} {@code <} <i>n</i> {@code <=} <i>r</i>.
* This byte sequence will be transferred from the buffer starting at index
* <i>p</i>, where <i>p</i> is the buffer's position at the moment the
* write is performed; the index of the last byte written will be
- * <i>p</i> <tt>+</tt> <i>n</i> <tt>-</tt> <tt>1</tt>.
+ * <i>p</i> {@code +} <i>n</i> {@code -} {@code 1}.
* Upon completion the buffer's position will be equal to
- * <i>p</i> <tt>+</tt> <i>n</i>; its limit will not have changed.
+ * <i>p</i> {@code +} <i>n</i>; its limit will not have changed.
*
* <p> Buffers are not safe for use by multiple concurrent threads so care
* should be taken to not access the buffer until the operation has
diff --git a/ojluni/src/main/java/java/nio/channels/AsynchronousChannelGroup.java b/ojluni/src/main/java/java/nio/channels/AsynchronousChannelGroup.java
index 92b7e66..2ee7fd7 100644
--- a/ojluni/src/main/java/java/nio/channels/AsynchronousChannelGroup.java
+++ b/ojluni/src/main/java/java/nio/channels/AsynchronousChannelGroup.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -60,13 +60,17 @@
* default group is not configured then the pooled threads of the default group
* are {@link Thread#isDaemon daemon} threads.
*
- * <table border summary="System properties">
+ * <table class="striped">
+ * <caption style="display:none:">System properties</caption>
+ * <thead>
* <tr>
- * <th>System property</th>
- * <th>Description</th>
+ * <th scope="col">System property</th>
+ * <th scope="col">Description</th>
* </tr>
+ * </thead>
+ * <tbody>
* <tr>
- * <td> {@code java.nio.channels.DefaultThreadPool.threadFactory} </td>
+ * <th scope="row"> {@code java.nio.channels.DefaultThreadPool.threadFactory} </th>
* <td> The value of this property is taken to be the fully-qualified name
* of a concrete {@link java.util.concurrent.ThreadFactory ThreadFactory}
* class. The class is loaded using the system class loader and instantiated.
@@ -77,7 +81,7 @@
* construction of the default group. </td>
* </tr>
* <tr>
- * <td> {@code java.nio.channels.DefaultThreadPool.initialSize} </td>
+ * <th scope="row"> {@code java.nio.channels.DefaultThreadPool.initialSize} </th>
* <td> The value of the {@code initialSize} parameter for the default
* group (see {@link #withCachedThreadPool withCachedThreadPool}).
* The value of the property is taken to be the {@code String}
@@ -86,9 +90,10 @@
* unspecified error to be thrown during the construction of the default
* group. </td>
* </tr>
+ * </tbody>
* </table>
*
- * <a name="threading"></a><h2>Threading</h2>
+ * <a id="threading"></a><h2>Threading</h2>
*
* <p> The completion handler for an I/O operation initiated on a channel bound
* to a group is guaranteed to be invoked by one of the pooled threads in the
@@ -103,7 +108,7 @@
* handler directly by the initiating thread (see {@link
* AsynchronousServerSocketChannel#accept(Object,CompletionHandler) accept}).
*
- * <a name="shutdown"></a><h2>Shutdown and Termination</h2>
+ * <a id="shutdown"></a><h2>Shutdown and Termination</h2>
*
* <p> The {@link #shutdown() shutdown} method is used to initiate an <em>orderly
* shutdown</em> of a group. An orderly shutdown marks the group as shutdown;
diff --git a/ojluni/src/main/java/java/nio/channels/AsynchronousFileChannel.java b/ojluni/src/main/java/java/nio/channels/AsynchronousFileChannel.java
index b985d77..17f6ff0 100644
--- a/ojluni/src/main/java/java/nio/channels/AsynchronousFileChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/AsynchronousFileChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -133,16 +133,20 @@
* <p> In addition to {@code READ} and {@code WRITE}, the following options
* may be present:
*
- * <table border=1 cellpadding=5 summary="">
- * <tr> <th>Option</th> <th>Description</th> </tr>
+ * <table class="striped">
+ * <caption style="display:none">additional options</caption>
+ * <thead>
+ * <tr> <th scope="col">Option</th> <th scope="col">Description</th> </tr>
+ * </thead>
+ * <tbody>
* <tr>
- * <td> {@link StandardOpenOption#TRUNCATE_EXISTING TRUNCATE_EXISTING} </td>
+ * <th scope="row"> {@link StandardOpenOption#TRUNCATE_EXISTING TRUNCATE_EXISTING} </th>
* <td> When opening an existing file, the file is first truncated to a
* size of 0 bytes. This option is ignored when the file is opened only
* for reading.</td>
* </tr>
* <tr>
- * <td> {@link StandardOpenOption#CREATE_NEW CREATE_NEW} </td>
+ * <th scope="row"> {@link StandardOpenOption#CREATE_NEW CREATE_NEW} </th>
* <td> If this option is present then a new file is created, failing if
* the file already exists. When creating a file the check for the
* existence of the file and the creation of the file if it does not exist
@@ -150,7 +154,7 @@
* ignored when the file is opened only for reading. </td>
* </tr>
* <tr>
- * <td > {@link StandardOpenOption#CREATE CREATE} </td>
+ * <th scope="row" > {@link StandardOpenOption#CREATE CREATE} </th>
* <td> If this option is present then an existing file is opened if it
* exists, otherwise a new file is created. When creating a file the check
* for the existence of the file and the creation of the file if it does
@@ -159,33 +163,34 @@
* the file is opened only for reading. </td>
* </tr>
* <tr>
- * <td > {@link StandardOpenOption#DELETE_ON_CLOSE DELETE_ON_CLOSE} </td>
+ * <th scope="row" > {@link StandardOpenOption#DELETE_ON_CLOSE DELETE_ON_CLOSE} </th>
* <td> When this option is present then the implementation makes a
- * <em>best effort</em> attempt to delete the file when closed by the
+ * <em>best effort</em> attempt to delete the file when closed by
* the {@link #close close} method. If the {@code close} method is not
* invoked then a <em>best effort</em> attempt is made to delete the file
* when the Java virtual machine terminates. </td>
* </tr>
* <tr>
- * <td>{@link StandardOpenOption#SPARSE SPARSE} </td>
+ * <th scope="row">{@link StandardOpenOption#SPARSE SPARSE} </th>
* <td> When creating a new file this option is a <em>hint</em> that the
* new file will be sparse. This option is ignored when not creating
* a new file. </td>
* </tr>
* <tr>
- * <td> {@link StandardOpenOption#SYNC SYNC} </td>
+ * <th scope="row"> {@link StandardOpenOption#SYNC SYNC} </th>
* <td> Requires that every update to the file's content or metadata be
* written synchronously to the underlying storage device. (see <a
* href="../file/package-summary.html#integrity"> Synchronized I/O file
* integrity</a>). </td>
* </tr>
* <tr>
- * <td> {@link StandardOpenOption#DSYNC DSYNC} </td>
+ * <th scope="row"> {@link StandardOpenOption#DSYNC DSYNC} </th>
* <td> Requires that every update to the file's content be written
* synchronously to the underlying storage device. (see <a
* href="../file/package-summary.html#integrity"> Synchronized I/O file
* integrity</a>). </td>
* </tr>
+ * </tbody>
* </table>
*
* <p> An implementation may also support additional options.
@@ -296,8 +301,13 @@
public static AsynchronousFileChannel open(Path file, OpenOption... options)
throws IOException
{
- Set<OpenOption> set = new HashSet<OpenOption>(options.length);
- Collections.addAll(set, options);
+ Set<OpenOption> set;
+ if (options.length == 0) {
+ set = Collections.emptySet();
+ } else {
+ set = new HashSet<>();
+ Collections.addAll(set, options);
+ }
return open(file, set, null, NO_ATTRIBUTES);
}
diff --git a/ojluni/src/main/java/java/nio/channels/AsynchronousServerSocketChannel.java b/ojluni/src/main/java/java/nio/channels/AsynchronousServerSocketChannel.java
index 29ecbd6..d50fa74 100644
--- a/ojluni/src/main/java/java/nio/channels/AsynchronousServerSocketChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/AsynchronousServerSocketChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
* by invoking the {@link #bind(SocketAddress,int) bind} method. Once bound,
* the {@link #accept(Object,CompletionHandler) accept} method
* is used to initiate the accepting of connections to the channel's socket.
- * An attempt to invoke the <tt>accept</tt> method on an unbound channel will
+ * An attempt to invoke the {@code accept} method on an unbound channel will
* cause a {@link NotYetBoundException} to be thrown.
*
* <p> Channels of this type are safe for use by multiple concurrent threads
@@ -52,19 +52,24 @@
* <p> Socket options are configured using the {@link #setOption(SocketOption,Object)
* setOption} method. Channels of this type support the following options:
* <blockquote>
- * <table border summary="Socket options">
+ * <table class="striped">
+ * <caption style="display:none">Socket options</caption>
+ * <thead>
* <tr>
- * <th>Option Name</th>
- * <th>Description</th>
+ * <th scope="col">Option Name</th>
+ * <th scope="col">Description</th>
* </tr>
+ * </thead>
+ * <tbody>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </th>
* <td> The size of the socket receive buffer </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </th>
* <td> Re-use address </td>
* </tr>
+ * </tbody>
* </table>
* </blockquote>
* Additional (implementation specific) options may also be supported.
@@ -122,13 +127,13 @@
* java.nio.channels.spi.AsynchronousChannelProvider#openAsynchronousServerSocketChannel
* openAsynchronousServerSocketChannel} method on the {@link
* java.nio.channels.spi.AsynchronousChannelProvider} object that created
- * the given group. If the group parameter is <tt>null</tt> then the
+ * the given group. If the group parameter is {@code null} then the
* resulting channel is created by the system-wide default provider, and
* bound to the <em>default group</em>.
*
* @param group
* The group to which the newly constructed channel should be bound,
- * or <tt>null</tt> for the default group
+ * or {@code null} for the default group
*
* @return A new asynchronous server socket channel
*
@@ -176,7 +181,7 @@
* </pre></blockquote>
*
* @param local
- * The local address to bind the socket, or <tt>null</tt> to bind
+ * The local address to bind the socket, or {@code null} to bind
* to an automatically assigned socket address
*
* @return This channel
diff --git a/ojluni/src/main/java/java/nio/channels/AsynchronousSocketChannel.java b/ojluni/src/main/java/java/nio/channels/AsynchronousSocketChannel.java
index 1ed1e86..8e54704 100644
--- a/ojluni/src/main/java/java/nio/channels/AsynchronousSocketChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/AsynchronousSocketChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -62,31 +62,36 @@
* <p> Socket options are configured using the {@link #setOption(SocketOption,Object)
* setOption} method. Asynchronous socket channels support the following options:
* <blockquote>
- * <table border summary="Socket options">
+ * <table class="striped">
+ * <caption style="display:none">Socket options</caption>
+ * <thead>
* <tr>
- * <th>Option Name</th>
- * <th>Description</th>
+ * <th scope="col">Option Name</th>
+ * <th scope="col">Description</th>
* </tr>
+ * </thead>
+ * <tbody>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} </th>
* <td> The size of the socket send buffer </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </th>
* <td> The size of the socket receive buffer </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE} </th>
* <td> Keep connection alive </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </th>
* <td> Re-use address </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY} </th>
* <td> Disable the Nagle algorithm </td>
* </tr>
+ * </tbody>
* </table>
* </blockquote>
* Additional (implementation specific) options may also be supported.
@@ -452,11 +457,11 @@
* at the moment that the read is attempted.
*
* <p> Suppose that a byte sequence of length <i>n</i> is read, where
- * <tt>0</tt> <tt><</tt> <i>n</i> <tt><=</tt> <i>r</i>.
- * Up to the first <tt>dsts[offset].remaining()</tt> bytes of this sequence
- * are transferred into buffer <tt>dsts[offset]</tt>, up to the next
- * <tt>dsts[offset+1].remaining()</tt> bytes are transferred into buffer
- * <tt>dsts[offset+1]</tt>, and so forth, until the entire byte sequence
+ * {@code 0} {@code <} <i>n</i> {@code <=} <i>r</i>.
+ * Up to the first {@code dsts[offset].remaining()} bytes of this sequence
+ * are transferred into buffer {@code dsts[offset]}, up to the next
+ * {@code dsts[offset+1].remaining()} bytes are transferred into buffer
+ * {@code dsts[offset+1]}, and so forth, until the entire byte sequence
* is transferred into the given buffers. As many bytes as possible are
* transferred into each buffer, hence the final position of each updated
* buffer, except the last updated buffer, is guaranteed to be equal to
@@ -606,11 +611,11 @@
* at the moment that the write is attempted.
*
* <p> Suppose that a byte sequence of length <i>n</i> is written, where
- * <tt>0</tt> <tt><</tt> <i>n</i> <tt><=</tt> <i>r</i>.
- * Up to the first <tt>srcs[offset].remaining()</tt> bytes of this sequence
- * are written from buffer <tt>srcs[offset]</tt>, up to the next
- * <tt>srcs[offset+1].remaining()</tt> bytes are written from buffer
- * <tt>srcs[offset+1]</tt>, and so forth, until the entire byte sequence is
+ * {@code 0} {@code <} <i>n</i> {@code <=} <i>r</i>.
+ * Up to the first {@code srcs[offset].remaining()} bytes of this sequence
+ * are written from buffer {@code srcs[offset]}, up to the next
+ * {@code srcs[offset+1].remaining()} bytes are written from buffer
+ * {@code srcs[offset+1]}, and so forth, until the entire byte sequence is
* written. As many bytes as possible are written from each buffer, hence
* the final position of each updated buffer, except the last updated
* buffer, is guaranteed to be equal to that buffer's limit. The underlying
diff --git a/ojluni/src/main/java/java/nio/channels/Channel.java b/ojluni/src/main/java/java/nio/channels/Channel.java
index 663d0e0..5cca15e0 100644
--- a/ojluni/src/main/java/java/nio/channels/Channel.java
+++ b/ojluni/src/main/java/java/nio/channels/Channel.java
@@ -58,7 +58,7 @@
/**
* Tells whether or not this channel is open.
*
- * @return <tt>true</tt> if, and only if, this channel is open
+ * @return {@code true} if, and only if, this channel is open
*/
public boolean isOpen();
diff --git a/ojluni/src/main/java/java/nio/channels/Channels.java b/ojluni/src/main/java/java/nio/channels/Channels.java
index 2ab10fa..dba3534 100644
--- a/ojluni/src/main/java/java/nio/channels/Channels.java
+++ b/ojluni/src/main/java/java/nio/channels/Channels.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,7 @@
import java.nio.charset.CharsetEncoder;
import java.nio.charset.UnsupportedCharsetException;
import java.nio.channels.spi.AbstractInterruptibleChannel;
+import java.util.Objects;
import java.util.concurrent.ExecutionException;
import sun.nio.ch.ChannelInputStream;
import sun.nio.cs.StreamDecoder;
@@ -48,8 +49,8 @@
* Utility methods for channels and streams.
*
* <p> This class defines static methods that support the interoperation of the
- * stream classes of the <tt>{@link java.io}</tt> package with the channel
- * classes of this package. </p>
+ * stream classes of the {@link java.io} package with the channel classes
+ * of this package. </p>
*
*
* @author Mark Reinhold
@@ -60,12 +61,7 @@
public final class Channels {
- private Channels() { } // No instantiation
-
- private static void checkNotNull(Object o, String name) {
- if (o == null)
- throw new NullPointerException("\"" + name + "\" is null!");
- }
+ private Channels() { throw new Error("no instances"); }
/**
* Write all remaining bytes in buffer to the given channel.
@@ -91,7 +87,7 @@
throws IOException
{
if (ch instanceof SelectableChannel) {
- SelectableChannel sc = (SelectableChannel)ch;
+ SelectableChannel sc = (SelectableChannel) ch;
synchronized (sc.blockingLock()) {
if (!sc.isBlocking())
throw new IllegalBlockingModeException();
@@ -107,7 +103,7 @@
/**
* Constructs a stream that reads bytes from the given channel.
*
- * <p> The <tt>read</tt> methods of the resulting stream will throw an
+ * <p> The {@code read} methods of the resulting stream will throw an
* {@link IllegalBlockingModeException} if invoked while the underlying
* channel is in non-blocking mode. The stream will not be buffered, and
* it will not support the {@link InputStream#mark mark} or {@link
@@ -121,14 +117,14 @@
* @return A new input stream
*/
public static InputStream newInputStream(ReadableByteChannel ch) {
- checkNotNull(ch, "ch");
- return new sun.nio.ch.ChannelInputStream(ch);
+ Objects.requireNonNull(ch, "ch");
+ return new ChannelInputStream(ch);
}
/**
* Constructs a stream that writes bytes to the given channel.
*
- * <p> The <tt>write</tt> methods of the resulting stream will throw an
+ * <p> The {@code write} methods of the resulting stream will throw an
* {@link IllegalBlockingModeException} if invoked while the underlying
* channel is in non-blocking mode. The stream will not be buffered. The
* stream will be safe for access by multiple concurrent threads. Closing
@@ -139,46 +135,49 @@
*
* @return A new output stream
*/
- public static OutputStream newOutputStream(final WritableByteChannel ch) {
- checkNotNull(ch, "ch");
+ public static OutputStream newOutputStream(WritableByteChannel ch) {
+ Objects.requireNonNull(ch, "ch");
return new OutputStream() {
- private ByteBuffer bb = null;
- private byte[] bs = null; // Invoker's previous array
- private byte[] b1 = null;
+ private ByteBuffer bb;
+ private byte[] bs; // Invoker's previous array
+ private byte[] b1;
- public synchronized void write(int b) throws IOException {
- if (b1 == null)
- b1 = new byte[1];
- b1[0] = (byte)b;
- this.write(b1);
- }
+ @Override
+ public synchronized void write(int b) throws IOException {
+ if (b1 == null)
+ b1 = new byte[1];
+ b1[0] = (byte) b;
+ this.write(b1);
+ }
- public synchronized void write(byte[] bs, int off, int len)
+ @Override
+ public synchronized void write(byte[] bs, int off, int len)
throws IOException
- {
- if ((off < 0) || (off > bs.length) || (len < 0) ||
- ((off + len) > bs.length) || ((off + len) < 0)) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return;
- }
- ByteBuffer bb = ((this.bs == bs)
- ? this.bb
- : ByteBuffer.wrap(bs));
- bb.limit(Math.min(off + len, bb.capacity()));
- bb.position(off);
- this.bb = bb;
- this.bs = bs;
- Channels.writeFully(ch, bb);
+ {
+ if ((off < 0) || (off > bs.length) || (len < 0) ||
+ ((off + len) > bs.length) || ((off + len) < 0)) {
+ throw new IndexOutOfBoundsException();
+ } else if (len == 0) {
+ return;
}
+ ByteBuffer bb = ((this.bs == bs)
+ ? this.bb
+ : ByteBuffer.wrap(bs));
+ bb.limit(Math.min(off + len, bb.capacity()));
+ bb.position(off);
+ this.bb = bb;
+ this.bs = bs;
+ Channels.writeFully(ch, bb);
+ }
- public void close() throws IOException {
- ch.close();
- }
+ @Override
+ public void close() throws IOException {
+ ch.close();
+ }
- };
+ };
}
/**
@@ -196,13 +195,13 @@
*
* @since 1.7
*/
- public static InputStream newInputStream(final AsynchronousByteChannel ch) {
- checkNotNull(ch, "ch");
+ public static InputStream newInputStream(AsynchronousByteChannel ch) {
+ Objects.requireNonNull(ch, "ch");
return new InputStream() {
- private ByteBuffer bb = null;
- private byte[] bs = null; // Invoker's previous array
- private byte[] b1 = null;
+ private ByteBuffer bb;
+ private byte[] bs; // Invoker's previous array
+ private byte[] b1;
@Override
public synchronized int read() throws IOException {
@@ -216,13 +215,14 @@
@Override
public synchronized int read(byte[] bs, int off, int len)
- throws IOException
+ throws IOException
{
if ((off < 0) || (off > bs.length) || (len < 0) ||
((off + len) > bs.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
- } else if (len == 0)
+ } else if (len == 0) {
return 0;
+ }
ByteBuffer bb = ((this.bs == bs)
? this.bb
@@ -270,25 +270,25 @@
*
* @since 1.7
*/
- public static OutputStream newOutputStream(final AsynchronousByteChannel ch) {
- checkNotNull(ch, "ch");
+ public static OutputStream newOutputStream(AsynchronousByteChannel ch) {
+ Objects.requireNonNull(ch, "ch");
return new OutputStream() {
- private ByteBuffer bb = null;
- private byte[] bs = null; // Invoker's previous array
- private byte[] b1 = null;
+ private ByteBuffer bb;
+ private byte[] bs; // Invoker's previous array
+ private byte[] b1;
@Override
public synchronized void write(int b) throws IOException {
- if (b1 == null)
+ if (b1 == null)
b1 = new byte[1];
- b1[0] = (byte)b;
+ b1[0] = (byte) b;
this.write(b1);
}
@Override
public synchronized void write(byte[] bs, int off, int len)
- throws IOException
+ throws IOException
{
if ((off < 0) || (off > bs.length) || (len < 0) ||
((off + len) > bs.length) || ((off + len) < 0)) {
@@ -343,12 +343,11 @@
*
* @return A new readable byte channel
*/
- public static ReadableByteChannel newChannel(final InputStream in) {
- checkNotNull(in, "in");
+ public static ReadableByteChannel newChannel(InputStream in) {
+ Objects.requireNonNull(in, "in");
- if (in instanceof FileInputStream &&
- FileInputStream.class.equals(in.getClass())) {
- return ((FileInputStream)in).getChannel();
+ if (in.getClass() == FileInputStream.class) {
+ return ((FileInputStream) in).getChannel();
}
return new ReadableByteChannelImpl(in);
@@ -358,17 +357,21 @@
extends AbstractInterruptibleChannel // Not really interruptible
implements ReadableByteChannel
{
- InputStream in;
+ private final InputStream in;
private static final int TRANSFER_SIZE = 8192;
- private byte buf[] = new byte[0];
- private boolean open = true;
- private Object readLock = new Object();
+ private byte[] buf = new byte[0];
+ private final Object readLock = new Object();
ReadableByteChannelImpl(InputStream in) {
this.in = in;
}
+ @Override
public int read(ByteBuffer dst) throws IOException {
+ if (!isOpen()) {
+ throw new ClosedChannelException();
+ }
+
int len = dst.remaining();
int totalRead = 0;
int bytesRead = 0;
@@ -399,9 +402,9 @@
}
}
+ @Override
protected void implCloseChannel() throws IOException {
in.close();
- open = false;
}
}
@@ -418,12 +421,11 @@
*
* @return A new writable byte channel
*/
- public static WritableByteChannel newChannel(final OutputStream out) {
- checkNotNull(out, "out");
+ public static WritableByteChannel newChannel(OutputStream out) {
+ Objects.requireNonNull(out, "out");
- if (out instanceof FileOutputStream &&
- FileOutputStream.class.equals(out.getClass())) {
- return ((FileOutputStream)out).getChannel();
+ if (out.getClass() == FileOutputStream.class) {
+ return ((FileOutputStream) out).getChannel();
}
return new WritableByteChannelImpl(out);
@@ -433,17 +435,21 @@
extends AbstractInterruptibleChannel // Not really interruptible
implements WritableByteChannel
{
- OutputStream out;
+ private final OutputStream out;
private static final int TRANSFER_SIZE = 8192;
- private byte buf[] = new byte[0];
- private boolean open = true;
- private Object writeLock = new Object();
+ private byte[] buf = new byte[0];
+ private final Object writeLock = new Object();
WritableByteChannelImpl(OutputStream out) {
this.out = out;
}
+ @Override
public int write(ByteBuffer src) throws IOException {
+ if (!isOpen()) {
+ throw new ClosedChannelException();
+ }
+
int len = src.remaining();
int totalWritten = 0;
synchronized (writeLock) {
@@ -465,9 +471,9 @@
}
}
+ @Override
protected void implCloseChannel() throws IOException {
out.close();
- open = false;
}
}
@@ -479,7 +485,7 @@
* given decoder.
*
* <p> The resulting stream will contain an internal input buffer of at
- * least <tt>minBufferCap</tt> bytes. The stream's <tt>read</tt> methods
+ * least {@code minBufferCap} bytes. The stream's {@code read} methods
* will, as needed, fill the buffer by reading bytes from the underlying
* channel; if the channel is in non-blocking mode when bytes are to be
* read then an {@link IllegalBlockingModeException} will be thrown. The
@@ -495,7 +501,7 @@
*
* @param minBufferCap
* The minimum capacity of the internal byte buffer,
- * or <tt>-1</tt> if an implementation-dependent
+ * or {@code -1} if an implementation-dependent
* default capacity is to be used
*
* @return A new reader
@@ -504,7 +510,7 @@
CharsetDecoder dec,
int minBufferCap)
{
- checkNotNull(ch, "ch");
+ Objects.requireNonNull(ch, "ch");
return StreamDecoder.forDecoder(ch, dec.reset(), minBufferCap);
}
@@ -514,16 +520,15 @@
*
* <p> An invocation of this method of the form
*
- * <blockquote><pre>
- * Channels.newReader(ch, csname)</pre></blockquote>
+ * <pre> {@code
+ * Channels.newReader(ch, csname)
+ * } </pre>
*
* behaves in exactly the same way as the expression
*
- * <blockquote><pre>
- * Channels.newReader(ch,
- * Charset.forName(csName)
- * .newDecoder(),
- * -1);</pre></blockquote>
+ * <pre> {@code
+ * Channels.newReader(ch, Charset.forName(csName))
+ * } </pre>
*
* @param ch
* The channel from which bytes will be read
@@ -540,16 +545,48 @@
public static Reader newReader(ReadableByteChannel ch,
String csName)
{
- checkNotNull(csName, "csName");
+ Objects.requireNonNull(csName, "csName");
return newReader(ch, Charset.forName(csName).newDecoder(), -1);
}
/**
+ * Constructs a reader that decodes bytes from the given channel according
+ * to the given charset.
+ *
+ * <p> An invocation of this method of the form
+ *
+ * <pre> {@code
+ * Channels.newReader(ch, charset)
+ * } </pre>
+ *
+ * behaves in exactly the same way as the expression
+ *
+ * <pre> {@code
+ * Channels.newReader(ch, Charset.forName(csName).newDecoder(), -1)
+ * } </pre>
+ *
+ * <p> The reader's default action for malformed-input and unmappable-character
+ * errors is to {@linkplain java.nio.charset.CodingErrorAction#REPORT report}
+ * them. When more control over the error handling is required, the constructor
+ * that takes a {@linkplain java.nio.charset.CharsetDecoder} should be used.
+ *
+ * @param ch The channel from which bytes will be read
+ *
+ * @param charset The charset to be used
+ *
+ * @return A new reader
+ */
+ public static Reader newReader(ReadableByteChannel ch, Charset charset) {
+ Objects.requireNonNull(charset, "charset");
+ return newReader(ch, charset.newDecoder(), -1);
+ }
+
+ /**
* Constructs a writer that encodes characters using the given encoder and
* writes the resulting bytes to the given channel.
*
* <p> The resulting stream will contain an internal output buffer of at
- * least <tt>minBufferCap</tt> bytes. The stream's <tt>write</tt> methods
+ * least {@code minBufferCap} bytes. The stream's {@code write} methods
* will, as needed, flush the buffer by writing bytes to the underlying
* channel; if the channel is in non-blocking mode when bytes are to be
* written then an {@link IllegalBlockingModeException} will be thrown.
@@ -564,16 +601,16 @@
*
* @param minBufferCap
* The minimum capacity of the internal byte buffer,
- * or <tt>-1</tt> if an implementation-dependent
+ * or {@code -1} if an implementation-dependent
* default capacity is to be used
*
* @return A new writer
*/
- public static Writer newWriter(final WritableByteChannel ch,
- final CharsetEncoder enc,
- final int minBufferCap)
+ public static Writer newWriter(WritableByteChannel ch,
+ CharsetEncoder enc,
+ int minBufferCap)
{
- checkNotNull(ch, "ch");
+ Objects.requireNonNull(ch, "ch");
return StreamEncoder.forEncoder(ch, enc.reset(), minBufferCap);
}
@@ -583,16 +620,15 @@
*
* <p> An invocation of this method of the form
*
- * <blockquote><pre>
- * Channels.newWriter(ch, csname)</pre></blockquote>
+ * <pre> {@code
+ * Channels.newWriter(ch, csname)
+ * } </pre>
*
* behaves in exactly the same way as the expression
*
- * <blockquote><pre>
- * Channels.newWriter(ch,
- * Charset.forName(csName)
- * .newEncoder(),
- * -1);</pre></blockquote>
+ * <pre> {@code
+ * Channels.newWriter(ch, Charset.forName(csName))
+ * } </pre>
*
* @param ch
* The channel to which bytes will be written
@@ -609,7 +645,41 @@
public static Writer newWriter(WritableByteChannel ch,
String csName)
{
- checkNotNull(csName, "csName");
+ Objects.requireNonNull(csName, "csName");
return newWriter(ch, Charset.forName(csName).newEncoder(), -1);
}
+
+ /**
+ * Constructs a writer that encodes characters according to the given
+ * charset and writes the resulting bytes to the given channel.
+ *
+ * <p> An invocation of this method of the form
+ *
+ * <pre> {@code
+ * Channels.newWriter(ch, charset)
+ * } </pre>
+ *
+ * behaves in exactly the same way as the expression
+ *
+ * <pre> {@code
+ * Channels.newWriter(ch, Charset.forName(csName).newEncoder(), -1)
+ * } </pre>
+ *
+ * <p> The writer's default action for malformed-input and unmappable-character
+ * errors is to {@linkplain java.nio.charset.CodingErrorAction#REPORT report}
+ * them. When more control over the error handling is required, the constructor
+ * that takes a {@linkplain java.nio.charset.CharsetEncoder} should be used.
+ *
+ * @param ch
+ * The channel to which bytes will be written
+ *
+ * @param charset
+ * The charset to be used
+ *
+ * @return A new writer
+ */
+ public static Writer newWriter(WritableByteChannel ch, Charset charset) {
+ Objects.requireNonNull(charset, "charset");
+ return newWriter(ch, charset.newEncoder(), -1);
+}
}
diff --git a/ojluni/src/main/java/java/nio/channels/DatagramChannel.java b/ojluni/src/main/java/java/nio/channels/DatagramChannel.java
index b85c98c..c555c1e 100644
--- a/ojluni/src/main/java/java/nio/channels/DatagramChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/DatagramChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -57,46 +57,51 @@
* setOption} method. A datagram channel to an Internet Protocol socket supports
* the following options:
* <blockquote>
- * <table border summary="Socket options">
+ * <table class="striped">
+ * <caption style="display:none">Socket options</caption>
+ * <thead>
* <tr>
- * <th>Option Name</th>
- * <th>Description</th>
+ * <th scope="col">Option Name</th>
+ * <th scope="col">Description</th>
* </tr>
+ * </thead>
+ * <tbody>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} </th>
* <td> The size of the socket send buffer </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </th>
* <td> The size of the socket receive buffer </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </th>
* <td> Re-use address </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_BROADCAST SO_BROADCAST} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_BROADCAST SO_BROADCAST} </th>
* <td> Allow transmission of broadcast datagrams </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#IP_TOS IP_TOS} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#IP_TOS IP_TOS} </th>
* <td> The Type of Service (ToS) octet in the Internet Protocol (IP) header </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#IP_MULTICAST_IF IP_MULTICAST_IF} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#IP_MULTICAST_IF IP_MULTICAST_IF} </th>
* <td> The network interface for Internet Protocol (IP) multicast datagrams </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#IP_MULTICAST_TTL
- * IP_MULTICAST_TTL} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#IP_MULTICAST_TTL
+ * IP_MULTICAST_TTL} </th>
* <td> The <em>time-to-live</em> for Internet Protocol (IP) multicast
* datagrams </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#IP_MULTICAST_LOOP
- * IP_MULTICAST_LOOP} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#IP_MULTICAST_LOOP
+ * IP_MULTICAST_LOOP} </th>
* <td> Loopback for Internet Protocol (IP) multicast datagrams </td>
* </tr>
+ * </tbody>
* </table>
* </blockquote>
* Additional (implementation specific) options may also be supported.
@@ -187,8 +192,8 @@
* operations.
*
* <p> Datagram channels support reading and writing, so this method
- * returns <tt>(</tt>{@link SelectionKey#OP_READ} <tt>|</tt> {@link
- * SelectionKey#OP_WRITE}<tt>)</tt>. </p>
+ * returns {@code (}{@link SelectionKey#OP_READ} {@code |} {@link
+ * SelectionKey#OP_WRITE}{@code )}.
*
* @return The valid-operation set
*/
@@ -274,6 +279,9 @@
*
* @return This datagram channel
*
+ * @throws AlreadyConnectedException
+ * If this channel is already connected
+ *
* @throws ClosedChannelException
* If this channel is closed
*
@@ -287,6 +295,12 @@
* closing the channel and setting the current thread's
* interrupt status
*
+ * @throws UnresolvedAddressException
+ * If the given remote address is not fully resolved
+ *
+ * @throws UnsupportedAddressTypeException
+ * If the type of the given remote address is not supported
+ *
* @throws SecurityException
* If a security manager has been installed
* and it does not permit access to the given remote address
@@ -341,7 +355,7 @@
* copied into the given byte buffer and its source address is returned.
* If this channel is in non-blocking mode and a datagram is not
* immediately available then this method immediately returns
- * <tt>null</tt>.
+ * {@code null}.
*
* <p> The datagram is transferred into the given byte buffer starting at
* its current position, as if by a regular {@link
@@ -371,7 +385,7 @@
* The buffer into which the datagram is to be transferred
*
* @return The datagram's source address,
- * or <tt>null</tt> if this channel is in non-blocking mode
+ * or {@code null} if this channel is in non-blocking mode
* and no datagram was immediately available
*
* @throws ClosedChannelException
@@ -439,6 +453,10 @@
* zero if there was insufficient room for the datagram in the
* underlying output buffer
*
+ * @throws AlreadyConnectedException
+ * If this channel is connected to a different address
+ * from that specified by {@code target}
+ *
* @throws ClosedChannelException
* If this channel is closed
*
@@ -452,6 +470,12 @@
* closing the channel and setting the current thread's
* interrupt status
*
+ * @throws UnresolvedAddressException
+ * If the given remote address is not fully resolved
+ *
+ * @throws UnsupportedAddressTypeException
+ * If the type of the given remote address is not supported
+ *
* @throws SecurityException
* If a security manager has been installed
* and it does not permit datagrams to be sent
diff --git a/ojluni/src/main/java/java/nio/channels/FileChannel.java b/ojluni/src/main/java/java/nio/channels/FileChannel.java
index a23f1c3..055cbfc 100644
--- a/ojluni/src/main/java/java/nio/channels/FileChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/FileChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -63,7 +63,7 @@
*
* <li><p> A region of a file may be {@link #map <i>mapped</i>}
* directly into memory; for large files this is often much more efficient
- * than invoking the usual <tt>read</tt> or <tt>write</tt> methods.
+ * than invoking the usual {@code read} or {@code write} methods.
* </p></li>
*
* <li><p> Updates made to a file may be {@link #force <i>forced
@@ -107,10 +107,10 @@
* existing {@link java.io.FileInputStream#getChannel FileInputStream}, {@link
* java.io.FileOutputStream#getChannel FileOutputStream}, or {@link
* java.io.RandomAccessFile#getChannel RandomAccessFile} object by invoking
- * that object's <tt>getChannel</tt> method, which returns a file channel that
+ * that object's {@code getChannel} method, which returns a file channel that
* is connected to the same underlying file. Where the file channel is obtained
* from an existing stream or random access file then the state of the file
- * channel is intimately connected to that of the object whose <tt>getChannel</tt>
+ * channel is intimately connected to that of the object whose {@code getChannel}
* method returned the channel. Changing the channel's position, whether
* explicitly or by reading or writing bytes, will change the file position of
* the originating object, and vice versa. Changing the file's length via the
@@ -118,7 +118,7 @@
* versa. Changing the file's content by writing bytes will change the content
* seen by the originating object, and vice versa.
*
- * <a name="open-mode"></a> <p> At various points this class specifies that an
+ * <a id="open-mode"></a> <p> At various points this class specifies that an
* instance that is "open for reading," "open for writing," or "open for
* reading and writing" is required. A channel obtained via the {@link
* java.io.FileInputStream#getChannel getChannel} method of a {@link
@@ -128,14 +128,14 @@
* writing. Finally, a channel obtained via the {@link
* java.io.RandomAccessFile#getChannel getChannel} method of a {@link
* java.io.RandomAccessFile} instance will be open for reading if the instance
- * was created with mode <tt>"r"</tt> and will be open for reading and writing
- * if the instance was created with mode <tt>"rw"</tt>.
+ * was created with mode {@code "r"} and will be open for reading and writing
+ * if the instance was created with mode {@code "rw"}.
*
- * <a name="append-mode"></a><p> A file channel that is open for writing may be in
+ * <a id="append-mode"></a><p> A file channel that is open for writing may be in
* <i>append mode</i>, for example if it was obtained from a file-output stream
* that was created by invoking the {@link
* java.io.FileOutputStream#FileOutputStream(java.io.File,boolean)
- * FileOutputStream(File,boolean)} constructor and passing <tt>true</tt> for
+ * FileOutputStream(File,boolean)} constructor and passing {@code true} for
* the second parameter. In this mode each invocation of a relative write
* operation first advances the position to the end of the file and then writes
* the requested data. Whether the advancement of the position and the writing
@@ -174,10 +174,14 @@
* <p> In the addition to {@code READ} and {@code WRITE}, the following
* options may be present:
*
- * <table border=1 cellpadding=5 summary="">
- * <tr> <th>Option</th> <th>Description</th> </tr>
+ * <table class="striped">
+ * <caption style="display:none">additional options</caption>
+ * <thead>
+ * <tr> <th scope="col">Option</th> <th scope="col">Description</th> </tr>
+ * </thead>
+ * <tbody>
* <tr>
- * <td> {@link StandardOpenOption#APPEND APPEND} </td>
+ * <th scope="row"> {@link StandardOpenOption#APPEND APPEND} </th>
* <td> If this option is present then the file is opened for writing and
* each invocation of the channel's {@code write} method first advances
* the position to the end of the file and then writes the requested
@@ -187,13 +191,13 @@
* with the {@code READ} or {@code TRUNCATE_EXISTING} options. </td>
* </tr>
* <tr>
- * <td> {@link StandardOpenOption#TRUNCATE_EXISTING TRUNCATE_EXISTING} </td>
+ * <th scope="row"> {@link StandardOpenOption#TRUNCATE_EXISTING TRUNCATE_EXISTING} </th>
* <td> If this option is present then the existing file is truncated to
* a size of 0 bytes. This option is ignored when the file is opened only
* for reading. </td>
* </tr>
* <tr>
- * <td> {@link StandardOpenOption#CREATE_NEW CREATE_NEW} </td>
+ * <th scope="row"> {@link StandardOpenOption#CREATE_NEW CREATE_NEW} </th>
* <td> If this option is present then a new file is created, failing if
* the file already exists. When creating a file the check for the
* existence of the file and the creation of the file if it does not exist
@@ -201,7 +205,7 @@
* ignored when the file is opened only for reading. </td>
* </tr>
* <tr>
- * <td > {@link StandardOpenOption#CREATE CREATE} </td>
+ * <th scope="row" > {@link StandardOpenOption#CREATE CREATE} </th>
* <td> If this option is present then an existing file is opened if it
* exists, otherwise a new file is created. When creating a file the check
* for the existence of the file and the creation of the file if it does
@@ -210,33 +214,34 @@
* the file is opened only for reading. </td>
* </tr>
* <tr>
- * <td > {@link StandardOpenOption#DELETE_ON_CLOSE DELETE_ON_CLOSE} </td>
+ * <th scope="row" > {@link StandardOpenOption#DELETE_ON_CLOSE DELETE_ON_CLOSE} </th>
* <td> When this option is present then the implementation makes a
- * <em>best effort</em> attempt to delete the file when closed by the
+ * <em>best effort</em> attempt to delete the file when closed by
* the {@link #close close} method. If the {@code close} method is not
* invoked then a <em>best effort</em> attempt is made to delete the file
* when the Java virtual machine terminates. </td>
* </tr>
* <tr>
- * <td>{@link StandardOpenOption#SPARSE SPARSE} </td>
+ * <th scope="row">{@link StandardOpenOption#SPARSE SPARSE} </th>
* <td> When creating a new file this option is a <em>hint</em> that the
* new file will be sparse. This option is ignored when not creating
* a new file. </td>
* </tr>
* <tr>
- * <td> {@link StandardOpenOption#SYNC SYNC} </td>
+ * <th scope="row"> {@link StandardOpenOption#SYNC SYNC} </th>
* <td> Requires that every update to the file's content or metadata be
* written synchronously to the underlying storage device. (see <a
* href="../file/package-summary.html#integrity"> Synchronized I/O file
* integrity</a>). </td>
* </tr>
* <tr>
- * <td> {@link StandardOpenOption#DSYNC DSYNC} </td>
+ * <th scope="row"> {@link StandardOpenOption#DSYNC DSYNC} </th>
* <td> Requires that every update to the file's content be written
* synchronously to the underlying storage device. (see <a
* href="../file/package-summary.html#integrity"> Synchronized I/O file
* integrity</a>). </td>
* </tr>
+ * </tbody>
* </table>
*
* <p> An implementation may also support additional options.
@@ -330,8 +335,13 @@
public static FileChannel open(Path path, OpenOption... options)
throws IOException
{
- Set<OpenOption> set = new HashSet<OpenOption>(options.length);
- Collections.addAll(set, options);
+ Set<OpenOption> set;
+ if (options.length == 0) {
+ set = Collections.emptySet();
+ } else {
+ set = new HashSet<>();
+ Collections.addAll(set, options);
+ }
return open(path, set, NO_ATTRIBUTES);
}
@@ -516,10 +526,10 @@
* <p> If the file does not reside on a local device then no such guarantee
* is made.
*
- * <p> The <tt>metaData</tt> parameter can be used to limit the number of
+ * <p> The {@code metaData} parameter can be used to limit the number of
* I/O operations that this method is required to perform. Passing
- * <tt>false</tt> for this parameter indicates that only updates to the
- * file's content need be written to storage; passing <tt>true</tt>
+ * {@code false} for this parameter indicates that only updates to the
+ * file's content need be written to storage; passing {@code true}
* indicates that updates to both the file's content and metadata must be
* written, which generally requires at least one more I/O operation.
* Whether this parameter actually has any effect is dependent upon the
@@ -540,7 +550,7 @@
* force changes made to the buffer's content to be written. </p>
*
* @param metaData
- * If <tt>true</tt> then this method is required to force changes
+ * If {@code true} then this method is required to force changes
* to both the file's content and metadata to be written to
* storage; otherwise, it need only force content changes to be
* written
@@ -557,14 +567,14 @@
* Transfers bytes from this channel's file to the given writable byte
* channel.
*
- * <p> An attempt is made to read up to <tt>count</tt> bytes starting at
- * the given <tt>position</tt> in this channel's file and write them to the
+ * <p> An attempt is made to read up to {@code count} bytes starting at
+ * the given {@code position} in this channel's file and write them to the
* target channel. An invocation of this method may or may not transfer
* all of the requested bytes; whether or not it does so depends upon the
* natures and states of the channels. Fewer than the requested number of
* bytes are transferred if this channel's file contains fewer than
- * <tt>count</tt> bytes starting at the given <tt>position</tt>, or if the
- * target channel is non-blocking and it has fewer than <tt>count</tt>
+ * {@code count} bytes starting at the given {@code position}, or if the
+ * target channel is non-blocking and it has fewer than {@code count}
* bytes free in its output buffer.
*
* <p> This method does not modify this channel's position. If the given
@@ -624,14 +634,14 @@
* Transfers bytes into this channel's file from the given readable byte
* channel.
*
- * <p> An attempt is made to read up to <tt>count</tt> bytes from the
+ * <p> An attempt is made to read up to {@code count} bytes from the
* source channel and write them to this channel's file starting at the
- * given <tt>position</tt>. An invocation of this method may or may not
+ * given {@code position}. An invocation of this method may or may not
* transfer all of the requested bytes; whether or not it does so depends
* upon the natures and states of the channels. Fewer than the requested
* number of bytes will be transferred if the source channel has fewer than
- * <tt>count</tt> bytes remaining, or if the source channel is non-blocking
- * and has fewer than <tt>count</tt> bytes immediately available in its
+ * {@code count} bytes remaining, or if the source channel is non-blocking
+ * and has fewer than {@code count} bytes immediately available in its
* input buffer.
*
* <p> This method does not modify this channel's position. If the given
@@ -704,7 +714,7 @@
* The file position at which the transfer is to begin;
* must be non-negative
*
- * @return The number of bytes read, possibly zero, or <tt>-1</tt> if the
+ * @return The number of bytes read, possibly zero, or {@code -1} if the
* given position is greater than or equal to the file's current
* size
*
@@ -855,7 +865,7 @@
*
* <p> The {@link MappedByteBuffer <i>mapped byte buffer</i>}
* returned by this method will have a position of zero and a limit and
- * capacity of <tt>size</tt>; its mark will be undefined. The buffer and
+ * capacity of {@code size}; its mark will be undefined. The buffer and
* the mapping that it represents will remain valid until the buffer itself
* is garbage-collected.
*
@@ -895,11 +905,11 @@
* @return The mapped byte buffer
*
* @throws NonReadableChannelException
- * If the <tt>mode</tt> is {@link MapMode#READ_ONLY READ_ONLY} but
+ * If the {@code mode} is {@link MapMode#READ_ONLY READ_ONLY} but
* this channel was not opened for reading
*
* @throws NonWritableChannelException
- * If the <tt>mode</tt> is {@link MapMode#READ_WRITE READ_WRITE} or
+ * If the {@code mode} is {@link MapMode#READ_WRITE READ_WRITE} or
* {@link MapMode#PRIVATE PRIVATE} but this channel was not opened
* for both reading and writing
*
@@ -936,7 +946,7 @@
* will be thrown immediately; the thread's interrupt status will not be
* changed.
*
- * <p> The region specified by the <tt>position</tt> and <tt>size</tt>
+ * <p> The region specified by the {@code position} and {@code size}
* parameters need not be contained within, or even overlap, the actual
* underlying file. Lock regions are fixed in size; if a locked region
* initially contains the end of the file and the file grows beyond the
@@ -963,12 +973,12 @@
*
* @param size
* The size of the locked region; must be non-negative, and the sum
- * <tt>position</tt> + <tt>size</tt> must be non-negative
+ * {@code position} + {@code size} must be non-negative
*
* @param shared
- * <tt>true</tt> to request a shared lock, in which case this
+ * {@code true} to request a shared lock, in which case this
* channel must be open for reading (and possibly writing);
- * <tt>false</tt> to request an exclusive lock, in which case this
+ * {@code false} to request an exclusive lock, in which case this
* channel must be open for writing (and possibly reading)
*
* @return A lock object representing the newly-acquired lock
@@ -994,11 +1004,11 @@
* region
*
* @throws NonReadableChannelException
- * If <tt>shared</tt> is <tt>true</tt> this channel was not
+ * If {@code shared} is {@code true} this channel was not
* opened for reading
*
* @throws NonWritableChannelException
- * If <tt>shared</tt> is <tt>false</tt> but this channel was not
+ * If {@code shared} is {@code false} but this channel was not
* opened for writing
*
* @throws IOException
@@ -1014,7 +1024,7 @@
/**
* Acquires an exclusive lock on this channel's file.
*
- * <p> An invocation of this method of the form <tt>fc.lock()</tt> behaves
+ * <p> An invocation of this method of the form {@code fc.lock()} behaves
* in exactly the same way as the invocation
*
* <pre>
@@ -1060,10 +1070,10 @@
* immediately, either having acquired a lock on the requested region or
* having failed to do so. If it fails to acquire a lock because an
* overlapping lock is held by another program then it returns
- * <tt>null</tt>. If it fails to acquire a lock for any other reason then
+ * {@code null}. If it fails to acquire a lock for any other reason then
* an appropriate exception is thrown.
*
- * <p> The region specified by the <tt>position</tt> and <tt>size</tt>
+ * <p> The region specified by the {@code position} and {@code size}
* parameters need not be contained within, or even overlap, the actual
* underlying file. Lock regions are fixed in size; if a locked region
* initially contains the end of the file and the file grows beyond the
@@ -1090,14 +1100,14 @@
*
* @param size
* The size of the locked region; must be non-negative, and the sum
- * <tt>position</tt> + <tt>size</tt> must be non-negative
+ * {@code position} + {@code size} must be non-negative
*
* @param shared
- * <tt>true</tt> to request a shared lock,
- * <tt>false</tt> to request an exclusive lock
+ * {@code true} to request a shared lock,
+ * {@code false} to request an exclusive lock
*
* @return A lock object representing the newly-acquired lock,
- * or <tt>null</tt> if the lock could not be acquired
+ * or {@code null} if the lock could not be acquired
* because another program holds an overlapping lock
*
* @throws IllegalArgumentException
@@ -1125,14 +1135,14 @@
/**
* Attempts to acquire an exclusive lock on this channel's file.
*
- * <p> An invocation of this method of the form <tt>fc.tryLock()</tt>
+ * <p> An invocation of this method of the form {@code fc.tryLock()}
* behaves in exactly the same way as the invocation
*
* <pre>
* fc.{@link #tryLock(long,long,boolean) tryLock}(0L, Long.MAX_VALUE, false) </pre>
*
* @return A lock object representing the newly-acquired lock,
- * or <tt>null</tt> if the lock could not be acquired
+ * or {@code null} if the lock could not be acquired
* because another program holds an overlapping lock
*
* @throws ClosedChannelException
diff --git a/ojluni/src/main/java/java/nio/channels/FileLock.java b/ojluni/src/main/java/java/nio/channels/FileLock.java
index 156071c..0edd94d 100644
--- a/ojluni/src/main/java/java/nio/channels/FileLock.java
+++ b/ojluni/src/main/java/java/nio/channels/FileLock.java
@@ -26,6 +26,7 @@
package java.nio.channels;
import java.io.IOException;
+import java.util.Objects;
/**
* A token representing a lock on a region of a file.
@@ -72,7 +73,7 @@
* <p> File-lock objects are safe for use by multiple concurrent threads.
*
*
- * <a name="pdep"></a><h2> Platform dependencies </h2>
+ * <a id="pdep"></a><h2> Platform dependencies </h2>
*
* <p> This file-locking API is intended to map directly to the native locking
* facility of the underlying operating system. Thus the locks held on a file
@@ -135,11 +136,11 @@
*
* @param size
* The size of the locked region; must be non-negative, and the sum
- * <tt>position</tt> + <tt>size</tt> must be non-negative
+ * {@code position} + {@code size} must be non-negative
*
* @param shared
- * <tt>true</tt> if this lock is shared,
- * <tt>false</tt> if it is exclusive
+ * {@code true} if this lock is shared,
+ * {@code false} if it is exclusive
*
* @throws IllegalArgumentException
* If the preconditions on the parameters do not hold
@@ -147,6 +148,7 @@
protected FileLock(FileChannel channel,
long position, long size, boolean shared)
{
+ Objects.requireNonNull(channel, "Null channel");
if (position < 0)
throw new IllegalArgumentException("Negative position");
if (size < 0)
@@ -171,11 +173,11 @@
*
* @param size
* The size of the locked region; must be non-negative, and the sum
- * <tt>position</tt> + <tt>size</tt> must be non-negative
+ * {@code position} + {@code size} must be non-negative
*
* @param shared
- * <tt>true</tt> if this lock is shared,
- * <tt>false</tt> if it is exclusive
+ * {@code true} if this lock is shared,
+ * {@code false} if it is exclusive
*
* @throws IllegalArgumentException
* If the preconditions on the parameters do not hold
@@ -185,6 +187,7 @@
protected FileLock(AsynchronousFileChannel channel,
long position, long size, boolean shared)
{
+ Objects.requireNonNull(channel, "Null channel");
if (position < 0)
throw new IllegalArgumentException("Negative position");
if (size < 0)
@@ -251,8 +254,8 @@
/**
* Tells whether this lock is shared.
*
- * @return <tt>true</tt> if lock is shared,
- * <tt>false</tt> if it is exclusive
+ * @return {@code true} if lock is shared,
+ * {@code false} if it is exclusive
*/
public final boolean isShared() {
return shared;
@@ -266,7 +269,7 @@
* @param size
* The size of the lock range
*
- * @return <tt>true</tt> if, and only if, this lock and the given lock
+ * @return {@code true} if, and only if, this lock and the given lock
* range overlap by at least one byte
*/
public final boolean overlaps(long position, long size) {
@@ -283,7 +286,7 @@
* <p> A lock object remains valid until it is released or the associated
* file channel is closed, whichever comes first. </p>
*
- * @return <tt>true</tt> if, and only if, this lock is valid
+ * @return {@code true} if, and only if, this lock is valid
*/
public abstract boolean isValid();
diff --git a/ojluni/src/main/java/java/nio/channels/GatheringByteChannel.java b/ojluni/src/main/java/java/nio/channels/GatheringByteChannel.java
index 9c50d93..f2ae40e 100644
--- a/ojluni/src/main/java/java/nio/channels/GatheringByteChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/GatheringByteChannel.java
@@ -66,11 +66,11 @@
* at the moment that this method is invoked.
*
* <p> Suppose that a byte sequence of length <i>n</i> is written, where
- * <tt>0</tt> <tt><=</tt> <i>n</i> <tt><=</tt> <i>r</i>.
- * Up to the first <tt>srcs[offset].remaining()</tt> bytes of this sequence
- * are written from buffer <tt>srcs[offset]</tt>, up to the next
- * <tt>srcs[offset+1].remaining()</tt> bytes are written from buffer
- * <tt>srcs[offset+1]</tt>, and so forth, until the entire byte sequence is
+ * {@code 0} {@code <=} <i>n</i> {@code <=} <i>r</i>.
+ * Up to the first {@code srcs[offset].remaining()} bytes of this sequence
+ * are written from buffer {@code srcs[offset]}, up to the next
+ * {@code srcs[offset+1].remaining()} bytes are written from buffer
+ * {@code srcs[offset+1]}, and so forth, until the entire byte sequence is
* written. As many bytes as possible are written from each buffer, hence
* the final position of each updated buffer, except the last updated
* buffer, is guaranteed to be equal to that buffer's limit.
@@ -92,17 +92,17 @@
* @param offset
* The offset within the buffer array of the first buffer from
* which bytes are to be retrieved; must be non-negative and no
- * larger than <tt>srcs.length</tt>
+ * larger than {@code srcs.length}
*
* @param length
* The maximum number of buffers to be accessed; must be
* non-negative and no larger than
- * <tt>srcs.length</tt> - <tt>offset</tt>
+ * {@code srcs.length} - {@code offset}
*
* @return The number of bytes written, possibly zero
*
* @throws IndexOutOfBoundsException
- * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * If the preconditions on the {@code offset} and {@code length}
* parameters do not hold
*
* @throws NonWritableChannelException
@@ -131,7 +131,7 @@
/**
* Writes a sequence of bytes to this channel from the given buffers.
*
- * <p> An invocation of this method of the form <tt>c.write(srcs)</tt>
+ * <p> An invocation of this method of the form {@code c.write(srcs)}
* behaves in exactly the same manner as the invocation
*
* <blockquote><pre>
diff --git a/ojluni/src/main/java/java/nio/channels/InterruptibleChannel.java b/ojluni/src/main/java/java/nio/channels/InterruptibleChannel.java
index 0e49aa6..d13a37a 100644
--- a/ojluni/src/main/java/java/nio/channels/InterruptibleChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/InterruptibleChannel.java
@@ -54,7 +54,7 @@
*
* <p> A channel supports asynchronous closing and interruption if, and only
* if, it implements this interface. This can be tested at runtime, if
- * necessary, via the <tt>instanceof</tt> operator.
+ * necessary, via the {@code instanceof} operator.
*
*
* @author Mark Reinhold
diff --git a/ojluni/src/main/java/java/nio/channels/MulticastChannel.java b/ojluni/src/main/java/java/nio/channels/MulticastChannel.java
index d1d13eb..f42cb8b 100644
--- a/ojluni/src/main/java/java/nio/channels/MulticastChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/MulticastChannel.java
@@ -40,10 +40,11 @@
* address.
*
* <p> In the case of a channel to an {@link StandardProtocolFamily#INET IPv4} socket,
- * the underlying operating system supports <a href="http://www.ietf.org/rfc/rfc2236.txt">
- * <i>RFC 2236: Internet Group Management Protocol, Version 2 (IGMPv2)</i></a>.
- * It may optionally support source filtering as specified by <a
- * href="http://www.ietf.org/rfc/rfc3376.txt"> <i>RFC 3376: Internet Group
+ * the underlying operating system optionally supports
+ * <a href="http://www.ietf.org/rfc/rfc2236.txt"> <i>RFC 2236: Internet Group
+ * Management Protocol, Version 2 (IGMPv2)</i></a>. When IGMPv2 is supported then
+ * the operating system may additionally support source filtering as specified by
+ * <a href="http://www.ietf.org/rfc/rfc3376.txt"> <i>RFC 3376: Internet Group
* Management Protocol, Version 3 (IGMPv3)</i></a>.
* For channels to an {@link StandardProtocolFamily#INET6 IPv6} socket, the equivalent
* standards are <a href="http://www.ietf.org/rfc/rfc2710.txt"> <i>RFC 2710:
@@ -167,7 +168,8 @@
* If the channel already has source-specific membership of the
* group on the interface
* @throws UnsupportedOperationException
- * If the channel's socket is not an Internet Protocol socket
+ * If the channel's socket is not an Internet Protocol socket, or
+ * the platform does not support multicasting
* @throws ClosedChannelException
* If this channel is closed
* @throws IOException
@@ -214,8 +216,9 @@
* If the channel is currently a member of the group on the given
* interface to receive all datagrams
* @throws UnsupportedOperationException
- * If the channel's socket is not an Internet Protocol socket or
- * source filtering is not supported
+ * If the channel's socket is not an Internet Protocol socket, or
+ * source filtering is not supported, or the platform does not
+ * support multicasting
* @throws ClosedChannelException
* If this channel is closed
* @throws IOException
diff --git a/ojluni/src/main/java/java/nio/channels/Pipe.java b/ojluni/src/main/java/java/nio/channels/Pipe.java
index d704680..b9a9b25 100644
--- a/ojluni/src/main/java/java/nio/channels/Pipe.java
+++ b/ojluni/src/main/java/java/nio/channels/Pipe.java
@@ -35,7 +35,7 @@
* <p> A pipe consists of a pair of channels: A writable {@link
* Pipe.SinkChannel sink} channel and a readable {@link Pipe.SourceChannel source}
* channel. Once some bytes are written to the sink channel they can be read
- * from source channel in exactlyAthe order in which they were written.
+ * from the source channel in exactly the order in which they were written.
*
* <p> Whether or not a thread writing bytes to a pipe will block until another
* thread reads those bytes, or some previously-written bytes, from the pipe is
@@ -56,7 +56,7 @@
*
* @since 1.4
*/
- public static abstract class SourceChannel
+ public abstract static class SourceChannel
extends AbstractSelectableChannel
implements ReadableByteChannel, ScatteringByteChannel
{
@@ -90,7 +90,7 @@
*
* @since 1.4
*/
- public static abstract class SinkChannel
+ public abstract static class SinkChannel
extends AbstractSelectableChannel
implements WritableByteChannel, GatheringByteChannel
{
diff --git a/ojluni/src/main/java/java/nio/channels/ReadableByteChannel.java b/ojluni/src/main/java/java/nio/channels/ReadableByteChannel.java
index 4cd99c0..83fd12b 100644
--- a/ojluni/src/main/java/java/nio/channels/ReadableByteChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/ReadableByteChannel.java
@@ -52,16 +52,16 @@
*
* <p> An attempt is made to read up to <i>r</i> bytes from the channel,
* where <i>r</i> is the number of bytes remaining in the buffer, that is,
- * <tt>dst.remaining()</tt>, at the moment this method is invoked.
+ * {@code dst.remaining()}, at the moment this method is invoked.
*
* <p> Suppose that a byte sequence of length <i>n</i> is read, where
- * <tt>0</tt> <tt><=</tt> <i>n</i> <tt><=</tt> <i>r</i>.
+ * {@code 0} {@code <=} <i>n</i> {@code <=} <i>r</i>.
* This byte sequence will be transferred into the buffer so that the first
* byte in the sequence is at index <i>p</i> and the last byte is at index
- * <i>p</i> <tt>+</tt> <i>n</i> <tt>-</tt> <tt>1</tt>,
+ * <i>p</i> {@code +} <i>n</i> {@code -} {@code 1},
* where <i>p</i> is the buffer's position at the moment this method is
* invoked. Upon return the buffer's position will be equal to
- * <i>p</i> <tt>+</tt> <i>n</i>; its limit will not have changed.
+ * <i>p</i> {@code +} <i>n</i>; its limit will not have changed.
*
* <p> A read operation might not fill the buffer, and in fact it might not
* read any bytes at all. Whether or not it does so depends upon the
@@ -81,7 +81,7 @@
* @param dst
* The buffer into which bytes are to be transferred
*
- * @return The number of bytes read, possibly zero, or <tt>-1</tt> if the
+ * @return The number of bytes read, possibly zero, or {@code -1} if the
* channel has reached end-of-stream
*
* @throws NonReadableChannelException
diff --git a/ojluni/src/main/java/java/nio/channels/ScatteringByteChannel.java b/ojluni/src/main/java/java/nio/channels/ScatteringByteChannel.java
index 7922909..d449397 100644
--- a/ojluni/src/main/java/java/nio/channels/ScatteringByteChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/ScatteringByteChannel.java
@@ -66,11 +66,11 @@
* at the moment that this method is invoked.
*
* <p> Suppose that a byte sequence of length <i>n</i> is read, where
- * <tt>0</tt> <tt><=</tt> <i>n</i> <tt><=</tt> <i>r</i>.
- * Up to the first <tt>dsts[offset].remaining()</tt> bytes of this sequence
- * are transferred into buffer <tt>dsts[offset]</tt>, up to the next
- * <tt>dsts[offset+1].remaining()</tt> bytes are transferred into buffer
- * <tt>dsts[offset+1]</tt>, and so forth, until the entire byte sequence
+ * {@code 0} {@code <=} <i>n</i> {@code <=} <i>r</i>.
+ * Up to the first {@code dsts[offset].remaining()} bytes of this sequence
+ * are transferred into buffer {@code dsts[offset]}, up to the next
+ * {@code dsts[offset+1].remaining()} bytes are transferred into buffer
+ * {@code dsts[offset+1]}, and so forth, until the entire byte sequence
* is transferred into the given buffers. As many bytes as possible are
* transferred into each buffer, hence the final position of each updated
* buffer, except the last updated buffer, is guaranteed to be equal to
@@ -87,18 +87,18 @@
* @param offset
* The offset within the buffer array of the first buffer into
* which bytes are to be transferred; must be non-negative and no
- * larger than <tt>dsts.length</tt>
+ * larger than {@code dsts.length}
*
* @param length
* The maximum number of buffers to be accessed; must be
* non-negative and no larger than
- * <tt>dsts.length</tt> - <tt>offset</tt>
+ * {@code dsts.length} - {@code offset}
*
* @return The number of bytes read, possibly zero,
- * or <tt>-1</tt> if the channel has reached end-of-stream
+ * or {@code -1} if the channel has reached end-of-stream
*
* @throws IndexOutOfBoundsException
- * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * If the preconditions on the {@code offset} and {@code length}
* parameters do not hold
*
* @throws NonReadableChannelException
@@ -126,7 +126,7 @@
/**
* Reads a sequence of bytes from this channel into the given buffers.
*
- * <p> An invocation of this method of the form <tt>c.read(dsts)</tt>
+ * <p> An invocation of this method of the form {@code c.read(dsts)}
* behaves in exactly the same manner as the invocation
*
* <blockquote><pre>
@@ -136,7 +136,7 @@
* The buffers into which bytes are to be transferred
*
* @return The number of bytes read, possibly zero,
- * or <tt>-1</tt> if the channel has reached end-of-stream
+ * or {@code -1} if the channel has reached end-of-stream
*
* @throws NonReadableChannelException
* If this channel was not opened for reading
diff --git a/ojluni/src/main/java/java/nio/channels/SelectableChannel.java b/ojluni/src/main/java/java/nio/channels/SelectableChannel.java
index 997d5c5..170a449 100644
--- a/ojluni/src/main/java/java/nio/channels/SelectableChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/SelectableChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -64,7 +64,7 @@
* threads. </p>
*
*
- * <a name="bm"></a>
+ * <a id="bm"></a>
* <h2>Blocking mode</h2>
*
* A selectable channel is either in <i>blocking</i> mode or in
@@ -117,12 +117,6 @@
*/
public abstract int validOps();
- // Internal state:
- // keySet, may be empty but is never null, typ. a tiny array
- // boolean isRegistered, protected by key set
- // regLock, lock object to prevent duplicate registrations
- // boolean isBlocking, protected by regLock
-
/**
* Tells whether or not this channel is currently registered with any
* selectors. A newly-created channel is not registered.
@@ -132,11 +126,9 @@
* of its keys have been cancelled. A channel may also remain registered
* for some time after it is closed. </p>
*
- * @return <tt>true</tt> if, and only if, this channel is registered
+ * @return {@code true} if, and only if, this channel is registered
*/
public abstract boolean isRegistered();
- //
- // sync(keySet) { return isRegistered; }
/**
* Retrieves the key representing the channel's registration with the given
@@ -146,12 +138,10 @@
* The selector
*
* @return The key returned when this channel was last registered with the
- * given selector, or <tt>null</tt> if this channel is not
+ * given selector, or {@code null} if this channel is not
* currently registered with that selector
*/
public abstract SelectionKey keyFor(Selector sel);
- //
- // sync(keySet) { return findKey(sel); }
/**
* Registers this channel with the given selector, returning a selection
@@ -159,24 +149,24 @@
*
* <p> If this channel is currently registered with the given selector then
* the selection key representing that registration is returned. The key's
- * interest set will have been changed to <tt>ops</tt>, as if by invoking
+ * interest set will have been changed to {@code ops}, as if by invoking
* the {@link SelectionKey#interestOps(int) interestOps(int)} method. If
- * the <tt>att</tt> argument is not <tt>null</tt> then the key's attachment
+ * the {@code att} argument is not {@code null} then the key's attachment
* will have been set to that value. A {@link CancelledKeyException} will
* be thrown if the key has already been cancelled.
*
* <p> Otherwise this channel has not yet been registered with the given
* selector, so it is registered and the resulting new key is returned.
- * The key's initial interest set will be <tt>ops</tt> and its attachment
- * will be <tt>att</tt>.
+ * The key's initial interest set will be {@code ops} and its attachment
+ * will be {@code att}.
*
* <p> This method may be invoked at any time. If this method is invoked
- * while another invocation of this method or of the {@link
- * #configureBlocking(boolean) configureBlocking} method is in progress
- * then it will first block until the other operation is complete. This
- * method will then synchronize on the selector's key set and therefore may
- * block if invoked concurrently with another registration or selection
- * operation involving the same selector. </p>
+ * while a selection operation is in progress then it has no effect upon
+ * that operation; the new registration or change to the key's interest set
+ * will be seen by the next selection operation. If this method is invoked
+ * while an invocation of {@link #configureBlocking(boolean) configureBlocking}
+ * is in progress then it will block until the channel's blocking mode has
+ * been adjusted.
*
* <p> If this channel is closed while this operation is in progress then
* the key returned by this method will have been cancelled and will
@@ -189,7 +179,7 @@
* The interest set for the resulting key
*
* @param att
- * The attachment for the resulting key; may be <tt>null</tt>
+ * The attachment for the resulting key; may be {@code null}
*
* @throws ClosedChannelException
* If this channel is closed
@@ -209,7 +199,7 @@
* but the corresponding key has already been cancelled
*
* @throws IllegalArgumentException
- * If a bit in the <tt>ops</tt> set does not correspond to an
+ * If a bit in the {@code ops} set does not correspond to an
* operation that is supported by this channel, that is, if
* {@code set & ~validOps() != 0}
*
@@ -218,16 +208,6 @@
*/
public abstract SelectionKey register(Selector sel, int ops, Object att)
throws ClosedChannelException;
- //
- // sync(regLock) {
- // sync(keySet) { look for selector }
- // if (channel found) { set interest ops -- may block in selector;
- // return key; }
- // create new key -- may block somewhere in selector;
- // sync(keySet) { add key; }
- // attach(attachment);
- // return key;
- // }
/**
* Registers this channel with the given selector, returning a selection
@@ -235,13 +215,13 @@
*
* <p> An invocation of this convenience method of the form
*
- * <blockquote><tt>sc.register(sel, ops)</tt></blockquote>
+ * <blockquote>{@code sc.register(sel, ops)}</blockquote>
*
* behaves in exactly the same way as the invocation
*
- * <blockquote><tt>sc.{@link
+ * <blockquote>{@code sc.}{@link
* #register(java.nio.channels.Selector,int,java.lang.Object)
- * register}(sel, ops, null)</tt></blockquote>
+ * register(sel, ops, null)}</blockquote>
*
* @param sel
* The selector with which this channel is to be registered
@@ -267,7 +247,7 @@
* but the corresponding key has already been cancelled
*
* @throws IllegalArgumentException
- * If a bit in <tt>ops</tt> does not correspond to an operation
+ * If a bit in {@code ops} does not correspond to an operation
* that is supported by this channel, that is, if {@code set &
* ~validOps() != 0}
*
@@ -296,8 +276,8 @@
* of the {@link #register(Selector, int) register} method is in progress
* then it will first block until the other operation is complete. </p>
*
- * @param block If <tt>true</tt> then this channel will be placed in
- * blocking mode; if <tt>false</tt> then it will be placed
+ * @param block If {@code true} then this channel will be placed in
+ * blocking mode; if {@code false} then it will be placed
* non-blocking mode
*
* @return This selectable channel
@@ -306,7 +286,7 @@
* If this channel is closed
*
* @throws IllegalBlockingModeException
- * If <tt>block</tt> is <tt>true</tt> and this channel is
+ * If {@code block} is {@code true} and this channel is
* registered with one or more selectors
*
* @throws IOException
@@ -314,11 +294,6 @@
*/
public abstract SelectableChannel configureBlocking(boolean block)
throws IOException;
- //
- // sync(regLock) {
- // sync(keySet) { throw IBME if block && isRegistered; }
- // change mode;
- // }
/**
* Tells whether or not every I/O operation on this channel will block
@@ -327,7 +302,7 @@
* <p> If this channel is closed then the value returned by this method is
* not specified. </p>
*
- * @return <tt>true</tt> if, and only if, this channel is in blocking mode
+ * @return {@code true} if, and only if, this channel is in blocking mode
*/
public abstract boolean isBlocking();
diff --git a/ojluni/src/main/java/java/nio/channels/ServerSocketChannel.java b/ojluni/src/main/java/java/nio/channels/ServerSocketChannel.java
index 8d967b3..2499238 100644
--- a/ojluni/src/main/java/java/nio/channels/ServerSocketChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/ServerSocketChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,19 +46,24 @@
* <p> Socket options are configured using the {@link #setOption(SocketOption,Object)
* setOption} method. Server-socket channels support the following options:
* <blockquote>
- * <table border summary="Socket options">
+ * <table class="striped">
+ * <caption style="display:none">Socket options</caption>
+ * <thead>
* <tr>
- * <th>Option Name</th>
- * <th>Description</th>
+ * <th scope="col">Option Name</th>
+ * <th scope="col">Description</th>
* </tr>
+ * </thead>
+ * <tbody>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </th>
* <td> The size of the socket receive buffer </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </th>
* <td> Re-use address </td>
* </tr>
+ * </tbody>
* </table>
* </blockquote>
* Additional (implementation specific) options may also be supported.
@@ -223,7 +228,7 @@
* Accepts a connection made to this channel's socket.
*
* <p> If this channel is in non-blocking mode then this method will
- * immediately return <tt>null</tt> if there are no pending connections.
+ * immediately return {@code null} if there are no pending connections.
* Otherwise it will block indefinitely until a new connection is available
* or an I/O error occurs.
*
@@ -239,7 +244,7 @@
* java.lang.SecurityManager#checkAccept checkAccept} method. </p>
*
* @return The socket channel for the new connection,
- * or <tt>null</tt> if this channel is in non-blocking mode
+ * or {@code null} if this channel is in non-blocking mode
* and no connection is available to be accepted
*
* @throws ClosedChannelException
diff --git a/ojluni/src/main/java/java/nio/channels/SocketChannel.java b/ojluni/src/main/java/java/nio/channels/SocketChannel.java
index eb13b15..b3b73dd 100644
--- a/ojluni/src/main/java/java/nio/channels/SocketChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/SocketChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,7 @@
* If the input side of a socket is shut down by one thread while another
* thread is blocked in a read operation on the socket's channel, then the read
* operation in the blocked thread will complete without reading any bytes and
- * will return <tt>-1</tt>. If the output side of a socket is shut down by one
+ * will return {@code -1}. If the output side of a socket is shut down by one
* thread while another thread is blocked in a write operation on the socket's
* channel, then the blocked thread will receive an {@link
* AsynchronousCloseException}.
@@ -66,36 +66,41 @@
* <p> Socket options are configured using the {@link #setOption(SocketOption,Object)
* setOption} method. Socket channels support the following options:
* <blockquote>
- * <table border summary="Socket options">
+ * <table class="striped">
+ * <caption style="display:none">Socket options</caption>
+ * <thead>
* <tr>
- * <th>Option Name</th>
- * <th>Description</th>
+ * <th scope="col">Option Name</th>
+ * <th scope="col">Description</th>
* </tr>
+ * </thead>
+ * <tbody>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} </th>
* <td> The size of the socket send buffer </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </th>
* <td> The size of the socket receive buffer </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE} </th>
* <td> Keep connection alive </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </th>
* <td> Re-use address </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#SO_LINGER SO_LINGER} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#SO_LINGER SO_LINGER} </th>
* <td> Linger on close if data is present (when configured in blocking mode
* only) </td>
* </tr>
* <tr>
- * <td> {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY} </td>
+ * <th scope="row"> {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY} </th>
* <td> Disable the Nagle algorithm </td>
* </tr>
+ * </tbody>
* </table>
* </blockquote>
* Additional (implementation specific) options may also be supported.
@@ -150,7 +155,7 @@
*
* <p> This convenience method works as if by invoking the {@link #open()}
* method, invoking the {@link #connect(SocketAddress) connect} method upon
- * the resulting socket channel, passing it <tt>remote</tt>, and then
+ * the resulting socket channel, passing it {@code remote}, and then
* returning that channel. </p>
*
* @param remote
@@ -204,9 +209,9 @@
* operations.
*
* <p> Socket channels support connecting, reading, and writing, so this
- * method returns <tt>(</tt>{@link SelectionKey#OP_CONNECT}
- * <tt>|</tt> {@link SelectionKey#OP_READ} <tt>|</tt> {@link
- * SelectionKey#OP_WRITE}<tt>)</tt>. </p>
+ * method returns {@code (}{@link SelectionKey#OP_CONNECT}
+ * {@code |} {@link SelectionKey#OP_READ} {@code |} {@link
+ * SelectionKey#OP_WRITE}{@code )}.
*
* @return The valid-operation set
*/
@@ -304,7 +309,7 @@
/**
* Tells whether or not this channel's network socket is connected.
*
- * @return <tt>true</tt> if, and only if, this channel's network socket
+ * @return {@code true} if, and only if, this channel's network socket
* is {@link #isOpen open} and connected
*/
public abstract boolean isConnected();
@@ -313,7 +318,7 @@
* Tells whether or not a connection operation is in progress on this
* channel.
*
- * @return <tt>true</tt> if, and only if, a connection operation has been
+ * @return {@code true} if, and only if, a connection operation has been
* initiated on this channel but not yet completed by invoking the
* {@link #finishConnect finishConnect} method
*/
@@ -325,8 +330,8 @@
* <p> If this channel is in non-blocking mode then an invocation of this
* method initiates a non-blocking connection operation. If the connection
* is established immediately, as can happen with a local connection, then
- * this method returns <tt>true</tt>. Otherwise this method returns
- * <tt>false</tt> and the connection operation must later be completed by
+ * this method returns {@code true}. Otherwise this method returns
+ * {@code false} and the connection operation must later be completed by
* invoking the {@link #finishConnect finishConnect} method.
*
* <p> If this channel is in blocking mode then an invocation of this
@@ -349,8 +354,8 @@
* @param remote
* The remote address to which this channel is to be connected
*
- * @return <tt>true</tt> if a connection was established,
- * <tt>false</tt> if this channel is in non-blocking mode
+ * @return {@code true} if a connection was established,
+ * {@code false} if this channel is in non-blocking mode
* and the connection operation is in progress
*
* @throws AlreadyConnectedException
@@ -400,11 +405,11 @@
* {@link java.io.IOException} to be thrown.
*
* <p> If this channel is already connected then this method will not block
- * and will immediately return <tt>true</tt>. If this channel is in
- * non-blocking mode then this method will return <tt>false</tt> if the
+ * and will immediately return {@code true}. If this channel is in
+ * non-blocking mode then this method will return {@code false} if the
* connection process is not yet complete. If this channel is in blocking
* mode then this method will block until the connection either completes
- * or fails, and will always either return <tt>true</tt> or throw a checked
+ * or fails, and will always either return {@code true} or throw a checked
* exception describing the failure.
*
* <p> This method may be invoked at any time. If a read or write
@@ -414,7 +419,7 @@
* invocation of this method throws a checked exception, then the channel
* will be closed. </p>
*
- * @return <tt>true</tt> if, and only if, this channel's socket is now
+ * @return {@code true} if, and only if, this channel's socket is now
* connected
*
* @throws NoConnectionPendingException
diff --git a/ojluni/src/main/java/java/nio/channels/WritableByteChannel.java b/ojluni/src/main/java/java/nio/channels/WritableByteChannel.java
index b2ea065..ef8efa5 100644
--- a/ojluni/src/main/java/java/nio/channels/WritableByteChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/WritableByteChannel.java
@@ -54,16 +54,16 @@
*
* <p> An attempt is made to write up to <i>r</i> bytes to the channel,
* where <i>r</i> is the number of bytes remaining in the buffer, that is,
- * <tt>src.remaining()</tt>, at the moment this method is invoked.
+ * {@code src.remaining()}, at the moment this method is invoked.
*
* <p> Suppose that a byte sequence of length <i>n</i> is written, where
- * <tt>0</tt> <tt><=</tt> <i>n</i> <tt><=</tt> <i>r</i>.
+ * {@code 0} {@code <=} <i>n</i> {@code <=} <i>r</i>.
* This byte sequence will be transferred from the buffer starting at index
* <i>p</i>, where <i>p</i> is the buffer's position at the moment this
* method is invoked; the index of the last byte written will be
- * <i>p</i> <tt>+</tt> <i>n</i> <tt>-</tt> <tt>1</tt>.
+ * <i>p</i> {@code +} <i>n</i> {@code -} {@code 1}.
* Upon return the buffer's position will be equal to
- * <i>p</i> <tt>+</tt> <i>n</i>; its limit will not have changed.
+ * <i>p</i> {@code +} <i>n</i>; its limit will not have changed.
*
* <p> Unless otherwise specified, a write operation will return only after
* writing all of the <i>r</i> requested bytes. Some types of channels,
diff --git a/ojluni/src/main/java/java/nio/channels/package-info.java b/ojluni/src/main/java/java/nio/channels/package-info.java
index 8118347..0dc410d 100644
--- a/ojluni/src/main/java/java/nio/channels/package-info.java
+++ b/ojluni/src/main/java/java/nio/channels/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,35 +28,52 @@
* performing I/O operations, such as files and sockets; defines selectors, for
* multiplexed, non-blocking I/O operations.
*
- * <a name="channels"></a>
+ * <a id="channels"></a>
*
- * <blockquote><table cellspacing=1 cellpadding=0 summary="Lists channels and their descriptions">
- * <tr><th align="left">Channels</th><th align="left">Description</th></tr>
- * <tr><td valign=top><tt><i>{@link java.nio.channels.Channel}</i></tt></td>
+ * <table class="striped" style="text-align:left; margin-left:2em">
+ * <caption style="display:none">Lists channels and their descriptions</caption>
+ * <thead>
+ * <tr><th scope="col">Channels</th>
+ * <th scope="col">Description</th></tr>
+ * </thead>
+ * <tbody>
+ * <tr><th scope="row"><i>{@link java.nio.channels.Channel}</i></th>
* <td>A nexus for I/O operations</td></tr>
- * <tr><td valign=top><tt> <i>{@link java.nio.channels.ReadableByteChannel}</i></tt></td>
+ * <tr><th scope="row">
+ * <span style="padding-left:1em"><i>{@link java.nio.channels.ReadableByteChannel}</i></span></th>
* <td>Can read into a buffer</td></tr>
- * <tr><td valign=top><tt> <i>{@link java.nio.channels.ScatteringByteChannel} </i></tt></td>
- * <td>Can read into a sequence of buffers</td></tr>
- * <tr><td valign=top><tt> <i>{@link java.nio.channels.WritableByteChannel}</i></tt></td>
+ * <tr><th scope="row">
+ * <span style="padding-left:2em"><i>{@link java.nio.channels.ScatteringByteChannel}</i></span></th>
+ * <td>Can read into a sequence of buffers</td></tr>
+ * <tr><th scope="row">
+ * <span style="padding-left:1em"><i>{@link java.nio.channels.WritableByteChannel}</i></span></th>
* <td>Can write from a buffer</td></tr>
- * <tr><td valign=top><tt> <i>{@link java.nio.channels.GatheringByteChannel}</i></tt></td>
- * <td>Can write from a sequence of buffers</td></tr>
- * <tr><td valign=top><tt> <i>{@link java.nio.channels.ByteChannel}</i></tt></td>
- * <td>Can read/write to/from a buffer</td></tr>
- * <tr><td valign=top><tt> <i>{@link java.nio.channels.SeekableByteChannel}</i></tt></td>
- * <td>A {@code ByteChannel} connected to an entity that contains a variable-length sequence of bytes</td></tr>
- * <tr><td valign=top><tt> <i>{@link java.nio.channels.AsynchronousChannel}</i></tt></td>
+ * <tr><th scope="row">
+ * <span style="padding-left:2em"><i>{@link java.nio.channels.GatheringByteChannel}</i></span></th>
+ * <td>Can write from a sequence of buffers</td></tr>
+ * <tr><th scope="row">
+ * <span style="padding-left:1em"><i>{@link java.nio.channels.ByteChannel}</i></span></th>
+ * <td>Can read/write to/from a buffer</td></tr>
+ * <tr><th scope="row">
+ * <span style="padding-left:2em"><i>{@link java.nio.channels.SeekableByteChannel}</i></span></th>
+ * <td>A {@code ByteChannel} connected to an entity that contains a variable-length
+ * sequence of bytes</td></tr>
+ * <tr><th scope="row">
+ * <span style="padding-left:1em"><i>{@link java.nio.channels.AsynchronousChannel}</i></span></th>
* <td>Supports asynchronous I/O operations.</td></tr>
- * <tr><td valign=top><tt> <i>{@link java.nio.channels.AsynchronousByteChannel}</i></tt></td>
+ * <tr><th scope="row">
+ * <span style="padding-left:2em"><i>{@link java.nio.channels.AsynchronousByteChannel}</i></span></th>
* <td>Can read and write bytes asynchronously</td></tr>
- * <tr><td valign=top><tt> <i>{@link java.nio.channels.NetworkChannel}</i></tt></td>
+ * <tr><th scope="row">
+ * <span style="padding-left:1em"><i>{@link java.nio.channels.NetworkChannel}</i></span></th>
* <td>A channel to a network socket</td></tr>
- * <tr><td valign=top><tt> <i>{@link java.nio.channels.MulticastChannel}</i></tt></td>
+ * <tr><th scope="row">
+ * <span style="padding-left:2em"><i>{@link java.nio.channels.MulticastChannel}</i></span></th>
* <td>Can join Internet Protocol (IP) multicast groups</td></tr>
- * <tr><td valign=top><tt>{@link java.nio.channels.Channels}</tt></td>
+ * <tr><th scope="row">{@link java.nio.channels.Channels}</th>
* <td>Utility methods for channel/stream interoperation</td></tr>
- * </table></blockquote>
+ * </tbody>
+ * </table>
*
* <p> A <i>channel</i> represents an open connection to an entity such as a
* hardware device, a file, a network socket, or a program component that is
@@ -99,8 +116,8 @@
* Internet Protocol (IP) multicast groups.
*
* <p> The {@link java.nio.channels.Channels} utility class defines static methods
- * that support the interoperation of the stream classes of the <tt>{@link
- * java.io}</tt> package with the channel classes of this package. An appropriate
+ * that support the interoperation of the stream classes of the {@link
+ * java.io} package with the channel classes of this package. An appropriate
* channel can be constructed from an {@link java.io.InputStream} or an {@link
* java.io.OutputStream}, and conversely an {@link java.io.InputStream} or an
* {@link java.io.OutputStream} can be constructed from a channel. A {@link
@@ -109,15 +126,25 @@
* be constructed that uses a given charset to encode characters into bytes and
* write them to a given writable byte channel.
*
- * <blockquote><table cellspacing=1 cellpadding=0 summary="Lists file channels and their descriptions">
- * <tr><th align="left">File channels</th><th align="left">Description</th></tr>
- * <tr><td valign=top><tt>{@link java.nio.channels.FileChannel}</tt></td>
+ * <table class="striped" style="margin-left:2em; text-align:left">
+ * <caption style="display:none">
+ * Lists file channels and their descriptions</caption>
+ * <thead>
+ * <tr><th scope="col">File channels</th>
+ * <th scope="col">Description</th></tr>
+ * </thead>
+ * <tbody>
+ * <tr><th scope="row">
+ * {@link java.nio.channels.FileChannel}</th>
* <td>Reads, writes, maps, and manipulates files</td></tr>
- * <tr><td valign=top><tt>{@link java.nio.channels.FileLock}</tt></td>
+ * <tr><th scope="row">
+ * {@link java.nio.channels.FileLock}</th>
* <td>A lock on a (region of a) file</td></tr>
- * <tr><td valign=top><tt>{@link java.nio.MappedByteBuffer} </tt></td>
- * <td>A direct byte buffer mapped to a region of a file</td></tr>
- * </table></blockquote>
+ * <tr><th scope="row">
+ * {@link java.nio.MappedByteBuffer}</th>
+ * <td>A direct byte buffer mapped to a region of a file</td></tr>
+ * </tbody>
+ * </table>
*
* <p> The {@link java.nio.channels.FileChannel} class supports the usual
* operations of reading bytes from, and writing bytes to, a channel connected to
@@ -133,32 +160,44 @@
* java.nio.channels.FileChannel#open open} methods, or by invoking the {@code
* getChannel} method of a {@link java.io.FileInputStream}, {@link
* java.io.FileOutputStream}, or {@link java.io.RandomAccessFile} to return a
- * file channel connected to the same underlying file as the <tt>{@link java.io}</tt>
+ * file channel connected to the same underlying file as the {@link java.io}
* class.
*
- * <a name="multiplex"></a>
- * <blockquote><table cellspacing=1 cellpadding=0 summary="Lists multiplexed, non-blocking channels and their descriptions">
- * <tr><th align="left">Multiplexed, non-blocking I/O</th><th align="left"><p>Description</th></tr>
- * <tr><td valign=top><tt>{@link java.nio.channels.SelectableChannel}</tt></td>
+ * <a id="multiplex"></a>
+ * <table class="striped" style="margin-left:2em; text-align:left">
+ * <caption style="display:none">
+ * Lists multiplexed, non-blocking channels and their descriptions</caption>
+ * <thead>
+ * <tr><th scope="col">Multiplexed, non-blocking I/O</th>
+ * <th scope="col">Description</th></tr>
+ * </thead>
+ * <tbody>
+ * <tr><th scope="row">{@link java.nio.channels.SelectableChannel}</th>
* <td>A channel that can be multiplexed</td></tr>
- * <tr><td valign=top><tt> {@link java.nio.channels.DatagramChannel}</tt></td>
+ * <tr><th scope="row">
+ * <span style="padding-left:2em">{@link java.nio.channels.DatagramChannel}</span></th>
* <td>A channel to a datagram-oriented socket</td></tr>
- * <tr><td valign=top><tt> {@link java.nio.channels.Pipe.SinkChannel}</tt></td>
+ * <tr><th scope="row">
+ * <span style="padding-left:2em">{@link java.nio.channels.Pipe.SinkChannel}</span></th>
* <td>The write end of a pipe</td></tr>
- * <tr><td valign=top><tt> {@link java.nio.channels.Pipe.SourceChannel}</tt></td>
+ * <tr><th scope="row">
+ * <span style="padding-left:2em">{@link java.nio.channels.Pipe.SourceChannel}</span></th>
* <td>The read end of a pipe</td></tr>
- * <tr><td valign=top><tt> {@link java.nio.channels.ServerSocketChannel} </tt></td>
+ * <tr><th scope="row">
+ * <span style="padding-left:2em">{@link java.nio.channels.ServerSocketChannel}</span></th>
* <td>A channel to a stream-oriented listening socket</td></tr>
- * <tr><td valign=top><tt> {@link java.nio.channels.SocketChannel}</tt></td>
+ * <tr><th scope="row">
+ * <span style="padding-left:2em">{@link java.nio.channels.SocketChannel}</span></th>
* <td>A channel for a stream-oriented connecting socket</td></tr>
- * <tr><td valign=top><tt>{@link java.nio.channels.Selector}</tt></td>
+ * <tr><th scope="row">{@link java.nio.channels.Selector}</th>
* <td>A multiplexor of selectable channels</td></tr>
- * <tr><td valign=top><tt>{@link java.nio.channels.SelectionKey}</tt></td>
- * <td>A token representing the registration <br> of a channel
- * with a selector</td></tr>
- * <tr><td valign=top><tt>{@link java.nio.channels.Pipe}</tt></td>
- * <td>Two channels that form a unidirectional pipe</td></tr>
- * </table></blockquote>
+ * <tr><th scope="row">{@link java.nio.channels.SelectionKey}</th>
+ * <td>A token representing the registration of a channel
+ * with a selector</td></tr>
+ * <tr><th scope="row">{@link java.nio.channels.Pipe}</th>
+ * <td>Two channels that form a unidirectional pipe</td></tr>
+ * </tbody>
+ * </table>
*
* <p> Multiplexed, non-blocking I/O, which is much more scalable than
* thread-oriented, blocking I/O, is provided by <i>selectors</i>, <i>selectable
@@ -194,18 +233,18 @@
*
* <p> This package defines selectable-channel classes corresponding to the {@link
* java.net.DatagramSocket}, {@link java.net.ServerSocket}, and {@link
- * java.net.Socket} classes defined in the <tt>{@link java.net}</tt> package.
+ * java.net.Socket} classes defined in the {@link java.net} package.
* Minor changes to these classes have been made in order to support sockets that
* are associated with channels. This package also defines a simple class that
* implements unidirectional pipes. In all cases, a new selectable channel is
- * created by invoking the static <tt>open</tt> method of the corresponding class.
+ * created by invoking the static {@code open} method of the corresponding class.
* If a channel needs an associated socket then a socket will be created as a side
* effect of this operation.
*
* <p> The implementation of selectors, selectable channels, and selection keys
* can be replaced by "plugging in" an alternative definition or instance of the
- * {@link java.nio.channels.spi.SelectorProvider} class defined in the <tt>{@link
- * java.nio.channels.spi}</tt> package. It is not expected that many developers
+ * {@link java.nio.channels.spi.SelectorProvider} class defined in the {@link
+ * java.nio.channels.spi} package. It is not expected that many developers
* will actually make use of this facility; it is provided primarily so that
* sophisticated users can take advantage of operating-system-specific
* I/O-multiplexing mechanisms when very high performance is required.
@@ -215,28 +254,40 @@
* java.nio.channels.spi.AbstractInterruptibleChannel}, {@link
* java.nio.channels.spi.AbstractSelectableChannel}, {@link
* java.nio.channels.spi.AbstractSelectionKey}, and {@link
- * java.nio.channels.spi.AbstractSelector} classes in the <tt>{@link
- * java.nio.channels.spi}</tt> package. When defining a custom selector provider,
+ * java.nio.channels.spi.AbstractSelector} classes in the {@link
+ * java.nio.channels.spi} package. When defining a custom selector provider,
* only the {@link java.nio.channels.spi.AbstractSelector} and {@link
* java.nio.channels.spi.AbstractSelectionKey} classes should be subclassed
* directly; custom channel classes should extend the appropriate {@link
* java.nio.channels.SelectableChannel} subclasses defined in this package.
*
- * <a name="async"></a>
+ * <a id="async"></a>
*
- * <blockquote><table cellspacing=1 cellpadding=0 summary="Lists asynchronous channels and their descriptions">
- * <tr><th align="left">Asynchronous I/O</th><th align="left">Description</th></tr>
- * <tr><td valign=top><tt>{@link java.nio.channels.AsynchronousFileChannel}</tt></td>
+ * <table class="striped" style="padding-left:2em; text-align:left">
+ * <caption style="display:none">
+ * Lists asynchronous channels and their descriptions</caption>
+ * <thead>
+ * <tr><th scope="col">Asynchronous I/O</th>
+ * <th scope="col">Description</th></tr>
+ * </thead>
+ * <tbody>
+ * <tr><th scope="row">
+ * {@link java.nio.channels.AsynchronousFileChannel}</th>
* <td>An asynchronous channel for reading, writing, and manipulating a file</td></tr>
- * <tr><td valign=top><tt>{@link java.nio.channels.AsynchronousSocketChannel}</tt></td>
+ * <tr><th scope="row">
+ * {@link java.nio.channels.AsynchronousSocketChannel}</th>
* <td>An asynchronous channel to a stream-oriented connecting socket</td></tr>
- * <tr><td valign=top><tt>{@link java.nio.channels.AsynchronousServerSocketChannel} </tt></td>
+ * <tr><th scope="row">
+ * {@link java.nio.channels.AsynchronousServerSocketChannel}</th>
* <td>An asynchronous channel to a stream-oriented listening socket</td></tr>
- * <tr><td valign=top><tt>{@link java.nio.channels.CompletionHandler}</tt></td>
+ * <tr><th scope="row">
+ * {@link java.nio.channels.CompletionHandler}</th>
* <td>A handler for consuming the result of an asynchronous operation</td></tr>
- * <tr><td valign=top><tt>{@link java.nio.channels.AsynchronousChannelGroup}</tt></td>
+ * <tr><th scope="row">
+ * {@link java.nio.channels.AsynchronousChannelGroup}</th>
* <td>A grouping of asynchronous channels for the purpose of resource sharing</td></tr>
- * </table></blockquote>
+ * </tbody>
+ * </table>
*
* <p> {@link java.nio.channels.AsynchronousChannel Asynchronous channels} are a
* special type of channel capable of asynchronous I/O operations. Asynchronous
@@ -272,13 +323,12 @@
* <p> As with selectors, the implementation of asynchronous channels can be
* replaced by "plugging in" an alternative definition or instance of the {@link
* java.nio.channels.spi.AsynchronousChannelProvider} class defined in the
- * <tt>{@link java.nio.channels.spi}</tt> package. It is not expected that many
+ * {@link java.nio.channels.spi} package. It is not expected that many
* developers will actually make use of this facility; it is provided primarily
* so that sophisticated users can take advantage of operating-system-specific
* asynchronous I/O mechanisms when very high performance is required.
*
- * <hr width="80%">
- * <p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor
+ * <p> Unless otherwise noted, passing a {@code null} argument to a constructor
* or method in any class or interface in this package will cause a {@link
* java.lang.NullPointerException NullPointerException} to be thrown.
*
diff --git a/ojluni/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java b/ojluni/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java
index 5000c58..fd74afc 100644
--- a/ojluni/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java
+++ b/ojluni/src/main/java/java/nio/channels/spi/AbstractInterruptibleChannel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,11 +29,8 @@
package java.nio.channels.spi;
import java.io.IOException;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
import java.nio.channels.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
+import jdk.internal.misc.SharedSecrets;
import sun.nio.ch.Interruptible;
@@ -46,9 +43,9 @@
* before and after, respectively, invoking an I/O operation that might block
* indefinitely. In order to ensure that the {@link #end end} method is always
* invoked, these methods should be used within a
- * <tt>try</tt> ... <tt>finally</tt> block:
+ * {@code try} ... {@code finally} block:
*
- * <blockquote><pre>
+ * <blockquote><pre id="be">
* boolean completed = false;
* try {
* begin();
@@ -58,11 +55,11 @@
* end(completed);
* }</pre></blockquote>
*
- * <p> The <tt>completed</tt> argument to the {@link #end end} method tells
+ * <p> The {@code completed} argument to the {@link #end end} method tells
* whether or not the I/O operation actually completed, that is, whether it had
* any effect that would be visible to the invoker. In the case of an
* operation that reads bytes, for example, this argument should be
- * <tt>true</tt> if, and only if, some bytes were actually transferred into the
+ * {@code true} if, and only if, some bytes were actually transferred into the
* invoker's target buffer.
*
* <p> A concrete channel class must also implement the {@link
@@ -89,7 +86,7 @@
{
private final Object closeLock = new Object();
- private volatile boolean open = true;
+ private volatile boolean closed;
/**
* Initializes a new instance of this class.
@@ -109,9 +106,9 @@
*/
public final void close() throws IOException {
synchronized (closeLock) {
- if (!open)
+ if (closed)
return;
- open = false;
+ closed = true;
implCloseChannel();
}
}
@@ -135,7 +132,7 @@
protected abstract void implCloseChannel() throws IOException;
public final boolean isOpen() {
- return open;
+ return !closed;
}
@@ -148,7 +145,7 @@
* Marks the beginning of an I/O operation that might block indefinitely.
*
* <p> This method should be invoked in tandem with the {@link #end end}
- * method, using a <tt>try</tt> ... <tt>finally</tt> block as
+ * method, using a {@code try} ... {@code finally} block as
* shown <a href="#be">above</a>, in order to implement asynchronous
* closing and interruption for this channel. </p>
*/
@@ -157,9 +154,9 @@
interruptor = new Interruptible() {
public void interrupt(Thread target) {
synchronized (closeLock) {
- if (!open)
+ if (closed)
return;
- open = false;
+ closed = true;
interrupted = target;
try {
AbstractInterruptibleChannel.this.implCloseChannel();
@@ -177,12 +174,12 @@
* Marks the end of an I/O operation that might block indefinitely.
*
* <p> This method should be invoked in tandem with the {@link #begin
- * begin} method, using a <tt>try</tt> ... <tt>finally</tt> block
+ * begin} method, using a {@code try} ... {@code finally} block
* as shown <a href="#be">above</a>, in order to implement asynchronous
* closing and interruption for this channel. </p>
*
* @param completed
- * <tt>true</tt> if, and only if, the I/O operation completed
+ * {@code true} if, and only if, the I/O operation completed
* successfully, that is, had some effect that would be visible to
* the operation's invoker
*
@@ -198,17 +195,16 @@
blockedOn(null);
Thread interrupted = this.interrupted;
if (interrupted != null && interrupted == Thread.currentThread()) {
- interrupted = null;
+ this.interrupted = null;
throw new ClosedByInterruptException();
}
- if (!completed && !open)
+ if (!completed && closed)
throw new AsynchronousCloseException();
}
- // -- sun.misc.SharedSecrets --
+ // -- jdk.internal.misc.SharedSecrets --
static void blockedOn(Interruptible intr) { // package-private
- sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(),
- intr);
+ SharedSecrets.getJavaLangAccess().blockedOn(intr);
}
}