commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NIO error checking improvements and javadoc fixes


From: Dalibor Topic
Subject: NIO error checking improvements and javadoc fixes
Date: Wed, 16 Jun 2004 11:52:04 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040608

Hi all,

I've committed the attached patch with this changelog:

2003-06-15  Dalibor Topic  <address@hidden>

        * java/nio/Buffer.java,
        java/nio/ByteBuffer.java,
        java/nio/ByteBufferHelper.java,
        java/nio/ByteBufferImpl.java,
        java/nio/CharBuffer.java,
        java/nio/CharBufferImpl.java,
        java/nio/CharViewBufferImpl.java,
        java/nio/DirectByteBufferImpl.java,
        java/nio/DoubleBuffer.java,
        java/nio/DoubleBufferImpl.java,
        java/nio/DoubleViewBufferImpl.java,
        java/nio/FloatBuffer.java,
        java/nio/FloatBufferImpl.java,
        java/nio/FloatViewBufferImpl.java,
        java/nio/IntBuffer.java,
        java/nio/IntBufferImpl.java,
        java/nio/IntViewBufferImpl.java,
        java/nio/LongBuffer.java,
        java/nio/LongBufferImpl.java,
        java/nio/LongViewBufferImpl.java,
        java/nio/MappedByteBufferImpl.java,
        java/nio/ShortBuffer.java,
        java/nio/ShortBufferImpl.java,
        java/nio/ShortViewBufferImpl.java:
        Fixed javadocs all over. Improved input error
        checking.

        * java/nio/Buffer.java
        (checkForUnderflow, checkForOverflow, checkIndex,
        checkIfReadOnly, checkArraySize): New helper methods
        for error checking.

        * java/nio/ByteBufferHelper.java
        (checkRemainingForRead, checkRemainingForWrite,
        checkAvailableForRead, checkAvailableForWrite): Removed
        no longer needed methods.

cheers,
dalibor topic
? compile
Index: java/nio/Buffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/Buffer.java,v
retrieving revision 1.11
diff -u -r1.11 Buffer.java
--- java/nio/Buffer.java        26 May 2004 22:11:50 -0000      1.11
+++ java/nio/Buffer.java        15 Jun 2004 16:44:47 -0000
@@ -233,7 +233,7 @@
    * Rewinds this buffer. The position is set to zero and the mark
    * is discarded.
    *
-   * @this buffer
+   * @return this buffer
    */
   public final Buffer rewind()
   {
@@ -241,4 +241,115 @@
     mark = -1;
     return this;
   }
+
+  /**
+   * Checks for underflow. This method is used internally to check
+   * whether a buffer has enough elements left to satisfy a read 
+   * request.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * elements in this buffer.
+   */
+  final void checkForUnderflow()
+  {
+    if (!hasRemaining())
+      throw new BufferUnderflowException();
+  }
+
+  /**
+   * Checks for underflow. This method is used internally to check
+   * whether a buffer has enough elements left to satisfy a read 
+   * request for a given number of elements.
+   *
+   * @param length The length of a sequence of elements.
+   *
+   * @exception BufferUnderflowException If there are not enough 
+   * remaining elements in this buffer.
+   */
+  final void checkForUnderflow(int length)
+  {
+    if (remaining() < length)
+      throw new BufferUnderflowException();
+  }
+
+  /**
+   * Checks for overflow. This method is used internally to check
+   * whether a buffer has enough space left to satisfy a write 
+   * request.
+   *
+   * @exception BufferOverflowException If there is no remaining
+   * space in this buffer.
+   */
+  final void checkForOverflow()
+  {
+    if (!hasRemaining())
+      throw new BufferOverflowException();
+  }
+
+  /**
+   * Checks for overflow. This method is used internally to check
+   * whether a buffer has enough space left to satisfy a write 
+   * request for a given number of elements.
+   *
+   * @param length The length of a sequence of elements.
+   *
+   * @exception BufferUnderflowException If there is not enough 
+   * remaining space in this buffer.
+   */
+  final void checkForOverflow(int length)
+  {
+    if (remaining() < length)
+      throw new BufferOverflowException();
+  }
+
+  /**
+   * Checks if index is negative or not smaller than the buffer's 
+   * limit. This method is used internally to check whether
+   * an indexed request can be fulfilled.
+   *
+   * @param index The requested position in the buffer.
+   *
+   * @exception IndexOutOfBoundsException If index is negative or not smaller
+   * than the buffer's limit.
+   */
+  final void checkIndex(int index)
+  {
+    if (index < 0
+        || index >= limit ())
+      throw new IndexOutOfBoundsException ();
+  }
+
+  /**
+   * Checks if buffer is read-only. This method is used internally to
+   * check if elements can be put into a buffer.
+   *
+   * @exception ReadOnlyBufferException If this buffer is read-only.
+   */
+  final void checkIfReadOnly() 
+  {
+    if (isReadOnly())
+      throw new ReadOnlyBufferException ();
+  }
+
+  /**
+   * Checks whether an array is large enough to hold the given number of
+   * elements at the given offset. This method is used internally to
+   * check if an array is big enough.
+   *
+   * @param arraylength The length of the array.
+   * @param offset The offset within the array of the first byte to be read;
+   * must be non-negative and no larger than arraylength.
+   * @param length The number of bytes to be read from the given array;
+   * must be non-negative and no larger than arraylength - offset.
+   *
+   * @exception IndexOutOfBoundsException If the preconditions on the offset
+   * and length parameters do not hold
+   */
+  final static void checkArraySize(int arraylength, int offset, int length)
+  {
+    if ((offset < 0) ||
+        (length < 0) ||
+        (arraylength < length + offset))
+      throw new IndexOutOfBoundsException ();
+  }
 }
Index: java/nio/ByteBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/ByteBuffer.java,v
retrieving revision 1.20
diff -u -r1.20 ByteBuffer.java
--- java/nio/ByteBuffer.java    29 Apr 2004 18:04:46 -0000      1.20
+++ java/nio/ByteBuffer.java    15 Jun 2004 16:44:47 -0000
@@ -100,8 +100,9 @@
   }
   
   /**
-   * This method transfers <code>bytes<code> from this buffer into the given
-   * destination array.
+   * This method transfers <code>byte</code>s from this buffer into the given
+   * destination array. Before the transfer, it checks if there are fewer than
+   * length <code>byte</code>s remaining in this buffer.
    *
    * @param dst The destination array
    * @param offset The offset within the array of the first <code>byte</code>
@@ -110,16 +111,14 @@
    * must be non-negative and no larger than dst.length - offset.
    *
    * @exception BufferUnderflowException If there are fewer than length
-   * <code>bytes</code> remaining in this buffer.
+   * <code>byte</code>s remaining in this buffer.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold.
    */
   public ByteBuffer get (byte[] dst, int offset, int length)
   {
-    if (offset < 0 || length < 0 || offset + length > dst.length)
-      throw new IndexOutOfBoundsException ();
-    if (length > remaining())
-      throw new BufferUnderflowException();
+    checkArraySize(dst.length, offset, length);
+    checkForUnderflow(length);
 
     for (int i = offset; i < offset + length; i++)
       {
@@ -130,13 +129,13 @@
   }
 
   /**
-   * This method transfers <code>bytes<code> from this buffer into the given
+   * This method transfers <code>byte</code>s from this buffer into the given
    * destination array.
    *
    * @param dst The byte array to write into.
    *
    * @exception BufferUnderflowException If there are fewer than dst.length
-   * <code>bytes</code> remaining in this buffer.
+   * <code>byte</code>s remaining in this buffer.
    */
   public ByteBuffer get (byte[] dst)
   {
@@ -145,12 +144,13 @@
 
   /**
    * Writes the content of the the <code>ByteBUFFER</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * <code>src.remaining()</code> space remaining in this buffer.
    *
    * @param src The source data.
    *
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>bytes<code> in the source buffer.
+   * buffer for the remaining <code>byte</code>s in the source buffer.
    * @exception IllegalArgumentException If the source buffer is this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
@@ -159,8 +159,7 @@
     if (src == this)
       throw new IllegalArgumentException ();
 
-    if (src.remaining () > remaining ())
-      throw new BufferOverflowException ();
+    checkForOverflow(src.remaining());
 
     if (src.remaining () > 0)
       {
@@ -174,7 +173,8 @@
 
   /**
    * Writes the content of the the <code>byte array</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * length space remaining in this buffer.
    *
    * @param src The array to copy into the buffer.
    * @param offset The offset within the array of the first byte to be read;
@@ -183,18 +183,15 @@
    * must be non-negative and no larger than src.length - offset.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>bytes<code> in the source array.
+   * buffer for the remaining <code>byte</code>s in the source array.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public ByteBuffer put (byte[] src, int offset, int length)
   {
-    if ((offset < 0) ||
-        (offset > src.length) ||
-        (length < 0) ||
-        (length > src.length - offset))
-      throw new IndexOutOfBoundsException ();
+    checkArraySize(src.length, offset, length);
+    checkForOverflow(length);
 
     for (int i = offset; i < offset + length; i++)
       put (src [i]);
@@ -209,7 +206,7 @@
    * @param src The array to copy into the buffer.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>bytes<code> in the source array.
+   * buffer for the remaining <code>byte</code>s in the source array.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public final ByteBuffer put (byte[] src)
@@ -239,8 +236,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return backing_buffer;
   }
@@ -257,8 +253,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return array_offset;
   }
@@ -338,7 +333,7 @@
    * and then increments the position.
    *
    * @exception BufferUnderflowException If there are no remaining
-   * <code>bytes</code> in this buffer.
+   * <code>byte</code>s in this buffer.
    */
   public abstract byte get ();
 
@@ -347,7 +342,7 @@
    * and then increments the position.
    *
    * @exception BufferOverflowException If there no remaining 
-   * <code>bytes</code> in this buffer.
+   * <code>byte</code>s in this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public abstract ByteBuffer put (byte b);
Index: java/nio/ByteBufferHelper.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/ByteBufferHelper.java,v
retrieving revision 1.4
diff -u -r1.4 ByteBufferHelper.java
--- java/nio/ByteBufferHelper.java      11 Feb 2004 19:05:14 -0000      1.4
+++ java/nio/ByteBufferHelper.java      15 Jun 2004 16:44:47 -0000
@@ -42,32 +42,6 @@
  */
 final class ByteBufferHelper
 {
-  private static void checkRemainingForRead (ByteBuffer buffer, int bytes)
-  {
-    if (buffer.remaining() < bytes)
-      throw new BufferUnderflowException();
-  }
-  
-  private static void checkRemainingForWrite (ByteBuffer buffer, int bytes)
-  {
-    if (buffer.remaining() < bytes)
-      throw new BufferOverflowException();
-  }
-
-  private static void checkAvailableForRead (ByteBuffer buffer,
-                                            int index, int bytes)
-  {
-    if (buffer.limit() < (index + bytes))
-      throw new BufferUnderflowException();
-  }
-  
-  private static void checkAvailableForWrite (ByteBuffer buffer,
-                                             int index, int bytes)
-  {
-    if (buffer.limit() < (index + bytes))
-      throw new BufferOverflowException();
-  }
-  
   public static char getChar (ByteBuffer buffer, ByteOrder order)
   {
     return (char) getShort (buffer, order);
@@ -91,7 +65,7 @@
 
   public static short getShort (ByteBuffer buffer, ByteOrder order)
   {
-    checkRemainingForRead (buffer, 2);
+    buffer.checkForUnderflow(2);
 
     if (order == ByteOrder.LITTLE_ENDIAN)
       {
@@ -105,7 +79,7 @@
   
   public static void putShort (ByteBuffer buffer, short value, ByteOrder order)
   {
-    checkRemainingForWrite (buffer, 2);
+    buffer.checkForOverflow(2);
 
     if (order == ByteOrder.LITTLE_ENDIAN)
       {
@@ -122,8 +96,6 @@
   public static short getShort (ByteBuffer buffer,
                                      int index, ByteOrder order)
   {
-    checkAvailableForRead (buffer, index, 2);
-
     if (order == ByteOrder.LITTLE_ENDIAN)
       {
         return (short) ((buffer.get (index) & 0xff)
@@ -137,8 +109,6 @@
   public static void putShort (ByteBuffer buffer, int index,
                               short value, ByteOrder order)
   {
-    checkAvailableForWrite (buffer, index, 2);
-
     if (order == ByteOrder.LITTLE_ENDIAN)
       {
         buffer.put (index, (byte) value);
@@ -153,7 +123,7 @@
 
   public static int getInt (ByteBuffer buffer, ByteOrder order)
   {
-    checkRemainingForRead (buffer, 4);
+    buffer.checkForUnderflow(4);
 
     if (order == ByteOrder.LITTLE_ENDIAN)
       {
@@ -171,7 +141,7 @@
   
   public static void putInt (ByteBuffer buffer, int value, ByteOrder order)
   {
-    checkRemainingForWrite (buffer, 4);
+    buffer.checkForOverflow(4);
 
     if (order == ByteOrder.LITTLE_ENDIAN)
       {
@@ -191,8 +161,6 @@
   
   public static int getInt (ByteBuffer buffer, int index, ByteOrder order)
   {
-    checkAvailableForRead (buffer, index, 4);
-
     if (order == ByteOrder.LITTLE_ENDIAN)
       {
         return ((buffer.get (index) & 0xff)
@@ -210,8 +178,6 @@
   public static void putInt (ByteBuffer buffer, int index,
                                   int value, ByteOrder order)
   {
-    checkAvailableForWrite (buffer, index, 4);
-
     if (order == ByteOrder.LITTLE_ENDIAN)
       {
         buffer.put (index, (byte) value);
@@ -230,7 +196,7 @@
 
   public static long getLong (ByteBuffer buffer, ByteOrder order)
   {
-    checkRemainingForRead (buffer, 8);
+    buffer.checkForUnderflow(8);
 
     if (order == ByteOrder.LITTLE_ENDIAN)
       {
@@ -256,7 +222,7 @@
   
   public static void putLong (ByteBuffer buffer, long value, ByteOrder order)
   {
-    checkRemainingForWrite (buffer, 8);
+    buffer.checkForOverflow(8);
 
     if (order == ByteOrder.LITTLE_ENDIAN)
       {
@@ -284,8 +250,6 @@
   
   public static long getLong (ByteBuffer buffer, int index, ByteOrder order)
   {
-    checkAvailableForRead (buffer, index, 8);
-
     if (order == ByteOrder.LITTLE_ENDIAN)
       {
         return ((buffer.get (index) & 0xff)
@@ -311,8 +275,6 @@
   public static void putLong (ByteBuffer buffer, int index,
                                    long value, ByteOrder order)
   {
-    checkAvailableForWrite (buffer, index, 8);
-
     if (order == ByteOrder.LITTLE_ENDIAN)
       {
         buffer.put (index, (byte) value);
Index: java/nio/ByteBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/ByteBufferImpl.java,v
retrieving revision 1.6
diff -u -r1.6 ByteBufferImpl.java
--- java/nio/ByteBufferImpl.java        8 Apr 2004 20:45:13 -0000       1.6
+++ java/nio/ByteBufferImpl.java        15 Jun 2004 16:44:47 -0000
@@ -129,10 +129,16 @@
   }
 
   /**
-   * Relative get method. Reads the next <code>byte</code> from the buffer.
+   * Reads the <code>byte</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>bytes</code> in this buffer.
    */
   public byte get ()
   {
+    checkForUnderflow();
+
     byte result = backing_buffer [position () + array_offset];
     position (position () + 1);
     return result;
@@ -141,13 +147,15 @@
   /**
    * Relative put method. Writes <code>value</code> to the next position
    * in the buffer.
-   * 
+   *
+   * @exception BufferOverflowException If there is no remaining
+   * space in this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public ByteBuffer put (byte value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
+    checkForOverflow();
 
     int pos = position();
     backing_buffer [pos + array_offset] = value;
@@ -164,6 +172,8 @@
    */
   public byte get (int index)
   {
+    checkIndex(index);
+
     return backing_buffer [index + array_offset];
   }
   
@@ -177,9 +187,9 @@
    */
   public ByteBuffer put (int index, byte value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
-           
+    checkIfReadOnly();
+    checkIndex(index);
+
     backing_buffer [index + array_offset] = value;
     return this;
   }
Index: java/nio/CharBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/CharBuffer.java,v
retrieving revision 1.20
diff -u -r1.20 CharBuffer.java
--- java/nio/CharBuffer.java    26 May 2004 22:16:36 -0000      1.20
+++ java/nio/CharBuffer.java    15 Jun 2004 16:44:47 -0000
@@ -137,8 +137,9 @@
   }
   
   /**
-   * This method transfers <code>chars<code> from this buffer into the given
-   * destination array.
+   * This method transfers <code>char</code>s from this buffer into the given
+   * destination array. Before the transfer, it checks if there are fewer than
+   * length <code>char</code>s remaining in this buffer. 
    *
    * @param dst The destination array
    * @param offset The offset within the array of the first <code>char</code>
@@ -147,12 +148,15 @@
    * must be non-negative and no larger than dst.length - offset.
    *
    * @exception BufferUnderflowException If there are fewer than length
-   * <code>chars</code> remaining in this buffer.
+   * <code>char</code>s remaining in this buffer.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold.
    */
   public CharBuffer get (char[] dst, int offset, int length)
   {
+    checkArraySize(dst.length, offset, length);
+    checkForUnderflow(length);
+
     for (int i = offset; i < offset + length; i++)
       {
         dst [i] = get ();
@@ -162,13 +166,13 @@
   }
 
   /**
-   * This method transfers <code>chars<code> from this buffer into the given
+   * This method transfers <code>char</code>s from this buffer into the given
    * destination array.
    *
    * @param dst The byte array to write into.
    *
    * @exception BufferUnderflowException If there are fewer than dst.length
-   * <code>chars</code> remaining in this buffer.
+   * <code>char</code>s remaining in this buffer.
    */
   public CharBuffer get (char[] dst)
   {
@@ -177,12 +181,13 @@
 
   /**
    * Writes the content of the the <code>CharBUFFER</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * <code>src.remaining()</code> space remaining in this buffer.
    *
    * @param src The source data.
    *
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>chars<code> in the source buffer.
+   * buffer for the remaining <code>char</code>s in the source buffer.
    * @exception IllegalArgumentException If the source buffer is this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
@@ -191,8 +196,7 @@
     if (src == this)
       throw new IllegalArgumentException ();
 
-    if (src.remaining () > remaining ())
-      throw new BufferOverflowException ();
+    checkForOverflow(src.remaining());
 
     if (src.remaining () > 0)
       {
@@ -206,7 +210,8 @@
 
   /**
    * Writes the content of the the <code>char array</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * length space remaining in this buffer.
    *
    * @param src The array to copy into the buffer.
    * @param offset The offset within the array of the first byte to be read;
@@ -215,22 +220,15 @@
    * must be non-negative and no larger than src.length - offset.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>chars<code> in the source array.
+   * buffer for the remaining <code>char</code>s in the source array.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public CharBuffer put (char[] src, int offset, int length)
   {
-    if (offset < 0
-        || offset >= src.length
-        || length < 0
-        || length > (src.length - offset))
-      throw new IndexOutOfBoundsException ();
-     
-    // Put nothing into this buffer when not enough space left.
-    if (length > remaining ())
-      throw new BufferOverflowException ();
+    checkArraySize(src.length, offset, length);
+    checkForOverflow(length);
                    
     for (int i = offset; i < offset + length; i++)
       put (src [i]);
@@ -245,7 +243,7 @@
    * @param src The array to copy into the buffer.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>chars<code> in the source array.
+   * buffer for the remaining <code>char</code>s in the source array.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public final CharBuffer put (char[] src)
@@ -275,9 +273,8 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
-    
+    checkIfReadOnly();
+
     return backing_buffer;
   }
 
@@ -293,8 +290,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return array_offset;
   }
@@ -362,7 +358,7 @@
    * and then increments the position.
    *
    * @exception BufferUnderflowException If there are no remaining
-   * <code>chars</code> in this buffer.
+   * <code>char</code>s in this buffer.
    */
   public abstract char get ();
 
@@ -371,7 +367,7 @@
    * and then increments the position.
    *
    * @exception BufferOverflowException If there no remaining 
-   * <code>chars</code> in this buffer.
+   * <code>char</code>s in this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public abstract CharBuffer put (char b);
Index: java/nio/CharBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/CharBufferImpl.java,v
retrieving revision 1.4
diff -u -r1.4 CharBufferImpl.java
--- java/nio/CharBufferImpl.java        8 Apr 2004 20:45:13 -0000       1.4
+++ java/nio/CharBufferImpl.java        15 Jun 2004 16:44:47 -0000
@@ -1,5 +1,5 @@
 /* CharBufferImpl.java -- 
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -116,10 +116,16 @@
   }
   
   /**
-   * Relative get method. Reads the next <code>char</code> from the buffer.
+   * Reads the <code>char</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>char</code>s in this buffer.
    */
   public char get ()
   {
+    checkForUnderflow();
+
     char result = backing_buffer [position ()];
     position (position () + 1);
     return result;
@@ -133,8 +139,7 @@
    */
   public CharBuffer put (char value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
                    
     backing_buffer [position ()] = value;
     position (position () + 1);
@@ -145,20 +150,20 @@
    * Absolute get method. Reads the <code>char</code> at position
    * <code>index</code>.
    *
+   * @param index Position to read the <code>char</code> from.
+   *
    * @exception IndexOutOfBoundsException If index is negative or not smaller
    * than the buffer's limit.
    */
   public char get (int index)
   {
-    if (index < 0
-        || index >= limit ())
-      throw new IndexOutOfBoundsException ();
+    checkIndex(index);
     
     return backing_buffer [index];
   }
   
   /**
-   * Absolute put method. Writes <code>value</value> to position
+   * Absolute put method. Writes <code>value</code> to position
    * <code>index</code> in the buffer.
    *
    * @exception IndexOutOfBoundsException If index is negative or not smaller
@@ -167,12 +172,8 @@
    */
   public CharBuffer put (int index, char value)
   {
-    if (index < 0
-        || index >= limit ())
-      throw new IndexOutOfBoundsException ();
-    
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
+    checkIndex(index);
+    checkIfReadOnly();
            
     backing_buffer [index] = value;
     return this;
Index: java/nio/CharViewBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/CharViewBufferImpl.java,v
retrieving revision 1.3
diff -u -r1.3 CharViewBufferImpl.java
--- java/nio/CharViewBufferImpl.java    17 Feb 2004 21:44:54 -0000      1.3
+++ java/nio/CharViewBufferImpl.java    15 Jun 2004 16:44:47 -0000
@@ -66,6 +66,13 @@
     this.endian = endian;
   }
 
+  /**
+   * Reads the <code>char</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>char</code>s in this buffer.
+   */
   public char get ()
   {
     int p = position();
@@ -74,6 +81,15 @@
     return result;
   }
 
+  /**
+   * Absolute get method. Reads the <code>char</code> at position
+   * <code>index</code>.
+   *
+   * @param index Position to read the <code>char</code> from.
+   *
+   * @exception IndexOutOfBoundsException If index is negative or not smaller
+   * than the buffer's limit.
+   */
   public char get (int index)
   {
     return ByteBufferHelper.getChar(bb, (index << 1) + offset, endian);
Index: java/nio/DirectByteBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/DirectByteBufferImpl.java,v
retrieving revision 1.10
diff -u -r1.10 DirectByteBufferImpl.java
--- java/nio/DirectByteBufferImpl.java  22 Apr 2004 07:28:17 -0000      1.10
+++ java/nio/DirectByteBufferImpl.java  15 Jun 2004 16:44:47 -0000
@@ -86,9 +86,9 @@
 
   public byte get ()
   {
+    checkForUnderflow();
+
     int pos = position();
-    if (pos >= limit())
-      throw new BufferUnderflowException();
     byte result = getImpl (address, pos);
     position (pos + 1);
     return result;
@@ -96,8 +96,8 @@
 
   public byte get (int index)
   {
-    if (index >= limit())
-      throw new BufferUnderflowException();
+    checkIndex(index);
+
     return getImpl (address, index);
   }
 
@@ -106,10 +106,8 @@
 
   public ByteBuffer get (byte[] dst, int offset, int length)
   {
-    if (offset < 0 || length < 0 || offset + length > dst.length)
-      throw new IndexOutOfBoundsException ();
-    if (length > remaining())
-      throw new BufferUnderflowException();
+    checkArraySize(dst.length, offset, length);
+    checkForUnderflow(length);
 
     int index = position();
     getImpl(address, index, dst, offset, length);
@@ -120,9 +118,10 @@
 
   public ByteBuffer put (byte value)
   {
+    checkIfReadOnly();
+    checkForOverflow();
+
     int pos = position();
-    if (pos >= limit())
-      throw new BufferUnderflowException();
     putImpl (address, pos, value);
     position (pos + 1);
     return this;
@@ -130,8 +129,9 @@
   
   public ByteBuffer put (int index, byte value)
   {
-    if (index >= limit())
-      throw new BufferUnderflowException();
+    checkIfReadOnly();
+    checkIndex(index);
+
     putImpl (address, index, value);
     return this;
   }
Index: java/nio/DoubleBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/DoubleBuffer.java,v
retrieving revision 1.15
diff -u -r1.15 DoubleBuffer.java
--- java/nio/DoubleBuffer.java  29 Apr 2004 18:04:46 -0000      1.15
+++ java/nio/DoubleBuffer.java  15 Jun 2004 16:44:47 -0000
@@ -83,8 +83,9 @@
   }
   
   /**
-   * This method transfers <code>doubles<code> from this buffer into the given
-   * destination array.
+   * This method transfers <code>double</code>s from this buffer into the given
+   * destination array. Before the transfer, it checks if there are fewer than
+   * length <code>double</code>s remaining in this buffer. 
    *
    * @param dst The destination array
    * @param offset The offset within the array of the first <code>double</code>
@@ -93,12 +94,15 @@
    * must be non-negative and no larger than dst.length - offset.
    *
    * @exception BufferUnderflowException If there are fewer than length
-   * <code>doubles</code> remaining in this buffer.
+   * <code>double</code>s remaining in this buffer.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold.
    */
   public DoubleBuffer get (double[] dst, int offset, int length)
   {
+    checkArraySize(dst.length, offset, length);
+    checkForUnderflow(length);
+
     for (int i = offset; i < offset + length; i++)
       {
         dst [i] = get ();
@@ -108,13 +112,13 @@
   }
 
   /**
-   * This method transfers <code>doubles<code> from this buffer into the given
+   * This method transfers <code>double</code>s from this buffer into the given
    * destination array.
    *
    * @param dst The byte array to write into.
    *
    * @exception BufferUnderflowException If there are fewer than dst.length
-   * <code>doubles</code> remaining in this buffer.
+   * <code>double</code>s remaining in this buffer.
    */
   public DoubleBuffer get (double[] dst)
   {
@@ -123,12 +127,13 @@
 
   /**
    * Writes the content of the the <code>DoubleBUFFER</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * <code>src.remaining()</code> space remaining in this buffer.
    *
    * @param src The source data.
    *
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>doubles<code> in the source buffer.
+   * buffer for the remaining <code>double</code>s in the source buffer.
    * @exception IllegalArgumentException If the source buffer is this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
@@ -137,8 +142,7 @@
     if (src == this)
       throw new IllegalArgumentException ();
 
-    if (src.remaining () > remaining ())
-      throw new BufferOverflowException ();
+    checkForOverflow(src.remaining ());
 
     if (src.remaining () > 0)
       {
@@ -152,7 +156,8 @@
 
   /**
    * Writes the content of the the <code>double array</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * length space remaining in this buffer.
    *
    * @param src The array to copy into the buffer.
    * @param offset The offset within the array of the first byte to be read;
@@ -161,13 +166,16 @@
    * must be non-negative and no larger than src.length - offset.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>doubles<code> in the source array.
+   * buffer for the remaining <code>double</code>s in the source array.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public DoubleBuffer put (double[] src, int offset, int length)
   {
+    checkArraySize(src.length, offset, length);
+    checkForOverflow(length);
+
     for (int i = offset; i < offset + length; i++)
       put (src [i]);
 
@@ -181,7 +189,7 @@
    * @param src The array to copy into the buffer.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>doubles<code> in the source array.
+   * buffer for the remaining <code>double</code>s in the source array.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public final DoubleBuffer put (double[] src)
@@ -211,8 +219,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return backing_buffer;
   }
@@ -229,8 +236,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return array_offset;
   }
@@ -298,7 +304,7 @@
    * and then increments the position.
    *
    * @exception BufferUnderflowException If there are no remaining
-   * <code>doubles</code> in this buffer.
+   * <code>double</code>s in this buffer.
    */
   public abstract double get ();
 
@@ -307,7 +313,7 @@
    * and then increments the position.
    *
    * @exception BufferOverflowException If there no remaining 
-   * <code>doubles</code> in this buffer.
+   * <code>double</code>s in this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public abstract DoubleBuffer put (double b);
Index: java/nio/DoubleBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/DoubleBufferImpl.java,v
retrieving revision 1.4
diff -u -r1.4 DoubleBufferImpl.java
--- java/nio/DoubleBufferImpl.java      8 Apr 2004 20:45:13 -0000       1.4
+++ java/nio/DoubleBufferImpl.java      15 Jun 2004 16:44:47 -0000
@@ -1,5 +1,5 @@
 /* DoubleBufferImpl.java -- 
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -98,10 +98,16 @@
   }
 
   /**
-   * Relative get method. Reads the next <code>double</code> from the buffer.
+   * Reads the <code>double</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>double</code>s in this buffer.
    */
   public double get ()
   {
+    checkForUnderflow();
+
     double result = backing_buffer [position ()];
     position (position () + 1);
     return result;
@@ -110,13 +116,15 @@
   /**
    * Relative put method. Writes <code>value</code> to the next position
    * in the buffer.
-   * 
+   *
+   * @exception BufferOverflowException If there no remaining 
+   * space in this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public DoubleBuffer put (double value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
+    checkForOverflow();
                    
     backing_buffer [position ()] = value;
     position (position () + 1);
@@ -132,6 +140,8 @@
    */
   public double get (int index)
   {
+    checkIndex(index);
+
     return backing_buffer [index];
   }
   
@@ -145,9 +155,9 @@
    */
   public DoubleBuffer put (int index, double value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
-           
+    checkIfReadOnly();
+    checkIndex(index);
+
     backing_buffer [index] = value;
     return this;
   }
Index: java/nio/DoubleViewBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/DoubleViewBufferImpl.java,v
retrieving revision 1.4
diff -u -r1.4 DoubleViewBufferImpl.java
--- java/nio/DoubleViewBufferImpl.java  8 Apr 2004 20:45:13 -0000       1.4
+++ java/nio/DoubleViewBufferImpl.java  15 Jun 2004 16:44:47 -0000
@@ -66,6 +66,13 @@
     this.endian = endian;
   }
 
+  /**
+   * Reads the <code>double</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>double</code>s in this buffer.
+   */
   public double get ()
   {
     int p = position();
@@ -74,6 +81,13 @@
     return result;
   }
 
+  /**
+   * Absolute get method. Reads the <code>double</code> at position
+   * <code>index</code>.
+   *
+   * @exception IndexOutOfBoundsException If index is negative or not smaller
+   * than the buffer's limit.
+   */
   public double get (int index)
   {
     return ByteBufferHelper.getDouble(bb, (index << 3) + offset, endian);
Index: java/nio/FloatBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/FloatBuffer.java,v
retrieving revision 1.15
diff -u -r1.15 FloatBuffer.java
--- java/nio/FloatBuffer.java   29 Apr 2004 18:04:46 -0000      1.15
+++ java/nio/FloatBuffer.java   15 Jun 2004 16:44:47 -0000
@@ -83,8 +83,9 @@
   }
   
   /**
-   * This method transfers <code>floats<code> from this buffer into the given
-   * destination array.
+   * This method transfers <code>float</code>s from this buffer into the given
+   * destination array. Before the transfer, it checks if there are fewer than
+   * length <code>float</code>s remaining in this buffer. 
    *
    * @param dst The destination array
    * @param offset The offset within the array of the first <code>float</code>
@@ -93,12 +94,15 @@
    * must be non-negative and no larger than dst.length - offset.
    *
    * @exception BufferUnderflowException If there are fewer than length
-   * <code>floats</code> remaining in this buffer.
+   * <code>float</code>s remaining in this buffer.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold.
    */
   public FloatBuffer get (float[] dst, int offset, int length)
   {
+    checkArraySize(dst.length, offset, length);
+    checkForUnderflow(length);
+
     for (int i = offset; i < offset + length; i++)
       {
         dst [i] = get ();
@@ -108,13 +112,13 @@
   }
 
   /**
-   * This method transfers <code>floats<code> from this buffer into the given
+   * This method transfers <code>float</code>s from this buffer into the given
    * destination array.
    *
    * @param dst The byte array to write into.
    *
    * @exception BufferUnderflowException If there are fewer than dst.length
-   * <code>floats</code> remaining in this buffer.
+   * <code>float</code>s remaining in this buffer.
    */
   public FloatBuffer get (float[] dst)
   {
@@ -123,12 +127,13 @@
 
   /**
    * Writes the content of the the <code>FloatBUFFER</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * <code>src.remaining()</code> space remaining in this buffer.
    *
    * @param src The source data.
    *
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>floats<code> in the source buffer.
+   * buffer for the remaining <code>float</code>s in the source buffer.
    * @exception IllegalArgumentException If the source buffer is this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
@@ -137,8 +142,7 @@
     if (src == this)
       throw new IllegalArgumentException ();
 
-    if (src.remaining () > remaining ())
-      throw new BufferOverflowException ();
+    checkForOverflow(src.remaining());
 
     if (src.remaining () > 0)
       {
@@ -152,7 +156,8 @@
 
   /**
    * Writes the content of the the <code>float array</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * length space remaining in this buffer.
    *
    * @param src The array to copy into the buffer.
    * @param offset The offset within the array of the first byte to be read;
@@ -161,13 +166,16 @@
    * must be non-negative and no larger than src.length - offset.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>floats<code> in the source array.
+   * buffer for the remaining <code>float</code>s in the source array.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public FloatBuffer put (float[] src, int offset, int length)
   {
+    checkArraySize(src.length, offset, length);
+    checkForOverflow(length);
+
     for (int i = offset; i < offset + length; i++)
       put (src [i]);
 
@@ -181,7 +189,7 @@
    * @param src The array to copy into the buffer.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>floats<code> in the source array.
+   * buffer for the remaining <code>float</code>s in the source array.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public final FloatBuffer put (float[] src)
@@ -211,8 +219,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return backing_buffer;
   }
@@ -229,8 +236,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return array_offset;
   }
@@ -298,7 +304,7 @@
    * and then increments the position.
    *
    * @exception BufferUnderflowException If there are no remaining
-   * <code>floats</code> in this buffer.
+   * <code>float</code>s in this buffer.
    */
   public abstract float get ();
 
@@ -307,7 +313,7 @@
    * and then increments the position.
    *
    * @exception BufferOverflowException If there no remaining 
-   * <code>floats</code> in this buffer.
+   * <code>float</code>s in this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public abstract FloatBuffer put (float b);
Index: java/nio/FloatBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/FloatBufferImpl.java,v
retrieving revision 1.4
diff -u -r1.4 FloatBufferImpl.java
--- java/nio/FloatBufferImpl.java       8 Apr 2004 20:45:13 -0000       1.4
+++ java/nio/FloatBufferImpl.java       15 Jun 2004 16:44:47 -0000
@@ -1,5 +1,5 @@
 /* FloatBufferImpl.java -- 
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -98,10 +98,16 @@
   }
 
   /**
-   * Relative get method. Reads the next <code>float</code> from the buffer.
+   * Reads the <code>float</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>floats</code> in this buffer.
    */
   public float get ()
   {
+    checkForUnderflow();
+
     float result = backing_buffer [position ()];
     position (position () + 1);
     return result;
@@ -111,13 +117,15 @@
    * Relative put method. Writes <code>value</code> to the next position
    * in the buffer.
    * 
+   * @exception BufferOverflowException If there no remaining 
+   * space in this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public FloatBuffer put (float value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
-                   
+    checkIfReadOnly();
+    checkForOverflow();
+
     backing_buffer [position ()] = value;
     position (position () + 1);
     return this;
@@ -132,6 +140,8 @@
    */
   public float get (int index)
   {
+    checkIndex(index);
+
     return backing_buffer [index];
   }
   
@@ -145,9 +155,9 @@
    */
   public FloatBuffer put (int index, float value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
-           
+    checkIfReadOnly();
+    checkIndex(index);
+
     backing_buffer [index] = value;
     return this;
   }
Index: java/nio/FloatViewBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/FloatViewBufferImpl.java,v
retrieving revision 1.4
diff -u -r1.4 FloatViewBufferImpl.java
--- java/nio/FloatViewBufferImpl.java   8 Apr 2004 20:45:13 -0000       1.4
+++ java/nio/FloatViewBufferImpl.java   15 Jun 2004 16:44:47 -0000
@@ -66,6 +66,13 @@
     this.endian = endian;
   }
 
+  /**
+   * Reads the <code>float</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>floats</code> in this buffer.
+   */
   public float get ()
   {
     int p = position();
@@ -74,6 +81,13 @@
     return result;
   }
 
+  /**
+   * Absolute get method. Reads the <code>float</code> at position
+   * <code>index</code>.
+   *
+   * @exception IndexOutOfBoundsException If index is negative or not smaller
+   * than the buffer's limit.
+   */
   public float get (int index)
   {
     return ByteBufferHelper.getFloat(bb, (index << 2) + offset, endian);
Index: java/nio/IntBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/IntBuffer.java,v
retrieving revision 1.15
diff -u -r1.15 IntBuffer.java
--- java/nio/IntBuffer.java     29 Apr 2004 18:04:46 -0000      1.15
+++ java/nio/IntBuffer.java     15 Jun 2004 16:44:47 -0000
@@ -83,8 +83,9 @@
   }
   
   /**
-   * This method transfers <code>ints<code> from this buffer into the given
-   * destination array.
+   * This method transfers <code>int</code>s from this buffer into the given
+   * destination array. Before the transfer, it checks if there are fewer than
+   * length <code>int</code>s remaining in this buffer. 
    *
    * @param dst The destination array
    * @param offset The offset within the array of the first <code>int</code>
@@ -93,12 +94,15 @@
    * must be non-negative and no larger than dst.length - offset.
    *
    * @exception BufferUnderflowException If there are fewer than length
-   * <code>ints</code> remaining in this buffer.
+   * <code>int</code>s remaining in this buffer.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold.
    */
   public IntBuffer get (int[] dst, int offset, int length)
   {
+    checkArraySize(dst.length, offset, length);
+    checkForUnderflow(length);
+
     for (int i = offset; i < offset + length; i++)
       {
         dst [i] = get ();
@@ -108,13 +112,13 @@
   }
 
   /**
-   * This method transfers <code>ints<code> from this buffer into the given
+   * This method transfers <code>int</code>s from this buffer into the given
    * destination array.
    *
    * @param dst The byte array to write into.
    *
    * @exception BufferUnderflowException If there are fewer than dst.length
-   * <code>ints</code> remaining in this buffer.
+   * <code>int</code>s remaining in this buffer.
    */
   public IntBuffer get (int[] dst)
   {
@@ -123,12 +127,13 @@
 
   /**
    * Writes the content of the the <code>IntBUFFER</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * <code>src.remaining()</code> space remaining in this buffer.
    *
    * @param src The source data.
    *
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>ints<code> in the source buffer.
+   * buffer for the remaining <code>int</code>s in the source buffer.
    * @exception IllegalArgumentException If the source buffer is this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
@@ -137,8 +142,7 @@
     if (src == this)
       throw new IllegalArgumentException ();
 
-    if (src.remaining () > remaining ())
-      throw new BufferOverflowException ();
+    checkForOverflow(src.remaining ());
 
     if (src.remaining () > 0)
       {
@@ -152,7 +156,8 @@
 
   /**
    * Writes the content of the the <code>int array</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * length space remaining in this buffer.
    *
    * @param src The array to copy into the buffer.
    * @param offset The offset within the array of the first byte to be read;
@@ -161,13 +166,16 @@
    * must be non-negative and no larger than src.length - offset.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>ints<code> in the source array.
+   * buffer for the remaining <code>int</code>s in the source array.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public IntBuffer put (int[] src, int offset, int length)
   {
+    checkArraySize(src.length, offset, length);
+    checkForOverflow(length);
+
     for (int i = offset; i < offset + length; i++)
       put (src [i]);
 
@@ -181,7 +189,7 @@
    * @param src The array to copy into the buffer.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>ints<code> in the source array.
+   * buffer for the remaining <code>int</code>s in the source array.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public final IntBuffer put (int[] src)
@@ -211,8 +219,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return backing_buffer;
   }
@@ -229,8 +236,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return array_offset;
   }
@@ -298,7 +304,7 @@
    * and then increments the position.
    *
    * @exception BufferUnderflowException If there are no remaining
-   * <code>ints</code> in this buffer.
+   * <code>int</code>s in this buffer.
    */
   public abstract int get ();
 
@@ -307,7 +313,7 @@
    * and then increments the position.
    *
    * @exception BufferOverflowException If there no remaining 
-   * <code>ints</code> in this buffer.
+   * <code>int</code>s in this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public abstract IntBuffer put (int b);
Index: java/nio/IntBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/IntBufferImpl.java,v
retrieving revision 1.4
diff -u -r1.4 IntBufferImpl.java
--- java/nio/IntBufferImpl.java 8 Apr 2004 20:45:13 -0000       1.4
+++ java/nio/IntBufferImpl.java 15 Jun 2004 16:44:47 -0000
@@ -1,5 +1,5 @@
 /* IntBufferImpl.java -- 
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -98,10 +98,16 @@
   }
 
   /**
-   * Relative get method. Reads the next <code>int</code> from the buffer.
+   * Reads the <code>int</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>ints</code> in this buffer.
    */
   public int get ()
   {
+    checkForUnderflow();
+
     int result = backing_buffer [position ()];
     position (position () + 1);
     return result;
@@ -110,14 +116,16 @@
   /**
    * Relative put method. Writes <code>value</code> to the next position
    * in the buffer.
-   * 
+   *
+   * @exception BufferOverflowException If there no remaining 
+   * space in this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public IntBuffer put (int value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
-                   
+    checkIfReadOnly();
+    checkForOverflow();
+
     backing_buffer [position ()] = value;
     position (position () + 1);
     return this;
@@ -132,6 +140,8 @@
    */
   public int get (int index)
   {
+    checkIndex(index);
+
     return backing_buffer [index];
   }
   
@@ -145,9 +155,9 @@
    */
   public IntBuffer put (int index, int value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
-           
+    checkIfReadOnly();
+    checkIndex(index);
+
     backing_buffer [index] = value;
     return this;
   }
Index: java/nio/IntViewBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/IntViewBufferImpl.java,v
retrieving revision 1.4
diff -u -r1.4 IntViewBufferImpl.java
--- java/nio/IntViewBufferImpl.java     8 Apr 2004 20:45:13 -0000       1.4
+++ java/nio/IntViewBufferImpl.java     15 Jun 2004 16:44:47 -0000
@@ -66,6 +66,13 @@
     this.endian = endian;
   }
 
+  /**
+   * Reads the <code>int</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>ints</code> in this buffer.
+   */
   public int get ()
   {
     int p = position();
@@ -74,6 +81,13 @@
     return result;
   }
 
+  /**
+   * Absolute get method. Reads the <code>int</code> at position
+   * <code>index</code>.
+   *
+   * @exception IndexOutOfBoundsException If index is negative or not smaller
+   * than the buffer's limit.
+   */
   public int get (int index)
   {
     return ByteBufferHelper.getInt(bb, (index << 2) + offset, endian);
Index: java/nio/LongBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/LongBuffer.java,v
retrieving revision 1.15
diff -u -r1.15 LongBuffer.java
--- java/nio/LongBuffer.java    29 Apr 2004 18:04:46 -0000      1.15
+++ java/nio/LongBuffer.java    15 Jun 2004 16:44:47 -0000
@@ -83,8 +83,9 @@
   }
   
   /**
-   * This method transfers <code>longs<code> from this buffer into the given
-   * destination array.
+   * This method transfers <code>long</code>s from this buffer into the given
+   * destination array. Before the transfer, it checks if there are fewer than
+   * length <code>long</code>s remaining in this buffer. 
    *
    * @param dst The destination array
    * @param offset The offset within the array of the first <code>long</code>
@@ -93,12 +94,15 @@
    * must be non-negative and no larger than dst.length - offset.
    *
    * @exception BufferUnderflowException If there are fewer than length
-   * <code>longs</code> remaining in this buffer.
+   * <code>long</code>s remaining in this buffer.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold.
    */
   public LongBuffer get (long[] dst, int offset, int length)
   {
+    checkArraySize(dst.length, offset, length);
+    checkForUnderflow(length);
+
     for (int i = offset; i < offset + length; i++)
       {
         dst [i] = get ();
@@ -108,13 +112,13 @@
   }
 
   /**
-   * This method transfers <code>longs<code> from this buffer into the given
+   * This method transfers <code>long</code>s from this buffer into the given
    * destination array.
    *
    * @param dst The byte array to write into.
    *
    * @exception BufferUnderflowException If there are fewer than dst.length
-   * <code>longs</code> remaining in this buffer.
+   * <code>long</code>s remaining in this buffer.
    */
   public LongBuffer get (long[] dst)
   {
@@ -123,12 +127,13 @@
 
   /**
    * Writes the content of the the <code>LongBUFFER</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * <code>src.remaining()</code> space remaining in this buffer.
    *
    * @param src The source data.
    *
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>longs<code> in the source buffer.
+   * buffer for the remaining <code>long</code>s in the source buffer.
    * @exception IllegalArgumentException If the source buffer is this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
@@ -137,8 +142,7 @@
     if (src == this)
       throw new IllegalArgumentException ();
 
-    if (src.remaining () > remaining ())
-      throw new BufferOverflowException ();
+    checkForOverflow(src.remaining ());
 
     if (src.remaining () > 0)
       {
@@ -152,7 +156,8 @@
 
   /**
    * Writes the content of the the <code>long array</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * length space remaining in this buffer.
    *
    * @param src The array to copy into the buffer.
    * @param offset The offset within the array of the first byte to be read;
@@ -161,13 +166,16 @@
    * must be non-negative and no larger than src.length - offset.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>longs<code> in the source array.
+   * buffer for the remaining <code>long</code>s in the source array.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public LongBuffer put (long[] src, int offset, int length)
   {
+    checkArraySize(src.length, offset, length);
+    checkForOverflow(length);
+
     for (int i = offset; i < offset + length; i++)
       put (src [i]);
 
@@ -181,7 +189,7 @@
    * @param src The array to copy into the buffer.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>longs<code> in the source array.
+   * buffer for the remaining <code>long</code>s in the source array.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public final LongBuffer put (long[] src)
@@ -211,8 +219,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return backing_buffer;
   }
@@ -229,8 +236,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return array_offset;
   }
@@ -298,7 +304,7 @@
    * and then increments the position.
    *
    * @exception BufferUnderflowException If there are no remaining
-   * <code>longs</code> in this buffer.
+   * <code>long</code>s in this buffer.
    */
   public abstract long get ();
 
@@ -307,7 +313,7 @@
    * and then increments the position.
    *
    * @exception BufferOverflowException If there no remaining 
-   * <code>longs</code> in this buffer.
+   * <code>long</code>s in this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public abstract LongBuffer put (long b);
Index: java/nio/LongBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/LongBufferImpl.java,v
retrieving revision 1.4
diff -u -r1.4 LongBufferImpl.java
--- java/nio/LongBufferImpl.java        8 Apr 2004 20:45:13 -0000       1.4
+++ java/nio/LongBufferImpl.java        15 Jun 2004 16:44:47 -0000
@@ -1,5 +1,5 @@
 /* LongBufferImpl.java -- 
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -98,10 +98,16 @@
   }
 
   /**
-   * Relative get method. Reads the next <code>long</code> from the buffer.
+   * Reads the <code>long</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>longs</code> in this buffer.
    */
   public long get ()
   {
+    checkForUnderflow();
+
     long result = backing_buffer [position ()];
     position (position () + 1);
     return result;
@@ -110,14 +116,16 @@
   /**
    * Relative put method. Writes <code>value</code> to the next position
    * in the buffer.
-   * 
+   *
+   * @exception BufferOverflowException If there is insufficient space in this
+   * buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public LongBuffer put (long value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
-                   
+    checkIfReadOnly();
+    checkForOverflow();
+
     backing_buffer [position ()] = value;
     position (position () + 1);
     return this;
@@ -132,6 +140,8 @@
    */
   public long get (int index)
   {
+    checkIndex(index);
+
     return backing_buffer [index];
   }
   
@@ -145,9 +155,9 @@
    */
   public LongBuffer put (int index, long value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
-           
+    checkIfReadOnly();
+    checkIndex(index);
+
     backing_buffer [index] = value;
     return this;
   }
Index: java/nio/LongViewBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/LongViewBufferImpl.java,v
retrieving revision 1.4
diff -u -r1.4 LongViewBufferImpl.java
--- java/nio/LongViewBufferImpl.java    8 Apr 2004 20:45:13 -0000       1.4
+++ java/nio/LongViewBufferImpl.java    15 Jun 2004 16:44:47 -0000
@@ -66,6 +66,13 @@
     this.endian = endian;
   }
 
+  /**
+   * Reads the <code>long</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>longs</code> in this buffer.
+   */
   public long get ()
   {
     int p = position();
@@ -74,6 +81,13 @@
     return result;
   }
 
+  /**
+   * Absolute get method. Reads the <code>long</code> at position
+   * <code>index</code>.
+   *
+   * @exception IndexOutOfBoundsException If index is negative or not smaller
+   * than the buffer's limit.
+   */
   public long get (int index)
   {
     return ByteBufferHelper.getLong(bb, (index << 3) + offset, endian);
Index: java/nio/MappedByteBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/MappedByteBufferImpl.java,v
retrieving revision 1.9
diff -u -r1.9 MappedByteBufferImpl.java
--- java/nio/MappedByteBufferImpl.java  22 Apr 2004 07:28:17 -0000      1.9
+++ java/nio/MappedByteBufferImpl.java  15 Jun 2004 16:44:47 -0000
@@ -68,9 +68,9 @@
   
   public byte get ()
   {
+    checkForUnderflow();
+
     int pos = position();
-    if (pos >= limit())
-      throw new BufferUnderflowException();
     byte result = DirectByteBufferImpl.getImpl(address, pos);
     position (pos + 1);
     return result;
@@ -78,9 +78,10 @@
 
   public ByteBuffer put (byte value)
   {
+    checkIfReadOnly();
+    checkForOverflow();
+
     int pos = position();
-    if (pos >= limit())
-      throw new BufferUnderflowException();
     DirectByteBufferImpl.putImpl(address, pos, value);
     position(pos + 1);
     return this;
@@ -88,17 +89,15 @@
 
   public byte get (int index)
   {
-    if (index >= limit())
-      throw new BufferUnderflowException();
+    checkIndex(index);
+
     return DirectByteBufferImpl.getImpl(address, index);
   }
 
   public ByteBuffer get (byte[] dst, int offset, int length)
   {
-    if (offset < 0 || length < 0 || offset + length > dst.length)
-      throw new IndexOutOfBoundsException ();
-    if (length > remaining())
-      throw new BufferUnderflowException();
+    checkArraySize(dst.length, offset, length);
+    checkForUnderflow(length);
 
     int index = position();
     DirectByteBufferImpl.getImpl(address, index, dst, offset, length);
@@ -109,8 +108,9 @@
 
   public ByteBuffer put (int index, byte value)
   {
-    if (index >= limit())
-      throw new BufferUnderflowException();
+    checkIfReadOnly();
+    checkIndex(index);
+
     DirectByteBufferImpl.putImpl(address, index, value);
     return this;
   }
Index: java/nio/ShortBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/ShortBuffer.java,v
retrieving revision 1.16
diff -u -r1.16 ShortBuffer.java
--- java/nio/ShortBuffer.java   29 Apr 2004 18:04:46 -0000      1.16
+++ java/nio/ShortBuffer.java   15 Jun 2004 16:44:47 -0000
@@ -83,8 +83,9 @@
   }
   
   /**
-   * This method transfers <code>shorts<code> from this buffer into the given
-   * destination array.
+   * This method transfers <code>short</code>s from this buffer into the given
+   * destination array. Before the transfer, it checks if there are fewer than
+   * length <code>short</code>s remaining in this buffer. 
    *
    * @param dst The destination array
    * @param offset The offset within the array of the first <code>short</code>
@@ -93,12 +94,15 @@
    * must be non-negative and no larger than dst.length - offset.
    *
    * @exception BufferUnderflowException If there are fewer than length
-   * <code>shorts</code> remaining in this buffer.
+   * <code>short</code>s remaining in this buffer.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold.
    */
   public ShortBuffer get (short[] dst, int offset, int length)
   {
+    checkArraySize(dst.length, offset, length);
+    checkForUnderflow(length);
+
     for (int i = offset; i < offset + length; i++)
       {
         dst [i] = get ();
@@ -108,13 +112,13 @@
   }
 
   /**
-   * This method transfers <code>shorts<code> from this buffer into the given
+   * This method transfers <code>short</code>s from this buffer into the given
    * destination array.
    *
    * @param dst The byte array to write into.
    *
    * @exception BufferUnderflowException If there are fewer than dst.length
-   * <code>shorts</code> remaining in this buffer.
+   * <code>short</code>s remaining in this buffer.
    */
   public ShortBuffer get (short[] dst)
   {
@@ -123,12 +127,13 @@
 
   /**
    * Writes the content of the the <code>ShortBUFFER</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * <code>src.remaining()</code> space remaining in this buffer.
    *
    * @param src The source data.
    *
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>shorts<code> in the source buffer.
+   * buffer for the remaining <code>short</code>s in the source buffer.
    * @exception IllegalArgumentException If the source buffer is this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
@@ -137,8 +142,7 @@
     if (src == this)
       throw new IllegalArgumentException ();
 
-    if (src.remaining () > remaining ())
-      throw new BufferOverflowException ();
+    checkForOverflow(src.remaining ());
 
     if (src.remaining () > 0)
       {
@@ -152,7 +156,8 @@
 
   /**
    * Writes the content of the the <code>short array</code> src
-   * into the buffer.
+   * into the buffer. Before the transfer, it checks if there is fewer than
+   * length space remaining in this buffer.
    *
    * @param src The array to copy into the buffer.
    * @param offset The offset within the array of the first byte to be read;
@@ -161,13 +166,16 @@
    * must be non-negative and no larger than src.length - offset.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>shorts<code> in the source array.
+   * buffer for the remaining <code>short</code>s in the source array.
    * @exception IndexOutOfBoundsException If the preconditions on the offset
    * and length parameters do not hold
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public ShortBuffer put (short[] src, int offset, int length)
   {
+    checkArraySize(src.length, offset, length);
+    checkForOverflow(length);
+
     for (int i = offset; i < offset + length; i++)
       put (src [i]);
 
@@ -181,7 +189,7 @@
    * @param src The array to copy into the buffer.
    * 
    * @exception BufferOverflowException If there is insufficient space in this
-   * buffer for the remaining <code>shorts<code> in the source array.
+   * buffer for the remaining <code>short</code>s in the source array.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public final ShortBuffer put (short[] src)
@@ -211,8 +219,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return backing_buffer;
   }
@@ -229,8 +236,7 @@
     if (backing_buffer == null)
       throw new UnsupportedOperationException ();
 
-    if (isReadOnly ())
-      throw new ReadOnlyBufferException ();
+    checkIfReadOnly();
     
     return array_offset;
   }
@@ -298,7 +304,7 @@
    * and then increments the position.
    *
    * @exception BufferUnderflowException If there are no remaining
-   * <code>shorts</code> in this buffer.
+   * <code>short</code>s in this buffer.
    */
   public abstract short get ();
 
@@ -307,7 +313,7 @@
    * and then increments the position.
    *
    * @exception BufferOverflowException If there no remaining 
-   * <code>shorts</code> in this buffer.
+   * <code>short</code>s in this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public abstract ShortBuffer put (short b);
Index: java/nio/ShortBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/ShortBufferImpl.java,v
retrieving revision 1.4
diff -u -r1.4 ShortBufferImpl.java
--- java/nio/ShortBufferImpl.java       8 Apr 2004 20:45:13 -0000       1.4
+++ java/nio/ShortBufferImpl.java       15 Jun 2004 16:44:47 -0000
@@ -1,5 +1,5 @@
 /* ShortBufferImpl.java -- 
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -98,10 +98,16 @@
   }
 
   /**
-   * Relative get method. Reads the next <code>short</code> from the buffer.
+   * Reads the <code>short</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>short</code>s in this buffer.
    */
   public short get ()
   {
+    checkForUnderflow();
+
     short result = backing_buffer [position ()];
     position (position () + 1);
     return result;
@@ -110,14 +116,16 @@
   /**
    * Relative put method. Writes <code>value</code> to the next position
    * in the buffer.
-   * 
+   *
+   * @exception BufferOverflowException If there no remaining 
+   * space in this buffer.
    * @exception ReadOnlyBufferException If this buffer is read-only.
    */
   public ShortBuffer put (short value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
-                   
+    checkIfReadOnly();
+    checkForOverflow();
+
     backing_buffer [position ()] = value;
     position (position () + 1);
     return this;
@@ -132,6 +140,8 @@
    */
   public short get (int index)
   {
+    checkIndex(index);
+
     return backing_buffer [index];
   }
   
@@ -145,9 +155,9 @@
    */
   public ShortBuffer put (int index, short value)
   {
-    if (readOnly)
-      throw new ReadOnlyBufferException ();
-           
+    checkIfReadOnly();
+    checkIndex(index);
+
     backing_buffer [index] = value;
     return this;
   }
Index: java/nio/ShortViewBufferImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/ShortViewBufferImpl.java,v
retrieving revision 1.4
diff -u -r1.4 ShortViewBufferImpl.java
--- java/nio/ShortViewBufferImpl.java   8 Apr 2004 20:45:13 -0000       1.4
+++ java/nio/ShortViewBufferImpl.java   15 Jun 2004 16:44:47 -0000
@@ -66,6 +66,13 @@
     this.endian = endian;
   }
 
+  /**
+   * Reads the <code>short</code> at this buffer's current position,
+   * and then increments the position.
+   *
+   * @exception BufferUnderflowException If there are no remaining
+   * <code>short</code>s in this buffer.
+   */
   public short get ()
   {
     int p = position();
@@ -74,6 +81,13 @@
     return result;
   }
 
+  /**
+   * Absolute get method. Reads the <code>short</code> at position
+   * <code>index</code>.
+   *
+   * @exception IndexOutOfBoundsException If index is negative or not smaller
+   * than the buffer's limit.
+   */
   public short get (int index)
   {
     return ByteBufferHelper.getShort(bb, (index << 1) + offset, endian);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]