Skip to main content

BufferOverflowException

java.nio.BufferOverflowException

BufferOverflowException is described in the javadoc comments as:

Unchecked exception thrown when a relative put operation reaches the target buffer's limit.
version: 1.14, 01/05/02 since: 1.4

Where is this exception thrown?

Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown.

How is this exception thrown?

The following sub-sections identify where this exception is thrown, and how (or why) the code is throwing the exception.

Any source code quoted in this section is subject to the Java Research License unless stated otherwise.

java.nio.Buffer.nextPutIndex()

/**
     * Checks the current position against the limit, throwing a {@link
     * BufferOverflowException} if it is not smaller than the limit, and then
     * increments the position. 
     * @return  The current position value, before it is incremented
     */
final int nextPutIndex() {
    if (position >= limit) throw new BufferOverflowException();
    return position++;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.Buffer.nextPutIndex(int)

final int nextPutIndex(int nb) {
    if (limit - position < nb) throw new BufferOverflowException();
    int p = position;
    position += nb;
    return p;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.ByteBuffer.put(ByteBuffer)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers the bytes remaining in the given source
     * buffer into this buffer.  If there are more bytes remaining in the
     * source buffer than in this buffer, that is, if
     * <tt>src.remaining()</tt> <tt>></tt> <tt>remaining()</tt>,
     * then no bytes are transferred and a {@link
     * BufferOverflowException} is thrown.
     *  Otherwise, this method copies
     * <i>n</i> = <tt>src.remaining()</tt> bytes from the given
     * buffer into this buffer, starting at each buffer's current position.
     * The positions of both buffers are then incremented by <i>n</i>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src)</tt> has exactly the same effect as the loop
     * 
     *     while (src.hasRemaining())
     *         dst.put(src.get()); 
     * except that it first checks that there is sufficient space in this
     * 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
     */
public ByteBuffer put(ByteBuffer src) {
    if (src == this) throw new IllegalArgumentException();
    int n = src.remaining();
    if (n > remaining()) throw new BufferOverflowException();
    for (int i = 0; i < n; i++) put(src.get());
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.ByteBuffer.put(byte[], int, int)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers bytes into this buffer from the given
     * source array.  If there are more bytes to be copied from the array
     * than remain in this buffer, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * bytes are transferred and a {@link BufferOverflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> bytes from the
     * given array into this buffer, starting at the given offset in the array
     * and at the current position of this buffer.  The position of this buffer
     * is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst.put(a[i]); 
     * except that it first checks that there is sufficient space in this
     * 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
     */
public ByteBuffer put(byte[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) this.put(src[i]);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.CharBuffer.put(CharBuffer)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers the characters remaining in the given source
     * buffer into this buffer.  If there are more characters remaining in the
     * source buffer than in this buffer, that is, if
     * <tt>src.remaining()</tt> <tt>></tt> <tt>remaining()</tt>,
     * then no characters are transferred and a {@link
     * BufferOverflowException} is thrown.
     *  Otherwise, this method copies
     * <i>n</i> = <tt>src.remaining()</tt> characters from the given
     * buffer into this buffer, starting at each buffer's current position.
     * The positions of both buffers are then incremented by <i>n</i>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src)</tt> has exactly the same effect as the loop
     * 
     *     while (src.hasRemaining())
     *         dst.put(src.get()); 
     * except that it first checks that there is sufficient space in this
     * buffer and it is potentially much more efficient. 
     * @param  src
     *         The source buffer from which characters 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 characters 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) throw new IllegalArgumentException();
    int n = src.remaining();
    if (n > remaining()) throw new BufferOverflowException();
    for (int i = 0; i < n; i++) put(src.get());
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.CharBuffer.put(char[], int, int)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers characters into this buffer from the given
     * source array.  If there are more characters to be copied from the array
     * than remain in this buffer, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * characters are transferred and a {@link BufferOverflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> characters from the
     * given array into this buffer, starting at the given offset in the array
     * and at the current position of this buffer.  The position of this buffer
     * is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst.put(a[i]); 
     * except that it first checks that there is sufficient space in this
     * buffer and it is potentially much more efficient. 
     * @param  src
     *         The array from which characters are to be read
     * @param  offset
     *         The offset within the array of the first character to be read;
     *         must be non-negative and no larger than <tt>array.length</tt>
     * @param  length
     *         The number of characters 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);
    if (length > remaining()) throw new BufferOverflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) this.put(src[i]);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectByteBuffer.put(ByteBuffer)

public ByteBuffer put(ByteBuffer src) {
    if (src instanceof DirectByteBuffer) {
        if (src == this) throw new IllegalArgumentException();
        DirectByteBuffer sb = (DirectByteBuffer) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 0);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectByteBuffer.put(byte[], int, int)

public ByteBuffer put(byte[] src, int offset, int length) {
    if ((length << 0) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromByteArray(src, offset << 0, ix(pos), length << 0); else Bits.copyFromByteArray(src, offset << 0, ix(pos), length << 0);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectCharBufferS.put(CharBuffer)

public CharBuffer put(CharBuffer src) {
    if (src instanceof DirectCharBufferS) {
        if (src == this) throw new IllegalArgumentException();
        DirectCharBufferS sb = (DirectCharBufferS) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 1);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectCharBufferS.put(char[], int, int)

public CharBuffer put(char[] src, int offset, int length) {
    if ((length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromCharArray(src, offset << 1, ix(pos), length << 1); else Bits.copyFromByteArray(src, offset << 1, ix(pos), length << 1);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectCharBufferU.put(CharBuffer)

public CharBuffer put(CharBuffer src) {
    if (src instanceof DirectCharBufferU) {
        if (src == this) throw new IllegalArgumentException();
        DirectCharBufferU sb = (DirectCharBufferU) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 1);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectCharBufferU.put(char[], int, int)

public CharBuffer put(char[] src, int offset, int length) {
    if ((length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromCharArray(src, offset << 1, ix(pos), length << 1); else Bits.copyFromByteArray(src, offset << 1, ix(pos), length << 1);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectDoubleBufferS.put(DoubleBuffer)

public DoubleBuffer put(DoubleBuffer src) {
    if (src instanceof DirectDoubleBufferS) {
        if (src == this) throw new IllegalArgumentException();
        DirectDoubleBufferS sb = (DirectDoubleBufferS) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 3);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectDoubleBufferS.put(double[], int, int)

public DoubleBuffer put(double[] src, int offset, int length) {
    if ((length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromLongArray(src, offset << 3, ix(pos), length << 3); else Bits.copyFromByteArray(src, offset << 3, ix(pos), length << 3);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectDoubleBufferU.put(DoubleBuffer)

public DoubleBuffer put(DoubleBuffer src) {
    if (src instanceof DirectDoubleBufferU) {
        if (src == this) throw new IllegalArgumentException();
        DirectDoubleBufferU sb = (DirectDoubleBufferU) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 3);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectDoubleBufferU.put(double[], int, int)

public DoubleBuffer put(double[] src, int offset, int length) {
    if ((length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromLongArray(src, offset << 3, ix(pos), length << 3); else Bits.copyFromByteArray(src, offset << 3, ix(pos), length << 3);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectFloatBufferS.put(FloatBuffer)

public FloatBuffer put(FloatBuffer src) {
    if (src instanceof DirectFloatBufferS) {
        if (src == this) throw new IllegalArgumentException();
        DirectFloatBufferS sb = (DirectFloatBufferS) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 2);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectFloatBufferS.put(float[], int, int)

public FloatBuffer put(float[] src, int offset, int length) {
    if ((length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromIntArray(src, offset << 2, ix(pos), length << 2); else Bits.copyFromByteArray(src, offset << 2, ix(pos), length << 2);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectFloatBufferU.put(FloatBuffer)

public FloatBuffer put(FloatBuffer src) {
    if (src instanceof DirectFloatBufferU) {
        if (src == this) throw new IllegalArgumentException();
        DirectFloatBufferU sb = (DirectFloatBufferU) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 2);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectFloatBufferU.put(float[], int, int)

public FloatBuffer put(float[] src, int offset, int length) {
    if ((length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromIntArray(src, offset << 2, ix(pos), length << 2); else Bits.copyFromByteArray(src, offset << 2, ix(pos), length << 2);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectIntBufferS.put(IntBuffer)

public IntBuffer put(IntBuffer src) {
    if (src instanceof DirectIntBufferS) {
        if (src == this) throw new IllegalArgumentException();
        DirectIntBufferS sb = (DirectIntBufferS) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 2);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectIntBufferS.put(int[], int, int)

public IntBuffer put(int[] src, int offset, int length) {
    if ((length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromIntArray(src, offset << 2, ix(pos), length << 2); else Bits.copyFromByteArray(src, offset << 2, ix(pos), length << 2);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectIntBufferU.put(IntBuffer)

public IntBuffer put(IntBuffer src) {
    if (src instanceof DirectIntBufferU) {
        if (src == this) throw new IllegalArgumentException();
        DirectIntBufferU sb = (DirectIntBufferU) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 2);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectIntBufferU.put(int[], int, int)

public IntBuffer put(int[] src, int offset, int length) {
    if ((length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromIntArray(src, offset << 2, ix(pos), length << 2); else Bits.copyFromByteArray(src, offset << 2, ix(pos), length << 2);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectLongBufferS.put(LongBuffer)

public LongBuffer put(LongBuffer src) {
    if (src instanceof DirectLongBufferS) {
        if (src == this) throw new IllegalArgumentException();
        DirectLongBufferS sb = (DirectLongBufferS) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 3);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectLongBufferS.put(long[], int, int)

public LongBuffer put(long[] src, int offset, int length) {
    if ((length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromLongArray(src, offset << 3, ix(pos), length << 3); else Bits.copyFromByteArray(src, offset << 3, ix(pos), length << 3);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectLongBufferU.put(LongBuffer)

public LongBuffer put(LongBuffer src) {
    if (src instanceof DirectLongBufferU) {
        if (src == this) throw new IllegalArgumentException();
        DirectLongBufferU sb = (DirectLongBufferU) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 3);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectLongBufferU.put(long[], int, int)

public LongBuffer put(long[] src, int offset, int length) {
    if ((length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromLongArray(src, offset << 3, ix(pos), length << 3); else Bits.copyFromByteArray(src, offset << 3, ix(pos), length << 3);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectShortBufferS.put(ShortBuffer)

public ShortBuffer put(ShortBuffer src) {
    if (src instanceof DirectShortBufferS) {
        if (src == this) throw new IllegalArgumentException();
        DirectShortBufferS sb = (DirectShortBufferS) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 1);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectShortBufferS.put(short[], int, int)

public ShortBuffer put(short[] src, int offset, int length) {
    if ((length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromShortArray(src, offset << 1, ix(pos), length << 1); else Bits.copyFromByteArray(src, offset << 1, ix(pos), length << 1);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectShortBufferU.put(ShortBuffer)

public ShortBuffer put(ShortBuffer src) {
    if (src instanceof DirectShortBufferU) {
        if (src == this) throw new IllegalArgumentException();
        DirectShortBufferU sb = (DirectShortBufferU) src;
        int spos = sb.position();
        int slim = sb.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (srem > rem) throw new BufferOverflowException();
        unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 1);
        sb.position(spos + srem);
        position(pos + srem);
    } else if (!src.isDirect()) {
        int spos = src.position();
        int slim = src.limit();
        assert (spos <= slim);
        int srem = (spos <= slim ? slim - spos : 0);
        put(src.hb, src.offset + spos, srem);
        src.position(spos + srem);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DirectShortBufferU.put(short[], int, int)

public ShortBuffer put(short[] src, int offset, int length) {
    if ((length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
        checkBounds(offset, length, src.length);
        int pos = position();
        int lim = limit();
        assert (pos <= lim);
        int rem = (pos <= lim ? lim - pos : 0);
        if (length > rem) throw new BufferOverflowException();
        if (order() != ByteOrder.nativeOrder()) Bits.copyFromShortArray(src, offset << 1, ix(pos), length << 1); else Bits.copyFromByteArray(src, offset << 1, ix(pos), length << 1);
        position(pos + length);
    } else {
        super.put(src, offset, length);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DoubleBuffer.put(DoubleBuffer)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers the doubles remaining in the given source
     * buffer into this buffer.  If there are more doubles remaining in the
     * source buffer than in this buffer, that is, if
     * <tt>src.remaining()</tt> <tt>></tt> <tt>remaining()</tt>,
     * then no doubles are transferred and a {@link
     * BufferOverflowException} is thrown.
     *  Otherwise, this method copies
     * <i>n</i> = <tt>src.remaining()</tt> doubles from the given
     * buffer into this buffer, starting at each buffer's current position.
     * The positions of both buffers are then incremented by <i>n</i>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src)</tt> has exactly the same effect as the loop
     * 
     *     while (src.hasRemaining())
     *         dst.put(src.get()); 
     * except that it first checks that there is sufficient space in this
     * 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
     */
public DoubleBuffer put(DoubleBuffer src) {
    if (src == this) throw new IllegalArgumentException();
    int n = src.remaining();
    if (n > remaining()) throw new BufferOverflowException();
    for (int i = 0; i < n; i++) put(src.get());
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.DoubleBuffer.put(double[], int, int)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers doubles into this buffer from the given
     * source array.  If there are more doubles to be copied from the array
     * than remain in this buffer, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * doubles are transferred and a {@link BufferOverflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> doubles from the
     * given array into this buffer, starting at the given offset in the array
     * and at the current position of this buffer.  The position of this buffer
     * is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst.put(a[i]); 
     * except that it first checks that there is sufficient space in this
     * 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
     */
public DoubleBuffer put(double[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) this.put(src[i]);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.FloatBuffer.put(FloatBuffer)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers the floats remaining in the given source
     * buffer into this buffer.  If there are more floats remaining in the
     * source buffer than in this buffer, that is, if
     * <tt>src.remaining()</tt> <tt>></tt> <tt>remaining()</tt>,
     * then no floats are transferred and a {@link
     * BufferOverflowException} is thrown.
     *  Otherwise, this method copies
     * <i>n</i> = <tt>src.remaining()</tt> floats from the given
     * buffer into this buffer, starting at each buffer's current position.
     * The positions of both buffers are then incremented by <i>n</i>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src)</tt> has exactly the same effect as the loop
     * 
     *     while (src.hasRemaining())
     *         dst.put(src.get()); 
     * except that it first checks that there is sufficient space in this
     * 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
     */
public FloatBuffer put(FloatBuffer src) {
    if (src == this) throw new IllegalArgumentException();
    int n = src.remaining();
    if (n > remaining()) throw new BufferOverflowException();
    for (int i = 0; i < n; i++) put(src.get());
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.FloatBuffer.put(float[], int, int)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers floats into this buffer from the given
     * source array.  If there are more floats to be copied from the array
     * than remain in this buffer, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * floats are transferred and a {@link BufferOverflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> floats from the
     * given array into this buffer, starting at the given offset in the array
     * and at the current position of this buffer.  The position of this buffer
     * is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst.put(a[i]); 
     * except that it first checks that there is sufficient space in this
     * 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
     */
public FloatBuffer put(float[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) this.put(src[i]);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapByteBuffer.put(ByteBuffer)

public ByteBuffer put(ByteBuffer src) {
    if (src instanceof HeapByteBuffer) {
        if (src == this) throw new IllegalArgumentException();
        HeapByteBuffer sb = (HeapByteBuffer) src;
        int n = sb.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        System.arraycopy(sb.hb, sb.ix(sb.position()), hb, ix(position()), n);
        sb.position(sb.position() + n);
        position(position() + n);
    } else if (src.isDirect()) {
        int n = src.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        src.get(hb, ix(position()), n);
        position(position() + n);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapByteBuffer.put(byte[], int, int)

public ByteBuffer put(byte[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    System.arraycopy(src, offset, hb, ix(position()), length);
    position(position() + length);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapCharBuffer.put(CharBuffer)

public CharBuffer put(CharBuffer src) {
    if (src instanceof HeapCharBuffer) {
        if (src == this) throw new IllegalArgumentException();
        HeapCharBuffer sb = (HeapCharBuffer) src;
        int n = sb.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        System.arraycopy(sb.hb, sb.ix(sb.position()), hb, ix(position()), n);
        sb.position(sb.position() + n);
        position(position() + n);
    } else if (src.isDirect()) {
        int n = src.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        src.get(hb, ix(position()), n);
        position(position() + n);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapCharBuffer.put(char[], int, int)

public CharBuffer put(char[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    System.arraycopy(src, offset, hb, ix(position()), length);
    position(position() + length);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapDoubleBuffer.put(DoubleBuffer)

public DoubleBuffer put(DoubleBuffer src) {
    if (src instanceof HeapDoubleBuffer) {
        if (src == this) throw new IllegalArgumentException();
        HeapDoubleBuffer sb = (HeapDoubleBuffer) src;
        int n = sb.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        System.arraycopy(sb.hb, sb.ix(sb.position()), hb, ix(position()), n);
        sb.position(sb.position() + n);
        position(position() + n);
    } else if (src.isDirect()) {
        int n = src.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        src.get(hb, ix(position()), n);
        position(position() + n);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapDoubleBuffer.put(double[], int, int)

public DoubleBuffer put(double[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    System.arraycopy(src, offset, hb, ix(position()), length);
    position(position() + length);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapFloatBuffer.put(FloatBuffer)

public FloatBuffer put(FloatBuffer src) {
    if (src instanceof HeapFloatBuffer) {
        if (src == this) throw new IllegalArgumentException();
        HeapFloatBuffer sb = (HeapFloatBuffer) src;
        int n = sb.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        System.arraycopy(sb.hb, sb.ix(sb.position()), hb, ix(position()), n);
        sb.position(sb.position() + n);
        position(position() + n);
    } else if (src.isDirect()) {
        int n = src.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        src.get(hb, ix(position()), n);
        position(position() + n);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapFloatBuffer.put(float[], int, int)

public FloatBuffer put(float[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    System.arraycopy(src, offset, hb, ix(position()), length);
    position(position() + length);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapIntBuffer.put(IntBuffer)

public IntBuffer put(IntBuffer src) {
    if (src instanceof HeapIntBuffer) {
        if (src == this) throw new IllegalArgumentException();
        HeapIntBuffer sb = (HeapIntBuffer) src;
        int n = sb.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        System.arraycopy(sb.hb, sb.ix(sb.position()), hb, ix(position()), n);
        sb.position(sb.position() + n);
        position(position() + n);
    } else if (src.isDirect()) {
        int n = src.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        src.get(hb, ix(position()), n);
        position(position() + n);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapIntBuffer.put(int[], int, int)

public IntBuffer put(int[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    System.arraycopy(src, offset, hb, ix(position()), length);
    position(position() + length);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapLongBuffer.put(LongBuffer)

public LongBuffer put(LongBuffer src) {
    if (src instanceof HeapLongBuffer) {
        if (src == this) throw new IllegalArgumentException();
        HeapLongBuffer sb = (HeapLongBuffer) src;
        int n = sb.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        System.arraycopy(sb.hb, sb.ix(sb.position()), hb, ix(position()), n);
        sb.position(sb.position() + n);
        position(position() + n);
    } else if (src.isDirect()) {
        int n = src.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        src.get(hb, ix(position()), n);
        position(position() + n);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapLongBuffer.put(long[], int, int)

public LongBuffer put(long[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    System.arraycopy(src, offset, hb, ix(position()), length);
    position(position() + length);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapShortBuffer.put(ShortBuffer)

public ShortBuffer put(ShortBuffer src) {
    if (src instanceof HeapShortBuffer) {
        if (src == this) throw new IllegalArgumentException();
        HeapShortBuffer sb = (HeapShortBuffer) src;
        int n = sb.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        System.arraycopy(sb.hb, sb.ix(sb.position()), hb, ix(position()), n);
        sb.position(sb.position() + n);
        position(position() + n);
    } else if (src.isDirect()) {
        int n = src.remaining();
        if (n > remaining()) throw new BufferOverflowException();
        src.get(hb, ix(position()), n);
        position(position() + n);
    } else {
        super.put(src);
    }
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.HeapShortBuffer.put(short[], int, int)

public ShortBuffer put(short[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    System.arraycopy(src, offset, hb, ix(position()), length);
    position(position() + length);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.IntBuffer.put(IntBuffer)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers the ints remaining in the given source
     * buffer into this buffer.  If there are more ints remaining in the
     * source buffer than in this buffer, that is, if
     * <tt>src.remaining()</tt> <tt>></tt> <tt>remaining()</tt>,
     * then no ints are transferred and a {@link
     * BufferOverflowException} is thrown.
     *  Otherwise, this method copies
     * <i>n</i> = <tt>src.remaining()</tt> ints from the given
     * buffer into this buffer, starting at each buffer's current position.
     * The positions of both buffers are then incremented by <i>n</i>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src)</tt> has exactly the same effect as the loop
     * 
     *     while (src.hasRemaining())
     *         dst.put(src.get()); 
     * except that it first checks that there is sufficient space in this
     * 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
     */
public IntBuffer put(IntBuffer src) {
    if (src == this) throw new IllegalArgumentException();
    int n = src.remaining();
    if (n > remaining()) throw new BufferOverflowException();
    for (int i = 0; i < n; i++) put(src.get());
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.IntBuffer.put(int[], int, int)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers ints into this buffer from the given
     * source array.  If there are more ints to be copied from the array
     * than remain in this buffer, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * ints are transferred and a {@link BufferOverflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> ints from the
     * given array into this buffer, starting at the given offset in the array
     * and at the current position of this buffer.  The position of this buffer
     * is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst.put(a[i]); 
     * except that it first checks that there is sufficient space in this
     * 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
     */
public IntBuffer put(int[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) this.put(src[i]);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.LongBuffer.put(LongBuffer)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers the longs remaining in the given source
     * buffer into this buffer.  If there are more longs remaining in the
     * source buffer than in this buffer, that is, if
     * <tt>src.remaining()</tt> <tt>></tt> <tt>remaining()</tt>,
     * then no longs are transferred and a {@link
     * BufferOverflowException} is thrown.
     *  Otherwise, this method copies
     * <i>n</i> = <tt>src.remaining()</tt> longs from the given
     * buffer into this buffer, starting at each buffer's current position.
     * The positions of both buffers are then incremented by <i>n</i>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src)</tt> has exactly the same effect as the loop
     * 
     *     while (src.hasRemaining())
     *         dst.put(src.get()); 
     * except that it first checks that there is sufficient space in this
     * 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
     */
public LongBuffer put(LongBuffer src) {
    if (src == this) throw new IllegalArgumentException();
    int n = src.remaining();
    if (n > remaining()) throw new BufferOverflowException();
    for (int i = 0; i < n; i++) put(src.get());
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.LongBuffer.put(long[], int, int)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers longs into this buffer from the given
     * source array.  If there are more longs to be copied from the array
     * than remain in this buffer, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * longs are transferred and a {@link BufferOverflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> longs from the
     * given array into this buffer, starting at the given offset in the array
     * and at the current position of this buffer.  The position of this buffer
     * is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst.put(a[i]); 
     * except that it first checks that there is sufficient space in this
     * 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
     */
public LongBuffer put(long[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) this.put(src[i]);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.ShortBuffer.put(ShortBuffer)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers the shorts remaining in the given source
     * buffer into this buffer.  If there are more shorts remaining in the
     * source buffer than in this buffer, that is, if
     * <tt>src.remaining()</tt> <tt>></tt> <tt>remaining()</tt>,
     * then no shorts are transferred and a {@link
     * BufferOverflowException} is thrown.
     *  Otherwise, this method copies
     * <i>n</i> = <tt>src.remaining()</tt> shorts from the given
     * buffer into this buffer, starting at each buffer's current position.
     * The positions of both buffers are then incremented by <i>n</i>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src)</tt> has exactly the same effect as the loop
     * 
     *     while (src.hasRemaining())
     *         dst.put(src.get()); 
     * except that it first checks that there is sufficient space in this
     * 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
     */
public ShortBuffer put(ShortBuffer src) {
    if (src == this) throw new IllegalArgumentException();
    int n = src.remaining();
    if (n > remaining()) throw new BufferOverflowException();
    for (int i = 0; i < n; i++) put(src.get());
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.ShortBuffer.put(short[], int, int)

/**
     * Relative bulk <i>put</i> method  <i>(optional operation)</i>.
     *  This method transfers shorts into this buffer from the given
     * source array.  If there are more shorts to be copied from the array
     * than remain in this buffer, that is, if
     * <tt>length</tt> <tt>></tt> <tt>remaining()</tt>, then no
     * shorts are transferred and a {@link BufferOverflowException} is
     * thrown.
     *  Otherwise, this method copies <tt>length</tt> shorts from the
     * given array into this buffer, starting at the given offset in the array
     * and at the current position of this buffer.  The position of this buffer
     * is then incremented by <tt>length</tt>.
     *  In other words, an invocation of this method of the form
     * <tt>dst.put(src, off, len)</tt> has exactly the same effect as
     * the loop
     * 
     *     for (int i = off; i < off + len; i++)
     *         dst.put(a[i]); 
     * except that it first checks that there is sufficient space in this
     * 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
     */
public ShortBuffer put(short[] src, int offset, int length) {
    checkBounds(offset, length, src.length);
    if (length > remaining()) throw new BufferOverflowException();
    int end = offset + length;
    for (int i = offset; i < end; i++) this.put(src[i]);
    return this;
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

java.nio.charset.CoderResult.throwException()

/**
     * Throws an exception appropriate to the result described by this object.
     *
     * @throws  BufferUnderflowException
     *          If this object is {@link #UNDERFLOW}
     * @throws  BufferOverflowException
     *          If this object is {@link #OVERFLOW}
     * @throws  MalformedInputException
     *          If this object represents a malformed-input error; the
     *          exception's length value will be that of this object
     * @throws  UnmappableCharacterException
     *          If this object represents an unmappable-character error; the
     *          exceptions length value will be that of this object
     */
public void throwException() throws CharacterCodingException {
    switch(type) {
        case CR_UNDERFLOW:
            throw new BufferUnderflowException();
        case CR_OVERFLOW:
            throw new BufferOverflowException();
        case CR_MALFORMED:
            throw new MalformedInputException(length);
        case CR_UNMAPPABLE:
            throw new UnmappableCharacterException(length);
        default:
            assert false;
    }
}

Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Comments

Popular posts from this blog

NullPointerException

java.lang.NullPointerException NullPointerException is described in the javadoc comments as: Thrown when an application attempts to use null in a case where an object is required. These include: Calling the instance method of a null object. Accessing or modifying the field of a null object. Taking the length of null as if it were an array. Accessing or modifying the slots of null as if it were an array. Throwing null as if it were a Throwable value. Applications should throw instances of this class to indicate other illegal uses of the null object. author: unascribed version: 1.19, 12/19/03 since: JDK1.0 Where is this exception thrown? Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown. The message ' java.lang.NullPointerException: ' is thrown within the method: com.sun.corba.se.impl.interceptors.ClientRequestInfoImpl.get_r

Connection refused: No available router to destination

This is a simple symptom-cause-solution blog entry only. I hope these blogs will help fellow administrators. Symptom The following exception occurs in WebLogic server logs. Most likely to occur during WebLogic server start-up, but similar exceptions may occur at other times. java.net.ConnectException: t3://myserver:8000: Destination unreachable; nested exception is: java.net.ConnectException: Connection refused: connect; No available router to destination] at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:49) at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:773) at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:363) at weblogic.jndi.Environment.getContext(Environment.java:307) at weblogic.jndi.Environment.getContext(Environment.java:277) Cause This message (Connection refused: connect; No available

SocketException

java.net.SocketException SocketException is described in the javadoc comments as: Thrown to indicate that there is an error in the underlying protocol, such as a TCP error. author: Jonathan Payne version: 1.17, 12/19/03 since: JDK1.0 Where is this exception thrown? Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown. The message ' java.net.SocketException: ... ' is thrown within the method: java.net.ServerSocket.createImpl() The message ' java.net.SocketException: ... ' is thrown within the method: java.net.Socket.createImpl(boolean) The message ' java.net.SocketException: ... ' is thrown within the method: java.net.SocksSocketImpl.connect(SocketAddress, int) The message ' java.net.SocketException: ... ' is thrown within the method: java.net.SocksSocketImpl.socksBind(InetSocketAddress) The message