harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r463234 - in /incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math: BigInteger.java Division.java Primality.java
Date Thu, 12 Oct 2006 13:00:36 GMT
Author: pyang
Date: Thu Oct 12 06:00:31 2006
New Revision: 463234

URL: http://svn.apache.org/viewvc?view=rev&rev=463234
Log:
Apply patch for HARMONY-1770([classlib][math]BigInteger has an unexpected 'protected clone()'
method)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java
    incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Division.java
    incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Primality.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java?view=diff&rev=463234&r1=463233&r2=463234
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java
Thu Oct 12 06:00:31 2006
@@ -596,7 +596,7 @@
                     .longValue()));
         }
         // Now 'val1' and 'val2' will be muttable
-        return Division.gcdBinary(val1.clone(), val2.clone());
+        return Division.gcdBinary(val1.copy(), val2.copy());
     }
 
     /** @ar.org.fitc.spec_ref */
@@ -906,15 +906,13 @@
         return firstNonzeroDigit;
     }
     
-    /**
-     * Returns a clone of {@code this}.
-     * @return a copy of {@code this}, so that {@code equals(clone()) == true}.
+    /*
+     * Returns a copy of the current instance to achieve immutability
      */
-    @Override
-    protected BigInteger clone() {
-        int[] clonedDigits = new int[numberLength];
-        System.arraycopy(digits, 0, clonedDigits, 0, numberLength);
-        return new BigInteger(sign, numberLength, clonedDigits);
+    BigInteger copy() {
+        int[] copyDigits = new int[numberLength];
+        System.arraycopy(digits, 0, copyDigits, 0, numberLength);
+        return new BigInteger(sign, numberLength, copyDigits);
     }
 
     /** @ar.org.fitc.spec_ref */

Modified: incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Division.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Division.java?view=diff&rev=463234&r1=463233&r2=463234
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Division.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Division.java
Thu Oct 12 06:00:31 2006
@@ -614,8 +614,8 @@
     static BigInteger pow2ModPow(BigInteger base, BigInteger exponent, int j) {
         // PRE: (base > 0), (exponent > 0) and (j > 0)
         BigInteger res = BigInteger.ONE;
-        BigInteger e = exponent.clone();
-        BigInteger baseMod2toN = base.clone();
+        BigInteger e = exponent.copy();
+        BigInteger baseMod2toN = base.copy();
         BigInteger res2;
         /*
          * If 'base' is odd then it's coprime with 2^j and phi(2^j) = 2^(j-1);
@@ -627,7 +627,7 @@
         inplaceModPow2(baseMod2toN, j);
 
         for (int i = e.bitLength() - 1; i >= 0; i--) {
-            res2 = res.clone();
+            res2 = res.copy();
             inplaceModPow2(res2, j);
             res = res.multiply(res2);
             if (BitLevel.testBit(e, i)) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Primality.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Primality.java?view=diff&rev=463234&r1=463233&r2=463234
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Primality.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Primality.java
Thu Oct 12 06:00:31 2006
@@ -145,7 +145,7 @@
             // primes
             for (j = 0; j < gapSize; j++) {
                 if (!isDivisible[j]) {
-                    probPrime = startPoint.clone();
+                    probPrime = startPoint.copy();
                     Elementary.inplaceAdd(probPrime, j);
 
                     if (millerRabin(probPrime, certainty)) {



Mime
View raw message