harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r465993 - in /incubator/harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/geom/AffineTransform.java test/api/java/common/java/awt/geom/AffineTransformTest.java
Date Fri, 20 Oct 2006 05:03:04 GMT
Author: mloenko
Date: Thu Oct 19 22:03:03 2006
New Revision: 465993

URL: http://svn.apache.org/viewvc?view=rev&rev=465993
Log:
applied patch from HARMONY-1405
[classlib][awt] AffineTransform.transform(Point2D[], int, Point2D[], int, int) expected NPE

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/AffineTransform.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AffineTransformTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/AffineTransform.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/AffineTransform.java?view=diff&rev=465993&r1=465992&r2=465993
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/AffineTransform.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/AffineTransform.java
Thu Oct 19 22:03:03 2006
@@ -421,10 +421,22 @@
 
     public void transform(Point2D[] src, int srcOff, Point2D[] dst, int dstOff, int length)
{
         while (--length >= 0) {
-            dst[dstOff] = transform(src[srcOff++], dst[dstOff++]);
+            Point2D srcPoint = src[srcOff++]; 
+            double x = srcPoint.getX();
+            double y = srcPoint.getY();
+            Point2D dstPoint = dst[dstOff]; 
+            if (dstPoint == null) {
+                if (srcPoint instanceof Point2D.Double) {
+                    dstPoint = new Point2D.Double();
+                } else {
+                    dstPoint = new Point2D.Float();
+                }
+            }
+            dstPoint.setLocation(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12);
+            dst[dstOff++] = dstPoint;
         }
     }
-
+    
     public void transform(double[] src, int srcOff, double[] dst, int dstOff, int length)
{
         while (--length >= 0) {
             double x = src[srcOff++];

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AffineTransformTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AffineTransformTest.java?view=diff&rev=465993&r1=465992&r2=465993
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AffineTransformTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AffineTransformTest.java
Thu Oct 19 22:03:03 2006
@@ -642,7 +642,7 @@
         }
     }
 
-    public void testTransform2() {
+    public void testTransformPointArray() {
         AffineTransform at = new AffineTransform(0, 1, -2, 0, 3, 4);
         Point2D[] src = new Point2D[]{
                 null,
@@ -655,6 +655,35 @@
         assertEquals(new Point2D.Float(1, 5), dst[3]);
     }
 
+    public void testTransformPointArrayBad() {
+        // Regression test HARMONY-1405
+        
+        AffineTransform at = new AffineTransform();
+        try {
+            at.transform(
+                    new Point2D[] { null, null, null, null },
+                    0,
+                    new Point2D[] { null, null, null, null },
+                    -1,
+                    1);
+            fail("Expected NPE");
+        } catch (NullPointerException e) {
+            // expected
+        }
+        
+        try {
+            at.transform(
+                    new Point2D[] { null, null, null, null },
+                    1,
+                    new Point2D[] { null, null, null, null },
+                    10,
+                    1);
+            fail("Expected NPE");
+        } catch (NullPointerException e) {
+            // expected
+        }        
+    }
+    
     public void testTransform3() {
         AffineTransform at = new AffineTransform(0, 1, -2, 0, 3, 4);
         double[] src = new double[]{0, 0, 0, 0, 0, 0, 1, 1, 0, 0};



Mime
View raw message