harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r486283 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/image/ main/java/common/org/apache/harmony/awt/internal/nls/ test/api/java/common/java/awt/image/
Date Tue, 12 Dec 2006 19:18:51 GMT
Author: apetrenko
Date: Tue Dec 12 11:18:51 2006
New Revision: 486283

URL: http://svn.apache.org/viewvc?view=rev&rev=486283
Log:
Patch for HARMONY-2183 "[classlib][awt] DataBufferUShort(short[] dataArray, int size, int
offset) doesn't throw IllegalArgumentException when dataArray.length less than size + offset"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/DataBufferUShort.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/DataBufferUShortTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/DataBufferUShort.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/DataBufferUShort.java?view=diff&rev=486283&r1=486282&r2=486283
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/DataBufferUShort.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/DataBufferUShort.java
Tue Dec 12 11:18:51 2006
@@ -20,6 +20,8 @@
  */
 package java.awt.image;
 
+import org.apache.harmony.awt.internal.nls.Messages;
+
 
 public final class DataBufferUShort extends DataBuffer {
 
@@ -27,6 +29,12 @@
 
     public DataBufferUShort(short dataArrays[][], int size, int offsets[]) {
         super(TYPE_USHORT, size, dataArrays.length, offsets);
+        for(int i = 0; i < dataArrays.length; i++){
+            if(dataArrays[i].length < offsets[i] + size){
+                // awt.28d=Length of dataArray[{0}] is less than size + offset[{1}]
+                throw new IllegalArgumentException(Messages.getString("awt.28D", i, i));
 //$NON-NLS-1$
+            }
+        }
         data = dataArrays.clone();
     }
 
@@ -37,6 +45,10 @@
 
     public DataBufferUShort(short dataArray[], int size, int offset) {
         super(TYPE_USHORT, size, 1, offset);
+        if(dataArray.length < size + offset){
+            // awt.28E=Length of dataArray is less than size + offset
+            throw new IllegalArgumentException(Messages.getString("awt.28E")); //$NON-NLS-1$
+        }
         data = new short[1][];
         data[0] = dataArray;
     }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties?view=diff&rev=486283&r1=486282&r2=486283
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
Tue Dec 12 11:18:51 2006
@@ -476,6 +476,8 @@
 awt.28A=childMinX + width results in integer overflow
 awt.28B=childMinY + height results in integer overflow
 awt.28C=Rect is null
+awt.28D=Length of dataArray[{0}] is less than size + offset[{1}]
+awt.28E=Length of dataArray is less than size + offset
 
 awt.err.00=file dialog {0} error!
 awt.err.01=error: {0}

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/DataBufferUShortTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/DataBufferUShortTest.java?view=diff&rev=486283&r1=486282&r2=486283
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/DataBufferUShortTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/DataBufferUShortTest.java
Tue Dec 12 11:18:51 2006
@@ -69,6 +69,33 @@
     public DataBufferUShortTest(String name) {
         super(name);
     }
+    
+    public final void testDataBufferUShort_1(){
+        // Test for constructor DataBufferUShort(short[] dataArray, int size, int offset)
+        short data[] = new short[10];
+        DataBufferUShort dbus = null;
+        try{
+            dbus = new DataBufferUShort(data, 10, 10);
+            fail("No IllegalArgumentException");
+        }catch(IllegalArgumentException e){
+            assertTrue(true);
+        }
+    }
+    
+    public final void testDataBufferUShort_2(){
+        // Test for constructor DataBufferUShort(short[][] dataArray, int size, int[] offsets)
+        short data[][] = new short[2][0];
+        data[0] = new short[20];
+        data[1] = new short[10];
+        int offsets[] = new int[]{10, 10};
+        DataBufferUShort dbus = null;
+        try{
+            dbus = new DataBufferUShort(data, 10, offsets);
+            fail("No IllegalArgumentException");
+        }catch(IllegalArgumentException e){
+            assertTrue(true);
+        }
+    }
 
     public final void testGetDataType(){
         assertEquals(DataBuffer.TYPE_USHORT, db1.getDataType());



Mime
View raw message