harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r496266 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/image/ColorModel.java main/java/common/org/apache/harmony/awt/internal/nls/messages.properties test/api/java/common/java/awt/image/ColorModelTest.java
Date Mon, 15 Jan 2007 10:17:38 GMT
Author: ayza
Date: Mon Jan 15 02:17:36 2007
New Revision: 496266

URL: http://svn.apache.org/viewvc?view=rev&rev=496266
Log:
Applying patch from HARMONY-2796 ([classlib][awt] java.awt.image.IndexColorModel.getNormalizedComponents()
throws UnsupportedOperationException while RI throws NPE)

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ColorModel.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/ColorModelTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ColorModel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ColorModel.java?view=diff&rev=496266&r1=496265&r2=496266
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ColorModel.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ColorModel.java
Mon Jan 15 02:17:36 2007
@@ -189,6 +189,12 @@
 
     public float[] getNormalizedComponents(Object pixel,
             float[] normComponents, int normOffset) {
+
+        if (pixel == null) {
+            // awt.294=pixel is null
+            throw new NullPointerException(Messages.getString("awt.294")); //$NON-NLS-1$
+        }
+
         int unnormComponents[] = getComponents(pixel, null, 0);
         return getNormalizedComponents(unnormComponents, 0, normComponents,
                 normOffset);

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=496266&r1=496265&r2=496266
==============================================================================
--- 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
Mon Jan 15 02:17:36 2007
@@ -483,6 +483,8 @@
 awt.291=Source and destination images do not have the same width!
 awt.292=Source and destination images do not have the same height!
 awt.293=SampleModel and DataBuffer have different data types
+awt.294=pixel is null
+awt.295=data is null
 
 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/ColorModelTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ColorModelTest.java?view=diff&rev=496266&r1=496265&r2=496266
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ColorModelTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ColorModelTest.java
Mon Jan 15 02:17:36 2007
@@ -44,4 +44,17 @@
         obj.getNormalizedComponents(new int[] { 1, -23, 5, 67, 89, 0 }, 1,
                 null, 1002);
     }
+    
+    // Regression test for JIRA HARMONY-2796
+    public void testGetNormalizedComponentsNullPixel() {
+        IndexColorModel cm = new IndexColorModel(4, 2, new byte[2],
+                new byte[2], new byte[2]);
+
+        try {
+            cm.getNormalizedComponents((Object) null, new float[] {}, 5);
+            fail("NullPointerException expected");
+        } catch (NullPointerException npe) {
+            // valid
+        }
+    }
 }



Mime
View raw message