harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r442620 - in /incubator/harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/Polygon.java test/api/java/common/java/awt/PolygonTest.java
Date Tue, 12 Sep 2006 15:37:34 GMT
Author: mloenko
Date: Tue Sep 12 08:37:34 2006
New Revision: 442620

URL: http://svn.apache.org/viewvc?view=rev&rev=442620
Log:
applied patch for HARMONY-1445
[classlib][awt] java.awt.Polygon(int[] , int[], int) doesn't copy array parameters

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Polygon.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/PolygonTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Polygon.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Polygon.java?view=diff&rev=442620&r1=442619&r2=442620
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Polygon.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Polygon.java
Tue Sep 12 08:37:34 2006
@@ -131,9 +131,11 @@
         if (npoints < 0) {
             throw new NegativeArraySizeException("Negative number of points");
         }
-        this.xpoints = xpoints;
-        this.ypoints = ypoints;
         this.npoints = npoints;
+        this.xpoints = new int[npoints];
+        this.ypoints = new int[npoints];
+        System.arraycopy(xpoints, 0, this.xpoints, 0, npoints);
+        System.arraycopy(ypoints, 0, this.ypoints, 0, npoints);
     }
 
     public void reset() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/PolygonTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/PolygonTest.java?view=diff&rev=442620&r1=442619&r2=442620
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/PolygonTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/PolygonTest.java
Tue Sep 12 08:37:34 2006
@@ -51,13 +51,26 @@
     }
 
     public void testCreate2() {
-        Polygon pg = new Polygon(new int[]{1, 2, 3, 4, 5, 6}, new int[]{7, 8, 9, 10, 11,
12}, 0);
+        int[] x = new int[]{1, 2, 3, 4, 5, 6};
+        int[] y = new int[]{7, 8, 9, 10, 11, 12};
+        
+        Polygon pg = new Polygon(x, y, 0);
         assertEquals(0, pg.npoints);
+        assertEquals(0, pg.xpoints.length);
+        assertEquals(0, pg.ypoints.length);
 
-        pg = new Polygon(new int[]{1, 2, 3, 4, 5, 6}, new int[]{7, 8, 9, 10, 11, 12}, 3);
+        pg = new Polygon(x, y, 3);
         assertEquals(3, pg.npoints);
         assertEquals(new int[]{1, 2, 3}, pg.xpoints, 3);
         assertEquals(new int[]{7, 8, 9}, pg.ypoints, 3);
+        assertEquals(3, pg.xpoints.length);
+        assertEquals(3, pg.ypoints.length);
+        
+        // Regression for HARMONY-1445
+        x[1] = 99;
+        y[2] = 77;
+        assertTrue(pg.xpoints[1] != 99);       
+        assertTrue(pg.ypoints[2] != 77);
     }
 
     public void testCreate3() {



Mime
View raw message