Merge "Updated test expectations for ICU 60.2"
diff --git a/luni/src/main/java/libcore/net/MimeUtils.java b/luni/src/main/java/libcore/net/MimeUtils.java
index 693b6da..3ab4300 100644
--- a/luni/src/main/java/libcore/net/MimeUtils.java
+++ b/luni/src/main/java/libcore/net/MimeUtils.java
@@ -114,6 +114,7 @@
add("application/vnd.sun.xml.writer.global", "sxg");
add("application/vnd.sun.xml.writer.template", "stw");
add("application/vnd.visio", "vsd");
+ add("application/vnd.youtube.yt", "yt");
add("application/x-abiword", "abw");
add("application/x-apple-diskimage", "dmg");
add("application/x-bcpio", "bcpio");
diff --git a/luni/src/test/java/libcore/javax/crypto/spec/KeyFactoryTestRSA.java b/luni/src/test/java/libcore/javax/crypto/spec/KeyFactoryTestRSA.java
index d287b97..5e174bd 100644
--- a/luni/src/test/java/libcore/javax/crypto/spec/KeyFactoryTestRSA.java
+++ b/luni/src/test/java/libcore/javax/crypto/spec/KeyFactoryTestRSA.java
@@ -15,10 +15,16 @@
*/
package libcore.javax.crypto.spec;
+import java.security.KeyFactory;
import java.security.KeyPair;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;
+import java.security.spec.X509EncodedKeySpec;
import tests.security.CipherAsymmetricCryptHelper;
+import tests.security.DefaultKeys;
import tests.security.KeyFactoryTest;
public class KeyFactoryTestRSA extends
@@ -33,4 +39,20 @@
protected void check(KeyPair keyPair) throws Exception {
new CipherAsymmetricCryptHelper("RSA").test(keyPair);
}
+
+ public void testExtraBufferSpace_Private() throws Exception {
+ PrivateKey privateKey = DefaultKeys.getPrivateKey("RSA");
+ byte[] encoded = privateKey.getEncoded();
+ byte[] longBuffer = new byte[encoded.length + 147];
+ System.arraycopy(encoded, 0, longBuffer, 0, encoded.length);
+ KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(longBuffer));
+ }
+
+ public void testExtraBufferSpace_Public() throws Exception {
+ PublicKey publicKey = DefaultKeys.getPublicKey("RSA");
+ byte[] encoded = publicKey.getEncoded();
+ byte[] longBuffer = new byte[encoded.length + 147];
+ System.arraycopy(encoded, 0, longBuffer, 0, encoded.length);
+ KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(longBuffer));
+ }
}
diff --git a/luni/src/test/java/libcore/libcore/net/MimeUtilsTest.java b/luni/src/test/java/libcore/libcore/net/MimeUtilsTest.java
index 76e6336..f9ff9df 100644
--- a/luni/src/test/java/libcore/libcore/net/MimeUtilsTest.java
+++ b/luni/src/test/java/libcore/libcore/net/MimeUtilsTest.java
@@ -87,4 +87,7 @@
assertEquals("video/ogg", MimeUtils.guessMimeTypeFromExtension("ogv"));
}
+ public void test_70851634() {
+ assertEquals("application/vnd.youtube.yt", MimeUtils.guessMimeTypeFromExtension("yt"));
+ }
}
diff --git a/ojluni/src/main/java/java/io/CharArrayReader.java b/ojluni/src/main/java/java/io/CharArrayReader.java
index 2190be3..4140976 100644
--- a/ojluni/src/main/java/java/io/CharArrayReader.java
+++ b/ojluni/src/main/java/java/io/CharArrayReader.java
@@ -130,11 +130,12 @@
if (pos >= count) {
return -1;
}
-
+ // BEGIN Android-changed: Backport of OpenJDK 9b132 fix to avoid integer overflow.
int avail = count - pos;
if (len > avail) {
len = avail;
}
+ // END Android-changed: Backport of OpenJDK 9b132 fix to avoid integer overflow.
if (len <= 0) {
return 0;
}
@@ -159,11 +160,12 @@
public long skip(long n) throws IOException {
synchronized (lock) {
ensureOpen();
-
+ // BEGIN Android-changed: Backport of OpenJDK 9b132 fix to avoid integer overflow.
long avail = count - pos;
if (n > avail) {
n = avail;
}
+ // END Android-changed: Backport of OpenJDK 9b132 fix to avoid integer overflow.
if (n < 0) {
return 0;
}
diff --git a/ojluni/src/main/java/java/io/StringBufferInputStream.java b/ojluni/src/main/java/java/io/StringBufferInputStream.java
index f47eebc..90c5d4d 100644
--- a/ojluni/src/main/java/java/io/StringBufferInputStream.java
+++ b/ojluni/src/main/java/java/io/StringBufferInputStream.java
@@ -118,11 +118,12 @@
if (pos >= count) {
return -1;
}
-
+ // BEGIN Android-changed: Backport of OpenJDK 9b132 fix to avoid integer overflow.
int avail = count - pos;
if (len > avail) {
len = avail;
}
+ // END Android-changed: Backport of OpenJDK 9b132 fix to avoid integer overflow.
if (len <= 0) {
return 0;
}
diff --git a/ojluni/src/main/java/java/nio/ByteBuffer.java b/ojluni/src/main/java/java/nio/ByteBuffer.java
index 7f51a61..e4a8d0f 100644
--- a/ojluni/src/main/java/java/nio/ByteBuffer.java
+++ b/ojluni/src/main/java/java/nio/ByteBuffer.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The Android Open Source Project
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, 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,43 +38,47 @@
*
* <ul>
*
- * <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and
- * {@link #put(byte) </code><i>put</i><code>} methods that read and write
- * single bytes; </p></li>
+ * <li><p> Absolute and relative {@link #get() <i>get</i>} and
+ * {@link #put(byte) <i>put</i>} methods that read and write
+ * single bytes; </p></li>
*
- * <li><p> Relative {@link #get(byte[]) </code><i>bulk get</i><code>}
- * methods that transfer contiguous sequences of bytes from this buffer
- * into an array; </p></li>
+ * <li><p> Relative {@link #get(byte[]) <i>bulk get</i>}
+ * methods that transfer contiguous sequences of bytes from this buffer
+ * into an array; </p></li>
*
- * <li><p> Relative {@link #put(byte[]) </code><i>bulk put</i><code>}
- * methods that transfer contiguous sequences of bytes from a
- * byte array or some other byte
- * buffer into this buffer; </p></li>
- *
- * <li><p> Absolute and relative {@link #getChar() </code><i>get</i><code>}
- * and {@link #putChar(char) </code><i>put</i><code>} methods that read and
- * write values of other primitive types, translating them to and from
- * sequences of bytes in a particular byte order; </p></li>
- *
- * <li><p> Methods for creating <i><a href="#views">view buffers</a></i>,
- * which allow a byte buffer to be viewed as a buffer containing values of
- * some other primitive type; and </p></li>
+ * <li><p> Relative {@link #put(byte[]) <i>bulk put</i>}
+ * methods that transfer contiguous sequences of bytes from a
+ * byte array or some other byte
+ * buffer into this buffer; </p></li>
*
*
+ * <li><p> Absolute and relative {@link #getChar() <i>get</i>}
+ * and {@link #putChar(char) <i>put</i>} methods that read and
+ * write values of other primitive types, translating them to and from
+ * sequences of bytes in a particular byte order; </p></li>
*
- * <li><p> Methods for {@link #compact </code>compacting<code>}, {@link
- * #duplicate </code>duplicating<code>}, and {@link #slice
- * </code>slicing<code>} a byte buffer. </p></li>
+ * <li><p> Methods for creating <i><a href="#views">view buffers</a></i>,
+ * which allow a byte buffer to be viewed as a buffer containing values of
+ * some other primitive type; and </p></li>
+ *
+ *
+ * <li><p> Methods for {@link #compact compacting}, {@link
+ * #duplicate duplicating}, and {@link #slice slicing}
+ * a byte buffer. </p></li>
*
* </ul>
*
* <p> Byte buffers can be created either by {@link #allocate
- * </code><i>allocation</i><code>}, which allocates space for the buffer's
- * content, or by {@link #wrap(byte[]) </code><i>wrapping</i><code>} an
+ * <i>allocation</i>}, which allocates space for the buffer's
+ *
+ *
+ * content, or by {@link #wrap(byte[]) <i>wrapping</i>} an
* existing byte array into a buffer.
*
- * <a name="direct">
- * <h4> Direct <i>vs.</i> non-direct buffers </h4>
+ *
+ *
+ * <a name="direct"></a>
+ * <h2> Direct <i>vs.</i> non-direct buffers </h2>
*
* <p> A byte buffer is either <i>direct</i> or <i>non-direct</i>. Given a
* direct byte buffer, the Java virtual machine will make a best effort to
@@ -95,7 +99,7 @@
* buffers only when they yield a measureable gain in program performance.
*
* <p> A direct byte buffer may also be created by {@link
- * java.nio.channels.FileChannel#map </code>mapping<code>} a region of a file
+ * java.nio.channels.FileChannel#map mapping} a region of a file
* directly into memory. An implementation of the Java platform may optionally
* support the creation of direct byte buffers from native code via JNI. If an
* instance of one of these kinds of buffers refers to an inaccessible region
@@ -107,8 +111,9 @@
* invoking its {@link #isDirect isDirect} method. This method is provided so
* that explicit buffer management can be done in performance-critical code.
*
- * <a name="bin">
- * <h4> Access to binary data </h4>
+ *
+ * <a name="bin"></a>
+ * <h2> Access to binary data </h2>
*
* <p> This class defines methods for reading and writing values of all other
* primitive types, except <tt>boolean</tt>. Primitive values are translated
@@ -127,14 +132,14 @@
* float {@link #getFloat()}
* float {@link #getFloat(int) getFloat(int index)}
* void {@link #putFloat(float) putFloat(float f)}
- * void {@link #putFloat(int, float) putFloat(int index, float f)}</pre></blockquote>
+ * void {@link #putFloat(int,float) putFloat(int index, float f)}</pre></blockquote>
*
* <p> Corresponding methods are defined for the types <tt>char</tt>,
* <tt>short</tt>, <tt>int</tt>, <tt>long</tt>, and <tt>double</tt>. The index
* parameters of the absolute <i>get</i> and <i>put</i> methods are in terms of
* bytes rather than of the type being read or written.
*
- * <a name="views">
+ * <a name="views"></a>
*
* <p> For access to homogeneous binary data, that is, sequences of values of
* the same type, this class defines methods that can create <i>views</i> of a
@@ -153,27 +158,31 @@
*
* <ul>
*
- * <li><p> A view buffer is indexed not in terms of bytes but rather in terms
- * of the type-specific size of its values; </p></li>
+ * <li><p> A view buffer is indexed not in terms of bytes but rather in terms
+ * of the type-specific size of its values; </p></li>
*
- * <li><p> A view buffer provides relative bulk <i>get</i> and <i>put</i>
- * methods that can transfer contiguous sequences of values between a buffer
- * and an array or some other buffer of the same type; and </p></li>
+ * <li><p> A view buffer provides relative bulk <i>get</i> and <i>put</i>
+ * methods that can transfer contiguous sequences of values between a buffer
+ * and an array or some other buffer of the same type; and </p></li>
*
- * <li><p> A view buffer is potentially much more efficient because it will
- * be direct if, and only if, its backing byte buffer is direct. </p></li>
+ * <li><p> A view buffer is potentially much more efficient because it will
+ * be direct if, and only if, its backing byte buffer is direct. </p></li>
*
* </ul>
*
* <p> The byte order of a view buffer is fixed to be that of its byte buffer
* at the time that the view is created. </p>
*
- * <h4> Invocation chaining </h4>
+*
+*
+ *
+ * <h2> Invocation chaining </h2>
*
* <p> Methods in this class that do not otherwise have a value to return are
* specified to return the buffer upon which they are invoked. This allows
* method invocations to be chained.
*
+ *
* The sequence of statements
*
* <blockquote><pre>
@@ -186,14 +195,17 @@
* <blockquote><pre>
* bb.putInt(0xCAFEBABE).putShort(3).putShort(45);</pre></blockquote>
*
+ *
+ *
* @author Mark Reinhold
* @author JSR-51 Expert Group
* @since 1.4
*/
public abstract class ByteBuffer
- extends Buffer
- implements Comparable<ByteBuffer> {
+ extends Buffer
+ implements Comparable<ByteBuffer>
+{
// These fields are declared here rather than in Heap-X-Buffer in order to
// reduce the number of virtual method invocations needed to access these
@@ -207,7 +219,8 @@
// backing array, and array offset
//
ByteBuffer(int mark, int pos, int lim, int cap, // package-private
- byte[] hb, int offset) {
+ byte[] hb, int offset)
+ {
super(mark, pos, lim, cap, 0);
this.hb = hb;
this.offset = offset;
@@ -226,11 +239,15 @@
* <p> The new buffer's position will be zero, its limit will be its
* capacity, its mark will be undefined, and each of its elements will be
* initialized to zero. Whether or not it has a
- * {@link #hasArray </code>backing array<code>} is unspecified.
+ * {@link #hasArray backing array} is unspecified.
*
- * @param capacity The new buffer's capacity, in bytes
- * @return The new byte buffer
- * @throws IllegalArgumentException If the <tt>capacity</tt> is a negative integer
+ * @param capacity
+ * The new buffer's capacity, in bytes
+ *
+ * @return The new byte buffer
+ *
+ * @throws IllegalArgumentException
+ * If the <tt>capacity</tt> is a negative integer
*/
public static ByteBuffer allocateDirect(int capacity) {
if (capacity < 0) {
@@ -247,13 +264,16 @@
*
* <p> The new buffer's position will be zero, its limit will be its
* capacity, its mark will be undefined, and each of its elements will be
- * initialized to zero. It will have a {@link #array
- * </code>backing array<code>}, and its {@link #arrayOffset </code>array
- * offset<code>} will be zero.
+ * initialized to zero. It will have a {@link #array backing array},
+ * and its {@link #arrayOffset array offset} will be zero.
*
- * @param capacity The new buffer's capacity, in bytes
- * @return The new byte buffer
- * @throws IllegalArgumentException If the <tt>capacity</tt> is a negative integer
+ * @param capacity
+ * The new buffer's capacity, in bytes
+ *
+ * @return The new byte buffer
+ *
+ * @throws IllegalArgumentException
+ * If the <tt>capacity</tt> is a negative integer
*/
public static ByteBuffer allocate(int capacity) {
if (capacity < 0)
@@ -269,24 +289,32 @@
* and vice versa. The new buffer's capacity will be
* <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit
* will be <tt>offset + length</tt>, and its mark will be undefined. Its
- * {@link #array </code>backing array<code>} will be the given array, and
- * its {@link #arrayOffset </code>array offset<code>} will be zero. </p>
+ * {@link #array backing array} will be the given array, and
+ * its {@link #arrayOffset array offset} will be zero. </p>
*
- * @param array The array that will back the new buffer
- * @param offset The offset of the subarray to be used; must be non-negative and
- * no larger than <tt>array.length</tt>. The new buffer's position
- * will be set to this value.
- * @param length The length of the subarray to be used;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>.
- * The new buffer's limit will be set to <tt>offset + length</tt>.
- * @return The new byte buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param array
+ * The array that will back the new buffer
+ *
+ * @param offset
+ * The offset of the subarray to be used; must be non-negative and
+ * no larger than <tt>array.length</tt>. The new buffer's position
+ * will be set to this value.
+ *
+ * @param length
+ * The length of the subarray to be used;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>.
+ * The new buffer's limit will be set to <tt>offset + length</tt>.
+ *
+ * @return The new byte buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public static ByteBuffer wrap(byte[] array,
- int offset, int length) {
+ int offset, int length)
+ {
try {
return new HeapByteBuffer(array, offset, length);
} catch (IllegalArgumentException x) {
@@ -301,12 +329,14 @@
* that is, modifications to the buffer will cause the array to be modified
* and vice versa. The new buffer's capacity and limit will be
* <tt>array.length</tt>, its position will be zero, and its mark will be
- * undefined. Its {@link #array </code>backing array<code>} will be the
- * given array, and its {@link #arrayOffset </code>array offset<code>} will
+ * undefined. Its {@link #array backing array} will be the
+ * given array, and its {@link #arrayOffset array offset>} will
* be zero. </p>
*
- * @param array The array that will back this buffer
- * @return The new byte buffer
+ * @param array
+ * The array that will back this buffer
+ *
+ * @return The new byte buffer
*/
public static ByteBuffer wrap(byte[] array) {
return wrap(array, 0, array.length);
@@ -328,7 +358,7 @@
* buffer is direct, and it will be read-only if, and only if, this buffer
* is read-only. </p>
*
- * @return The new byte buffer
+ * @return The new byte buffer
*/
public abstract ByteBuffer slice();
@@ -345,7 +375,7 @@
* and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return The new byte buffer
+ * @return The new byte buffer
*/
public abstract ByteBuffer duplicate();
@@ -365,7 +395,7 @@
* <p> If this buffer is itself read-only then this method behaves in
* exactly the same way as the {@link #duplicate duplicate} method. </p>
*
- * @return The new, read-only byte buffer
+ * @return The new, read-only byte buffer
*/
public abstract ByteBuffer asReadOnlyBuffer();
@@ -374,11 +404,12 @@
/**
* Relative <i>get</i> method. Reads the byte at this buffer's
- * current position, and then increments the position. </p>
+ * current position, and then increments the position.
*
- * @return The byte at the buffer's current position
- * @throws BufferUnderflowException If the buffer's current position is not smaller than its
- * limit
+ * @return The byte at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If the buffer's current position is not smaller than its limit
*/
public abstract byte get();
@@ -388,22 +419,31 @@
* <p> Writes the given byte into this buffer at the current
* position, and then increments the position. </p>
*
- * @param b The byte to be written
- * @return This buffer
- * @throws BufferOverflowException If this buffer's current position is not smaller than its
- * limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param b
+ * The byte to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If this buffer's current position is not smaller than its limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer put(byte b);
/**
* Absolute <i>get</i> method. Reads the byte at the given
- * index. </p>
+ * index.
*
- * @param index The index from which the byte will be read
- * @return The byte at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
+ * @param index
+ * The index from which the byte will be read
+ *
+ * @return The byte at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
*/
public abstract byte get(int index);
@@ -413,12 +453,20 @@
* <p> Writes the given byte into this buffer at the given
* index. </p>
*
- * @param index The index at which the byte will be written
- * @param b The byte value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the byte will be written
+ *
+ * @param b
+ * The byte value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer put(int index, byte b);
@@ -444,26 +492,36 @@
* <tt>src.get(dst, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst[i] = src.get(); </pre>
+ * dst[i] = src.get();
+ * }</pre>
*
* except that it first checks that there are sufficient bytes in
- * this buffer and it is potentially much more efficient. </p>
+ * this buffer and it is potentially much more efficient.
*
- * @param dst The array into which bytes are to be written
- * @param offset The offset within the array of the first byte to be
- * written; must be non-negative and no larger than
- * <tt>dst.length</tt>
- * @param length The maximum number of bytes to be written to the given
- * array; must be non-negative and no larger than
- * <tt>dst.length - offset</tt>
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> bytes
- * remaining in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param dst
+ * The array into which bytes are to be written
+ *
+ * @param offset
+ * The offset within the array of the first byte to be
+ * written; must be non-negative and no larger than
+ * <tt>dst.length</tt>
+ *
+ * @param length
+ * The maximum number of bytes to be written to the given
+ * array; must be non-negative and no larger than
+ * <tt>dst.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> bytes
+ * remaining in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public ByteBuffer get(byte[] dst, int offset, int length) {
checkBounds(offset, length, dst.length);
@@ -485,9 +543,14 @@
* <pre>
* src.get(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> bytes
- * remaining in this buffer
+ * @param dst
+ * The destination array
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> bytes
+ * remaining in this buffer
*/
public ByteBuffer get(byte[] dst) {
return get(dst, 0, dst.length);
@@ -519,15 +582,23 @@
* dst.put(src.get()); </pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The source buffer from which bytes are to be read;
- * must not be this buffer
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * for the remaining bytes in the source buffer
- * @throws IllegalArgumentException If the source buffer is this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source buffer from which bytes are to be read;
+ * must not be this buffer
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ * for the remaining bytes in the source buffer
+ *
+ * @throws IllegalArgumentException
+ * If the source buffer is this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public ByteBuffer put(ByteBuffer src) {
if (!isAccessible()) {
@@ -593,25 +664,37 @@
* <tt>dst.put(src, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst.put(a[i]); </pre>
+ * dst.put(a[i]);
+ * }</pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The array from which bytes are to be read
- * @param offset The offset within the array of the first byte to be read;
- * must be non-negative and no larger than <tt>array.length</tt>
- * @param length The number of bytes to be read from the given array;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The array from which bytes are to be read
+ *
+ * @param offset
+ * The offset within the array of the first byte to be read;
+ * must be non-negative and no larger than <tt>array.length</tt>
+ *
+ * @param length
+ * The number of bytes to be read from the given array;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public ByteBuffer put(byte[] src, int offset, int length) {
checkBounds(offset, length, src.length);
@@ -634,9 +717,16 @@
* <pre>
* dst.put(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source array
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public final ByteBuffer put(byte[] src) {
return put(src, 0, src.length);
@@ -653,11 +743,11 @@
* and {@link #arrayOffset() arrayOffset} methods may safely be invoked.
* </p>
*
- * @return <tt>true</tt> if, and only if, this buffer
- * is backed by an array and is not read-only
+ * @return <tt>true</tt> if, and only if, this buffer
+ * is backed by an array and is not read-only
*/
public final boolean hasArray() {
- return (hb != null) && !isReadOnly();
+ return (hb != null) && !isReadOnly;
}
/**
@@ -671,9 +761,13 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The array that backs this buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The array that backs this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final byte[] array() {
if (hb == null)
@@ -694,10 +788,14 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The offset within this buffer's array
- * of the first element of the buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The offset within this buffer's array
+ * of the first element of the buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final int arrayOffset() {
if (hb == null)
@@ -725,37 +823,42 @@
* followed immediately by an invocation of another relative <i>put</i>
* method. </p>
*
- *
+
*
* <p> Invoke this method after writing data from a buffer in case the
* write was incomplete. The following loop, for example, copies bytes
* from one channel to another via the buffer <tt>buf</tt>:
*
- * <blockquote><pre>
- * buf.clear(); // Prepare buffer for use
- * while (in.read(buf) >= 0 || buf.position != 0) {
- * buf.flip();
- * out.write(buf);
- * buf.compact(); // In case of partial write
+ * <blockquote><pre>{@code
+ * buf.clear(); // Prepare buffer for use
+ * while (in.read(buf) >= 0 || buf.position != 0) {
+ * buf.flip();
+ * out.write(buf);
+ * buf.compact(); // In case of partial write
+ * }
* }</pre></blockquote>
*
- * @return This buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+
+ *
+ * @return This buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer compact();
/**
- * Tells whether or not this byte buffer is direct. </p>
+ * Tells whether or not this byte buffer is direct.
*
- * @return <tt>true</tt> if, and only if, this buffer is direct
+ * @return <tt>true</tt> if, and only if, this buffer is direct
*/
public abstract boolean isDirect();
/**
- * Returns a string summarizing the state of this buffer. </p>
+ * Returns a string summarizing the state of this buffer.
*
- * @return A summary string
+ * @return A summary string
*/
public String toString() {
StringBuffer sb = new StringBuffer();
@@ -782,13 +885,13 @@
* to use buffers as keys in hash maps or similar data structures unless it
* is known that their contents will not change. </p>
*
- * @return The current hash code of this buffer
+ * @return The current hash code of this buffer
*/
public int hashCode() {
int h = 1;
int p = position();
for (int i = limit() - 1; i >= p; i--)
- h = 31 * h + (int) get(i);
+ h = 31 * h + (int)get(i);
return h;
}
@@ -797,38 +900,33 @@
*
* <p> Two byte buffers are equal if, and only if,
*
- * <p><ol>
+ * <ol>
*
- * <li><p> They have the same element type, </p></li>
+ * <li><p> They have the same element type, </p></li>
*
- * <li><p> They have the same number of remaining elements, and
- * </p></li>
+ * <li><p> They have the same number of remaining elements, and
+ * </p></li>
*
- * <li><p> The two sequences of remaining elements, considered
- * independently of their starting positions, are pointwise equal.
- *
- *
- *
- *
- *
- *
- *
- * </p></li>
+ * <li><p> The two sequences of remaining elements, considered
+ * independently of their starting positions, are pointwise equal.
+
+ * </p></li>
*
* </ol>
*
* <p> A byte buffer is not equal to any other type of object. </p>
*
- * @param ob The object to which this buffer is to be compared
- * @return <tt>true</tt> if, and only if, this buffer is equal to the
- * given object
+ * @param ob The object to which this buffer is to be compared
+ *
+ * @return <tt>true</tt> if, and only if, this buffer is equal to the
+ * given object
*/
public boolean equals(Object ob) {
if (this == ob)
return true;
if (!(ob instanceof ByteBuffer))
return false;
- ByteBuffer that = (ByteBuffer) ob;
+ ByteBuffer that = (ByteBuffer)ob;
if (this.remaining() != that.remaining())
return false;
int p = this.position();
@@ -860,13 +958,13 @@
*
*
* Pairs of {@code byte} elements are compared as if by invoking
- * {@link Byte#compare(byte, byte)}.
- *
+ * {@link Byte#compare(byte,byte)}.
+
*
* <p> A byte buffer is not comparable to any other type of object.
*
- * @return A negative integer, zero, or a positive integer as this buffer
- * is less than, equal to, or greater than the given buffer
+ * @return A negative integer, zero, or a positive integer as this buffer
+ * is less than, equal to, or greater than the given buffer
*/
public int compareTo(ByteBuffer that) {
int n = this.position() + Math.min(this.remaining(), that.remaining());
@@ -892,9 +990,9 @@
boolean bigEndian // package-private
- = true;
+ = true;
boolean nativeByteOrder // package-private
- = (Bits.byteOrder() == ByteOrder.BIG_ENDIAN);
+ = (Bits.byteOrder() == ByteOrder.BIG_ENDIAN);
/**
* Retrieves this buffer's byte order.
@@ -904,31 +1002,32 @@
* a newly-created byte buffer is always {@link ByteOrder#BIG_ENDIAN
* BIG_ENDIAN}. </p>
*
- * @return This buffer's byte order
+ * @return This buffer's byte order
*/
public final ByteOrder order() {
return bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
}
/**
- * Modifies this buffer's byte order. </p>
+ * Modifies this buffer's byte order.
*
- * @param bo The new byte order,
- * either {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}
- * or {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN}
- * @return This buffer
+ * @param bo
+ * The new byte order,
+ * either {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}
+ * or {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN}
+ *
+ * @return This buffer
*/
public final ByteBuffer order(ByteOrder bo) {
bigEndian = (bo == ByteOrder.BIG_ENDIAN);
nativeByteOrder =
- (bigEndian == (Bits.byteOrder() == ByteOrder.BIG_ENDIAN));
+ (bigEndian == (Bits.byteOrder() == ByteOrder.BIG_ENDIAN));
return this;
}
// Unchecked accessors, for use by ByteBufferAs-X-Buffer classes
//
abstract byte _get(int i); // package-private
-
abstract void _put(int i, byte b); // package-private
@@ -939,9 +1038,11 @@
* composing them into a char value according to the current byte order,
* and then increments the position by two. </p>
*
- * @return The char value at the buffer's current position
- * @throws BufferUnderflowException If there are fewer than two bytes
- * remaining in this buffer
+ * @return The char value at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than two bytes
+ * remaining in this buffer
*/
public abstract char getChar();
@@ -953,11 +1054,17 @@
* current byte order, into this buffer at the current position, and then
* increments the position by two. </p>
*
- * @param value The char value to be written
- * @return This buffer
- * @throws BufferOverflowException If there are fewer than two bytes
- * remaining in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param value
+ * The char value to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there are fewer than two bytes
+ * remaining in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer putChar(char value);
@@ -967,11 +1074,15 @@
* <p> Reads two bytes at the given index, composing them into a
* char value according to the current byte order. </p>
*
- * @param index The index from which the bytes will be read
- * @return The char value at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit,
- * minus one
+ * @param index
+ * The index from which the bytes will be read
+ *
+ * @return The char value at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit,
+ * minus one
*/
public abstract char getChar(int index);
@@ -990,13 +1101,21 @@
* <p> Writes two bytes containing the given char value, in the
* current byte order, into this buffer at the given index. </p>
*
- * @param index The index at which the bytes will be written
- * @param value The char value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit,
- * minus one
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the bytes will be written
+ *
+ * @param value
+ * The char value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit,
+ * minus one
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer putChar(int index, char value);
@@ -1022,7 +1141,7 @@
* if, and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return A new char buffer
+ * @return A new char buffer
*/
public abstract CharBuffer asCharBuffer();
@@ -1034,9 +1153,11 @@
* composing them into a short value according to the current byte order,
* and then increments the position by two. </p>
*
- * @return The short value at the buffer's current position
- * @throws BufferUnderflowException If there are fewer than two bytes
- * remaining in this buffer
+ * @return The short value at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than two bytes
+ * remaining in this buffer
*/
public abstract short getShort();
@@ -1048,11 +1169,17 @@
* current byte order, into this buffer at the current position, and then
* increments the position by two. </p>
*
- * @param value The short value to be written
- * @return This buffer
- * @throws BufferOverflowException If there are fewer than two bytes
- * remaining in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param value
+ * The short value to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there are fewer than two bytes
+ * remaining in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer putShort(short value);
@@ -1062,11 +1189,15 @@
* <p> Reads two bytes at the given index, composing them into a
* short value according to the current byte order. </p>
*
- * @param index The index from which the bytes will be read
- * @return The short value at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit,
- * minus one
+ * @param index
+ * The index from which the bytes will be read
+ *
+ * @return The short value at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit,
+ * minus one
*/
public abstract short getShort(int index);
@@ -1085,13 +1216,21 @@
* <p> Writes two bytes containing the given short value, in the
* current byte order, into this buffer at the given index. </p>
*
- * @param index The index at which the bytes will be written
- * @param value The short value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit,
- * minus one
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the bytes will be written
+ *
+ * @param value
+ * The short value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit,
+ * minus one
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer putShort(int index, short value);
@@ -1117,7 +1256,7 @@
* if, and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return A new short buffer
+ * @return A new short buffer
*/
public abstract ShortBuffer asShortBuffer();
@@ -1129,9 +1268,11 @@
* composing them into an int value according to the current byte order,
* and then increments the position by four. </p>
*
- * @return The int value at the buffer's current position
- * @throws BufferUnderflowException If there are fewer than four bytes
- * remaining in this buffer
+ * @return The int value at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than four bytes
+ * remaining in this buffer
*/
public abstract int getInt();
@@ -1143,11 +1284,17 @@
* current byte order, into this buffer at the current position, and then
* increments the position by four. </p>
*
- * @param value The int value to be written
- * @return This buffer
- * @throws BufferOverflowException If there are fewer than four bytes
- * remaining in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param value
+ * The int value to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there are fewer than four bytes
+ * remaining in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer putInt(int value);
@@ -1157,11 +1304,15 @@
* <p> Reads four bytes at the given index, composing them into a
* int value according to the current byte order. </p>
*
- * @param index The index from which the bytes will be read
- * @return The int value at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit,
- * minus three
+ * @param index
+ * The index from which the bytes will be read
+ *
+ * @return The int value at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit,
+ * minus three
*/
public abstract int getInt(int index);
@@ -1180,13 +1331,21 @@
* <p> Writes four bytes containing the given int value, in the
* current byte order, into this buffer at the given index. </p>
*
- * @param index The index at which the bytes will be written
- * @param value The int value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit,
- * minus three
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the bytes will be written
+ *
+ * @param value
+ * The int value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit,
+ * minus three
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer putInt(int index, int value);
@@ -1212,7 +1371,7 @@
* if, and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return A new int buffer
+ * @return A new int buffer
*/
public abstract IntBuffer asIntBuffer();
@@ -1224,9 +1383,11 @@
* composing them into a long value according to the current byte order,
* and then increments the position by eight. </p>
*
- * @return The long value at the buffer's current position
- * @throws BufferUnderflowException If there are fewer than eight bytes
- * remaining in this buffer
+ * @return The long value at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than eight bytes
+ * remaining in this buffer
*/
public abstract long getLong();
@@ -1238,11 +1399,17 @@
* current byte order, into this buffer at the current position, and then
* increments the position by eight. </p>
*
- * @param value The long value to be written
- * @return This buffer
- * @throws BufferOverflowException If there are fewer than eight bytes
- * remaining in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param value
+ * The long value to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there are fewer than eight bytes
+ * remaining in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer putLong(long value);
@@ -1252,11 +1419,15 @@
* <p> Reads eight bytes at the given index, composing them into a
* long value according to the current byte order. </p>
*
- * @param index The index from which the bytes will be read
- * @return The long value at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit,
- * minus seven
+ * @param index
+ * The index from which the bytes will be read
+ *
+ * @return The long value at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit,
+ * minus seven
*/
public abstract long getLong(int index);
@@ -1275,13 +1446,21 @@
* <p> Writes eight bytes containing the given long value, in the
* current byte order, into this buffer at the given index. </p>
*
- * @param index The index at which the bytes will be written
- * @param value The long value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit,
- * minus seven
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the bytes will be written
+ *
+ * @param value
+ * The long value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit,
+ * minus seven
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer putLong(int index, long value);
@@ -1307,7 +1486,7 @@
* if, and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return A new long buffer
+ * @return A new long buffer
*/
public abstract LongBuffer asLongBuffer();
@@ -1319,9 +1498,11 @@
* composing them into a float value according to the current byte order,
* and then increments the position by four. </p>
*
- * @return The float value at the buffer's current position
- * @throws BufferUnderflowException If there are fewer than four bytes
- * remaining in this buffer
+ * @return The float value at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than four bytes
+ * remaining in this buffer
*/
public abstract float getFloat();
@@ -1333,11 +1514,17 @@
* current byte order, into this buffer at the current position, and then
* increments the position by four. </p>
*
- * @param value The float value to be written
- * @return This buffer
- * @throws BufferOverflowException If there are fewer than four bytes
- * remaining in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param value
+ * The float value to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there are fewer than four bytes
+ * remaining in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer putFloat(float value);
@@ -1347,11 +1534,15 @@
* <p> Reads four bytes at the given index, composing them into a
* float value according to the current byte order. </p>
*
- * @param index The index from which the bytes will be read
- * @return The float value at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit,
- * minus three
+ * @param index
+ * The index from which the bytes will be read
+ *
+ * @return The float value at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit,
+ * minus three
*/
public abstract float getFloat(int index);
@@ -1370,13 +1561,21 @@
* <p> Writes four bytes containing the given float value, in the
* current byte order, into this buffer at the given index. </p>
*
- * @param index The index at which the bytes will be written
- * @param value The float value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit,
- * minus three
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the bytes will be written
+ *
+ * @param value
+ * The float value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit,
+ * minus three
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer putFloat(int index, float value);
@@ -1402,7 +1601,7 @@
* if, and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return A new float buffer
+ * @return A new float buffer
*/
public abstract FloatBuffer asFloatBuffer();
@@ -1414,9 +1613,11 @@
* composing them into a double value according to the current byte order,
* and then increments the position by eight. </p>
*
- * @return The double value at the buffer's current position
- * @throws BufferUnderflowException If there are fewer than eight bytes
- * remaining in this buffer
+ * @return The double value at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than eight bytes
+ * remaining in this buffer
*/
public abstract double getDouble();
@@ -1428,11 +1629,17 @@
* current byte order, into this buffer at the current position, and then
* increments the position by eight. </p>
*
- * @param value The double value to be written
- * @return This buffer
- * @throws BufferOverflowException If there are fewer than eight bytes
- * remaining in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param value
+ * The double value to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there are fewer than eight bytes
+ * remaining in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer putDouble(double value);
@@ -1442,11 +1649,15 @@
* <p> Reads eight bytes at the given index, composing them into a
* double value according to the current byte order. </p>
*
- * @param index The index from which the bytes will be read
- * @return The double value at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit,
- * minus seven
+ * @param index
+ * The index from which the bytes will be read
+ *
+ * @return The double value at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit,
+ * minus seven
*/
public abstract double getDouble(int index);
@@ -1465,13 +1676,21 @@
* <p> Writes eight bytes containing the given double value, in the
* current byte order, into this buffer at the given index. </p>
*
- * @param index The index at which the bytes will be written
- * @param value The double value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit,
- * minus seven
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the bytes will be written
+ *
+ * @param value
+ * The double value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit,
+ * minus seven
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ByteBuffer putDouble(int index, double value);
@@ -1497,7 +1716,7 @@
* if, and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return A new double buffer
+ * @return A new double buffer
*/
public abstract DoubleBuffer asDoubleBuffer();
diff --git a/ojluni/src/main/java/java/nio/CharBuffer.java b/ojluni/src/main/java/java/nio/CharBuffer.java
index 65eb2db..61265d7 100644
--- a/ojluni/src/main/java/java/nio/CharBuffer.java
+++ b/ojluni/src/main/java/java/nio/CharBuffer.java
@@ -43,31 +43,37 @@
*
* <ul>
*
- * <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and
- * {@link #put(char) </code><i>put</i><code>} methods that read and write
- * single chars; </p></li>
+ * <li><p> Absolute and relative {@link #get() <i>get</i>} and
+ * {@link #put(char) <i>put</i>} methods that read and write
+ * single chars; </p></li>
*
- * <li><p> Relative {@link #get(char[]) </code><i>bulk get</i><code>}
- * methods that transfer contiguous sequences of chars from this buffer
- * into an array; and</p></li>
+ * <li><p> Relative {@link #get(char[]) <i>bulk get</i>}
+ * methods that transfer contiguous sequences of chars from this buffer
+ * into an array; and</p></li>
*
- * <li><p> Relative {@link #put(char[]) </code><i>bulk put</i><code>}
- * methods that transfer contiguous sequences of chars from a
- * char array, a string, or some other char
- * buffer into this buffer; and </p></li>
+ * <li><p> Relative {@link #put(char[]) <i>bulk put</i>}
+ * methods that transfer contiguous sequences of chars from a
+ * char array, a string, or some other char
+ * buffer into this buffer; and </p></li>
*
- * <li><p> Methods for {@link #compact </code>compacting<code>}, {@link
- * #duplicate </code>duplicating<code>}, and {@link #slice
- * </code>slicing<code>} a char buffer. </p></li>
+ *
+ * <li><p> Methods for {@link #compact compacting}, {@link
+ * #duplicate duplicating}, and {@link #slice slicing}
+ * a char buffer. </p></li>
*
* </ul>
*
* <p> Char buffers can be created either by {@link #allocate
- * </code><i>allocation</i><code>}, which allocates space for the buffer's
- * content, by {@link #wrap(char[]) </code><i>wrapping</i><code>} an existing
+ * <i>allocation</i>}, which allocates space for the buffer's
+ *
+ *
+ * content, by {@link #wrap(char[]) <i>wrapping</i>} an existing
* char array or string into a buffer, or by creating a
* <a href="ByteBuffer.html#views"><i>view</i></a> of an existing byte buffer.
*
+ *
+*
+ *
* <p> Like a byte buffer, a char buffer is either <a
* href="ByteBuffer.html#direct"><i>direct</i> or <i>non-direct</i></a>. A
* char buffer created via the <tt>wrap</tt> methods of this class will
@@ -76,11 +82,15 @@
* a char buffer is direct may be determined by invoking the {@link
* #isDirect isDirect} method. </p>
*
+*
+ *
* <p> This class implements the {@link CharSequence} interface so that
* character buffers may be used wherever character sequences are accepted, for
* example in the regular-expression package <tt>{@link java.util.regex}</tt>.
* </p>
*
+ *
+ *
* <p> Methods in this class that do not otherwise have a value to return are
* specified to return the buffer upon which they are invoked. This allows
* method invocations to be chained.
@@ -99,14 +109,17 @@
* <blockquote><pre>
* cb.put("text/").put(subtype).put("; charset=").put(enc);</pre></blockquote>
*
+ *
+ *
* @author Mark Reinhold
* @author JSR-51 Expert Group
* @since 1.4
*/
public abstract class CharBuffer
- extends Buffer
- implements Comparable<CharBuffer>, Appendable, CharSequence, Readable {
+ extends Buffer
+ implements Comparable<CharBuffer>, Appendable, CharSequence, Readable
+{
// These fields are declared here rather than in Heap-X-Buffer in order to
// reduce the number of virtual method invocations needed to access these
@@ -120,7 +133,8 @@
// backing array, and array offset
//
CharBuffer(int mark, int pos, int lim, int cap, // package-private
- char[] hb, int offset) {
+ char[] hb, int offset)
+ {
super(mark, pos, lim, cap, 1);
this.hb = hb;
this.offset = offset;
@@ -138,13 +152,16 @@
*
* <p> The new buffer's position will be zero, its limit will be its
* capacity, its mark will be undefined, and each of its elements will be
- * initialized to zero. It will have a {@link #array
- * </code>backing array<code>}, and its {@link #arrayOffset </code>array
- * offset<code>} will be zero.
+ * initialized to zero. It will have a {@link #array backing array},
+ * and its {@link #arrayOffset array offset} will be zero.
*
- * @param capacity The new buffer's capacity, in chars
- * @return The new char buffer
- * @throws IllegalArgumentException If the <tt>capacity</tt> is a negative integer
+ * @param capacity
+ * The new buffer's capacity, in chars
+ *
+ * @return The new char buffer
+ *
+ * @throws IllegalArgumentException
+ * If the <tt>capacity</tt> is a negative integer
*/
public static CharBuffer allocate(int capacity) {
if (capacity < 0)
@@ -160,24 +177,32 @@
* and vice versa. The new buffer's capacity will be
* <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit
* will be <tt>offset + length</tt>, and its mark will be undefined. Its
- * {@link #array </code>backing array<code>} will be the given array, and
- * its {@link #arrayOffset </code>array offset<code>} will be zero. </p>
+ * {@link #array backing array} will be the given array, and
+ * its {@link #arrayOffset array offset} will be zero. </p>
*
- * @param array The array that will back the new buffer
- * @param offset The offset of the subarray to be used; must be non-negative and
- * no larger than <tt>array.length</tt>. The new buffer's position
- * will be set to this value.
- * @param length The length of the subarray to be used;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>.
- * The new buffer's limit will be set to <tt>offset + length</tt>.
- * @return The new char buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param array
+ * The array that will back the new buffer
+ *
+ * @param offset
+ * The offset of the subarray to be used; must be non-negative and
+ * no larger than <tt>array.length</tt>. The new buffer's position
+ * will be set to this value.
+ *
+ * @param length
+ * The length of the subarray to be used;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>.
+ * The new buffer's limit will be set to <tt>offset + length</tt>.
+ *
+ * @return The new char buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public static CharBuffer wrap(char[] array,
- int offset, int length) {
+ int offset, int length)
+ {
try {
return new HeapCharBuffer(array, offset, length);
} catch (IllegalArgumentException x) {
@@ -192,12 +217,14 @@
* that is, modifications to the buffer will cause the array to be modified
* and vice versa. The new buffer's capacity and limit will be
* <tt>array.length</tt>, its position will be zero, and its mark will be
- * undefined. Its {@link #array </code>backing array<code>} will be the
- * given array, and its {@link #arrayOffset </code>array offset<code>} will
+ * undefined. Its {@link #array backing array} will be the
+ * given array, and its {@link #arrayOffset array offset>} will
* be zero. </p>
*
- * @param array The array that will back this buffer
- * @return The new char buffer
+ * @param array
+ * The array that will back this buffer
+ *
+ * @return The new char buffer
*/
public static CharBuffer wrap(char[] array) {
return wrap(array, 0, array.length);
@@ -212,9 +239,9 @@
*
* @param target the buffer to read characters into
* @return The number of characters added to the buffer, or
- * -1 if this source of characters is at its end
- * @throws IOException if an I/O error occurs
- * @throws NullPointerException if target is null
+ * -1 if this source of characters is at its end
+ * @throws IOException if an I/O error occurs
+ * @throws NullPointerException if target is null
* @throws ReadOnlyBufferException if target is a read only buffer
* @since 1.5
*/
@@ -246,19 +273,26 @@
* <tt>csq.length()</tt>, its position will be <tt>start</tt>, its limit
* will be <tt>end</tt>, and its mark will be undefined. </p>
*
- * @param csq The character sequence from which the new character buffer is to
- * be created
- * @param start The index of the first character to be used;
- * must be non-negative and no larger than <tt>csq.length()</tt>.
- * The new buffer's position will be set to this value.
- * @param end The index of the character following the last character to be
- * used; must be no smaller than <tt>start</tt> and no larger
- * than <tt>csq.length()</tt>.
- * The new buffer's limit will be set to this value.
- * @return The new character buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>start</tt> and
- * <tt>end</tt>
- * parameters do not hold
+ * @param csq
+ * The character sequence from which the new character buffer is to
+ * be created
+ *
+ * @param start
+ * The index of the first character to be used;
+ * must be non-negative and no larger than <tt>csq.length()</tt>.
+ * The new buffer's position will be set to this value.
+ *
+ * @param end
+ * The index of the character following the last character to be
+ * used; must be no smaller than <tt>start</tt> and no larger
+ * than <tt>csq.length()</tt>.
+ * The new buffer's limit will be set to this value.
+ *
+ * @return The new character buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>start</tt> and <tt>end</tt>
+ * parameters do not hold
*/
public static CharBuffer wrap(CharSequence csq, int start, int end) {
try {
@@ -276,9 +310,11 @@
* <tt>csq.length()</tt>, its position will be zero, and its mark will be
* undefined. </p>
*
- * @param csq The character sequence from which the new character buffer is to
- * be created
- * @return The new character buffer
+ * @param csq
+ * The character sequence from which the new character buffer is to
+ * be created
+ *
+ * @return The new character buffer
*/
public static CharBuffer wrap(CharSequence csq) {
return wrap(csq, 0, csq.length());
@@ -300,7 +336,7 @@
* buffer is direct, and it will be read-only if, and only if, this buffer
* is read-only. </p>
*
- * @return The new char buffer
+ * @return The new char buffer
*/
public abstract CharBuffer slice();
@@ -317,7 +353,7 @@
* and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return The new char buffer
+ * @return The new char buffer
*/
public abstract CharBuffer duplicate();
@@ -337,7 +373,7 @@
* <p> If this buffer is itself read-only then this method behaves in
* exactly the same way as the {@link #duplicate duplicate} method. </p>
*
- * @return The new, read-only char buffer
+ * @return The new, read-only char buffer
*/
public abstract CharBuffer asReadOnlyBuffer();
@@ -346,11 +382,12 @@
/**
* Relative <i>get</i> method. Reads the char at this buffer's
- * current position, and then increments the position. </p>
+ * current position, and then increments the position.
*
- * @return The char at the buffer's current position
- * @throws BufferUnderflowException If the buffer's current position is not smaller than its
- * limit
+ * @return The char at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If the buffer's current position is not smaller than its limit
*/
public abstract char get();
@@ -360,22 +397,31 @@
* <p> Writes the given char into this buffer at the current
* position, and then increments the position. </p>
*
- * @param c The char to be written
- * @return This buffer
- * @throws BufferOverflowException If this buffer's current position is not smaller than its
- * limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param c
+ * The char to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If this buffer's current position is not smaller than its limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract CharBuffer put(char c);
/**
* Absolute <i>get</i> method. Reads the char at the given
- * index. </p>
+ * index.
*
- * @param index The index from which the char will be read
- * @return The char at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
+ * @param index
+ * The index from which the char will be read
+ *
+ * @return The char at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
*/
public abstract char get(int index);
@@ -396,12 +442,20 @@
* <p> Writes the given char into this buffer at the given
* index. </p>
*
- * @param index The index at which the char will be written
- * @param c The char value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the char will be written
+ *
+ * @param c
+ * The char value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract CharBuffer put(int index, char c);
@@ -427,26 +481,36 @@
* <tt>src.get(dst, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst[i] = src.get(); </pre>
+ * dst[i] = src.get();
+ * }</pre>
*
* except that it first checks that there are sufficient chars in
- * this buffer and it is potentially much more efficient. </p>
+ * this buffer and it is potentially much more efficient.
*
- * @param dst The array into which chars are to be written
- * @param offset The offset within the array of the first char to be
- * written; must be non-negative and no larger than
- * <tt>dst.length</tt>
- * @param length The maximum number of chars to be written to the given
- * array; must be non-negative and no larger than
- * <tt>dst.length - offset</tt>
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> chars
- * remaining in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param dst
+ * The array into which chars are to be written
+ *
+ * @param offset
+ * The offset within the array of the first char to be
+ * written; must be non-negative and no larger than
+ * <tt>dst.length</tt>
+ *
+ * @param length
+ * The maximum number of chars to be written to the given
+ * array; must be non-negative and no larger than
+ * <tt>dst.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> chars
+ * remaining in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public CharBuffer get(char[] dst, int offset, int length) {
checkBounds(offset, length, dst.length);
@@ -502,15 +566,23 @@
* dst.put(src.get()); </pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The source buffer from which chars are to be read;
- * must not be this buffer
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * for the remaining chars in the source buffer
- * @throws IllegalArgumentException If the source buffer is this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source buffer from which chars are to be read;
+ * must not be this buffer
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ * for the remaining chars in the source buffer
+ *
+ * @throws IllegalArgumentException
+ * If the source buffer is this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public CharBuffer put(CharBuffer src) {
if (src == this)
@@ -542,25 +614,37 @@
* <tt>dst.put(src, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst.put(a[i]); </pre>
+ * dst.put(a[i]);
+ * }</pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The array from which chars are to be read
- * @param offset The offset within the array of the first char to be read;
- * must be non-negative and no larger than <tt>array.length</tt>
- * @param length The number of chars to be read from the given array;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The array from which chars are to be read
+ *
+ * @param offset
+ * The offset within the array of the first char to be read;
+ * must be non-negative and no larger than <tt>array.length</tt>
+ *
+ * @param length
+ * The number of chars to be read from the given array;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public CharBuffer put(char[] src, int offset, int length) {
checkBounds(offset, length, src.length);
@@ -583,9 +667,16 @@
* <pre>
* dst.put(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source array
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public final CharBuffer put(char[] src) {
return put(src, 0, src.length);
@@ -612,26 +703,38 @@
* <tt>dst.put(src, start, end)</tt> has exactly the same effect
* as the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = start; i < end; i++)
- * dst.put(src.charAt(i)); </pre>
+ * dst.put(src.charAt(i));
+ * }</pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The string from which chars are to be read
- * @param start The offset within the string of the first char to be read;
- * must be non-negative and no larger than
- * <tt>string.length()</tt>
- * @param end The offset within the string of the last char to be read,
- * plus one; must be non-negative and no larger than
- * <tt>string.length()</tt>
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>start</tt> and
- * <tt>end</tt>
- * parameters do not hold
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The string from which chars are to be read
+ *
+ * @param start
+ * The offset within the string of the first char to be read;
+ * must be non-negative and no larger than
+ * <tt>string.length()</tt>
+ *
+ * @param end
+ * The offset within the string of the last char to be read,
+ * plus one; must be non-negative and no larger than
+ * <tt>string.length()</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>start</tt> and <tt>end</tt>
+ * parameters do not hold
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public CharBuffer put(String src, int start, int end) {
checkBounds(start, end - start, src.length());
@@ -667,9 +770,16 @@
* <pre>
* dst.put(s, 0, s.length()) </pre>
*
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source string
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public final CharBuffer put(String src) {
return put(src, 0, src.length());
@@ -686,8 +796,8 @@
* and {@link #arrayOffset() arrayOffset} methods may safely be invoked.
* </p>
*
- * @return <tt>true</tt> if, and only if, this buffer
- * is backed by an array and is not read-only
+ * @return <tt>true</tt> if, and only if, this buffer
+ * is backed by an array and is not read-only
*/
public final boolean hasArray() {
return (hb != null) && !isReadOnly;
@@ -704,9 +814,13 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The array that backs this buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The array that backs this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final char[] array() {
if (hb == null)
@@ -727,10 +841,14 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The offset within this buffer's array
- * of the first element of the buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The offset within this buffer's array
+ * of the first element of the buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final int arrayOffset() {
if (hb == null)
@@ -758,15 +876,19 @@
* followed immediately by an invocation of another relative <i>put</i>
* method. </p>
*
- * @return This buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+
+ *
+ * @return This buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract CharBuffer compact();
/**
- * Tells whether or not this char buffer is direct. </p>
+ * Tells whether or not this char buffer is direct.
*
- * @return <tt>true</tt> if, and only if, this buffer is direct
+ * @return <tt>true</tt> if, and only if, this buffer is direct
*/
public abstract boolean isDirect();
@@ -782,7 +904,7 @@
* to use buffers as keys in hash maps or similar data structures unless it
* is known that their contents will not change. </p>
*
- * @return The current hash code of this buffer
+ * @return The current hash code of this buffer
*/
public int hashCode() {
int h = 1;
@@ -797,15 +919,15 @@
*
* <p> Two char buffers are equal if, and only if,
*
- * <p><ol>
+ * <ol>
*
- * <li><p> They have the same element type, </p></li>
+ * <li><p> They have the same element type, </p></li>
*
- * <li><p> They have the same number of remaining elements, and
- * </p></li>
+ * <li><p> They have the same number of remaining elements, and
+ * </p></li>
*
- * <li><p> The two sequences of remaining elements, considered
- * independently of their starting positions, are pointwise equal.
+ * <li><p> The two sequences of remaining elements, considered
+ * independently of their starting positions, are pointwise equal.
*
*
*
@@ -813,22 +935,23 @@
*
*
*
- * </p></li>
+ * </p></li>
*
* </ol>
*
* <p> A char buffer is not equal to any other type of object. </p>
*
- * @param ob The object to which this buffer is to be compared
- * @return <tt>true</tt> if, and only if, this buffer is equal to the
- * given object
+ * @param ob The object to which this buffer is to be compared
+ *
+ * @return <tt>true</tt> if, and only if, this buffer is equal to the
+ * given object
*/
public boolean equals(Object ob) {
if (this == ob)
return true;
if (!(ob instanceof CharBuffer))
return false;
- CharBuffer that = (CharBuffer) ob;
+ CharBuffer that = (CharBuffer)ob;
if (this.remaining() != that.remaining())
return false;
int p = this.position();
@@ -860,13 +983,13 @@
*
*
* Pairs of {@code char} elements are compared as if by invoking
- * {@link Character#compare(char, char)}.
- *
+ * {@link Character#compare(char,char)}.
+
*
* <p> A char buffer is not comparable to any other type of object.
*
- * @return A negative integer, zero, or a positive integer as this buffer
- * is less than, equal to, or greater than the given buffer
+ * @return A negative integer, zero, or a positive integer as this buffer
+ * is less than, equal to, or greater than the given buffer
*/
public int compareTo(CharBuffer that) {
int n = this.position() + Math.min(this.remaining(), that.remaining());
@@ -896,7 +1019,7 @@
* at index <tt>limit()</tt> - 1. Invoking this method does not
* change the buffer's position. </p>
*
- * @return The specified string
+ * @return The specified string
*/
public String toString() {
return toString(position(), limit());
@@ -915,7 +1038,7 @@
* (inclusive) and the limit (exclusive); that is, it is equivalent to
* <tt>remaining()</tt>. </p>
*
- * @return The length of this character buffer
+ * @return The length of this character buffer
*/
public final int length() {
return remaining();
@@ -923,13 +1046,17 @@
/**
* Reads the character at the given index relative to the current
- * position. </p>
+ * position.
*
- * @param index The index of the character to be read, relative to the position;
- * must be non-negative and smaller than <tt>remaining()</tt>
- * @return The character at index
- * <tt>position() + index</tt>
- * @throws IndexOutOfBoundsException If the preconditions on <tt>index</tt> do not hold
+ * @param index
+ * The index of the character to be read, relative to the position;
+ * must be non-negative and smaller than <tt>remaining()</tt>
+ *
+ * @return The character at index
+ * <tt>position() + index</tt>
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on <tt>index</tt> do not hold
*/
public final char charAt(int index) {
return get(position() + checkIndex(index, 1));
@@ -948,16 +1075,22 @@
* direct if, and only if, this buffer is direct, and it will be read-only
* if, and only if, this buffer is read-only. </p>
*
- * @param start The index, relative to the current position, of the first
- * character in the subsequence; must be non-negative and no larger
- * than <tt>remaining()</tt>
- * @param end The index, relative to the current position, of the character
- * following the last character in the subsequence; must be no
- * smaller than <tt>start</tt> and no larger than
- * <tt>remaining()</tt>
- * @return The new character buffer
- * @throws IndexOutOfBoundsException If the preconditions on <tt>start</tt> and <tt>end</tt>
- * do not hold
+ * @param start
+ * The index, relative to the current position, of the first
+ * character in the subsequence; must be non-negative and no larger
+ * than <tt>remaining()</tt>
+ *
+ * @param end
+ * The index, relative to the current position, of the character
+ * following the last character in the subsequence; must be no
+ * smaller than <tt>start</tt> and no larger than
+ * <tt>remaining()</tt>
+ *
+ * @return The new character buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on <tt>start</tt> and <tt>end</tt>
+ * do not hold
*/
public abstract CharBuffer subSequence(int start, int end);
@@ -980,13 +1113,20 @@
* toString} method of a character buffer will return a subsequence whose
* content depends upon the buffer's position and limit.
*
- * @param csq The character sequence to append. If <tt>csq</tt> is
- * <tt>null</tt>, then the four characters <tt>"null"</tt> are
- * appended to this character buffer.
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
- * @since 1.5
+ * @param csq
+ * The character sequence to append. If <tt>csq</tt> is
+ * <tt>null</tt>, then the four characters <tt>"null"</tt> are
+ * appended to this character buffer.
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
+ *
+ * @since 1.5
*/
public CharBuffer append(CharSequence csq) {
if (csq == null)
@@ -1006,19 +1146,26 @@
* <pre>
* dst.put(csq.subSequence(start, end).toString()) </pre>
*
- * @param csq The character sequence from which a subsequence will be
- * appended. If <tt>csq</tt> is <tt>null</tt>, then characters
- * will be appended as if <tt>csq</tt> contained the four
- * characters <tt>"null"</tt>.
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws IndexOutOfBoundsException If <tt>start</tt> or <tt>end</tt> are negative,
- * <tt>start</tt>
- * is greater than <tt>end</tt>, or <tt>end</tt> is greater
- * than
- * <tt>csq.length()</tt>
- * @throws ReadOnlyBufferException If this buffer is read-only
- * @since 1.5
+ * @param csq
+ * The character sequence from which a subsequence will be
+ * appended. If <tt>csq</tt> is <tt>null</tt>, then characters
+ * will be appended as if <tt>csq</tt> contained the four
+ * characters <tt>"null"</tt>.
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>start</tt> or <tt>end</tt> are negative, <tt>start</tt>
+ * is greater than <tt>end</tt>, or <tt>end</tt> is greater than
+ * <tt>csq.length()</tt>
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
+ *
+ * @since 1.5
*/
public CharBuffer append(CharSequence csq, int start, int end) {
CharSequence cs = (csq == null ? "null" : csq);
@@ -1035,11 +1182,18 @@
* <pre>
* dst.put(c) </pre>
*
- * @param c The 16-bit char to append
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
- * @since 1.5
+ * @param c
+ * The 16-bit char to append
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
+ *
+ * @since 1.5
*/
public CharBuffer append(char c) {
return put(c);
@@ -1054,12 +1208,12 @@
*
* <p> The byte order of a char buffer created by allocation or by
* wrapping an existing <tt>char</tt> array is the {@link
- * ByteOrder#nativeOrder </code>native order<code>} of the underlying
+ * ByteOrder#nativeOrder native order} of the underlying
* hardware. The byte order of a char buffer created as a <a
* href="ByteBuffer.html#views">view</a> of a byte buffer is that of the
* byte buffer at the moment that the view is created. </p>
*
- * @return This buffer's byte order
+ * @return This buffer's byte order
*/
public abstract ByteOrder order();
diff --git a/ojluni/src/main/java/java/nio/DoubleBuffer.java b/ojluni/src/main/java/java/nio/DoubleBuffer.java
index 5f63d24..d0a0c15 100644
--- a/ojluni/src/main/java/java/nio/DoubleBuffer.java
+++ b/ojluni/src/main/java/java/nio/DoubleBuffer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, 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
@@ -36,30 +36,37 @@
*
* <ul>
*
- * <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and
- * {@link #put(double) </code><i>put</i><code>} methods that read and write
- * single doubles; </p></li>
+ * <li><p> Absolute and relative {@link #get() <i>get</i>} and
+ * {@link #put(double) <i>put</i>} methods that read and write
+ * single doubles; </p></li>
*
- * <li><p> Relative {@link #get(double[]) </code><i>bulk get</i><code>}
- * methods that transfer contiguous sequences of doubles from this buffer
- * into an array; and</p></li>
+ * <li><p> Relative {@link #get(double[]) <i>bulk get</i>}
+ * methods that transfer contiguous sequences of doubles from this buffer
+ * into an array; and</p></li>
*
- * <li><p> Relative {@link #put(double[]) </code><i>bulk put</i><code>}
- * methods that transfer contiguous sequences of doubles from a
- * double array or some other double
- * buffer into this buffer; and </p></li>
+ * <li><p> Relative {@link #put(double[]) <i>bulk put</i>}
+ * methods that transfer contiguous sequences of doubles from a
+ * double array or some other double
+ * buffer into this buffer; and </p></li>
*
- * <li><p> Methods for {@link #compact </code>compacting<code>}, {@link
- * #duplicate </code>duplicating<code>}, and {@link #slice
- * </code>slicing<code>} a double buffer. </p></li>
+ *
+ * <li><p> Methods for {@link #compact compacting}, {@link
+ * #duplicate duplicating}, and {@link #slice slicing}
+ * a double buffer. </p></li>
+ *
* </ul>
*
* <p> Double buffers can be created either by {@link #allocate
- * </code><i>allocation</i><code>}, which allocates space for the buffer's
- * content, by {@link #wrap(double[]) </code><i>wrapping</i><code>} an existing
+ * <i>allocation</i>}, which allocates space for the buffer's
+ *
+ *
+ * content, by {@link #wrap(double[]) <i>wrapping</i>} an existing
* double array into a buffer, or by creating a
* <a href="ByteBuffer.html#views"><i>view</i></a> of an existing byte buffer.
*
+ *
+*
+ *
* <p> Like a byte buffer, a double buffer is either <a
* href="ByteBuffer.html#direct"><i>direct</i> or <i>non-direct</i></a>. A
* double buffer created via the <tt>wrap</tt> methods of this class will
@@ -68,18 +75,24 @@
* a double buffer is direct may be determined by invoking the {@link
* #isDirect isDirect} method. </p>
*
+*
+ *
+ *
* <p> Methods in this class that do not otherwise have a value to return are
* specified to return the buffer upon which they are invoked. This allows
* method invocations to be chained.
*
+ *
+ *
* @author Mark Reinhold
* @author JSR-51 Expert Group
* @since 1.4
*/
public abstract class DoubleBuffer
- extends Buffer
- implements Comparable<DoubleBuffer> {
+ extends Buffer
+ implements Comparable<DoubleBuffer>
+{
// These fields are declared here rather than in Heap-X-Buffer in order to
// reduce the number of virtual method invocations needed to access these
@@ -93,7 +106,8 @@
// backing array, and array offset
//
DoubleBuffer(int mark, int pos, int lim, int cap, // package-private
- double[] hb, int offset) {
+ double[] hb, int offset)
+ {
super(mark, pos, lim, cap, 3);
this.hb = hb;
this.offset = offset;
@@ -111,13 +125,16 @@
*
* <p> The new buffer's position will be zero, its limit will be its
* capacity, its mark will be undefined, and each of its elements will be
- * initialized to zero. It will have a {@link #array
- * </code>backing array<code>}, and its {@link #arrayOffset </code>array
- * offset<code>} will be zero.
+ * initialized to zero. It will have a {@link #array backing array},
+ * and its {@link #arrayOffset array offset} will be zero.
*
- * @param capacity The new buffer's capacity, in doubles
- * @return The new double buffer
- * @throws IllegalArgumentException If the <tt>capacity</tt> is a negative integer
+ * @param capacity
+ * The new buffer's capacity, in doubles
+ *
+ * @return The new double buffer
+ *
+ * @throws IllegalArgumentException
+ * If the <tt>capacity</tt> is a negative integer
*/
public static DoubleBuffer allocate(int capacity) {
if (capacity < 0)
@@ -133,24 +150,32 @@
* and vice versa. The new buffer's capacity will be
* <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit
* will be <tt>offset + length</tt>, and its mark will be undefined. Its
- * {@link #array </code>backing array<code>} will be the given array, and
- * its {@link #arrayOffset </code>array offset<code>} will be zero. </p>
+ * {@link #array backing array} will be the given array, and
+ * its {@link #arrayOffset array offset} will be zero. </p>
*
- * @param array The array that will back the new buffer
- * @param offset The offset of the subarray to be used; must be non-negative and
- * no larger than <tt>array.length</tt>. The new buffer's position
- * will be set to this value.
- * @param length The length of the subarray to be used;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>.
- * The new buffer's limit will be set to <tt>offset + length</tt>.
- * @return The new double buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param array
+ * The array that will back the new buffer
+ *
+ * @param offset
+ * The offset of the subarray to be used; must be non-negative and
+ * no larger than <tt>array.length</tt>. The new buffer's position
+ * will be set to this value.
+ *
+ * @param length
+ * The length of the subarray to be used;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>.
+ * The new buffer's limit will be set to <tt>offset + length</tt>.
+ *
+ * @return The new double buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public static DoubleBuffer wrap(double[] array,
- int offset, int length) {
+ int offset, int length)
+ {
try {
return new HeapDoubleBuffer(array, offset, length);
} catch (IllegalArgumentException x) {
@@ -165,12 +190,14 @@
* that is, modifications to the buffer will cause the array to be modified
* and vice versa. The new buffer's capacity and limit will be
* <tt>array.length</tt>, its position will be zero, and its mark will be
- * undefined. Its {@link #array </code>backing array<code>} will be the
- * given array, and its {@link #arrayOffset </code>array offset<code>} will
+ * undefined. Its {@link #array backing array} will be the
+ * given array, and its {@link #arrayOffset array offset>} will
* be zero. </p>
*
- * @param array The array that will back this buffer
- * @return The new double buffer
+ * @param array
+ * The array that will back this buffer
+ *
+ * @return The new double buffer
*/
public static DoubleBuffer wrap(double[] array) {
return wrap(array, 0, array.length);
@@ -192,7 +219,7 @@
* buffer is direct, and it will be read-only if, and only if, this buffer
* is read-only. </p>
*
- * @return The new double buffer
+ * @return The new double buffer
*/
public abstract DoubleBuffer slice();
@@ -209,7 +236,7 @@
* and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return The new double buffer
+ * @return The new double buffer
*/
public abstract DoubleBuffer duplicate();
@@ -229,7 +256,7 @@
* <p> If this buffer is itself read-only then this method behaves in
* exactly the same way as the {@link #duplicate duplicate} method. </p>
*
- * @return The new, read-only double buffer
+ * @return The new, read-only double buffer
*/
public abstract DoubleBuffer asReadOnlyBuffer();
@@ -238,11 +265,12 @@
/**
* Relative <i>get</i> method. Reads the double at this buffer's
- * current position, and then increments the position. </p>
+ * current position, and then increments the position.
*
- * @return The double at the buffer's current position
- * @throws BufferUnderflowException If the buffer's current position is not smaller than its
- * limit
+ * @return The double at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If the buffer's current position is not smaller than its limit
*/
public abstract double get();
@@ -252,22 +280,31 @@
* <p> Writes the given double into this buffer at the current
* position, and then increments the position. </p>
*
- * @param d The double to be written
- * @return This buffer
- * @throws BufferOverflowException If this buffer's current position is not smaller than its
- * limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param d
+ * The double to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If this buffer's current position is not smaller than its limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract DoubleBuffer put(double d);
/**
* Absolute <i>get</i> method. Reads the double at the given
- * index. </p>
+ * index.
*
- * @param index The index from which the double will be read
- * @return The double at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
+ * @param index
+ * The index from which the double will be read
+ *
+ * @return The double at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
*/
public abstract double get(int index);
@@ -277,12 +314,20 @@
* <p> Writes the given double into this buffer at the given
* index. </p>
*
- * @param index The index at which the double will be written
- * @param d The double value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the double will be written
+ *
+ * @param d
+ * The double value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract DoubleBuffer put(int index, double d);
@@ -308,26 +353,36 @@
* <tt>src.get(dst, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst[i] = src.get(); </pre>
+ * dst[i] = src.get();
+ * }</pre>
*
* except that it first checks that there are sufficient doubles in
- * this buffer and it is potentially much more efficient. </p>
+ * this buffer and it is potentially much more efficient.
*
- * @param dst The array into which doubles are to be written
- * @param offset The offset within the array of the first double to be
- * written; must be non-negative and no larger than
- * <tt>dst.length</tt>
- * @param length The maximum number of doubles to be written to the given
- * array; must be non-negative and no larger than
- * <tt>dst.length - offset</tt>
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> doubles
- * remaining in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param dst
+ * The array into which doubles are to be written
+ *
+ * @param offset
+ * The offset within the array of the first double to be
+ * written; must be non-negative and no larger than
+ * <tt>dst.length</tt>
+ *
+ * @param length
+ * The maximum number of doubles to be written to the given
+ * array; must be non-negative and no larger than
+ * <tt>dst.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> doubles
+ * remaining in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public DoubleBuffer get(double[] dst, int offset, int length) {
checkBounds(offset, length, dst.length);
@@ -349,9 +404,14 @@
* <pre>
* src.get(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> doubles
- * remaining in this buffer
+ * @param dst
+ * The destination array
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> doubles
+ * remaining in this buffer
*/
public DoubleBuffer get(double[] dst) {
return get(dst, 0, dst.length);
@@ -383,15 +443,23 @@
* dst.put(src.get()); </pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The source buffer from which doubles are to be read;
- * must not be this buffer
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * for the remaining doubles in the source buffer
- * @throws IllegalArgumentException If the source buffer is this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source buffer from which doubles are to be read;
+ * must not be this buffer
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ * for the remaining doubles in the source buffer
+ *
+ * @throws IllegalArgumentException
+ * If the source buffer is this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public DoubleBuffer put(DoubleBuffer src) {
if (src == this)
@@ -423,25 +491,37 @@
* <tt>dst.put(src, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst.put(a[i]); </pre>
+ * dst.put(a[i]);
+ * }</pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The array from which doubles are to be read
- * @param offset The offset within the array of the first double to be read;
- * must be non-negative and no larger than <tt>array.length</tt>
- * @param length The number of doubles to be read from the given array;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The array from which doubles are to be read
+ *
+ * @param offset
+ * The offset within the array of the first double to be read;
+ * must be non-negative and no larger than <tt>array.length</tt>
+ *
+ * @param length
+ * The number of doubles to be read from the given array;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public DoubleBuffer put(double[] src, int offset, int length) {
checkBounds(offset, length, src.length);
@@ -464,9 +544,16 @@
* <pre>
* dst.put(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source array
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public final DoubleBuffer put(double[] src) {
return put(src, 0, src.length);
@@ -483,8 +570,8 @@
* and {@link #arrayOffset() arrayOffset} methods may safely be invoked.
* </p>
*
- * @return <tt>true</tt> if, and only if, this buffer
- * is backed by an array and is not read-only
+ * @return <tt>true</tt> if, and only if, this buffer
+ * is backed by an array and is not read-only
*/
public final boolean hasArray() {
return (hb != null) && !isReadOnly;
@@ -501,9 +588,13 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The array that backs this buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The array that backs this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final double[] array() {
if (hb == null)
@@ -524,10 +615,14 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The offset within this buffer's array
- * of the first element of the buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The offset within this buffer's array
+ * of the first element of the buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final int arrayOffset() {
if (hb == null)
@@ -555,23 +650,27 @@
* followed immediately by an invocation of another relative <i>put</i>
* method. </p>
*
- * @return This buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+
+ *
+ * @return This buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract DoubleBuffer compact();
/**
- * Tells whether or not this double buffer is direct. </p>
+ * Tells whether or not this double buffer is direct.
*
- * @return <tt>true</tt> if, and only if, this buffer is direct
+ * @return <tt>true</tt> if, and only if, this buffer is direct
*/
public abstract boolean isDirect();
/**
- * Returns a string summarizing the state of this buffer. </p>
+ * Returns a string summarizing the state of this buffer.
*
- * @return A summary string
+ * @return A summary string
*/
public String toString() {
StringBuffer sb = new StringBuffer();
@@ -598,7 +697,7 @@
* to use buffers as keys in hash maps or similar data structures unless it
* is known that their contents will not change. </p>
*
- * @return The current hash code of this buffer
+ * @return The current hash code of this buffer
*/
public int hashCode() {
int h = 1;
@@ -613,38 +712,39 @@
*
* <p> Two double buffers are equal if, and only if,
*
- * <p><ol>
+ * <ol>
*
- * <li><p> They have the same element type, </p></li>
+ * <li><p> They have the same element type, </p></li>
*
- * <li><p> They have the same number of remaining elements, and
- * </p></li>
+ * <li><p> They have the same number of remaining elements, and
+ * </p></li>
*
- * <li><p> The two sequences of remaining elements, considered
- * independently of their starting positions, are pointwise equal.
- *
- * This method considers two double elements {@code a} and {@code b}
- * to be equal if
- * {@code (a == b) || (Double.isNaN(a) && Double.isNaN(b))}.
- * The values {@code -0.0} and {@code +0.0} are considered to be
- * equal, unlike {@link Double#equals(Object)}.
- *
- * </p></li>
+ * <li><p> The two sequences of remaining elements, considered
+ * independently of their starting positions, are pointwise equal.
+
+ * This method considers two double elements {@code a} and {@code b}
+ * to be equal if
+ * {@code (a == b) || (Double.isNaN(a) && Double.isNaN(b))}.
+ * The values {@code -0.0} and {@code +0.0} are considered to be
+ * equal, unlike {@link Double#equals(Object)}.
+
+ * </p></li>
*
* </ol>
*
* <p> A double buffer is not equal to any other type of object. </p>
*
- * @param ob The object to which this buffer is to be compared
- * @return <tt>true</tt> if, and only if, this buffer is equal to the
- * given object
+ * @param ob The object to which this buffer is to be compared
+ *
+ * @return <tt>true</tt> if, and only if, this buffer is equal to the
+ * given object
*/
public boolean equals(Object ob) {
if (this == ob)
return true;
if (!(ob instanceof DoubleBuffer))
return false;
- DoubleBuffer that = (DoubleBuffer) ob;
+ DoubleBuffer that = (DoubleBuffer)ob;
if (this.remaining() != that.remaining())
return false;
int p = this.position();
@@ -667,22 +767,19 @@
* <p> Two double buffers are compared by comparing their sequences of
* remaining elements lexicographically, without regard to the starting
* position of each sequence within its corresponding buffer.
- *
+
* Pairs of {@code double} elements are compared as if by invoking
- * {@link Double#compare(double, double)}, except that
+ * {@link Double#compare(double,double)}, except that
* {@code -0.0} and {@code 0.0} are considered to be equal.
* {@code Double.NaN} is considered by this method to be equal
* to itself and greater than all other {@code double} values
* (including {@code Double.POSITIVE_INFINITY}).
- *
- *
- *
- *
+
*
* <p> A double buffer is not comparable to any other type of object.
*
- * @return A negative integer, zero, or a positive integer as this buffer
- * is less than, equal to, or greater than the given buffer
+ * @return A negative integer, zero, or a positive integer as this buffer
+ * is less than, equal to, or greater than the given buffer
*/
public int compareTo(DoubleBuffer that) {
int n = this.position() + Math.min(this.remaining(), that.remaining());
@@ -698,11 +795,10 @@
private static int compare(double x, double y) {
- return ((x < y) ? -1 :
- (x > y) ? +1 :
- (x == y) ? 0 :
- Double.isNaN(x) ? (Double.isNaN(y) ? 0 : +1) : -1);
-
+ return ((x < y) ? -1 :
+ (x > y) ? +1 :
+ (x == y) ? 0 :
+ Double.isNaN(x) ? (Double.isNaN(y) ? 0 : +1) : -1);
}
@@ -717,12 +813,12 @@
*
* <p> The byte order of a double buffer created by allocation or by
* wrapping an existing <tt>double</tt> array is the {@link
- * ByteOrder#nativeOrder </code>native order<code>} of the underlying
+ * ByteOrder#nativeOrder native order} of the underlying
* hardware. The byte order of a double buffer created as a <a
* href="ByteBuffer.html#views">view</a> of a byte buffer is that of the
* byte buffer at the moment that the view is created. </p>
*
- * @return This buffer's byte order
+ * @return This buffer's byte order
*/
public abstract ByteOrder order();
diff --git a/ojluni/src/main/java/java/nio/FloatBuffer.java b/ojluni/src/main/java/java/nio/FloatBuffer.java
index cd2a502..90e65ff 100644
--- a/ojluni/src/main/java/java/nio/FloatBuffer.java
+++ b/ojluni/src/main/java/java/nio/FloatBuffer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, 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
@@ -36,31 +36,37 @@
*
* <ul>
*
- * <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and
- * {@link #put(float) </code><i>put</i><code>} methods that read and write
- * single floats; </p></li>
+ * <li><p> Absolute and relative {@link #get() <i>get</i>} and
+ * {@link #put(float) <i>put</i>} methods that read and write
+ * single floats; </p></li>
*
- * <li><p> Relative {@link #get(float[]) </code><i>bulk get</i><code>}
- * methods that transfer contiguous sequences of floats from this buffer
- * into an array; and</p></li>
+ * <li><p> Relative {@link #get(float[]) <i>bulk get</i>}
+ * methods that transfer contiguous sequences of floats from this buffer
+ * into an array; and</p></li>
*
- * <li><p> Relative {@link #put(float[]) </code><i>bulk put</i><code>}
- * methods that transfer contiguous sequences of floats from a
- * float array or some other float
- * buffer into this buffer; and </p></li>
+ * <li><p> Relative {@link #put(float[]) <i>bulk put</i>}
+ * methods that transfer contiguous sequences of floats from a
+ * float array or some other float
+ * buffer into this buffer; and </p></li>
*
- * <li><p> Methods for {@link #compact </code>compacting<code>}, {@link
- * #duplicate </code>duplicating<code>}, and {@link #slice
- * </code>slicing<code>} a float buffer. </p></li>
+ *
+ * <li><p> Methods for {@link #compact compacting}, {@link
+ * #duplicate duplicating}, and {@link #slice slicing}
+ * a float buffer. </p></li>
*
* </ul>
*
* <p> Float buffers can be created either by {@link #allocate
- * </code><i>allocation</i><code>}, which allocates space for the buffer's
- * content, by {@link #wrap(float[]) </code><i>wrapping</i><code>} an existing
+ * <i>allocation</i>}, which allocates space for the buffer's
+ *
+ *
+ * content, by {@link #wrap(float[]) <i>wrapping</i>} an existing
* float array into a buffer, or by creating a
* <a href="ByteBuffer.html#views"><i>view</i></a> of an existing byte buffer.
*
+ *
+*
+ *
* <p> Like a byte buffer, a float buffer is either <a
* href="ByteBuffer.html#direct"><i>direct</i> or <i>non-direct</i></a>. A
* float buffer created via the <tt>wrap</tt> methods of this class will
@@ -69,18 +75,24 @@
* a float buffer is direct may be determined by invoking the {@link
* #isDirect isDirect} method. </p>
*
+*
+ *
+ *
* <p> Methods in this class that do not otherwise have a value to return are
* specified to return the buffer upon which they are invoked. This allows
* method invocations to be chained.
*
+ *
+ *
* @author Mark Reinhold
* @author JSR-51 Expert Group
* @since 1.4
*/
public abstract class FloatBuffer
- extends Buffer
- implements Comparable<FloatBuffer> {
+ extends Buffer
+ implements Comparable<FloatBuffer>
+{
// These fields are declared here rather than in Heap-X-Buffer in order to
// reduce the number of virtual method invocations needed to access these
@@ -94,7 +106,8 @@
// backing array, and array offset
//
FloatBuffer(int mark, int pos, int lim, int cap, // package-private
- float[] hb, int offset) {
+ float[] hb, int offset)
+ {
super(mark, pos, lim, cap, 2);
this.hb = hb;
this.offset = offset;
@@ -112,13 +125,16 @@
*
* <p> The new buffer's position will be zero, its limit will be its
* capacity, its mark will be undefined, and each of its elements will be
- * initialized to zero. It will have a {@link #array
- * </code>backing array<code>}, and its {@link #arrayOffset </code>array
- * offset<code>} will be zero.
+ * initialized to zero. It will have a {@link #array backing array},
+ * and its {@link #arrayOffset array offset} will be zero.
*
- * @param capacity The new buffer's capacity, in floats
- * @return The new float buffer
- * @throws IllegalArgumentException If the <tt>capacity</tt> is a negative integer
+ * @param capacity
+ * The new buffer's capacity, in floats
+ *
+ * @return The new float buffer
+ *
+ * @throws IllegalArgumentException
+ * If the <tt>capacity</tt> is a negative integer
*/
public static FloatBuffer allocate(int capacity) {
if (capacity < 0)
@@ -134,24 +150,32 @@
* and vice versa. The new buffer's capacity will be
* <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit
* will be <tt>offset + length</tt>, and its mark will be undefined. Its
- * {@link #array </code>backing array<code>} will be the given array, and
- * its {@link #arrayOffset </code>array offset<code>} will be zero. </p>
+ * {@link #array backing array} will be the given array, and
+ * its {@link #arrayOffset array offset} will be zero. </p>
*
- * @param array The array that will back the new buffer
- * @param offset The offset of the subarray to be used; must be non-negative and
- * no larger than <tt>array.length</tt>. The new buffer's position
- * will be set to this value.
- * @param length The length of the subarray to be used;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>.
- * The new buffer's limit will be set to <tt>offset + length</tt>.
- * @return The new float buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param array
+ * The array that will back the new buffer
+ *
+ * @param offset
+ * The offset of the subarray to be used; must be non-negative and
+ * no larger than <tt>array.length</tt>. The new buffer's position
+ * will be set to this value.
+ *
+ * @param length
+ * The length of the subarray to be used;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>.
+ * The new buffer's limit will be set to <tt>offset + length</tt>.
+ *
+ * @return The new float buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public static FloatBuffer wrap(float[] array,
- int offset, int length) {
+ int offset, int length)
+ {
try {
return new HeapFloatBuffer(array, offset, length);
} catch (IllegalArgumentException x) {
@@ -166,12 +190,14 @@
* that is, modifications to the buffer will cause the array to be modified
* and vice versa. The new buffer's capacity and limit will be
* <tt>array.length</tt>, its position will be zero, and its mark will be
- * undefined. Its {@link #array </code>backing array<code>} will be the
- * given array, and its {@link #arrayOffset </code>array offset<code>} will
+ * undefined. Its {@link #array backing array} will be the
+ * given array, and its {@link #arrayOffset array offset>} will
* be zero. </p>
*
- * @param array The array that will back this buffer
- * @return The new float buffer
+ * @param array
+ * The array that will back this buffer
+ *
+ * @return The new float buffer
*/
public static FloatBuffer wrap(float[] array) {
return wrap(array, 0, array.length);
@@ -193,7 +219,7 @@
* buffer is direct, and it will be read-only if, and only if, this buffer
* is read-only. </p>
*
- * @return The new float buffer
+ * @return The new float buffer
*/
public abstract FloatBuffer slice();
@@ -210,7 +236,7 @@
* and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return The new float buffer
+ * @return The new float buffer
*/
public abstract FloatBuffer duplicate();
@@ -230,7 +256,7 @@
* <p> If this buffer is itself read-only then this method behaves in
* exactly the same way as the {@link #duplicate duplicate} method. </p>
*
- * @return The new, read-only float buffer
+ * @return The new, read-only float buffer
*/
public abstract FloatBuffer asReadOnlyBuffer();
@@ -239,11 +265,12 @@
/**
* Relative <i>get</i> method. Reads the float at this buffer's
- * current position, and then increments the position. </p>
+ * current position, and then increments the position.
*
- * @return The float at the buffer's current position
- * @throws BufferUnderflowException If the buffer's current position is not smaller than its
- * limit
+ * @return The float at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If the buffer's current position is not smaller than its limit
*/
public abstract float get();
@@ -253,22 +280,31 @@
* <p> Writes the given float into this buffer at the current
* position, and then increments the position. </p>
*
- * @param f The float to be written
- * @return This buffer
- * @throws BufferOverflowException If this buffer's current position is not smaller than its
- * limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param f
+ * The float to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If this buffer's current position is not smaller than its limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract FloatBuffer put(float f);
/**
* Absolute <i>get</i> method. Reads the float at the given
- * index. </p>
+ * index.
*
- * @param index The index from which the float will be read
- * @return The float at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
+ * @param index
+ * The index from which the float will be read
+ *
+ * @return The float at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
*/
public abstract float get(int index);
@@ -278,12 +314,20 @@
* <p> Writes the given float into this buffer at the given
* index. </p>
*
- * @param index The index at which the float will be written
- * @param f The float value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the float will be written
+ *
+ * @param f
+ * The float value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract FloatBuffer put(int index, float f);
@@ -309,26 +353,36 @@
* <tt>src.get(dst, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst[i] = src.get(); </pre>
+ * dst[i] = src.get();
+ * }</pre>
*
* except that it first checks that there are sufficient floats in
- * this buffer and it is potentially much more efficient. </p>
+ * this buffer and it is potentially much more efficient.
*
- * @param dst The array into which floats are to be written
- * @param offset The offset within the array of the first float to be
- * written; must be non-negative and no larger than
- * <tt>dst.length</tt>
- * @param length The maximum number of floats to be written to the given
- * array; must be non-negative and no larger than
- * <tt>dst.length - offset</tt>
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> floats
- * remaining in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param dst
+ * The array into which floats are to be written
+ *
+ * @param offset
+ * The offset within the array of the first float to be
+ * written; must be non-negative and no larger than
+ * <tt>dst.length</tt>
+ *
+ * @param length
+ * The maximum number of floats to be written to the given
+ * array; must be non-negative and no larger than
+ * <tt>dst.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> floats
+ * remaining in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public FloatBuffer get(float[] dst, int offset, int length) {
checkBounds(offset, length, dst.length);
@@ -350,9 +404,14 @@
* <pre>
* src.get(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> floats
- * remaining in this buffer
+ * @param dst
+ * The destination array
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> floats
+ * remaining in this buffer
*/
public FloatBuffer get(float[] dst) {
return get(dst, 0, dst.length);
@@ -384,15 +443,23 @@
* dst.put(src.get()); </pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The source buffer from which floats are to be read;
- * must not be this buffer
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * for the remaining floats in the source buffer
- * @throws IllegalArgumentException If the source buffer is this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source buffer from which floats are to be read;
+ * must not be this buffer
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ * for the remaining floats in the source buffer
+ *
+ * @throws IllegalArgumentException
+ * If the source buffer is this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public FloatBuffer put(FloatBuffer src) {
if (src == this)
@@ -424,25 +491,37 @@
* <tt>dst.put(src, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst.put(a[i]); </pre>
+ * dst.put(a[i]);
+ * }</pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The array from which floats are to be read
- * @param offset The offset within the array of the first float to be read;
- * must be non-negative and no larger than <tt>array.length</tt>
- * @param length The number of floats to be read from the given array;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The array from which floats are to be read
+ *
+ * @param offset
+ * The offset within the array of the first float to be read;
+ * must be non-negative and no larger than <tt>array.length</tt>
+ *
+ * @param length
+ * The number of floats to be read from the given array;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public FloatBuffer put(float[] src, int offset, int length) {
checkBounds(offset, length, src.length);
@@ -465,9 +544,16 @@
* <pre>
* dst.put(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source array
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public final FloatBuffer put(float[] src) {
return put(src, 0, src.length);
@@ -484,8 +570,8 @@
* and {@link #arrayOffset() arrayOffset} methods may safely be invoked.
* </p>
*
- * @return <tt>true</tt> if, and only if, this buffer
- * is backed by an array and is not read-only
+ * @return <tt>true</tt> if, and only if, this buffer
+ * is backed by an array and is not read-only
*/
public final boolean hasArray() {
return (hb != null) && !isReadOnly;
@@ -502,9 +588,13 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The array that backs this buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The array that backs this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final float[] array() {
if (hb == null)
@@ -525,10 +615,14 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The offset within this buffer's array
- * of the first element of the buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The offset within this buffer's array
+ * of the first element of the buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final int arrayOffset() {
if (hb == null)
@@ -556,23 +650,27 @@
* followed immediately by an invocation of another relative <i>put</i>
* method. </p>
*
- * @return This buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+
+ *
+ * @return This buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract FloatBuffer compact();
/**
- * Tells whether or not this float buffer is direct. </p>
+ * Tells whether or not this float buffer is direct.
*
- * @return <tt>true</tt> if, and only if, this buffer is direct
+ * @return <tt>true</tt> if, and only if, this buffer is direct
*/
public abstract boolean isDirect();
/**
- * Returns a string summarizing the state of this buffer. </p>
+ * Returns a string summarizing the state of this buffer.
*
- * @return A summary string
+ * @return A summary string
*/
public String toString() {
StringBuffer sb = new StringBuffer();
@@ -599,7 +697,7 @@
* to use buffers as keys in hash maps or similar data structures unless it
* is known that their contents will not change. </p>
*
- * @return The current hash code of this buffer
+ * @return The current hash code of this buffer
*/
public int hashCode() {
int h = 1;
@@ -614,38 +712,39 @@
*
* <p> Two float buffers are equal if, and only if,
*
- * <p><ol>
+ * <ol>
*
- * <li><p> They have the same element type, </p></li>
+ * <li><p> They have the same element type, </p></li>
*
- * <li><p> They have the same number of remaining elements, and
- * </p></li>
+ * <li><p> They have the same number of remaining elements, and
+ * </p></li>
*
- * <li><p> The two sequences of remaining elements, considered
- * independently of their starting positions, are pointwise equal.
- *
- * This method considers two float elements {@code a} and {@code b}
- * to be equal if
- * {@code (a == b) || (Float.isNaN(a) && Float.isNaN(b))}.
- * The values {@code -0.0} and {@code +0.0} are considered to be
- * equal, unlike {@link Float#equals(Object)}.
- *
- * </p></li>
+ * <li><p> The two sequences of remaining elements, considered
+ * independently of their starting positions, are pointwise equal.
+
+ * This method considers two float elements {@code a} and {@code b}
+ * to be equal if
+ * {@code (a == b) || (Float.isNaN(a) && Float.isNaN(b))}.
+ * The values {@code -0.0} and {@code +0.0} are considered to be
+ * equal, unlike {@link Float#equals(Object)}.
+
+ * </p></li>
*
* </ol>
*
* <p> A float buffer is not equal to any other type of object. </p>
*
- * @param ob The object to which this buffer is to be compared
- * @return <tt>true</tt> if, and only if, this buffer is equal to the
- * given object
+ * @param ob The object to which this buffer is to be compared
+ *
+ * @return <tt>true</tt> if, and only if, this buffer is equal to the
+ * given object
*/
public boolean equals(Object ob) {
if (this == ob)
return true;
if (!(ob instanceof FloatBuffer))
return false;
- FloatBuffer that = (FloatBuffer) ob;
+ FloatBuffer that = (FloatBuffer)ob;
if (this.remaining() != that.remaining())
return false;
int p = this.position();
@@ -668,9 +767,9 @@
* <p> Two float buffers are compared by comparing their sequences of
* remaining elements lexicographically, without regard to the starting
* position of each sequence within its corresponding buffer.
- *
+
* Pairs of {@code float} elements are compared as if by invoking
- * {@link Float#compare(float, float)}, except that
+ * {@link Float#compare(float,float)}, except that
* {@code -0.0} and {@code 0.0} are considered to be equal.
* {@code Float.NaN} is considered by this method to be equal
* to itself and greater than all other {@code float} values
@@ -682,8 +781,8 @@
*
* <p> A float buffer is not comparable to any other type of object.
*
- * @return A negative integer, zero, or a positive integer as this buffer
- * is less than, equal to, or greater than the given buffer
+ * @return A negative integer, zero, or a positive integer as this buffer
+ * is less than, equal to, or greater than the given buffer
*/
public int compareTo(FloatBuffer that) {
int n = this.position() + Math.min(this.remaining(), that.remaining());
@@ -697,25 +796,28 @@
private static int compare(float x, float y) {
- return ((x < y) ? -1 :
- (x > y) ? +1 :
- (x == y) ? 0 :
- Float.isNaN(x) ? (Float.isNaN(y) ? 0 : +1) : -1);
-
+ return ((x < y) ? -1 :
+ (x > y) ? +1 :
+ (x == y) ? 0 :
+ Float.isNaN(x) ? (Float.isNaN(y) ? 0 : +1) : -1);
}
+ // -- Other char stuff --
+
+ // -- Other byte stuff: Access to binary data --
+
/**
* Retrieves this buffer's byte order.
*
* <p> The byte order of a float buffer created by allocation or by
* wrapping an existing <tt>float</tt> array is the {@link
- * ByteOrder#nativeOrder </code>native order<code>} of the underlying
+ * ByteOrder#nativeOrder native order} of the underlying
* hardware. The byte order of a float buffer created as a <a
* href="ByteBuffer.html#views">view</a> of a byte buffer is that of the
* byte buffer at the moment that the view is created. </p>
*
- * @return This buffer's byte order
+ * @return This buffer's byte order
*/
public abstract ByteOrder order();
diff --git a/ojluni/src/main/java/java/nio/IntBuffer.java b/ojluni/src/main/java/java/nio/IntBuffer.java
index 4a20949..a0004ba 100644
--- a/ojluni/src/main/java/java/nio/IntBuffer.java
+++ b/ojluni/src/main/java/java/nio/IntBuffer.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 The Android Open Source Project
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, 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
@@ -37,32 +37,37 @@
*
* <ul>
*
- * <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and
- * {@link #put(int) </code><i>put</i><code>} methods that read and write
- * single ints; </p></li>
+ * <li><p> Absolute and relative {@link #get() <i>get</i>} and
+ * {@link #put(int) <i>put</i>} methods that read and write
+ * single ints; </p></li>
*
- * <li><p> Relative {@link #get(int[]) </code><i>bulk get</i><code>}
- * methods that transfer contiguous sequences of ints from this buffer
- * into an array; and</p></li>
+ * <li><p> Relative {@link #get(int[]) <i>bulk get</i>}
+ * methods that transfer contiguous sequences of ints from this buffer
+ * into an array; and</p></li>
*
- * <li><p> Relative {@link #put(int[]) </code><i>bulk put</i><code>}
- * methods that transfer contiguous sequences of ints from an
- * int array or some other int
- * buffer into this buffer; and </p></li>
+ * <li><p> Relative {@link #put(int[]) <i>bulk put</i>}
+ * methods that transfer contiguous sequences of ints from an
+ * int array or some other int
+ * buffer into this buffer; and </p></li>
*
- * <li><p> Methods for {@link #compact </code>compacting<code>}, {@link
- * #duplicate </code>duplicating<code>}, and {@link #slice
- * </code>slicing<code>} an int buffer. </p></li>
+ *
+ * <li><p> Methods for {@link #compact compacting}, {@link
+ * #duplicate duplicating}, and {@link #slice slicing}
+ * an int buffer. </p></li>
*
* </ul>
*
* <p> Int buffers can be created either by {@link #allocate
- * </code><i>allocation</i><code>}, which allocates space for the buffer's
+ * <i>allocation</i>}, which allocates space for the buffer's
*
- * content, by {@link #wrap(int[]) </code><i>wrapping</i><code>} an existing
+ *
+ * content, by {@link #wrap(int[]) <i>wrapping</i>} an existing
* int array into a buffer, or by creating a
* <a href="ByteBuffer.html#views"><i>view</i></a> of an existing byte buffer.
*
+ *
+*
+ *
* <p> Like a byte buffer, an int buffer is either <a
* href="ByteBuffer.html#direct"><i>direct</i> or <i>non-direct</i></a>. A
* int buffer created via the <tt>wrap</tt> methods of this class will
@@ -71,18 +76,24 @@
* an int buffer is direct may be determined by invoking the {@link
* #isDirect isDirect} method. </p>
*
+*
+ *
+ *
* <p> Methods in this class that do not otherwise have a value to return are
* specified to return the buffer upon which they are invoked. This allows
* method invocations to be chained.
*
+ *
+ *
* @author Mark Reinhold
* @author JSR-51 Expert Group
* @since 1.4
*/
public abstract class IntBuffer
- extends Buffer
- implements Comparable<IntBuffer> {
+ extends Buffer
+ implements Comparable<IntBuffer>
+{
// These fields are declared here rather than in Heap-X-Buffer in order to
// reduce the number of virtual method invocations needed to access these
@@ -96,7 +107,8 @@
// backing array, and array offset
//
IntBuffer(int mark, int pos, int lim, int cap, // package-private
- int[] hb, int offset) {
+ int[] hb, int offset)
+ {
super(mark, pos, lim, cap, 2);
this.hb = hb;
this.offset = offset;
@@ -114,13 +126,16 @@
*
* <p> The new buffer's position will be zero, its limit will be its
* capacity, its mark will be undefined, and each of its elements will be
- * initialized to zero. It will have a {@link #array
- * </code>backing array<code>}, and its {@link #arrayOffset </code>array
- * offset<code>} will be zero.
+ * initialized to zero. It will have a {@link #array backing array},
+ * and its {@link #arrayOffset array offset} will be zero.
*
- * @param capacity The new buffer's capacity, in ints
- * @return The new int buffer
- * @throws IllegalArgumentException If the <tt>capacity</tt> is a negative integer
+ * @param capacity
+ * The new buffer's capacity, in ints
+ *
+ * @return The new int buffer
+ *
+ * @throws IllegalArgumentException
+ * If the <tt>capacity</tt> is a negative integer
*/
public static IntBuffer allocate(int capacity) {
if (capacity < 0)
@@ -136,24 +151,32 @@
* and vice versa. The new buffer's capacity will be
* <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit
* will be <tt>offset + length</tt>, and its mark will be undefined. Its
- * {@link #array </code>backing array<code>} will be the given array, and
- * its {@link #arrayOffset </code>array offset<code>} will be zero. </p>
+ * {@link #array backing array} will be the given array, and
+ * its {@link #arrayOffset array offset} will be zero. </p>
*
- * @param array The array that will back the new buffer
- * @param offset The offset of the subarray to be used; must be non-negative and
- * no larger than <tt>array.length</tt>. The new buffer's position
- * will be set to this value.
- * @param length The length of the subarray to be used;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>.
- * The new buffer's limit will be set to <tt>offset + length</tt>.
- * @return The new int buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param array
+ * The array that will back the new buffer
+ *
+ * @param offset
+ * The offset of the subarray to be used; must be non-negative and
+ * no larger than <tt>array.length</tt>. The new buffer's position
+ * will be set to this value.
+ *
+ * @param length
+ * The length of the subarray to be used;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>.
+ * The new buffer's limit will be set to <tt>offset + length</tt>.
+ *
+ * @return The new int buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public static IntBuffer wrap(int[] array,
- int offset, int length) {
+ int offset, int length)
+ {
try {
return new HeapIntBuffer(array, offset, length);
} catch (IllegalArgumentException x) {
@@ -168,12 +191,14 @@
* that is, modifications to the buffer will cause the array to be modified
* and vice versa. The new buffer's capacity and limit will be
* <tt>array.length</tt>, its position will be zero, and its mark will be
- * undefined. Its {@link #array </code>backing array<code>} will be the
- * given array, and its {@link #arrayOffset </code>array offset<code>} will
+ * undefined. Its {@link #array backing array} will be the
+ * given array, and its {@link #arrayOffset array offset>} will
* be zero. </p>
*
- * @param array The array that will back this buffer
- * @return The new int buffer
+ * @param array
+ * The array that will back this buffer
+ *
+ * @return The new int buffer
*/
public static IntBuffer wrap(int[] array) {
return wrap(array, 0, array.length);
@@ -195,7 +220,7 @@
* buffer is direct, and it will be read-only if, and only if, this buffer
* is read-only. </p>
*
- * @return The new int buffer
+ * @return The new int buffer
*/
public abstract IntBuffer slice();
@@ -212,7 +237,7 @@
* and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return The new int buffer
+ * @return The new int buffer
*/
public abstract IntBuffer duplicate();
@@ -232,7 +257,7 @@
* <p> If this buffer is itself read-only then this method behaves in
* exactly the same way as the {@link #duplicate duplicate} method. </p>
*
- * @return The new, read-only int buffer
+ * @return The new, read-only int buffer
*/
public abstract IntBuffer asReadOnlyBuffer();
@@ -241,11 +266,12 @@
/**
* Relative <i>get</i> method. Reads the int at this buffer's
- * current position, and then increments the position. </p>
+ * current position, and then increments the position.
*
- * @return The int at the buffer's current position
- * @throws BufferUnderflowException If the buffer's current position is not smaller than its
- * limit
+ * @return The int at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If the buffer's current position is not smaller than its limit
*/
public abstract int get();
@@ -255,22 +281,31 @@
* <p> Writes the given int into this buffer at the current
* position, and then increments the position. </p>
*
- * @param i The int to be written
- * @return This buffer
- * @throws BufferOverflowException If this buffer's current position is not smaller than its
- * limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param i
+ * The int to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If this buffer's current position is not smaller than its limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract IntBuffer put(int i);
/**
* Absolute <i>get</i> method. Reads the int at the given
- * index. </p>
+ * index.
*
- * @param index The index from which the int will be read
- * @return The int at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
+ * @param index
+ * The index from which the int will be read
+ *
+ * @return The int at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
*/
public abstract int get(int index);
@@ -280,12 +315,20 @@
* <p> Writes the given int into this buffer at the given
* index. </p>
*
- * @param index The index at which the int will be written
- * @param i The int value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the int will be written
+ *
+ * @param i
+ * The int value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract IntBuffer put(int index, int i);
@@ -311,26 +354,36 @@
* <tt>src.get(dst, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst[i] = src.get(); </pre>
+ * dst[i] = src.get();
+ * }</pre>
*
* except that it first checks that there are sufficient ints in
- * this buffer and it is potentially much more efficient. </p>
+ * this buffer and it is potentially much more efficient.
*
- * @param dst The array into which ints are to be written
- * @param offset The offset within the array of the first int to be
- * written; must be non-negative and no larger than
- * <tt>dst.length</tt>
- * @param length The maximum number of ints to be written to the given
- * array; must be non-negative and no larger than
- * <tt>dst.length - offset</tt>
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> ints
- * remaining in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param dst
+ * The array into which ints are to be written
+ *
+ * @param offset
+ * The offset within the array of the first int to be
+ * written; must be non-negative and no larger than
+ * <tt>dst.length</tt>
+ *
+ * @param length
+ * The maximum number of ints to be written to the given
+ * array; must be non-negative and no larger than
+ * <tt>dst.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> ints
+ * remaining in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public IntBuffer get(int[] dst, int offset, int length) {
checkBounds(offset, length, dst.length);
@@ -352,9 +405,14 @@
* <pre>
* src.get(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> ints
- * remaining in this buffer
+ * @param dst
+ * The destination array
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> ints
+ * remaining in this buffer
*/
public IntBuffer get(int[] dst) {
return get(dst, 0, dst.length);
@@ -386,15 +444,23 @@
* dst.put(src.get()); </pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The source buffer from which ints are to be read;
- * must not be this buffer
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * for the remaining ints in the source buffer
- * @throws IllegalArgumentException If the source buffer is this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source buffer from which ints are to be read;
+ * must not be this buffer
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ * for the remaining ints in the source buffer
+ *
+ * @throws IllegalArgumentException
+ * If the source buffer is this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public IntBuffer put(IntBuffer src) {
if (src == this)
@@ -426,25 +492,37 @@
* <tt>dst.put(src, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst.put(a[i]); </pre>
+ * dst.put(a[i]);
+ * }</pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The array from which ints are to be read
- * @param offset The offset within the array of the first int to be read;
- * must be non-negative and no larger than <tt>array.length</tt>
- * @param length The number of ints to be read from the given array;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The array from which ints are to be read
+ *
+ * @param offset
+ * The offset within the array of the first int to be read;
+ * must be non-negative and no larger than <tt>array.length</tt>
+ *
+ * @param length
+ * The number of ints to be read from the given array;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public IntBuffer put(int[] src, int offset, int length) {
checkBounds(offset, length, src.length);
@@ -467,9 +545,16 @@
* <pre>
* dst.put(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source array
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public final IntBuffer put(int[] src) {
return put(src, 0, src.length);
@@ -486,8 +571,8 @@
* and {@link #arrayOffset() arrayOffset} methods may safely be invoked.
* </p>
*
- * @return <tt>true</tt> if, and only if, this buffer
- * is backed by an array and is not read-only
+ * @return <tt>true</tt> if, and only if, this buffer
+ * is backed by an array and is not read-only
*/
public final boolean hasArray() {
return (hb != null) && !isReadOnly;
@@ -504,9 +589,13 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The array that backs this buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The array that backs this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final int[] array() {
if (hb == null)
@@ -527,10 +616,14 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The offset within this buffer's array
- * of the first element of the buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The offset within this buffer's array
+ * of the first element of the buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final int arrayOffset() {
if (hb == null)
@@ -558,23 +651,27 @@
* followed immediately by an invocation of another relative <i>put</i>
* method. </p>
*
- * @return This buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+
+ *
+ * @return This buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract IntBuffer compact();
/**
- * Tells whether or not this int buffer is direct. </p>
+ * Tells whether or not this int buffer is direct.
*
- * @return <tt>true</tt> if, and only if, this buffer is direct
+ * @return <tt>true</tt> if, and only if, this buffer is direct
*/
public abstract boolean isDirect();
/**
- * Returns a string summarizing the state of this buffer. </p>
+ * Returns a string summarizing the state of this buffer.
*
- * @return A summary string
+ * @return A summary string
*/
public String toString() {
StringBuffer sb = new StringBuffer();
@@ -601,7 +698,7 @@
* to use buffers as keys in hash maps or similar data structures unless it
* is known that their contents will not change. </p>
*
- * @return The current hash code of this buffer
+ * @return The current hash code of this buffer
*/
public int hashCode() {
int h = 1;
@@ -616,15 +713,15 @@
*
* <p> Two int buffers are equal if, and only if,
*
- * <p><ol>
+ * <ol>
*
- * <li><p> They have the same element type, </p></li>
+ * <li><p> They have the same element type, </p></li>
*
- * <li><p> They have the same number of remaining elements, and
- * </p></li>
+ * <li><p> They have the same number of remaining elements, and
+ * </p></li>
*
- * <li><p> The two sequences of remaining elements, considered
- * independently of their starting positions, are pointwise equal.
+ * <li><p> The two sequences of remaining elements, considered
+ * independently of their starting positions, are pointwise equal.
*
*
*
@@ -632,22 +729,23 @@
*
*
*
- * </p></li>
+ * </p></li>
*
* </ol>
*
* <p> A int buffer is not equal to any other type of object. </p>
*
- * @param ob The object to which this buffer is to be compared
- * @return <tt>true</tt> if, and only if, this buffer is equal to the
- * given object
+ * @param ob The object to which this buffer is to be compared
+ *
+ * @return <tt>true</tt> if, and only if, this buffer is equal to the
+ * given object
*/
public boolean equals(Object ob) {
if (this == ob)
return true;
if (!(ob instanceof IntBuffer))
return false;
- IntBuffer that = (IntBuffer) ob;
+ IntBuffer that = (IntBuffer)ob;
if (this.remaining() != that.remaining())
return false;
int p = this.position();
@@ -679,13 +777,13 @@
*
*
* Pairs of {@code int} elements are compared as if by invoking
- * {@link Integer#compare(int, int)}.
- *
+ * {@link Integer#compare(int,int)}.
+
*
* <p> A int buffer is not comparable to any other type of object.
*
- * @return A negative integer, zero, or a positive integer as this buffer
- * is less than, equal to, or greater than the given buffer
+ * @return A negative integer, zero, or a positive integer as this buffer
+ * is less than, equal to, or greater than the given buffer
*/
public int compareTo(IntBuffer that) {
int n = this.position() + Math.min(this.remaining(), that.remaining());
@@ -715,12 +813,12 @@
*
* <p> The byte order of an int buffer created by allocation or by
* wrapping an existing <tt>int</tt> array is the {@link
- * ByteOrder#nativeOrder </code>native order<code>} of the underlying
+ * ByteOrder#nativeOrder native order} of the underlying
* hardware. The byte order of an int buffer created as a <a
* href="ByteBuffer.html#views">view</a> of a byte buffer is that of the
* byte buffer at the moment that the view is created. </p>
*
- * @return This buffer's byte order
+ * @return This buffer's byte order
*/
public abstract ByteOrder order();
diff --git a/ojluni/src/main/java/java/nio/LongBuffer.java b/ojluni/src/main/java/java/nio/LongBuffer.java
index c1c2888..80e506c 100644
--- a/ojluni/src/main/java/java/nio/LongBuffer.java
+++ b/ojluni/src/main/java/java/nio/LongBuffer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, 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
@@ -36,31 +36,37 @@
*
* <ul>
*
- * <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and
- * {@link #put(long) </code><i>put</i><code>} methods that read and write
- * single longs; </p></li>
+ * <li><p> Absolute and relative {@link #get() <i>get</i>} and
+ * {@link #put(long) <i>put</i>} methods that read and write
+ * single longs; </p></li>
*
- * <li><p> Relative {@link #get(long[]) </code><i>bulk get</i><code>}
- * methods that transfer contiguous sequences of longs from this buffer
- * into an array; and</p></li>
+ * <li><p> Relative {@link #get(long[]) <i>bulk get</i>}
+ * methods that transfer contiguous sequences of longs from this buffer
+ * into an array; and</p></li>
*
- * <li><p> Relative {@link #put(long[]) </code><i>bulk put</i><code>}
- * methods that transfer contiguous sequences of longs from a
- * long array or some other long
- * buffer into this buffer; and </p></li>
+ * <li><p> Relative {@link #put(long[]) <i>bulk put</i>}
+ * methods that transfer contiguous sequences of longs from a
+ * long array or some other long
+ * buffer into this buffer; and </p></li>
*
- * <li><p> Methods for {@link #compact </code>compacting<code>}, {@link
- * #duplicate </code>duplicating<code>}, and {@link #slice
- * </code>slicing<code>} a long buffer. </p></li>
+ *
+ * <li><p> Methods for {@link #compact compacting}, {@link
+ * #duplicate duplicating}, and {@link #slice slicing}
+ * a long buffer. </p></li>
*
* </ul>
*
* <p> Long buffers can be created either by {@link #allocate
- * </code><i>allocation</i><code>}, which allocates space for the buffer's
- * content, by {@link #wrap(long[]) </code><i>wrapping</i><code>} an existing
+ * <i>allocation</i>}, which allocates space for the buffer's
+ *
+ *
+ * content, by {@link #wrap(long[]) <i>wrapping</i>} an existing
* long array into a buffer, or by creating a
* <a href="ByteBuffer.html#views"><i>view</i></a> of an existing byte buffer.
*
+ *
+*
+ *
* <p> Like a byte buffer, a long buffer is either <a
* href="ByteBuffer.html#direct"><i>direct</i> or <i>non-direct</i></a>. A
* long buffer created via the <tt>wrap</tt> methods of this class will
@@ -69,18 +75,24 @@
* a long buffer is direct may be determined by invoking the {@link
* #isDirect isDirect} method. </p>
*
+*
+ *
+ *
* <p> Methods in this class that do not otherwise have a value to return are
* specified to return the buffer upon which they are invoked. This allows
* method invocations to be chained.
*
+ *
+ *
* @author Mark Reinhold
* @author JSR-51 Expert Group
* @since 1.4
*/
public abstract class LongBuffer
- extends Buffer
- implements Comparable<LongBuffer> {
+ extends Buffer
+ implements Comparable<LongBuffer>
+{
// These fields are declared here rather than in Heap-X-Buffer in order to
// reduce the number of virtual method invocations needed to access these
@@ -94,7 +106,8 @@
// backing array, and array offset
//
LongBuffer(int mark, int pos, int lim, int cap, // package-private
- long[] hb, int offset) {
+ long[] hb, int offset)
+ {
super(mark, pos, lim, cap, 3);
this.hb = hb;
this.offset = offset;
@@ -112,13 +125,16 @@
*
* <p> The new buffer's position will be zero, its limit will be its
* capacity, its mark will be undefined, and each of its elements will be
- * initialized to zero. It will have a {@link #array
- * </code>backing array<code>}, and its {@link #arrayOffset </code>array
- * offset<code>} will be zero.
+ * initialized to zero. It will have a {@link #array backing array},
+ * and its {@link #arrayOffset array offset} will be zero.
*
- * @param capacity The new buffer's capacity, in longs
- * @return The new long buffer
- * @throws IllegalArgumentException If the <tt>capacity</tt> is a negative integer
+ * @param capacity
+ * The new buffer's capacity, in longs
+ *
+ * @return The new long buffer
+ *
+ * @throws IllegalArgumentException
+ * If the <tt>capacity</tt> is a negative integer
*/
public static LongBuffer allocate(int capacity) {
if (capacity < 0)
@@ -134,24 +150,32 @@
* and vice versa. The new buffer's capacity will be
* <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit
* will be <tt>offset + length</tt>, and its mark will be undefined. Its
- * {@link #array </code>backing array<code>} will be the given array, and
- * its {@link #arrayOffset </code>array offset<code>} will be zero. </p>
+ * {@link #array backing array} will be the given array, and
+ * its {@link #arrayOffset array offset} will be zero. </p>
*
- * @param array The array that will back the new buffer
- * @param offset The offset of the subarray to be used; must be non-negative and
- * no larger than <tt>array.length</tt>. The new buffer's position
- * will be set to this value.
- * @param length The length of the subarray to be used;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>.
- * The new buffer's limit will be set to <tt>offset + length</tt>.
- * @return The new long buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param array
+ * The array that will back the new buffer
+ *
+ * @param offset
+ * The offset of the subarray to be used; must be non-negative and
+ * no larger than <tt>array.length</tt>. The new buffer's position
+ * will be set to this value.
+ *
+ * @param length
+ * The length of the subarray to be used;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>.
+ * The new buffer's limit will be set to <tt>offset + length</tt>.
+ *
+ * @return The new long buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public static LongBuffer wrap(long[] array,
- int offset, int length) {
+ int offset, int length)
+ {
try {
return new HeapLongBuffer(array, offset, length);
} catch (IllegalArgumentException x) {
@@ -166,12 +190,14 @@
* that is, modifications to the buffer will cause the array to be modified
* and vice versa. The new buffer's capacity and limit will be
* <tt>array.length</tt>, its position will be zero, and its mark will be
- * undefined. Its {@link #array </code>backing array<code>} will be the
- * given array, and its {@link #arrayOffset </code>array offset<code>} will
+ * undefined. Its {@link #array backing array} will be the
+ * given array, and its {@link #arrayOffset array offset>} will
* be zero. </p>
*
- * @param array The array that will back this buffer
- * @return The new long buffer
+ * @param array
+ * The array that will back this buffer
+ *
+ * @return The new long buffer
*/
public static LongBuffer wrap(long[] array) {
return wrap(array, 0, array.length);
@@ -193,7 +219,7 @@
* buffer is direct, and it will be read-only if, and only if, this buffer
* is read-only. </p>
*
- * @return The new long buffer
+ * @return The new long buffer
*/
public abstract LongBuffer slice();
@@ -210,7 +236,7 @@
* and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return The new long buffer
+ * @return The new long buffer
*/
public abstract LongBuffer duplicate();
@@ -230,7 +256,7 @@
* <p> If this buffer is itself read-only then this method behaves in
* exactly the same way as the {@link #duplicate duplicate} method. </p>
*
- * @return The new, read-only long buffer
+ * @return The new, read-only long buffer
*/
public abstract LongBuffer asReadOnlyBuffer();
@@ -239,11 +265,12 @@
/**
* Relative <i>get</i> method. Reads the long at this buffer's
- * current position, and then increments the position. </p>
+ * current position, and then increments the position.
*
- * @return The long at the buffer's current position
- * @throws BufferUnderflowException If the buffer's current position is not smaller than its
- * limit
+ * @return The long at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If the buffer's current position is not smaller than its limit
*/
public abstract long get();
@@ -253,22 +280,31 @@
* <p> Writes the given long into this buffer at the current
* position, and then increments the position. </p>
*
- * @param l The long to be written
- * @return This buffer
- * @throws BufferOverflowException If this buffer's current position is not smaller than its
- * limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param l
+ * The long to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If this buffer's current position is not smaller than its limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract LongBuffer put(long l);
/**
* Absolute <i>get</i> method. Reads the long at the given
- * index. </p>
+ * index.
*
- * @param index The index from which the long will be read
- * @return The long at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
+ * @param index
+ * The index from which the long will be read
+ *
+ * @return The long at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
*/
public abstract long get(int index);
@@ -278,12 +314,20 @@
* <p> Writes the given long into this buffer at the given
* index. </p>
*
- * @param index The index at which the long will be written
- * @param l The long value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the long will be written
+ *
+ * @param l
+ * The long value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract LongBuffer put(int index, long l);
@@ -309,26 +353,36 @@
* <tt>src.get(dst, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst[i] = src.get(); </pre>
+ * dst[i] = src.get();
+ * }</pre>
*
* except that it first checks that there are sufficient longs in
- * this buffer and it is potentially much more efficient. </p>
+ * this buffer and it is potentially much more efficient.
*
- * @param dst The array into which longs are to be written
- * @param offset The offset within the array of the first long to be
- * written; must be non-negative and no larger than
- * <tt>dst.length</tt>
- * @param length The maximum number of longs to be written to the given
- * array; must be non-negative and no larger than
- * <tt>dst.length - offset</tt>
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> longs
- * remaining in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param dst
+ * The array into which longs are to be written
+ *
+ * @param offset
+ * The offset within the array of the first long to be
+ * written; must be non-negative and no larger than
+ * <tt>dst.length</tt>
+ *
+ * @param length
+ * The maximum number of longs to be written to the given
+ * array; must be non-negative and no larger than
+ * <tt>dst.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> longs
+ * remaining in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public LongBuffer get(long[] dst, int offset, int length) {
checkBounds(offset, length, dst.length);
@@ -350,9 +404,14 @@
* <pre>
* src.get(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> longs
- * remaining in this buffer
+ * @param dst
+ * The destination array
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> longs
+ * remaining in this buffer
*/
public LongBuffer get(long[] dst) {
return get(dst, 0, dst.length);
@@ -384,15 +443,23 @@
* dst.put(src.get()); </pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The source buffer from which longs are to be read;
- * must not be this buffer
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * for the remaining longs in the source buffer
- * @throws IllegalArgumentException If the source buffer is this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source buffer from which longs are to be read;
+ * must not be this buffer
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ * for the remaining longs in the source buffer
+ *
+ * @throws IllegalArgumentException
+ * If the source buffer is this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public LongBuffer put(LongBuffer src) {
if (src == this)
@@ -424,25 +491,37 @@
* <tt>dst.put(src, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst.put(a[i]); </pre>
+ * dst.put(a[i]);
+ * }</pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The array from which longs are to be read
- * @param offset The offset within the array of the first long to be read;
- * must be non-negative and no larger than <tt>array.length</tt>
- * @param length The number of longs to be read from the given array;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The array from which longs are to be read
+ *
+ * @param offset
+ * The offset within the array of the first long to be read;
+ * must be non-negative and no larger than <tt>array.length</tt>
+ *
+ * @param length
+ * The number of longs to be read from the given array;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public LongBuffer put(long[] src, int offset, int length) {
checkBounds(offset, length, src.length);
@@ -465,9 +544,16 @@
* <pre>
* dst.put(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source array
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public final LongBuffer put(long[] src) {
return put(src, 0, src.length);
@@ -484,8 +570,8 @@
* and {@link #arrayOffset() arrayOffset} methods may safely be invoked.
* </p>
*
- * @return <tt>true</tt> if, and only if, this buffer
- * is backed by an array and is not read-only
+ * @return <tt>true</tt> if, and only if, this buffer
+ * is backed by an array and is not read-only
*/
public final boolean hasArray() {
return (hb != null) && !isReadOnly;
@@ -502,9 +588,13 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The array that backs this buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The array that backs this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final long[] array() {
if (hb == null)
@@ -525,10 +615,14 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The offset within this buffer's array
- * of the first element of the buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The offset within this buffer's array
+ * of the first element of the buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final int arrayOffset() {
if (hb == null)
@@ -556,23 +650,27 @@
* followed immediately by an invocation of another relative <i>put</i>
* method. </p>
*
- * @return This buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+
+ *
+ * @return This buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract LongBuffer compact();
/**
- * Tells whether or not this long buffer is direct. </p>
+ * Tells whether or not this long buffer is direct.
*
- * @return <tt>true</tt> if, and only if, this buffer is direct
+ * @return <tt>true</tt> if, and only if, this buffer is direct
*/
public abstract boolean isDirect();
/**
- * Returns a string summarizing the state of this buffer. </p>
+ * Returns a string summarizing the state of this buffer.
*
- * @return A summary string
+ * @return A summary string
*/
public String toString() {
StringBuffer sb = new StringBuffer();
@@ -599,7 +697,7 @@
* to use buffers as keys in hash maps or similar data structures unless it
* is known that their contents will not change. </p>
*
- * @return The current hash code of this buffer
+ * @return The current hash code of this buffer
*/
public int hashCode() {
int h = 1;
@@ -614,38 +712,33 @@
*
* <p> Two long buffers are equal if, and only if,
*
- * <p><ol>
+ * <ol>
*
- * <li><p> They have the same element type, </p></li>
+ * <li><p> They have the same element type, </p></li>
*
- * <li><p> They have the same number of remaining elements, and
- * </p></li>
+ * <li><p> They have the same number of remaining elements, and
+ * </p></li>
*
- * <li><p> The two sequences of remaining elements, considered
- * independently of their starting positions, are pointwise equal.
- *
- *
- *
- *
- *
- *
- *
- * </p></li>
+ * <li><p> The two sequences of remaining elements, considered
+ * independently of their starting positions, are pointwise equal.
+
+ * </p></li>
*
* </ol>
*
* <p> A long buffer is not equal to any other type of object. </p>
*
- * @param ob The object to which this buffer is to be compared
- * @return <tt>true</tt> if, and only if, this buffer is equal to the
- * given object
+ * @param ob The object to which this buffer is to be compared
+ *
+ * @return <tt>true</tt> if, and only if, this buffer is equal to the
+ * given object
*/
public boolean equals(Object ob) {
if (this == ob)
return true;
if (!(ob instanceof LongBuffer))
return false;
- LongBuffer that = (LongBuffer) ob;
+ LongBuffer that = (LongBuffer)ob;
if (this.remaining() != that.remaining())
return false;
int p = this.position();
@@ -677,13 +770,13 @@
*
*
* Pairs of {@code long} elements are compared as if by invoking
- * {@link Long#compare(long, long)}.
- *
+ * {@link Long#compare(long,long)}.
+
*
* <p> A long buffer is not comparable to any other type of object.
*
- * @return A negative integer, zero, or a positive integer as this buffer
- * is less than, equal to, or greater than the given buffer
+ * @return A negative integer, zero, or a positive integer as this buffer
+ * is less than, equal to, or greater than the given buffer
*/
public int compareTo(LongBuffer that) {
int n = this.position() + Math.min(this.remaining(), that.remaining());
@@ -713,12 +806,12 @@
*
* <p> The byte order of a long buffer created by allocation or by
* wrapping an existing <tt>long</tt> array is the {@link
- * ByteOrder#nativeOrder </code>native order<code>} of the underlying
+ * ByteOrder#nativeOrder native order} of the underlying
* hardware. The byte order of a long buffer created as a <a
* href="ByteBuffer.html#views">view</a> of a byte buffer is that of the
* byte buffer at the moment that the view is created. </p>
*
- * @return This buffer's byte order
+ * @return This buffer's byte order
*/
public abstract ByteOrder order();
diff --git a/ojluni/src/main/java/java/nio/ShortBuffer.java b/ojluni/src/main/java/java/nio/ShortBuffer.java
index 9ca0f36..6903b54 100644
--- a/ojluni/src/main/java/java/nio/ShortBuffer.java
+++ b/ojluni/src/main/java/java/nio/ShortBuffer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, 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
@@ -36,32 +36,37 @@
*
* <ul>
*
- * <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and
- * {@link #put(short) </code><i>put</i><code>} methods that read and write
- * single shorts; </p></li>
+ * <li><p> Absolute and relative {@link #get() <i>get</i>} and
+ * {@link #put(short) <i>put</i>} methods that read and write
+ * single shorts; </p></li>
*
- * <li><p> Relative {@link #get(short[]) </code><i>bulk get</i><code>}
- * methods that transfer contiguous sequences of shorts from this buffer
- * into an array; and</p></li>
+ * <li><p> Relative {@link #get(short[]) <i>bulk get</i>}
+ * methods that transfer contiguous sequences of shorts from this buffer
+ * into an array; and</p></li>
*
- * <li><p> Relative {@link #put(short[]) </code><i>bulk put</i><code>}
- * methods that transfer contiguous sequences of shorts from a
- * short array or some other short
- * buffer into this buffer; and </p></li>
+ * <li><p> Relative {@link #put(short[]) <i>bulk put</i>}
+ * methods that transfer contiguous sequences of shorts from a
+ * short array or some other short
+ * buffer into this buffer; and </p></li>
*
- * <li><p> Methods for {@link #compact </code>compacting<code>}, {@link
- * #duplicate </code>duplicating<code>}, and {@link #slice
- * </code>slicing<code>} a short buffer. </p></li>
+ *
+ * <li><p> Methods for {@link #compact compacting}, {@link
+ * #duplicate duplicating}, and {@link #slice slicing}
+ * a short buffer. </p></li>
*
* </ul>
*
* <p> Short buffers can be created either by {@link #allocate
- * </code><i>allocation</i><code>}, which allocates space for the buffer's
+ * <i>allocation</i>}, which allocates space for the buffer's
*
- * content, by {@link #wrap(short[]) </code><i>wrapping</i><code>} an existing
+ *
+ * content, by {@link #wrap(short[]) <i>wrapping</i>} an existing
* short array into a buffer, or by creating a
* <a href="ByteBuffer.html#views"><i>view</i></a> of an existing byte buffer.
*
+ *
+*
+ *
* <p> Like a byte buffer, a short buffer is either <a
* href="ByteBuffer.html#direct"><i>direct</i> or <i>non-direct</i></a>. A
* short buffer created via the <tt>wrap</tt> methods of this class will
@@ -70,18 +75,24 @@
* a short buffer is direct may be determined by invoking the {@link
* #isDirect isDirect} method. </p>
*
+*
+ *
+ *
* <p> Methods in this class that do not otherwise have a value to return are
* specified to return the buffer upon which they are invoked. This allows
* method invocations to be chained.
*
+ *
+ *
* @author Mark Reinhold
* @author JSR-51 Expert Group
* @since 1.4
*/
public abstract class ShortBuffer
- extends Buffer
- implements Comparable<ShortBuffer> {
+ extends Buffer
+ implements Comparable<ShortBuffer>
+{
// These fields are declared here rather than in Heap-X-Buffer in order to
// reduce the number of virtual method invocations needed to access these
@@ -95,7 +106,8 @@
// backing array, and array offset
//
ShortBuffer(int mark, int pos, int lim, int cap, // package-private
- short[] hb, int offset) {
+ short[] hb, int offset)
+ {
super(mark, pos, lim, cap, 1);
this.hb = hb;
this.offset = offset;
@@ -113,13 +125,16 @@
*
* <p> The new buffer's position will be zero, its limit will be its
* capacity, its mark will be undefined, and each of its elements will be
- * initialized to zero. It will have a {@link #array
- * </code>backing array<code>}, and its {@link #arrayOffset </code>array
- * offset<code>} will be zero.
+ * initialized to zero. It will have a {@link #array backing array},
+ * and its {@link #arrayOffset array offset} will be zero.
*
- * @param capacity The new buffer's capacity, in shorts
- * @return The new short buffer
- * @throws IllegalArgumentException If the <tt>capacity</tt> is a negative integer
+ * @param capacity
+ * The new buffer's capacity, in shorts
+ *
+ * @return The new short buffer
+ *
+ * @throws IllegalArgumentException
+ * If the <tt>capacity</tt> is a negative integer
*/
public static ShortBuffer allocate(int capacity) {
if (capacity < 0)
@@ -135,24 +150,32 @@
* and vice versa. The new buffer's capacity will be
* <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit
* will be <tt>offset + length</tt>, and its mark will be undefined. Its
- * {@link #array </code>backing array<code>} will be the given array, and
- * its {@link #arrayOffset </code>array offset<code>} will be zero. </p>
+ * {@link #array backing array} will be the given array, and
+ * its {@link #arrayOffset array offset} will be zero. </p>
*
- * @param array The array that will back the new buffer
- * @param offset The offset of the subarray to be used; must be non-negative and
- * no larger than <tt>array.length</tt>. The new buffer's position
- * will be set to this value.
- * @param length The length of the subarray to be used;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>.
- * The new buffer's limit will be set to <tt>offset + length</tt>.
- * @return The new short buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param array
+ * The array that will back the new buffer
+ *
+ * @param offset
+ * The offset of the subarray to be used; must be non-negative and
+ * no larger than <tt>array.length</tt>. The new buffer's position
+ * will be set to this value.
+ *
+ * @param length
+ * The length of the subarray to be used;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>.
+ * The new buffer's limit will be set to <tt>offset + length</tt>.
+ *
+ * @return The new short buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public static ShortBuffer wrap(short[] array,
- int offset, int length) {
+ int offset, int length)
+ {
try {
return new HeapShortBuffer(array, offset, length);
} catch (IllegalArgumentException x) {
@@ -167,12 +190,14 @@
* that is, modifications to the buffer will cause the array to be modified
* and vice versa. The new buffer's capacity and limit will be
* <tt>array.length</tt>, its position will be zero, and its mark will be
- * undefined. Its {@link #array </code>backing array<code>} will be the
- * given array, and its {@link #arrayOffset </code>array offset<code>} will
+ * undefined. Its {@link #array backing array} will be the
+ * given array, and its {@link #arrayOffset array offset>} will
* be zero. </p>
*
- * @param array The array that will back this buffer
- * @return The new short buffer
+ * @param array
+ * The array that will back this buffer
+ *
+ * @return The new short buffer
*/
public static ShortBuffer wrap(short[] array) {
return wrap(array, 0, array.length);
@@ -194,7 +219,7 @@
* buffer is direct, and it will be read-only if, and only if, this buffer
* is read-only. </p>
*
- * @return The new short buffer
+ * @return The new short buffer
*/
public abstract ShortBuffer slice();
@@ -211,7 +236,7 @@
* and only if, this buffer is direct, and it will be read-only if, and
* only if, this buffer is read-only. </p>
*
- * @return The new short buffer
+ * @return The new short buffer
*/
public abstract ShortBuffer duplicate();
@@ -231,7 +256,7 @@
* <p> If this buffer is itself read-only then this method behaves in
* exactly the same way as the {@link #duplicate duplicate} method. </p>
*
- * @return The new, read-only short buffer
+ * @return The new, read-only short buffer
*/
public abstract ShortBuffer asReadOnlyBuffer();
@@ -240,11 +265,12 @@
/**
* Relative <i>get</i> method. Reads the short at this buffer's
- * current position, and then increments the position. </p>
+ * current position, and then increments the position.
*
- * @return The short at the buffer's current position
- * @throws BufferUnderflowException If the buffer's current position is not smaller than its
- * limit
+ * @return The short at the buffer's current position
+ *
+ * @throws BufferUnderflowException
+ * If the buffer's current position is not smaller than its limit
*/
public abstract short get();
@@ -254,22 +280,31 @@
* <p> Writes the given short into this buffer at the current
* position, and then increments the position. </p>
*
- * @param s The short to be written
- * @return This buffer
- * @throws BufferOverflowException If this buffer's current position is not smaller than its
- * limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param s
+ * The short to be written
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If this buffer's current position is not smaller than its limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ShortBuffer put(short s);
/**
* Absolute <i>get</i> method. Reads the short at the given
- * index. </p>
+ * index.
*
- * @param index The index from which the short will be read
- * @return The short at the given index
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
+ * @param index
+ * The index from which the short will be read
+ *
+ * @return The short at the given index
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
*/
public abstract short get(int index);
@@ -279,12 +314,20 @@
* <p> Writes the given short into this buffer at the given
* index. </p>
*
- * @param index The index at which the short will be written
- * @param s The short value to be written
- * @return This buffer
- * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
- * or not smaller than the buffer's limit
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param index
+ * The index at which the short will be written
+ *
+ * @param s
+ * The short value to be written
+ *
+ * @return This buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If <tt>index</tt> is negative
+ * or not smaller than the buffer's limit
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ShortBuffer put(int index, short s);
@@ -310,26 +353,36 @@
* <tt>src.get(dst, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst[i] = src.get(); </pre>
+ * dst[i] = src.get();
+ * }</pre>
*
* except that it first checks that there are sufficient shorts in
- * this buffer and it is potentially much more efficient. </p>
+ * this buffer and it is potentially much more efficient.
*
- * @param dst The array into which shorts are to be written
- * @param offset The offset within the array of the first short to be
- * written; must be non-negative and no larger than
- * <tt>dst.length</tt>
- * @param length The maximum number of shorts to be written to the given
- * array; must be non-negative and no larger than
- * <tt>dst.length - offset</tt>
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> shorts
- * remaining in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
+ * @param dst
+ * The array into which shorts are to be written
+ *
+ * @param offset
+ * The offset within the array of the first short to be
+ * written; must be non-negative and no larger than
+ * <tt>dst.length</tt>
+ *
+ * @param length
+ * The maximum number of shorts to be written to the given
+ * array; must be non-negative and no larger than
+ * <tt>dst.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> shorts
+ * remaining in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
*/
public ShortBuffer get(short[] dst, int offset, int length) {
checkBounds(offset, length, dst.length);
@@ -351,9 +404,14 @@
* <pre>
* src.get(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferUnderflowException If there are fewer than <tt>length</tt> shorts
- * remaining in this buffer
+ * @param dst
+ * The destination array
+ *
+ * @return This buffer
+ *
+ * @throws BufferUnderflowException
+ * If there are fewer than <tt>length</tt> shorts
+ * remaining in this buffer
*/
public ShortBuffer get(short[] dst) {
return get(dst, 0, dst.length);
@@ -385,15 +443,23 @@
* dst.put(src.get()); </pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The source buffer from which shorts are to be read;
- * must not be this buffer
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * for the remaining shorts in the source buffer
- * @throws IllegalArgumentException If the source buffer is this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source buffer from which shorts are to be read;
+ * must not be this buffer
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ * for the remaining shorts in the source buffer
+ *
+ * @throws IllegalArgumentException
+ * If the source buffer is this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public ShortBuffer put(ShortBuffer src) {
if (src == this)
@@ -425,25 +491,37 @@
* <tt>dst.put(src, off, len)</tt> has exactly the same effect as
* the loop
*
- * <pre>
+ * <pre>{@code
* for (int i = off; i < off + len; i++)
- * dst.put(a[i]); </pre>
+ * dst.put(a[i]);
+ * }</pre>
*
* except that it first checks that there is sufficient space in this
- * buffer and it is potentially much more efficient. </p>
+ * buffer and it is potentially much more efficient.
*
- * @param src The array from which shorts are to be read
- * @param offset The offset within the array of the first short to be read;
- * must be non-negative and no larger than <tt>array.length</tt>
- * @param length The number of shorts to be read from the given array;
- * must be non-negative and no larger than
- * <tt>array.length - offset</tt>
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and
- * <tt>length</tt>
- * parameters do not hold
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The array from which shorts are to be read
+ *
+ * @param offset
+ * The offset within the array of the first short to be read;
+ * must be non-negative and no larger than <tt>array.length</tt>
+ *
+ * @param length
+ * The number of shorts to be read from the given array;
+ * must be non-negative and no larger than
+ * <tt>array.length - offset</tt>
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws IndexOutOfBoundsException
+ * If the preconditions on the <tt>offset</tt> and <tt>length</tt>
+ * parameters do not hold
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public ShortBuffer put(short[] src, int offset, int length) {
checkBounds(offset, length, src.length);
@@ -466,9 +544,16 @@
* <pre>
* dst.put(a, 0, a.length) </pre>
*
- * @return This buffer
- * @throws BufferOverflowException If there is insufficient space in this buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+ * @param src
+ * The source array
+ *
+ * @return This buffer
+ *
+ * @throws BufferOverflowException
+ * If there is insufficient space in this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public final ShortBuffer put(short[] src) {
return put(src, 0, src.length);
@@ -485,8 +570,8 @@
* and {@link #arrayOffset() arrayOffset} methods may safely be invoked.
* </p>
*
- * @return <tt>true</tt> if, and only if, this buffer
- * is backed by an array and is not read-only
+ * @return <tt>true</tt> if, and only if, this buffer
+ * is backed by an array and is not read-only
*/
public final boolean hasArray() {
return (hb != null) && !isReadOnly;
@@ -503,9 +588,13 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The array that backs this buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The array that backs this buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final short[] array() {
if (hb == null)
@@ -526,10 +615,14 @@
* method in order to ensure that this buffer has an accessible backing
* array. </p>
*
- * @return The offset within this buffer's array
- * of the first element of the buffer
- * @throws ReadOnlyBufferException If this buffer is backed by an array but is read-only
- * @throws UnsupportedOperationException If this buffer is not backed by an accessible array
+ * @return The offset within this buffer's array
+ * of the first element of the buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is backed by an array but is read-only
+ *
+ * @throws UnsupportedOperationException
+ * If this buffer is not backed by an accessible array
*/
public final int arrayOffset() {
if (hb == null)
@@ -557,23 +650,27 @@
* followed immediately by an invocation of another relative <i>put</i>
* method. </p>
*
- * @return This buffer
- * @throws ReadOnlyBufferException If this buffer is read-only
+
+ *
+ * @return This buffer
+ *
+ * @throws ReadOnlyBufferException
+ * If this buffer is read-only
*/
public abstract ShortBuffer compact();
/**
- * Tells whether or not this short buffer is direct. </p>
+ * Tells whether or not this short buffer is direct.
*
- * @return <tt>true</tt> if, and only if, this buffer is direct
+ * @return <tt>true</tt> if, and only if, this buffer is direct
*/
public abstract boolean isDirect();
/**
- * Returns a string summarizing the state of this buffer. </p>
+ * Returns a string summarizing the state of this buffer.
*
- * @return A summary string
+ * @return A summary string
*/
public String toString() {
StringBuffer sb = new StringBuffer();
@@ -600,7 +697,7 @@
* to use buffers as keys in hash maps or similar data structures unless it
* is known that their contents will not change. </p>
*
- * @return The current hash code of this buffer
+ * @return The current hash code of this buffer
*/
public int hashCode() {
int h = 1;
@@ -615,38 +712,33 @@
*
* <p> Two short buffers are equal if, and only if,
*
- * <p><ol>
+ * <ol>
*
- * <li><p> They have the same element type, </p></li>
+ * <li><p> They have the same element type, </p></li>
*
- * <li><p> They have the same number of remaining elements, and
- * </p></li>
+ * <li><p> They have the same number of remaining elements, and
+ * </p></li>
*
- * <li><p> The two sequences of remaining elements, considered
- * independently of their starting positions, are pointwise equal.
- *
- *
- *
- *
- *
- *
- *
- * </p></li>
+ * <li><p> The two sequences of remaining elements, considered
+ * independently of their starting positions, are pointwise equal.
+
+ * </p></li>
*
* </ol>
*
* <p> A short buffer is not equal to any other type of object. </p>
*
- * @param ob The object to which this buffer is to be compared
- * @return <tt>true</tt> if, and only if, this buffer is equal to the
- * given object
+ * @param ob The object to which this buffer is to be compared
+ *
+ * @return <tt>true</tt> if, and only if, this buffer is equal to the
+ * given object
*/
public boolean equals(Object ob) {
if (this == ob)
return true;
if (!(ob instanceof ShortBuffer))
return false;
- ShortBuffer that = (ShortBuffer) ob;
+ ShortBuffer that = (ShortBuffer)ob;
if (this.remaining() != that.remaining())
return false;
int p = this.position();
@@ -678,13 +770,13 @@
*
*
* Pairs of {@code short} elements are compared as if by invoking
- * {@link Short#compare(short, short)}.
- *
+ * {@link Short#compare(short,short)}.
+
*
* <p> A short buffer is not comparable to any other type of object.
*
- * @return A negative integer, zero, or a positive integer as this buffer
- * is less than, equal to, or greater than the given buffer
+ * @return A negative integer, zero, or a positive integer as this buffer
+ * is less than, equal to, or greater than the given buffer
*/
public int compareTo(ShortBuffer that) {
int n = this.position() + Math.min(this.remaining(), that.remaining());
@@ -714,12 +806,12 @@
*
* <p> The byte order of a short buffer created by allocation or by
* wrapping an existing <tt>short</tt> array is the {@link
- * ByteOrder#nativeOrder </code>native order<code>} of the underlying
+ * ByteOrder#nativeOrder native order} of the underlying
* hardware. The byte order of a short buffer created as a <a
* href="ByteBuffer.html#views">view</a> of a byte buffer is that of the
* byte buffer at the moment that the view is created. </p>
*
- * @return This buffer's byte order
+ * @return This buffer's byte order
*/
public abstract ByteOrder order();
diff --git a/ojluni/src/main/java/java/security/AlgorithmParameters.java b/ojluni/src/main/java/java/security/AlgorithmParameters.java
index 864866e..bca4a5c 100644
--- a/ojluni/src/main/java/java/security/AlgorithmParameters.java
+++ b/ojluni/src/main/java/java/security/AlgorithmParameters.java
@@ -66,6 +66,10 @@
* <td>10+</td>
* </tr>
* <tr>
+ * <td>ChaCha20</td>
+ * <td>28+</td>
+ * </tr>
+ * <tr>
* <td>DES</td>
* <td>1+</td>
* </tr>
diff --git a/ojluni/src/main/java/java/util/concurrent/TimeUnit.java b/ojluni/src/main/java/java/util/concurrent/TimeUnit.java
index fa52083..44d7964 100644
--- a/ojluni/src/main/java/java/util/concurrent/TimeUnit.java
+++ b/ojluni/src/main/java/java/util/concurrent/TimeUnit.java
@@ -37,10 +37,6 @@
import java.util.Objects;
-// BEGIN android-note
-// removed java 9 ChronoUnit related code
-// END android-note
-
/**
* A {@code TimeUnit} represents time durations at a given unit of
* granularity and provides utility methods to convert across units,
@@ -395,4 +391,53 @@
Thread.sleep(ms, ns);
}
}
+
+ // BEGIN Android-removed: OpenJDK 9 ChronoUnit related code.
+ /*
+ /**
+ * Converts this {@code TimeUnit} to the equivalent {@code ChronoUnit}.
+ *
+ * @return the converted equivalent ChronoUnit
+ * @since 9
+ *
+ public ChronoUnit toChronoUnit() {
+ switch (this) {
+ case NANOSECONDS: return ChronoUnit.NANOS;
+ case MICROSECONDS: return ChronoUnit.MICROS;
+ case MILLISECONDS: return ChronoUnit.MILLIS;
+ case SECONDS: return ChronoUnit.SECONDS;
+ case MINUTES: return ChronoUnit.MINUTES;
+ case HOURS: return ChronoUnit.HOURS;
+ case DAYS: return ChronoUnit.DAYS;
+ default: throw new AssertionError();
+ }
+ }
+
+ /**
+ * Converts a {@code ChronoUnit} to the equivalent {@code TimeUnit}.
+ *
+ * @param chronoUnit the ChronoUnit to convert
+ * @return the converted equivalent TimeUnit
+ * @throws IllegalArgumentException if {@code chronoUnit} has no
+ * equivalent TimeUnit
+ * @throws NullPointerException if {@code chronoUnit} is null
+ * @since 9
+ *
+ public static TimeUnit of(ChronoUnit chronoUnit) {
+ switch (Objects.requireNonNull(chronoUnit, "chronoUnit")) {
+ case NANOS: return TimeUnit.NANOSECONDS;
+ case MICROS: return TimeUnit.MICROSECONDS;
+ case MILLIS: return TimeUnit.MILLISECONDS;
+ case SECONDS: return TimeUnit.SECONDS;
+ case MINUTES: return TimeUnit.MINUTES;
+ case HOURS: return TimeUnit.HOURS;
+ case DAYS: return TimeUnit.DAYS;
+ default:
+ throw new IllegalArgumentException(
+ "No TimeUnit equivalent for " + chronoUnit);
+ }
+ }
+ */
+ // END Android-removed: OpenJDK 9 ChronoUnit related code.
+
}
diff --git a/ojluni/src/main/java/javax/crypto/Cipher.java b/ojluni/src/main/java/javax/crypto/Cipher.java
index 010587d..f3da679 100644
--- a/ojluni/src/main/java/javax/crypto/Cipher.java
+++ b/ojluni/src/main/java/javax/crypto/Cipher.java
@@ -174,18 +174,29 @@
* <td>26+</td>
* </tr>
* <tr>
- * <td>ARC4</td>
+ * <td rowspan="2">ARC4</td>
* <td>ECB</td>
* <td>NoPadding</td>
* <td>10+</td>
* </tr>
* <tr>
+ * <td>NONE</td>
+ * <td>NoPadding</td>
+ * <td>28+</td>
+ * </tr>
+ * <tr>
* <td>BLOWFISH</td>
* <td>CBC<br>CFB<br>CTR<br>CTS<br>ECB<br>OFB</td>
* <td>ISO10126Padding<br>NoPadding<br>PKCS5Padding</td>
* <td>10+</td>
* </tr>
* <tr>
+ * <td>ChaCha20</td>
+ * <td>NONE<br>Poly1305</td>
+ * <td>NoPadding</td>
+ * <td>28+</td>
+ * </tr>
+ * <tr>
* <td>DES</td>
* <td>CBC<br>CFB<br>CTR<br>CTS<br>ECB<br>OFB</td>
* <td>ISO10126Padding<br>NoPadding<br>PKCS5Padding</td>
diff --git a/ojluni/src/main/java/javax/crypto/KeyGenerator.java b/ojluni/src/main/java/javax/crypto/KeyGenerator.java
index b0977f0..2d6f43d 100644
--- a/ojluni/src/main/java/javax/crypto/KeyGenerator.java
+++ b/ojluni/src/main/java/javax/crypto/KeyGenerator.java
@@ -109,6 +109,10 @@
* <td>10+</td>
* </tr>
* <tr>
+ * <td>ChaCha20</td>
+ * <td>28+</td>
+ * </tr>
+ * <tr>
* <td>DES</td>
* <td>1+</td>
* </tr>
diff --git a/ojluni/src/main/java/sun/invoke/util/VerifyAccess.java b/ojluni/src/main/java/sun/invoke/util/VerifyAccess.java
index d2e5820..94c401f 100644
--- a/ojluni/src/main/java/sun/invoke/util/VerifyAccess.java
+++ b/ojluni/src/main/java/sun/invoke/util/VerifyAccess.java
@@ -143,6 +143,19 @@
!lookupClass.isInterface(); // interfaces are types, not classes.
}
+ // Android-removed: Use public API instead of getClassModifiers() to check if public.
+ /*
+ static int getClassModifiers(Class<?> c) {
+ // This would return the mask stored by javac for the source-level modifiers.
+ // return c.getModifiers();
+ // But what we need for JVM access checks are the actual bits from the class header.
+ // ...But arrays and primitives are synthesized with their own odd flags:
+ if (c.isArray() || c.isPrimitive())
+ return c.getModifiers();
+ return Reflection.getClassAccessFlags(c);
+ }
+ */
+
/**
* Evaluate the JVM linkage rules for access to the given class on behalf of caller.
* <h3>JVM Specification, 5.4.4 "Access Control"</h3>
@@ -157,8 +170,13 @@
public static boolean isClassAccessible(Class<?> refc, Class<?> lookupClass,
int allowedModes) {
if (allowedModes == 0) return false;
- // Android-changed: Use public APIs to figure out whether a class
- // is public or not.
+ // Android-changed: Use public API instead of getClassModifiers() to check if public.
+ /*
+ assert((allowedModes & PUBLIC) != 0 &&
+ (allowedModes & ~(ALL_ACCESS_MODES|PACKAGE_ALLOWED)) == 0);
+ int mods = getClassModifiers(refc);
+ if (isPublic(mods))
+ */
if (Modifier.isPublic(refc.getModifiers()))
return true;
if ((allowedModes & PACKAGE_ALLOWED) != 0 &&
@@ -215,6 +233,7 @@
*/
public static boolean isSamePackage(Class<?> class1, Class<?> class2) {
// Android-changed: Throw IAE (instead of asserting) if called with array classes.
+ // assert(!class1.isArray() && !class2.isArray());
if (class1.isArray() || class2.isArray()) {
throw new IllegalArgumentException();
}
diff --git a/tools/docs/crypto/data/crypto_support.json b/tools/docs/crypto/data/crypto_support.json
index 124a457..8730405 100644
--- a/tools/docs/crypto/data/crypto_support.json
+++ b/tools/docs/crypto/data/crypto_support.json
@@ -1,6 +1,6 @@
# This file is autogenerated. See libcore/tools/docs/crypto/README for details.
{
- "api_level": "26",
+ "api_level": "28",
"categories": [
{
"algorithms": [
@@ -41,6 +41,10 @@
"supported_api_levels": "10+"
},
{
+ "name": "ChaCha20",
+ "supported_api_levels": "28+"
+ },
+ {
"name": "DES",
"supported_api_levels": "1+"
},
@@ -283,6 +287,10 @@
"supported_api_levels": "10+"
},
{
+ "name": "ARC4/NONE/NoPadding",
+ "supported_api_levels": "28+"
+ },
+ {
"name": "BLOWFISH/CBC/ISO10126Padding",
"supported_api_levels": "10+"
},
@@ -355,6 +363,14 @@
"supported_api_levels": "10+"
},
{
+ "name": "ChaCha20/NONE/NoPadding",
+ "supported_api_levels": "28+"
+ },
+ {
+ "name": "ChaCha20/Poly1305/NoPadding",
+ "supported_api_levels": "28+"
+ },
+ {
"name": "DES/CBC/ISO10126Padding",
"supported_api_levels": "1+"
},
@@ -624,6 +640,10 @@
"supported_api_levels": "10+"
},
{
+ "name": "ChaCha20",
+ "supported_api_levels": "28+"
+ },
+ {
"name": "DES",
"supported_api_levels": "1+"
},
@@ -2721,5 +2741,5 @@
"name": "TrustManagerFactory"
}
],
- "last_updated": "2017-05-05 07:40:17 UTC"
+ "last_updated": "2018-01-03 14:21:23 UTC"
}
\ No newline at end of file