harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r419909 - in /incubator/harmony/enhanced/classlib/trunk/modules/nio/src: main/java/java/nio/ test/java/common/org/apache/harmony/tests/java/nio/
Date Fri, 07 Jul 2006 15:38:13 GMT
Author: tellison
Date: Fri Jul  7 08:38:13 2006
New Revision: 419909

URL: http://svn.apache.org/viewvc?rev=419909&view=rev
Log:
Apply slightly modified version of patches for
HARMONY-796 ([classlib][nio]java.nio.ByteBuffer.wrap(byte[], int off, int len) does not throw
IndexOutOfBoundsException if off/len ==Integer.MAX_VALUE)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ByteBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/CharBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ShortBuffer.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ByteBufferTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ByteBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ByteBuffer.java?rev=419909&r1=419908&r2=419909&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ByteBuffer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ByteBuffer.java
Fri Jul  7 08:38:13 2006
@@ -104,7 +104,7 @@
                 if (array == null) {
                         throw new NullPointerException();
                 }
-                if ((start< 0 ) || (len < 0) || start+ len > array.length) {
+                if ((start < 0 ) || (len < 0) || ((long)start + (long)len > array.length))
{
                         throw new IndexOutOfBoundsException();
                 }
 
@@ -427,7 +427,7 @@
 	 *                <code>remaining()</code>
 	 */
 	public ByteBuffer get(byte[] dest, int off, int len) {
-        if ((off < 0 ) || (len < 0) || off + len > dest.length) {
+        if ((off < 0 ) || (len < 0) || ((long)off + (long)len > dest.length)) {
             throw new IndexOutOfBoundsException();
         }
         
@@ -784,7 +784,7 @@
 	 *                If no changes may be made to the contents of this buffer
 	 */
 	public ByteBuffer put(byte[] src, int off, int len) {
-        if ((off < 0 ) || (len < 0) || off + len > src.length) {
+        if ((off < 0 ) || (len < 0) || ((long)off + (long)len > src.length)) {
             throw new IndexOutOfBoundsException();
         }
         

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/CharBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/CharBuffer.java?rev=419909&r1=419908&r2=419909&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/CharBuffer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/CharBuffer.java
Fri Jul  7 08:38:13 2006
@@ -94,7 +94,7 @@
                 if (array == null) {
                         throw new NullPointerException();
                 }
-                if ((start < 0 ) || (len < 0) || start + len > array.length) {
+                if ((start < 0 ) || (len < 0) || (long)start + (long)len > array.length)
{
                         throw new IndexOutOfBoundsException();
                 }
 
@@ -142,8 +142,9 @@
 	 *                invalid
 	 */
 	public static CharBuffer wrap(CharSequence chseq, int start, int end) {
-	    if (chseq == null)
-	        throw new NullPointerException();
+	    if (chseq == null) {
+            throw new NullPointerException();
+        }
 	    if (start < 0 || end < start || end > chseq.length()) {
 	        throw new IndexOutOfBoundsException();
 	    }
@@ -381,7 +382,7 @@
 	 *                <code>remaining()</code>
 	 */
 	public CharBuffer get(char[] dest, int off, int len) {
-        if ((off < 0 ) || (len < 0) || off + len > dest.length) {
+        if ((off < 0 ) || (len < 0) || (long)off + (long)len > dest.length) {
             throw new IndexOutOfBoundsException();
         }
         
@@ -552,7 +553,7 @@
 	 *                If no changes may be made to the contents of this buffer
 	 */
 	public CharBuffer put(char[] src, int off, int len) {
-        if ((off < 0 ) || (len < 0) || off + len > src.length) {
+        if ((off < 0 ) || (len < 0) || (long)off + (long)len > src.length) {
             throw new IndexOutOfBoundsException();
         }
         

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatBuffer.java?rev=419909&r1=419908&r2=419909&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatBuffer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/FloatBuffer.java
Fri Jul  7 08:38:13 2006
@@ -85,7 +85,7 @@
                 if (array == null) {
                         throw new NullPointerException();
                 }
-                if (start < 0 || len < 0 || start + len > array.length) {
+                if (start < 0 || len < 0 || (long)start + (long)len > array.length)
{
                         throw new IndexOutOfBoundsException();
                 }
 
@@ -294,7 +294,7 @@
 	 *                <code>remaining()</code>
 	 */
 	public FloatBuffer get(float[] dest, int off, int len) {
-        if (off < 0 || len < 0 || off + len > dest.length) {
+        if (off < 0 || len < 0 || (long)off + (long)len > dest.length) {
             throw new IndexOutOfBoundsException();
         }
         
@@ -449,7 +449,7 @@
 	 *                If no changes may be made to the contents of this buffer
 	 */
 	public FloatBuffer put(float[] src, int off, int len) {
-        if (off < 0 || len < 0 || off + len > src.length) {
+        if (off < 0 || len < 0 || (long)off + (long)len > src.length) {
             throw new IndexOutOfBoundsException();
         }
         

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntBuffer.java?rev=419909&r1=419908&r2=419909&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntBuffer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/IntBuffer.java
Fri Jul  7 08:38:13 2006
@@ -87,7 +87,7 @@
                 if (array == null) {
                         throw new NullPointerException();
                 }
-                if (start < 0 || len < 0 || len + start > array.length) {
+                if (start < 0 || len < 0 || (long)len + (long)start > array.length)
{
                         throw new IndexOutOfBoundsException();
                 }
 
@@ -305,7 +305,7 @@
 	 *                <code>remaining()</code>
 	 */
 	public IntBuffer get(int[] dest, int off, int len) {
-        if (off < 0 || len < 0 || len + off > dest.length) {
+        if (off < 0 || len < 0 || (long)len + (long)off > dest.length) {
             throw new IndexOutOfBoundsException();
         }
 		if (len > remaining()) {
@@ -462,7 +462,7 @@
 	 *                If no changes may be made to the contents of this buffer
 	 */
 	public IntBuffer put(int[] src, int off, int len) {
-        if (off < 0 || len < 0 || len + off > src.length) {
+        if (off < 0 || len < 0 || (long)len + (long)off > src.length) {
             throw new IndexOutOfBoundsException();
         }
         

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongBuffer.java?rev=419909&r1=419908&r2=419909&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongBuffer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/LongBuffer.java
Fri Jul  7 08:38:13 2006
@@ -88,7 +88,7 @@
                 if (array == null) {
                         throw new NullPointerException();
                 }
-                if (start < 0 || len < 0 || len + start > array.length) {
+                if (start < 0 || len < 0 || (long)len + (long)start > array.length)
{
                         throw new IndexOutOfBoundsException();
                 }
 
@@ -306,7 +306,7 @@
 	 *                <code>remaining()</code>
 	 */
 	public LongBuffer get(long[] dest, int off, int len) {
-        if (off < 0 || len < 0 || len + off > dest.length) {
+        if (off < 0 || len < 0 || (long)len + (long)off > dest.length) {
             throw new IndexOutOfBoundsException();
         }
         
@@ -470,7 +470,7 @@
 	 *                If no changes may be made to the contents of this buffer
 	 */
 	public LongBuffer put(long[] src, int off, int len) {
-        if (off < 0 || len < 0 || len + off > src.length) {
+        if (off < 0 || len < 0 || (long)len + (long)off > src.length) {
             throw new IndexOutOfBoundsException();
         }
         

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ShortBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ShortBuffer.java?rev=419909&r1=419908&r2=419909&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ShortBuffer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/ShortBuffer.java
Fri Jul  7 08:38:13 2006
@@ -88,7 +88,7 @@
                 if (array == null) {
                         throw new NullPointerException();
                 }
-                if (start< 0 || len < 0 || start + len > array.length) {
+                if (start< 0 || len < 0 || (long)start + (long)len > array.length)
{
                         throw new IndexOutOfBoundsException();
                 }
 
@@ -306,7 +306,7 @@
 	 *                <code>remaining()</code>
 	 */
 	public ShortBuffer get(short[] dest, int off, int len) {
-        if (off < 0 || len < 0 || off + len > dest.length) {
+        if (off < 0 || len < 0 || (long)off + (long)len > dest.length) {
             throw new IndexOutOfBoundsException();
         }
 		if (len > remaining()) {
@@ -467,7 +467,7 @@
 	 *                If no changes may be made to the contents of this buffer
 	 */
 	public ShortBuffer put(short[] src, int off, int len) {
-        if (off < 0 || len < 0 || off + len > src.length) {
+        if (off < 0 || len < 0 || (long)off + (long)len > src.length) {
             throw new IndexOutOfBoundsException();
         }
         

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ByteBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ByteBufferTest.java?rev=419909&r1=419908&r2=419909&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ByteBufferTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/ByteBufferTest.java
Fri Jul  7 08:38:13 2006
@@ -1884,6 +1884,11 @@
             fail("Should throw NPE"); //$NON-NLS-1$
         } catch (NullPointerException e) {
         }
+        try {
+            ByteBuffer.wrap(new byte[10], Integer.MAX_VALUE, 2);
+            fail("Should throw IndexOutOfBoundsException"); //$NON-NLS-1$
+        } catch (IndexOutOfBoundsException e) {
+        }
     }
 
     private void loadTestData1(byte array[], int offset, int length) {



Mime
View raw message