harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r499481 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/image/Raster.java test/api/java/common/java/awt/image/RasterTest.java
Date Wed, 24 Jan 2007 17:01:42 GMT
Author: ayza
Date: Wed Jan 24 09:01:41 2007
New Revision: 499481

URL: http://svn.apache.org/viewvc?view=rev&rev=499481
Log:
Applying the patch from HARMONY-2435 ([classlib][awt] Raster.createPackedRaster(...) throws
RasterFormatException while RI throws IAE)

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/Raster.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RasterTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/Raster.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/Raster.java?view=diff&rev=499481&r1=499480&r2=499481
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/Raster.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/Raster.java
Wed Jan 24 09:01:41 2007
@@ -481,6 +481,13 @@
 
     public static WritableRaster createPackedRaster(int dataType, int w, int h,
             int bandMasks[], Point location) {
+        
+        if (dataType != DataBuffer.TYPE_BYTE
+                && dataType != DataBuffer.TYPE_USHORT
+                && dataType != DataBuffer.TYPE_INT) {
+            // awt.230=dataType is not one of the supported data types
+            throw new IllegalArgumentException(Messages.getString("awt.230")); //$NON-NLS-1$
+        }
 
         if (w <= 0 || h <= 0) {
             // awt.22E=w or h is less than or equal to zero
@@ -499,14 +506,7 @@
 
         if (bandMasks == null) {
             // awt.27C=bandMasks is null
-            throw new RasterFormatException(Messages.getString("awt.27C")); //$NON-NLS-1$
-        }
-
-        if (dataType != DataBuffer.TYPE_BYTE
-                && dataType != DataBuffer.TYPE_USHORT
-                && dataType != DataBuffer.TYPE_INT) {
-            // awt.230=dataType is not one of the supported data types
-            throw new IllegalArgumentException(Messages.getString("awt.230")); //$NON-NLS-1$
+            throw new NullPointerException(Messages.getString("awt.27C")); //$NON-NLS-1$
         }
 
         DataBuffer data = null;

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RasterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RasterTest.java?view=diff&rev=499481&r1=499480&r2=499481
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RasterTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/RasterTest.java
Wed Jan 24 09:01:41 2007
@@ -22,6 +22,29 @@
 import java.awt.Point;
 
 public class RasterTest extends TestCase {
+
+    /**
+     * Test method for
+     * {@link java.awt.image.Raster#createPackedRaster(int, int, int, int[], java.awt.Point)}.
+     */
+    public void testCreatePackedRasterIntIntIntIntArrayPoint() {
+        // Regression test for HARMONY-2435
+        try {
+            Raster.createPackedRaster(-1, -1, -1, new int[1], null);
+            fail("IllegalArgumentException was not thrown"); //$NON-NLS-1$
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+
+        // Regression test for HARMONY-2435
+        try {
+            Raster.createPackedRaster(DataBuffer.TYPE_BYTE, 1, 1, null, null);
+            fail("NullPointerException was not thrown"); //$NON-NLS-1$
+        } catch (NullPointerException ex) {
+            // expected
+        }
+    }
+    
     // Regression test for harmony-2717
     public void test_createPackedRaster() throws RasterFormatException {
         try {



Mime
View raw message