harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r418829 - in /incubator/harmony/enhanced/classlib/trunk/modules/nio/src: main/java/java/nio/ test/java/org/apache/harmony/tests/java/nio/
Date Mon, 03 Jul 2006 19:06:15 GMT
Author: ndbeyer
Date: Mon Jul  3 12:06:14 2006
New Revision: 418829

URL: http://svn.apache.org/viewvc?rev=418829&view=rev
Log:
Apply patch for HARMONY-264: java.nio.CharBuffer.wrap NullPointerException behaviour

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/DoubleBuffer.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/org/apache/harmony/tests/java/nio/ByteBufferTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/CharBufferTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/DoubleBufferTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/FloatBufferTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/IntBufferTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/LongBufferTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/ShortBufferTest.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=418829&r1=418828&r2=418829&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
Mon Jul  3 12:06:14 2006
@@ -101,9 +101,12 @@
 	 *                invalid
 	 */
 	public static ByteBuffer wrap(byte[] array, int start, int len) {
-        if ((start< 0 ) || (len < 0) || start+ len > array.length) {
-            throw new IndexOutOfBoundsException();
-        }
+                if (array == null) {
+                        throw new NullPointerException();
+                }
+                if ((start< 0 ) || (len < 0) || start+ len > array.length) {
+                        throw new IndexOutOfBoundsException();
+                }
 
 		ByteBuffer buf = BufferFactory.newByteBuffer(array);
 		buf.position = start;

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=418829&r1=418828&r2=418829&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
Mon Jul  3 12:06:14 2006
@@ -91,9 +91,12 @@
 	 *                invalid
 	 */
 	public static CharBuffer wrap(char[] array, int start, int len) {
-        if ((start < 0 ) || (len < 0) || start + len > array.length) {
-            throw new IndexOutOfBoundsException();
-        }
+                if (array == null) {
+                        throw new NullPointerException();
+                }
+                if ((start < 0 ) || (len < 0) || start + len > array.length) {
+                        throw new IndexOutOfBoundsException();
+                }
 
 		CharBuffer buf = BufferFactory.newCharBuffer(array);
 		buf.position = start;
@@ -139,9 +142,11 @@
 	 *                invalid
 	 */
 	public static CharBuffer wrap(CharSequence chseq, int start, int end) {
-        if (start < 0 || end < start || end > chseq.length()) {
-            throw new IndexOutOfBoundsException();
-        }
+	    if (chseq == null)
+	        throw new NullPointerException();
+	    if (start < 0 || end < start || end > chseq.length()) {
+	        throw new IndexOutOfBoundsException();
+	    }
         
 		CharBuffer result = BufferFactory.newCharBuffer(chseq);
 		result.position = start;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DoubleBuffer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DoubleBuffer.java?rev=418829&r1=418828&r2=418829&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DoubleBuffer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/DoubleBuffer.java
Mon Jul  3 12:06:14 2006
@@ -82,9 +82,12 @@
 	 *                invalid
 	 */
 	public static DoubleBuffer wrap(double[] array, int start, int len) {
-        if (start < 0 || len < 0 || start+ len > array.length) {
-            throw new IndexOutOfBoundsException();
-        }
+                if (array == null) {
+                        throw new NullPointerException();
+                }
+                if (start < 0 || len < 0 || start+ len > array.length) {
+                        throw new IndexOutOfBoundsException();
+                }
 
 		DoubleBuffer buf = BufferFactory.newDoubleBuffer(array);
 		buf.position = start;

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=418829&r1=418828&r2=418829&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
Mon Jul  3 12:06:14 2006
@@ -82,9 +82,12 @@
 	 *                invalid
 	 */
 	public static FloatBuffer wrap(float[] array, int start, int len) {
-        if (start < 0 || len < 0 || start + len > array.length) {
-            throw new IndexOutOfBoundsException();
-        }
+                if (array == null) {
+                        throw new NullPointerException();
+                }
+                if (start < 0 || len < 0 || start + len > array.length) {
+                        throw new IndexOutOfBoundsException();
+                }
 
 		FloatBuffer buf = BufferFactory.newFloatBuffer(array);
 		buf.position = start;

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=418829&r1=418828&r2=418829&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
Mon Jul  3 12:06:14 2006
@@ -84,9 +84,12 @@
 	 *                invalid
 	 */
 	public static IntBuffer wrap(int[] array, int start, int len) {
-        if (start < 0 || len < 0 || len + start > array.length) {
-            throw new IndexOutOfBoundsException();
-        }
+                if (array == null) {
+                        throw new NullPointerException();
+                }
+                if (start < 0 || len < 0 || len + start > array.length) {
+                        throw new IndexOutOfBoundsException();
+                }
 
 		IntBuffer buf = BufferFactory.newIntBuffer(array);
 		buf.position = start;

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=418829&r1=418828&r2=418829&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
Mon Jul  3 12:06:14 2006
@@ -85,9 +85,12 @@
 	 *                invalid
 	 */
 	public static LongBuffer wrap(long[] array, int start, int len) {
-        if (start < 0 || len < 0 || len + start > array.length) {
-            throw new IndexOutOfBoundsException();
-        }
+                if (array == null) {
+                        throw new NullPointerException();
+                }
+                if (start < 0 || len < 0 || len + start > array.length) {
+                        throw new IndexOutOfBoundsException();
+                }
 
 		LongBuffer buf = BufferFactory.newLongBuffer(array);
 		buf.position = start;

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=418829&r1=418828&r2=418829&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
Mon Jul  3 12:06:14 2006
@@ -85,9 +85,12 @@
 	 *                invalid
 	 */
 	public static ShortBuffer wrap(short[] array, int start, int len) {
-        if (start< 0 || len < 0 || start + len > array.length) {
-            throw new IndexOutOfBoundsException();
-        }
+                if (array == null) {
+                        throw new NullPointerException();
+                }
+                if (start< 0 || len < 0 || start + len > array.length) {
+                        throw new IndexOutOfBoundsException();
+                }
 
 		ShortBuffer buf = BufferFactory.newShortBuffer(array);
 		buf.position = start;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/ByteBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/ByteBufferTest.java?rev=418829&r1=418828&r2=418829&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/ByteBufferTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/ByteBufferTest.java
Mon Jul  3 12:06:14 2006
@@ -1872,6 +1872,19 @@
 
         buf.order(ByteOrder.BIG_ENDIAN);
     }
+    
+    /**
+     * @tests java.nio.ByteBuffer.wrap(byte[],int,int)
+     */
+    public void testWrappedByteBuffer_null_array() {
+        // Regression for HARMONY-264
+        byte array[] = null;
+        try {
+            ByteBuffer.wrap(array, -1, 0);
+            fail("Should throw NPE"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+        }
+    }
 
     private void loadTestData1(byte array[], int offset, int length) {
         for (int i = 0; i < length; i++) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/CharBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/CharBufferTest.java?rev=418829&r1=418828&r2=418829&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/CharBufferTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/CharBufferTest.java
Mon Jul  3 12:06:14 2006
@@ -1008,4 +1008,24 @@
 	public void testIsReadOnly() {
 		assertFalse(buf.isReadOnly());
 	}
+    
+	/**
+	 * @tests java.nio.CharBuffer.wrap(CharSequence,int,int)
+	 */
+	public void testWrapNPE() {
+	    // Regression for HARMONY-264
+	    try {
+	        CharBuffer.wrap((CharSequence)null,1,0);
+	        fail("CharBuffer.wrap((CharSequence)null,1,0) should throw NullPointerException");
+	    } catch (NullPointerException e) {
+	    }
+
+
+	    char[] array = null;
+	    try {
+	        CharBuffer.wrap(array,-1,0);
+	        fail("CharBuffer.wrap((char[])null,-1,0) should throw NullPointerException");
+	    } catch (NullPointerException e) {
+	    }
+	}
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/DoubleBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/DoubleBufferTest.java?rev=418829&r1=418828&r2=418829&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/DoubleBufferTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/DoubleBufferTest.java
Mon Jul  3 12:06:14 2006
@@ -812,6 +812,19 @@
         testDoubleBufferInstanceThoroughly(buf);
     }
 
+    /**
+     * @tests java.nio.DoubleBuffer.wrap(double[],int,int)
+     */
+    public void testWrappedDoubleBuffer_null_array() {
+        // Regression for HARMONY-264
+        double array[] = null;
+        try {
+            DoubleBuffer.wrap(array, -1, 0);
+            fail("Should throw NPE"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+        }
+    }
+
     public void testByteBufferAsDoubleBuffer() {
         DoubleBuffer buf = ByteBuffer.allocate(160).asDoubleBuffer();
         testDoubleBufferInstanceThoroughly(buf);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/FloatBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/FloatBufferTest.java?rev=418829&r1=418828&r2=418829&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/FloatBufferTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/FloatBufferTest.java
Mon Jul  3 12:06:14 2006
@@ -789,6 +789,19 @@
         testFloatBufferInstanceThoroughly(buf);
     }
 
+    /**
+     * @tests java.nio.FloatBuffer.wrap(float[],int,int)
+     */
+    public void testWrappedFloatBuffer_null_array() {
+        // Regression for HARMONY-264
+        float array[] = null;
+        try {
+            FloatBuffer.wrap(array, -1, 0);
+            fail("Should throw NPE"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+        }
+    }
+
     public void testByteBufferAsFloatBuffer() {
         FloatBuffer buf = ByteBuffer.allocate(160).asFloatBuffer();
         testFloatBufferInstanceThoroughly(buf);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/IntBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/IntBufferTest.java?rev=418829&r1=418828&r2=418829&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/IntBufferTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/IntBufferTest.java
Mon Jul  3 12:06:14 2006
@@ -789,6 +789,19 @@
         testIntBufferInstanceThoroughly(buf);
     }
 
+    /**
+     * @tests java.nio.IntBuffer.wrap(int[],int,int)
+     */
+    public void testWrappedIntBuffer_null_array() {
+        // Regression for HARMONY-264
+        int array[] = null;
+        try {
+            IntBuffer.wrap(array, -1, 0);
+            fail("Should throw NPE"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+        }
+    }
+
     public void testByteBufferAsIntBuffer() {
         IntBuffer buf = ByteBuffer.allocate(160).asIntBuffer();
         testIntBufferInstanceThoroughly(buf);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/LongBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/LongBufferTest.java?rev=418829&r1=418828&r2=418829&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/LongBufferTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/LongBufferTest.java
Mon Jul  3 12:06:14 2006
@@ -789,6 +789,19 @@
         testLongBufferInstanceThoroughly(buf);
     }
 
+    /**
+     * @tests java.nio.LongBuffer.wrap(long[],int,int)
+     */
+    public void testWrappedLongBuffer_null_array() {
+        // Regression for HARMONY-264
+        long array[] = null;
+        try {
+            LongBuffer.wrap(array, -1, 0);
+            fail("Should throw NPE"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+        }
+    }
+
     public void testByteBufferAsLongBuffer() {
         LongBuffer buf = ByteBuffer.allocate(160).asLongBuffer();
         testLongBufferInstanceThoroughly(buf);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/ShortBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/ShortBufferTest.java?rev=418829&r1=418828&r2=418829&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/ShortBufferTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/ShortBufferTest.java
Mon Jul  3 12:06:14 2006
@@ -789,6 +789,19 @@
         testShortBufferInstanceThoroughly(buf);
     }
 
+    /**
+     * @tests java.nio.ShortBuffer.wrap(short[],int,int)
+     */
+    public void testWrappedShortBuffer_null_array() {
+        // Regression for HARMONY-264
+        short array[] = null;
+        try {
+            ShortBuffer.wrap(array, -1, 0);
+            fail("Should throw NPE"); //$NON-NLS-1$
+        } catch (NullPointerException e) {
+        }
+    }
+
     public void testByteBufferAsShortBuffer() {
         ShortBuffer buf = ByteBuffer.allocate(160).asShortBuffer();
         testShortBufferInstanceThoroughly(buf);



Mime
View raw message