harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r495310 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/image/ComponentSampleModel.java test/api/java/common/java/awt/image/ComponentSampleModelTest.java
Date Thu, 11 Jan 2007 17:53:09 GMT
Author: ayza
Date: Thu Jan 11 09:53:08 2007
New Revision: 495310

URL: http://svn.apache.org/viewvc?view=rev&rev=495310
Log:
Applying patch from HARMONY-2783 ([classlib][awt] Compatibility: java.awt.image.ComponentSampleModel.getPixels(int,int,inrt,int,int[],DataBuffer)
does not throw ArrayIndexOutOfBoundsException while RI throws it)

Added:
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java
Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ComponentSampleModel.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ComponentSampleModel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ComponentSampleModel.java?view=diff&rev=495310&r1=495309&r2=495310
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ComponentSampleModel.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/image/ComponentSampleModel.java
Thu Jan 11 09:53:08 2007
@@ -331,7 +331,8 @@
     @Override
     public int[] getPixels(int x, int y, int w, int h, int iArray[],
             DataBuffer data) {
-        if (x < 0 || y < 0 || x + w > this.width || y + h > this.height) {
+        if (x < 0 || y < 0 || x > this.width || x + w > this.width
+                || y > this.height || y + h > this.height) {
             // awt.63=Coordinates are not in bounds
             throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.63")); //$NON-NLS-1$
         }
@@ -571,4 +572,5 @@
     }
 
 }
+
 

Added: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java?view=auto&rev=495310
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java
Thu Jan 11 09:53:08 2007
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance    
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package java.awt.image;
+
+import junit.framework.TestCase;
+
+public class ComponentSampleModelTest extends TestCase {
+  
+    public void testGetPixelsMaxValue()  throws Exception {
+        ComponentSampleModel csm = new ComponentSampleModel(0, 10, 10, 1, 10, new int[]{0});

+        DataBufferInt dbi = new DataBufferInt(100); 
+
+        try { 
+            csm.getPixels(8, Integer.MAX_VALUE, 1, 1, (int[]) null, dbi);
+            fail("Exception expected");
+        } catch(ArrayIndexOutOfBoundsException expectedException) { 
+            // expected
+        } 
+    }
+}



Mime
View raw message