classpath
[Top][All Lists]
Advanced

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

Patch: check for undeflow in nio


From: Dalibor Topic
Subject: Patch: check for undeflow in nio
Date: Tue, 15 Jun 2004 00:36:37 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040608

Hi all,

attached is a changelog and a small patch to add underlow check in get method in *Impl files and fix javadocs all over.

cheers,
dalibor topic
2003-06-14  Dalibor Topic  <address@hidden>

        * java/nio/ByteBuffer.java,
        java/nio/ByteBufferImpl.java,
        java/nio/CharBuffer.java,
        java/nio/DoubleBuffer.java,
        java/nio/FloatBuffer.java,
        java/nio/IntBuffer.java,
        java/nio/LongBuffer.java,
        java/nio/ShortBuffer.java,
        Fixed javadocs all over.

        * java/nio/ByteBufferImpl.java,
        java/nio/CharBufferImpl.java,
        java/nio/DoubleBufferImpl.java,
        java/nio/FloatBufferImpl.java,
        java/nio/IntBufferImpl.java,
        java/nio/LongBufferImpl.java,
        java/nio/ShortBufferImpl.java,
        (get) Check for underflow.
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/ByteBuffer.java java/nio/ByteBuffer.java
--- /tmp/topic/classpath/java/nio/ByteBuffer.java       Wed Jun  9 13:26:05 2004
+++ java/nio/ByteBuffer.java    Mon Jun 14 14:16:48 2004
@@ -100,7 +100,7 @@
   }
   
   /**
-   * 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 destination array
@@ -110,7 +110,7 @@
    * 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.
    */
@@ -130,13 +130,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)
   {
@@ -150,7 +150,7 @@
    * @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.
    */
@@ -183,7 +183,7 @@
    * 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.
@@ -209,7 +209,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)
@@ -338,7 +338,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 +347,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);
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/ByteBufferImpl.java java/nio/ByteBufferImpl.java
--- /tmp/topic/classpath/java/nio/ByteBufferImpl.java   Wed Jun  9 13:26:06 2004
+++ java/nio/ByteBufferImpl.java        Wed Jun  9 15:44:08 2004
@@ -129,10 +129,17 @@
   }
 
   /**
-   * 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 ()
   {
+    if (!hasRemaining())
+       throw new BufferUnderflowException();
+
     byte result = backing_buffer [position () + array_offset];
     position (position () + 1);
     return result;
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/CharBuffer.java java/nio/CharBuffer.java
--- /tmp/topic/classpath/java/nio/CharBuffer.java       Wed Jun  9 13:26:06 2004
+++ java/nio/CharBuffer.java    Mon Jun 14 14:15:59 2004
@@ -137,7 +137,7 @@
   }
   
   /**
-   * 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 destination array
@@ -147,7 +147,7 @@
    * 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.
    */
@@ -162,13 +162,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)
   {
@@ -182,7 +182,7 @@
    * @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.
    */
@@ -215,7 +215,7 @@
    * 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.
@@ -245,7 +245,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)
@@ -362,7 +362,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 +371,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);
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/CharBufferImpl.java java/nio/CharBufferImpl.java
--- /tmp/topic/classpath/java/nio/CharBufferImpl.java   Wed Jun  9 13:26:06 2004
+++ java/nio/CharBufferImpl.java        Wed Jun  9 15:44:08 2004
@@ -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,17 @@
   }
   
   /**
-   * 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>chars</code> in this buffer.
    */
   public char get ()
   {
+    if (!hasRemaining())
+       throw new BufferUnderflowException();
+
     char result = backing_buffer [position ()];
     position (position () + 1);
     return result;
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/DoubleBuffer.java java/nio/DoubleBuffer.java
--- /tmp/topic/classpath/java/nio/DoubleBuffer.java     Wed Jun  9 13:26:06 2004
+++ java/nio/DoubleBuffer.java  Mon Jun 14 14:17:43 2004
@@ -83,7 +83,7 @@
   }
   
   /**
-   * 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 destination array
@@ -93,7 +93,7 @@
    * 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.
    */
@@ -108,13 +108,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)
   {
@@ -128,7 +128,7 @@
    * @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.
    */
@@ -161,7 +161,7 @@
    * 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.
@@ -181,7 +181,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)
@@ -298,7 +298,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 +307,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);
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/DoubleBufferImpl.java 
java/nio/DoubleBufferImpl.java
--- /tmp/topic/classpath/java/nio/DoubleBufferImpl.java Wed Jun  9 13:26:06 2004
+++ java/nio/DoubleBufferImpl.java      Wed Jun  9 15:44:08 2004
@@ -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,17 @@
   }
 
   /**
-   * 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>doubles</code> in this buffer.
    */
   public double get ()
   {
+    if (!hasRemaining())
+      throw new BufferUnderflowException();
+
     double result = backing_buffer [position ()];
     position (position () + 1);
     return result;
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/FloatBuffer.java java/nio/FloatBuffer.java
--- /tmp/topic/classpath/java/nio/FloatBuffer.java      Wed Jun  9 13:26:06 2004
+++ java/nio/FloatBuffer.java   Mon Jun 14 14:18:26 2004
@@ -83,7 +83,7 @@
   }
   
   /**
-   * 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 destination array
@@ -93,7 +93,7 @@
    * 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.
    */
@@ -108,13 +108,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)
   {
@@ -128,7 +128,7 @@
    * @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.
    */
@@ -161,7 +161,7 @@
    * 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.
@@ -181,7 +181,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)
@@ -298,7 +298,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 +307,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);
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/FloatBufferImpl.java java/nio/FloatBufferImpl.java
--- /tmp/topic/classpath/java/nio/FloatBufferImpl.java  Wed Jun  9 13:26:06 2004
+++ java/nio/FloatBufferImpl.java       Wed Jun  9 15:44:08 2004
@@ -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,17 @@
   }
 
   /**
-   * 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 ()
   {
+    if (!hasRemaining())
+      throw new BufferUnderflowException();
+
     float result = backing_buffer [position ()];
     position (position () + 1);
     return result;
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/IntBuffer.java java/nio/IntBuffer.java
--- /tmp/topic/classpath/java/nio/IntBuffer.java        Wed Jun  9 13:26:06 2004
+++ java/nio/IntBuffer.java     Mon Jun 14 14:13:04 2004
@@ -83,7 +83,7 @@
   }
   
   /**
-   * 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 destination array
@@ -93,7 +93,7 @@
    * 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.
    */
@@ -108,13 +108,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)
   {
@@ -128,7 +128,7 @@
    * @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.
    */
@@ -161,7 +161,7 @@
    * 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.
@@ -181,7 +181,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)
@@ -298,7 +298,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 +307,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);
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/IntBufferImpl.java java/nio/IntBufferImpl.java
--- /tmp/topic/classpath/java/nio/IntBufferImpl.java    Wed Jun  9 13:26:06 2004
+++ java/nio/IntBufferImpl.java Wed Jun  9 15:44:09 2004
@@ -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,17 @@
   }
 
   /**
-   * 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 ()
   {
+    if (!hasRemaining())
+      throw new BufferUnderflowException();
+
     int result = backing_buffer [position ()];
     position (position () + 1);
     return result;
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/LongBuffer.java java/nio/LongBuffer.java
--- /tmp/topic/classpath/java/nio/LongBuffer.java       Wed Jun  9 13:26:06 2004
+++ java/nio/LongBuffer.java    Mon Jun 14 14:19:01 2004
@@ -83,7 +83,7 @@
   }
   
   /**
-   * 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 destination array
@@ -93,7 +93,7 @@
    * 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.
    */
@@ -108,13 +108,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)
   {
@@ -128,7 +128,7 @@
    * @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.
    */
@@ -161,7 +161,7 @@
    * 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.
@@ -181,7 +181,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)
@@ -298,7 +298,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 +307,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);
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/LongBufferImpl.java java/nio/LongBufferImpl.java
--- /tmp/topic/classpath/java/nio/LongBufferImpl.java   Wed Jun  9 13:26:06 2004
+++ java/nio/LongBufferImpl.java        Wed Jun  9 15:44:09 2004
@@ -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,17 @@
   }
 
   /**
-   * 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 ()
   {
+    if (!hasRemaining())
+      throw new BufferUnderflowException();
+
     long result = backing_buffer [position ()];
     position (position () + 1);
     return result;
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/ShortBuffer.java java/nio/ShortBuffer.java
--- /tmp/topic/classpath/java/nio/ShortBuffer.java      Wed Jun  9 13:26:06 2004
+++ java/nio/ShortBuffer.java   Mon Jun 14 14:14:44 2004
@@ -83,7 +83,7 @@
   }
   
   /**
-   * 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 destination array
@@ -93,7 +93,7 @@
    * 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.
    */
@@ -108,13 +108,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)
   {
@@ -128,7 +128,7 @@
    * @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.
    */
@@ -161,7 +161,7 @@
    * 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.
@@ -181,7 +181,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)
@@ -298,7 +298,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 +307,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);
diff -ur -x CVS -x *.orig -x *.rej -x *.am -x *.in -x *.cvsignore 
/tmp/topic/classpath/java/nio/ShortBufferImpl.java java/nio/ShortBufferImpl.java
--- /tmp/topic/classpath/java/nio/ShortBufferImpl.java  Wed Jun  9 13:26:06 2004
+++ java/nio/ShortBufferImpl.java       Wed Jun  9 15:44:09 2004
@@ -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,17 @@
   }
 
   /**
-   * 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>shorts</code> in this buffer.
    */
   public short get ()
   {
+    if (!hasRemaining())
+      throw new BufferUnderflowException();
+
     short result = backing_buffer [position ()];
     position (position () + 1);
     return result;

reply via email to

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