harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r496269 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/image/IndexColorModel.java test/api/java/common/java/awt/image/IndexColorModelRTest.java
Date Mon, 15 Jan 2007 10:21:18 GMT
Author: ayza
Date: Mon Jan 15 02:21:16 2007
New Revision: 496269

URL: http://svn.apache.org/viewvc?view=rev&rev=496269
Log:
The patch for HARMONY-2799 ([java][awt] Compatibility: java.awt.image.IndexColorModel.getDataElement()
throws ArrayIndexOutOfBoundsException on RI and doesn't on Harmony) was applied.

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

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/IndexColorModel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/IndexColorModel.java?view=diff&rev=496269&r1=496268&r2=496269
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/IndexColorModel.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/IndexColorModel.java
Mon Jan 15 02:21:16 2007
@@ -528,14 +528,15 @@
 
     @Override
     public int getDataElement(int components[], int offset) {
-        int rgb = (components[0] << 16) | (components[1] << 8) | components[2];
-
+        int rgb = (components[offset] << 16) | (components[offset + 1]) << 8
+                | components[offset + 2];
+        
         if (hasAlpha) {
-            rgb |= (components[3] << 24);
+            rgb |= components[offset + 3] << 24;
         } else {
             rgb |= 0xff000000;
         }
-
+ 
         int pixel;
 
         switch (transferType) {
@@ -806,4 +807,5 @@
     }
 
 }
+
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/IndexColorModelRTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/IndexColorModelRTest.java?view=diff&rev=496269&r1=496268&r2=496269
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/IndexColorModelRTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/IndexColorModelRTest.java
Mon Jan 15 02:21:16 2007
@@ -101,4 +101,22 @@
         assertEquals(1, icm6.getTransparentPixel());
         
     }
+    
+    public void testGetDataElementOffset() {
+        // Regression test for harmony-2799
+        int bits = 4;
+        int size = 166;
+        IndexColorModel localIndexColorModel = new IndexColorModel(bits, size,
+                new byte[size], new byte[size], new byte[size]);
+        int[] components = new int[] { 0, 0, 0, 0, 0, 0, 0 };
+        int offset = 6;
+
+        try {
+            localIndexColorModel.getDataElement(components, offset);
+            fail("ArrayIndexOutOfBoundsException expected");
+        } catch (ArrayIndexOutOfBoundsException e) {
+            // valid
+        }
+
+    }
 }



Mime
View raw message