You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by qi...@apache.org on 2009/07/04 10:38:24 UTC
svn commit: r791082 [3/8] - in /harmony/enhanced/classlib/branches/java6: ./
depends/build/ depends/build/platform/ depends/manifests/asm-3.1/ make/
modules/accessibility/ modules/accessibility/make/
modules/accessibility/src/main/java/javax/accessibil...
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Math.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Math.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Math.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Math.java Sat Jul 4 08:38:13 2009
@@ -17,7 +17,6 @@
package java.lang;
-
/**
* Class Math provides basic math constants and operations such as trigonometric
* functions, hyperbolic functions, exponential, logarithms, etc.
@@ -77,16 +76,16 @@
* <li>{@code abs(-infinity) = +infinity}</li>
* <li>{@code abs(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose absolute value has to be computed.
* @return the absolute value of the argument.
*/
- public static double abs(double d) {
- long bits = Double.doubleToLongBits(d);
- bits &= 0x7fffffffffffffffL;
- return Double.longBitsToDouble(bits);
- }
+ public static double abs(double d) {
+ long bits = Double.doubleToLongBits(d);
+ bits &= 0x7fffffffffffffffL;
+ return Double.longBitsToDouble(bits);
+ }
/**
* Returns the absolute value of the argument.
@@ -98,45 +97,45 @@
* <li>{@code abs(-infinity) = +infinity}</li>
* <li>{@code abs(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param f
* the value whose absolute value has to be computed.
* @return the argument if it is positive, otherwise the negation of the
* argument.
*/
- public static float abs(float f) {
- int bits = Float.floatToIntBits(f);
- bits &= 0x7fffffff;
- return Float.intBitsToFloat(bits);
- }
+ public static float abs(float f) {
+ int bits = Float.floatToIntBits(f);
+ bits &= 0x7fffffff;
+ return Float.intBitsToFloat(bits);
+ }
/**
* Returns the absolute value of the argument.
* <p>
* If the argument is {@code Integer.MIN_VALUE}, {@code Integer.MIN_VALUE}
* is returned.
- *
+ *
* @param i
* the value whose absolute value has to be computed.
* @return the argument if it is positive, otherwise the negation of the
* argument.
*/
- public static int abs(int i) {
- return i >= 0 ? i : -i;
- }
+ public static int abs(int i) {
+ return i >= 0 ? i : -i;
+ }
/**
* Returns the absolute value of the argument. If the argument is {@code
* Long.MIN_VALUE}, {@code Long.MIN_VALUE} is returned.
- *
+ *
* @param l
* the value whose absolute value has to be computed.
* @return the argument if it is positive, otherwise the negation of the
* argument.
*/
- public static long abs(long l) {
- return l >= 0 ? l : -l;
- }
+ public static long abs(long l) {
+ return l >= 0 ? l : -l;
+ }
/**
* Returns the closest double approximation of the arc cosine of the
@@ -149,12 +148,12 @@
* <li>{@code acos((anything < -1) = NaN}</li>
* <li>{@code acos(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value to compute arc cosine of.
* @return the arc cosine of the argument.
*/
- public static native double acos(double d);
+ public static native double acos(double d);
/**
* Returns the closest double approximation of the arc sine of the argument
@@ -167,12 +166,12 @@
* <li>{@code asin((anything < -1)) = NaN}</li>
* <li>{@code asin(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose arc sine has to be computed.
* @return the arc sine of the argument.
*/
- public static native double asin(double d);
+ public static native double asin(double d);
/**
* Returns the closest double approximation of the arc tangent of the
@@ -187,7 +186,7 @@
* <li>{@code atan(-infinity) = -pi/2}</li>
* <li>{@code atan(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose arc tangent has to be computed.
* @return the arc tangent of the argument.
@@ -195,10 +194,10 @@
public static native double atan(double d);
/**
- * Returns the closest double approximation of the arc tangent of
- * {@code y/x} within the range {@code [-pi..pi]}. This is the angle of the
- * polar representation of the rectangular coordinates (x,y). The returned
- * result is within 2 ulps (units in the last place) of the real result.
+ * Returns the closest double approximation of the arc tangent of {@code
+ * y/x} within the range {@code [-pi..pi]}. This is the angle of the polar
+ * representation of the rectangular coordinates (x,y). The returned result
+ * is within 2 ulps (units in the last place) of the real result.
* <p>
* Special cases:
* <ul>
@@ -220,12 +219,12 @@
* <li>{@code atan2(-infinity, +infinity ) = -pi/4}</li>
* <li>{@code atan2(+infinity, -infinity ) = +3pi/4}</li>
* <li>{@code atan2(-infinity, -infinity ) = -3pi/4}</li>
- * <li>{@code atan2(+infinity, (anything but,0, NaN, and infinity))}
- * {@code =} {@code +pi/2}</li>
- * <li>{@code atan2(-infinity, (anything but,0, NaN, and infinity))}
- * {@code =} {@code -pi/2}</li>
+ * <li>{@code atan2(+infinity, (anything but,0, NaN, and infinity))} {@code
+ * =} {@code +pi/2}</li>
+ * <li>{@code atan2(-infinity, (anything but,0, NaN, and infinity))} {@code
+ * =} {@code -pi/2}</li>
* </ul>
- *
+ *
* @param y
* the numerator of the value whose atan has to be computed.
* @param x
@@ -233,7 +232,7 @@
* @return the arc tangent of {@code y/x}.
*/
public static native double atan2(double x, double y);
-
+
/**
* Returns the closest double approximation of the cube root of the
* argument.
@@ -246,7 +245,7 @@
* <li>{@code cbrt(-infinity) = -infinity}</li>
* <li>{@code cbrt(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose cube root has to be computed.
* @return the cube root of the argument.
@@ -254,8 +253,8 @@
public static native double cbrt(double d);
/**
- * Returns the double conversion of the most negative (closest to
- * negative infinity) integer value which is greater than the argument.
+ * Returns the double conversion of the most negative (closest to negative
+ * infinity) integer value which is greater than the argument.
* <p>
* Special cases:
* <ul>
@@ -266,16 +265,16 @@
* <li>{@code ceil(-infinity) = -infinity}</li>
* <li>{@code ceil(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose closest integer value has to be computed.
* @return the ceiling of the argument.
*/
- public static double ceil(double d) {
- return -floor(-d);
- }
+ public static double ceil(double d) {
+ return -floor(-d);
+ }
- /**
+ /**
* Returns the closest double approximation of the cosine of the argument.
* The returned result is within 1 ulp (unit in the last place) of the real
* result.
@@ -286,13 +285,13 @@
* <li>{@code cos(-infinity) = NaN}</li>
* <li>{@code cos(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the angle whose cosine has to be computed, in radians.
* @return the cosine of the argument.
*/
public static native double cos(double d);
-
+
/**
* Returns the closest double approximation of the hyperbolic cosine of the
* argument. The returned result is within 2.5 ulps (units in the last
@@ -304,7 +303,7 @@
* <li>{@code cosh(-infinity) = +infinity}</li>
* <li>{@code cosh(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose hyperbolic cosine has to be computed.
* @return the hyperbolic cosine of the argument.
@@ -322,17 +321,17 @@
* <li>{@code exp(-infinity) = +0.0}</li>
* <li>{@code exp(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose exponential has to be computed.
* @return the exponential of the argument.
*/
public static native double exp(double d);
-
+
/**
- * Returns the closest double approximation of <i>{@code e}</i><sup>
- * {@code d}</sup>{@code - 1}. If the argument is very close to 0, it is
- * much more accurate to use {@code expm1(d)+1} than {@code exp(d)} (due to
+ * Returns the closest double approximation of <i>{@code e}</i><sup> {@code
+ * d}</sup>{@code - 1}. If the argument is very close to 0, it is much more
+ * accurate to use {@code expm1(d)+1} than {@code exp(d)} (due to
* cancellation of significant digits). The returned result is within 1 ulp
* (unit in the last place) of the real result.
* <p>
@@ -347,12 +346,12 @@
* <li>{@code expm1(-infinity) = -1.0}</li>
* <li>{@code expm1(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
- * the value to compute the <i>{@code e}</i><sup>{@code d}
- * </sup>{@code - 1} of.
- * @return the <i>{@code e}</i><sup>{@code d}</sup>{@code - 1} value
- * of the argument.
+ * the value to compute the <i>{@code e}</i><sup>{@code d} </sup>
+ * {@code - 1} of.
+ * @return the <i>{@code e}</i><sup>{@code d}</sup>{@code - 1} value of the
+ * argument.
*/
public static native double expm1(double d);
@@ -368,25 +367,25 @@
* <li>{@code floor(-infinity) = -infinity}</li>
* <li>{@code floor(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose closest integer value has to be computed.
* @return the floor of the argument.
*/
- public static double floor(double d) {
- if (Double.isNaN(d) || Double.isInfinite(d) || d == 0) {
- return d;
- }
- double res = (double)(long)d;
- return d > 0 || res == d ? res : res - 1;
+ public static double floor(double d) {
+ if (Double.isNaN(d) || Double.isInfinite(d) || d == 0) {
+ return d;
}
-
+ double res = (long) d;
+ return d > 0 || res == d ? res : res - 1;
+ }
+
/**
- * Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +}
- * <i> {@code y}</i><sup>{@code 2}</sup>{@code )}. The final result is
- * without medium underflow or overflow. The returned result is within 1 ulp
- * (unit in the last place) of the real result. If one parameter remains
- * constant, the result should be semi-monotonic.
+ * Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i>
+ * {@code y}</i><sup>{@code 2}</sup>{@code )}. The final result is without
+ * medium underflow or overflow. The returned result is within 1 ulp (unit
+ * in the last place) of the real result. If one parameter remains constant,
+ * the result should be semi-monotonic.
* <p>
* Special cases:
* <ul>
@@ -396,7 +395,7 @@
* <li>{@code hypot((anything including NaN), -infinity) = +infinity}</li>
* <li>{@code hypot(NaN, NaN) = NaN}</li>
* </ul>
- *
+ *
* @param x
* a double number.
* @param y
@@ -425,7 +424,7 @@
* <li>{@code IEEEremainder(x, -infinity) = x } where x is anything but
* +/-infinity</li>
* </ul>
- *
+ *
* @param x
* the numerator of the operation.
* @param y
@@ -448,7 +447,7 @@
* <li>{@code log(-infinity) = NaN}</li>
* <li>{@code log(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose log has to be computed.
* @return the natural logarithm of the argument.
@@ -469,13 +468,13 @@
* <li>{@code log10(-infinity) = NaN}</li>
* <li>{@code log10(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose base 10 log has to be computed.
* @return the natural logarithm of the argument.
*/
public static native double log10(double d);
-
+
/**
* Returns the closest double approximation of the natural logarithm of the
* sum of the argument and 1. If the argument is very close to 0, it is much
@@ -493,7 +492,7 @@
* <li>{@code log1p(-infinity) = NaN}</li>
* <li>{@code log1p(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value to compute the {@code ln(1+d)} of.
* @return the natural logarithm of the sum of the argument and 1.
@@ -511,26 +510,30 @@
* <li>{@code max(+0.0, -0.0) = +0.0}</li>
* <li>{@code max(-0.0, +0.0) = +0.0}</li>
* </ul>
- *
+ *
* @param d1
* the first argument.
* @param d2
* the second argument.
* @return the larger of {@code d1} and {@code d2}.
*/
- public static double max(double d1, double d2) {
- if (d1 > d2)
- return d1;
- if (d1 < d2)
- return d2;
- /* if either arg is NaN, return NaN */
- if (d1 != d2)
- return Double.NaN;
- /* max( +0.0,-0.0) == +0.0 */
- if (d1 == 0.0 && (d1 != -0.0d || d2 != -0.0d))
- return 0.0;
- return d1;
- }
+ public static double max(double d1, double d2) {
+ if (d1 > d2) {
+ return d1;
+ }
+ if (d1 < d2) {
+ return d2;
+ }
+ /* if either arg is NaN, return NaN */
+ if (d1 != d2) {
+ return Double.NaN;
+ }
+ /* max(+0.0,-0.0) == +0.0 */
+ if (Double.doubleToRawLongBits(d1) != Double.doubleToRawLongBits(0.0d)) {
+ return d2;
+ }
+ return 0.0d;
+ }
/**
* Returns the most positive (closest to positive infinity) of the two
@@ -543,54 +546,58 @@
* <li>{@code max(+0.0, -0.0) = +0.0}</li>
* <li>{@code max(-0.0, +0.0) = +0.0}</li>
* </ul>
- *
+ *
* @param f1
* the first argument.
* @param f2
* the second argument.
* @return the larger of {@code f1} and {@code f2}.
*/
- public static float max(float f1, float f2) {
- if (f1 > f2)
- return f1;
- if (f1 < f2)
- return f2;
- /* if either arg is NaN, return NaN */
- if (f1 != f2)
- return Float.NaN;
- /* max( +0.0,-0.0) == +0.0 */
- if (f1 == 0.0f && (f1 != -0.0f || f2 != -0.0f))
- return 0.0f;
- return f1;
- }
+ public static float max(float f1, float f2) {
+ if (f1 > f2) {
+ return f1;
+ }
+ if (f1 < f2) {
+ return f2;
+ }
+ /* if either arg is NaN, return NaN */
+ if (f1 != f2) {
+ return Float.NaN;
+ }
+ /* max(+0.0,-0.0) == +0.0 */
+ if (Float.floatToRawIntBits(f1) != Float.floatToRawIntBits(0.0f)) {
+ return f2;
+ }
+ return 0.0f;
+ }
/**
* Returns the most positive (closest to positive infinity) of the two
* arguments.
- *
+ *
* @param i1
* the first argument.
* @param i2
* the second argument.
* @return the larger of {@code i1} and {@code i2}.
*/
- public static int max(int i1, int i2) {
- return i1 > i2 ? i1 : i2;
- }
+ public static int max(int i1, int i2) {
+ return i1 > i2 ? i1 : i2;
+ }
/**
* Returns the most positive (closest to positive infinity) of the two
* arguments.
- *
+ *
* @param l1
* the first argument.
* @param l2
* the second argument.
* @return the larger of {@code l1} and {@code l2}.
*/
- public static long max(long l1, long l2) {
- return l1 > l2 ? l1 : l2;
- }
+ public static long max(long l1, long l2) {
+ return l1 > l2 ? l1 : l2;
+ }
/**
* Returns the most negative (closest to negative infinity) of the two
@@ -603,26 +610,30 @@
* <li>{@code min(+0.0, -0.0) = -0.0}</li>
* <li>{@code min(-0.0, +0.0) = -0.0}</li>
* </ul>
- *
+ *
* @param d1
* the first argument.
* @param d2
* the second argument.
* @return the smaller of {@code d1} and {@code d2}.
*/
- public static double min(double d1, double d2) {
- if (d1 > d2)
- return d2;
- if (d1 < d2)
- return d1;
- /* if either arg is NaN, return NaN */
- if (d1 != d2)
- return Double.NaN;
- /* min( +0.0,-0.0) == -0.0 */
- if (d1 == 0.0 && (d1 == -0.0d || d2 == -0.0d))
- return -0.0d;
- return d1;
- }
+ public static double min(double d1, double d2) {
+ if (d1 > d2) {
+ return d2;
+ }
+ if (d1 < d2) {
+ return d1;
+ }
+ /* if either arg is NaN, return NaN */
+ if (d1 != d2) {
+ return Double.NaN;
+ }
+ /* min(+0.0,-0.0) == -0.0 */
+ if (Double.doubleToRawLongBits(d1) != Double.doubleToRawLongBits(0.0d)) {
+ return -0.0d;
+ }
+ return d2;
+ }
/**
* Returns the most negative (closest to negative infinity) of the two
@@ -635,58 +646,62 @@
* <li>{@code min(+0.0, -0.0) = -0.0}</li>
* <li>{@code min(-0.0, +0.0) = -0.0}</li>
* </ul>
- *
+ *
* @param f1
* the first argument.
* @param f2
* the second argument.
* @return the smaller of {@code f1} and {@code f2}.
*/
- public static float min(float f1, float f2) {
- if (f1 > f2)
- return f2;
- if (f1 < f2)
- return f1;
- /* if either arg is NaN, return NaN */
- if (f1 != f2)
- return Float.NaN;
- /* min( +0.0,-0.0) == -0.0 */
- if (f1 == 0.0f && (f1 == -0.0f || f2 == -0.0f))
- return -0.0f;
- return f1;
- }
+ public static float min(float f1, float f2) {
+ if (f1 > f2) {
+ return f2;
+ }
+ if (f1 < f2) {
+ return f1;
+ }
+ /* if either arg is NaN, return NaN */
+ if (f1 != f2) {
+ return Float.NaN;
+ }
+ /* min(+0.0,-0.0) == -0.0 */
+ if (Float.floatToRawIntBits(f1) != Float.floatToRawIntBits(0.0f)) {
+ return -0.0f;
+ }
+ return f2;
+ }
/**
* Returns the most negative (closest to negative infinity) of the two
* arguments.
- *
+ *
* @param i1
* the first argument.
* @param i2
* the second argument.
* @return the smaller of {@code i1} and {@code i2}.
*/
- public static int min(int i1, int i2) {
- return i1 < i2 ? i1 : i2;
- }
+ public static int min(int i1, int i2) {
+ return i1 < i2 ? i1 : i2;
+ }
/**
* Returns the most negative (closest to negative infinity) of the two
* arguments.
- *
+ *
* @param l1
* the first argument.
* @param l2
* the second argument.
* @return the smaller of {@code l1} and {@code l2}.
*/
- public static long min(long l1, long l2) {
- return l1 < l2 ? l1 : l2;
- }
+ public static long min(long l1, long l2) {
+ return l1 < l2 ? l1 : l2;
+ }
/**
- * Returns the closest double approximation of the result of raising
- * {@code x} to the power of {@code y}.
+ * Returns the closest double approximation of the result of raising {@code
+ * x} to the power of {@code y}.
* <p>
* Special cases:
* <ul>
@@ -710,11 +725,11 @@
* <li>{@code pow(+infinity, (+anything except 0, NaN)) = +infinity}</li>
* <li>{@code pow(+infinity, (-anything except 0, NaN)) = +0.0}</li>
* <li>{@code pow(-infinity, (anything)) = -pow(0, (-anything))}</li>
- * <li>{@code pow((-anything), (integer))} {@code =}
- * {@code pow(-1,(integer))*pow(+anything,integer) }</li>
+ * <li>{@code pow((-anything), (integer))} {@code =} {@code
+ * pow(-1,(integer))*pow(+anything,integer) }</li>
* <li>{@code pow((-anything except 0 and inf), (non-integer)) = NAN}</li>
* </ul>
- *
+ *
* @param x
* the base of the operation.
* @param y
@@ -735,20 +750,20 @@
* <li>{@code rint(-infinity) = -infinity}</li>
* <li>{@code rint(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value to be rounded.
* @return the closest integer to the argument (as a double).
*/
- public static double rint(double d) {
- if(d == +0.0d || d == -0.0d) {
- return d;
- }
- double res = floor(d + 0.5d);
- return res - d == 0.5d && res%2 != 0 ? res - 1 : res;
+ public static double rint(double d) {
+ if (d == +0.0d || d == -0.0d) {
+ return d;
}
+ double res = floor(d + 0.5d);
+ return res - d == 0.5d && res % 2 != 0 ? res - 1 : res;
+ }
- /**
+ /**
* Returns the result of rounding the argument to an integer. The result is
* equivalent to {@code (long) Math.floor(d+0.5)}.
* <p>
@@ -762,17 +777,18 @@
* <li>{@code round(-infintiy) = Long.MIN_VALUE}</li>
* <li>{@code round(NaN) = +0.0}</li>
* </ul>
- *
+ *
* @param d
* the value to be rounded.
* @return the closest integer to the argument.
*/
- public static long round(double d) {
- // check for NaN
- if (d != d)
- return 0L;
- return (long) floor(d + 0.5d);
- }
+ public static long round(double d) {
+ // check for NaN
+ if (d != d) {
+ return 0L;
+ }
+ return (long) floor(d + 0.5d);
+ }
/**
* Returns the result of rounding the argument to an integer. The result is
@@ -788,18 +804,19 @@
* <li>{@code round(-infintiy) = Integer.MIN_VALUE}</li>
* <li>{@code round(NaN) = +0.0}</li>
* </ul>
- *
+ *
* @param f
* the value to be rounded.
* @return the closest integer to the argument.
*/
- public static int round(float f) {
- // check for NaN
- if (f != f)
- return 0;
- return (int) floor(f + 0.5f);
- }
-
+ public static int round(float f) {
+ // check for NaN
+ if (f != f) {
+ return 0;
+ }
+ return (int) floor(f + 0.5f);
+ }
+
/**
* Returns the signum function of the argument. If the argument is less than
* zero, it returns -1.0. If the argument is greater than zero, 1.0 is
@@ -814,7 +831,7 @@
* <li>{@code signum(-infinity) = -1.0}</li>
* <li>{@code signum(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose signum has to be computed.
* @return the value of the signum function.
@@ -822,7 +839,7 @@
public static double signum(double d) {
return StrictMath.signum(d);
}
-
+
/**
* Returns the signum function of the argument. If the argument is less than
* zero, it returns -1.0. If the argument is greater than zero, 1.0 is
@@ -837,7 +854,7 @@
* <li>{@code signum(-infinity) = -1.0}</li>
* <li>{@code signum(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param f
* the value whose signum has to be computed.
* @return the value of the signum function.
@@ -859,13 +876,13 @@
* <li>{@code sin(-infinity) = NaN}</li>
* <li>{@code sin(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the angle whose sin has to be computed, in radians.
* @return the sine of the argument.
*/
public static native double sin(double d);
-
+
/**
* Returns the closest double approximation of the hyperbolic sine of the
* argument. The returned result is within 2.5 ulps (units in the last
@@ -879,7 +896,7 @@
* <li>{@code sinh(-infinity) = -infinity}</li>
* <li>{@code sinh(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose hyperbolic sine has to be computed.
* @return the hyperbolic sine of the argument.
@@ -898,7 +915,7 @@
* <li>{@code sqrt(+infinity) = +infinity}</li>
* <li>{@code sqrt(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose square root has to be computed.
* @return the square root of the argument.
@@ -918,13 +935,13 @@
* <li>{@code tan(-infinity) = NaN}</li>
* <li>{@code tan(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the angle whose tangens has to be computed, in radians.
* @return the tangent of the argument.
*/
public static native double tan(double d);
-
+
/**
* Returns the closest double approximation of the hyperbolic tangent of the
* argument. The absolute value is always less than 1. The returned result
@@ -940,7 +957,7 @@
* <li>{@code tanh(-infinity) = -1.0}</li>
* <li>{@code tanh(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the value whose hyperbolic tangent has to be computed.
* @return the hyperbolic tangent of the argument.
@@ -950,15 +967,15 @@
/**
* Returns a pseudo-random number between 0.0 (inclusive) and 1.0
* (exclusive).
- *
+ *
* @return a pseudo-random number.
*/
- public static double random() {
- if (random == null) {
- random = new java.util.Random();
- }
- return random.nextDouble();
- }
+ public static double random() {
+ if (random == null) {
+ random = new java.util.Random();
+ }
+ return random.nextDouble();
+ }
/**
* Returns the measure in radians of the supplied degree angle. The result
@@ -972,14 +989,14 @@
* <li>{@code toRadians(-infinity) = -infinity}</li>
* <li>{@code toRadians(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param angdeg
* an angle in degrees.
* @return the radian measure of the angle.
*/
- public static double toRadians(double angdeg) {
- return angdeg / 180d * PI;
- }
+ public static double toRadians(double angdeg) {
+ return angdeg / 180d * PI;
+ }
/**
* Returns the measure in degrees of the supplied radian angle. The result
@@ -993,20 +1010,20 @@
* <li>{@code toDegrees(-infinity) = -infinity}</li>
* <li>{@code toDegrees(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param angrad
* an angle in radians.
* @return the degree measure of the angle.
*/
- public static double toDegrees(double angrad) {
- return angrad * 180d / PI;
- }
-
- /**
+ public static double toDegrees(double angrad) {
+ return angrad * 180d / PI;
+ }
+
+ /**
* Returns the argument's ulp (unit in the last place). The size of a ulp of
* a double value is the positive distance between this value and the double
- * value next larger in magnitude. For non-NaN {@code x},
- * {@code ulp(-x) == ulp(x)}.
+ * value next larger in magnitude. For non-NaN {@code x}, {@code ulp(-x) ==
+ * ulp(x)}.
* <p>
* Special cases:
* <ul>
@@ -1016,7 +1033,7 @@
* <li>{@code ulp(-infintiy) = infinity}</li>
* <li>{@code ulp(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param d
* the floating-point value to compute ulp of.
* @return the size of a ulp of the argument.
@@ -1035,8 +1052,8 @@
/**
* Returns the argument's ulp (unit in the last place). The size of a ulp of
* a float value is the positive distance between this value and the float
- * value next larger in magnitude. For non-NaN {@code x},
- * {@code ulp(-x) == ulp(x)}.
+ * value next larger in magnitude. For non-NaN {@code x}, {@code ulp(-x) ==
+ * ulp(x)}.
* <p>
* Special cases:
* <ul>
@@ -1046,7 +1063,7 @@
* <li>{@code ulp(-infintiy) = infinity}</li>
* <li>{@code ulp(NaN) = NaN}</li>
* </ul>
- *
+ *
* @param f
* the floating-point value to compute ulp of.
* @return the size of a ulp of the argument.
@@ -1066,7 +1083,7 @@
private native static double nextafter(double x, double y);
- private native static float nextafterf(float x, float y);
+ private native static float nextafterf(float x, float y);
/**
* Answers a result of the magnitude of the first given double value and the
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/String.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/String.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/String.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/String.java Sat Jul 4 08:38:13 2009
@@ -162,6 +162,9 @@
count = 0;
}
+ /*
+ * Private constructor used for JIT optimization.
+ */
@SuppressWarnings("unused")
private String(String s, char c) {
offset = 0;
@@ -491,6 +494,47 @@
count = string.count;
}
+ /*
+ * Private constructor useful for JIT optimization.
+ */
+ @SuppressWarnings( { "unused", "nls" })
+ private String(String s1, String s2) {
+ if (s1 == null) {
+ s1 = "null";
+ }
+ if (s2 == null) {
+ s2 = "null";
+ }
+ count = s1.count + s2.count;
+ value = new char[count];
+ offset = 0;
+ System.arraycopy(s1.value, s1.offset, value, 0, s1.count);
+ System.arraycopy(s2.value, s2.offset, value, s1.count, s2.count);
+ }
+
+ /*
+ * Private constructor useful for JIT optimization.
+ */
+ @SuppressWarnings( { "unused", "nls" })
+ private String(String s1, String s2, String s3) {
+ if (s1 == null) {
+ s1 = "null";
+ }
+ if (s2 == null) {
+ s2 = "null";
+ }
+ if (s3 == null) {
+ s3 = "null";
+ }
+ count = s1.count + s2.count + s3.count;
+ value = new char[count];
+ offset = 0;
+ System.arraycopy(s1.value, s1.offset, value, 0, s1.count);
+ System.arraycopy(s2.value, s2.offset, value, s1.count, s2.count);
+ System.arraycopy(s3.value, s3.offset, value, s1.count + s2.count,
+ s3.count);
+ }
+
/**
* Creates a {@code String} from the contents of the specified
* {@code StringBuffer}.
@@ -990,11 +1034,12 @@
@Override
public int hashCode() {
if (hashCode == 0) {
- int hash = 0, multiplier = 1;
- for (int i = offset + count - 1; i >= offset; i--) {
- hash += value[i] * multiplier;
- int shifted = multiplier << 5;
- multiplier = shifted - multiplier;
+ if (count == 0) {
+ return 0;
+ }
+ int hash = 0;
+ for (int i = offset; i < count + offset; i++) {
+ hash = value[i] + ((hash << 5) - hash);
}
hashCode = hash;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/reflect/Modifier.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/reflect/Modifier.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/reflect/Modifier.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/reflect/Modifier.java Sat Jul 4 08:38:13 2009
@@ -279,9 +279,7 @@
*/
@SuppressWarnings("nls")
public static java.lang.String toString(int modifiers) {
- StringBuffer buf;
-
- buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
if (isPublic(modifiers)) {
buf.append("public ");
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/ServerSocket.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/ServerSocket.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/ServerSocket.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/ServerSocket.java Sat Jul 4 08:38:13 2009
@@ -328,7 +328,7 @@
*/
@Override
public String toString() {
- StringBuffer result = new StringBuffer(64);
+ StringBuilder result = new StringBuilder(64);
result.append("ServerSocket["); //$NON-NLS-1$
if (!isBound()) {
return result.append("unbound]").toString(); //$NON-NLS-1$
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketImpl.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketImpl.java Sat Jul 4 08:38:13 2009
@@ -257,7 +257,7 @@
@SuppressWarnings("nls")
@Override
public String toString() {
- return new StringBuffer(100).append("Socket[addr=").append(
+ return new StringBuilder(100).append("Socket[addr=").append(
getInetAddress()).append(",port=").append(port).append(
",localport=").append(getLocalPort()).append("]").toString();
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketPermission.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketPermission.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketPermission.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/SocketPermission.java Sat Jul 4 08:38:13 2009
@@ -211,7 +211,7 @@
}
boolean parsing = true;
String action;
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
int pos = 0, length = actions.length();
while (parsing) {
char c;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URI.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URI.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URI.java Sat Jul 4 08:38:13 2009
@@ -106,7 +106,7 @@
*/
public URI(String scheme, String ssp, String frag)
throws URISyntaxException {
- StringBuffer uri = new StringBuffer();
+ StringBuilder uri = new StringBuilder();
if (scheme != null) {
uri.append(scheme);
uri.append(':');
@@ -166,7 +166,7 @@
throw new URISyntaxException(path, Msg.getString("K0302")); //$NON-NLS-1$
}
- StringBuffer uri = new StringBuffer();
+ StringBuilder uri = new StringBuilder();
if (scheme != null) {
uri.append(scheme);
uri.append(':');
@@ -270,7 +270,7 @@
throw new URISyntaxException(path, Msg.getString("K0302")); //$NON-NLS-1$
}
- StringBuffer uri = new StringBuffer();
+ StringBuilder uri = new StringBuilder();
if (scheme != null) {
uri.append(scheme);
uri.append(':');
@@ -994,7 +994,7 @@
* converts the hex values following the '%' to lowercase
*/
private String convertHexToLowerCase(String s) {
- StringBuffer result = new StringBuffer(""); //$NON-NLS-1$
+ StringBuilder result = new StringBuilder(""); //$NON-NLS-1$
if (s.indexOf('%') == -1) {
return s;
}
@@ -1357,7 +1357,7 @@
}
// put the path back together
- StringBuffer newpath = new StringBuffer();
+ StringBuilder newpath = new StringBuilder();
if (path.startsWith("/")) { //$NON-NLS-1$
newpath.append('/');
}
@@ -1548,7 +1548,7 @@
*/
private void setSchemeSpecificPart() {
// ssp = [//authority][path][?query]
- StringBuffer ssp = new StringBuffer();
+ StringBuilder ssp = new StringBuilder();
if (authority != null) {
ssp.append("//" + authority); //$NON-NLS-1$
}
@@ -1631,7 +1631,7 @@
@Override
public String toString() {
if (string == null) {
- StringBuffer result = new StringBuffer();
+ StringBuilder result = new StringBuilder();
if (scheme != null) {
result.append(scheme);
result.append(':');
@@ -1670,7 +1670,7 @@
* and converts escaped octets to lowercase.
*/
private String getHashString() {
- StringBuffer result = new StringBuffer();
+ StringBuilder result = new StringBuilder();
if (scheme != null) {
result.append(scheme.toLowerCase());
result.append(':');
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URIEncoderDecoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URIEncoderDecoder.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URIEncoderDecoder.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URIEncoderDecoder.java Sat Jul 4 08:38:13 2009
@@ -112,7 +112,7 @@
*/
static String quoteIllegal(String s, String legal)
throws UnsupportedEncodingException {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if ((ch >= 'a' && ch <= 'z')
@@ -148,7 +148,7 @@
* @return java.lang.String the converted string
*/
static String encodeOthers(String s) throws UnsupportedEncodingException {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (ch <= 127) {
@@ -183,7 +183,7 @@
*/
static String decode(String s) throws UnsupportedEncodingException {
- StringBuffer result = new StringBuffer();
+ StringBuilder result = new StringBuilder();
ByteArrayOutputStream out = new ByteArrayOutputStream();
for (int i = 0; i < s.length();) {
char c = s.charAt(i);
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLConnection.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLConnection.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLConnection.java Sat Jul 4 08:38:13 2009
@@ -758,7 +758,7 @@
* @return the string to be parsed
*/
private String parseTypeString(String typeString) {
- StringBuffer typeStringBuffer = new StringBuffer(typeString);
+ StringBuilder typeStringBuffer = new StringBuilder(typeString);
for (int i = 0; i < typeStringBuffer.length(); i++) {
// if non-alphanumeric, replace it with '_'
char c = typeStringBuffer.charAt(i);
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLEncoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLEncoder.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLEncoder.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLEncoder.java Sat Jul 4 08:38:13 2009
@@ -49,7 +49,7 @@
*/
@Deprecated
public static String encode(String s) {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLStreamHandler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLStreamHandler.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLStreamHandler.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLStreamHandler.java Sat Jul 4 08:38:13 2009
@@ -305,8 +305,7 @@
* @see URL#toExternalForm()
*/
protected String toExternalForm(URL url) {
- StringBuffer answer = new StringBuffer(url.getProtocol().length()
- + url.getFile().length() + 16);
+ StringBuilder answer = new StringBuilder();
answer.append(url.getProtocol());
answer.append(':');
String authority = url.getAuthority();
@@ -317,8 +316,9 @@
String file = url.getFile();
String ref = url.getRef();
- // file is never null
- answer.append(file);
+ if (file != null) {
+ answer.append(file);
+ }
if (ref != null) {
answer.append('#');
answer.append(ref);
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/BitSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/BitSet.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/BitSet.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/BitSet.java Sat Jul 4 08:38:13 2009
@@ -818,7 +818,7 @@
*/
@Override
public String toString() {
- StringBuffer sb = new StringBuffer(bits.length / 2);
+ StringBuilder sb = new StringBuilder(bits.length / 2);
int bitCount = 0;
sb.append('{');
boolean comma = false;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Calendar.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Calendar.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Calendar.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Calendar.java Sat Jul 4 08:38:13 2009
@@ -1343,7 +1343,7 @@
@Override
@SuppressWarnings("nls")
public String toString() {
- StringBuffer result = new StringBuffer(getClass().getName() + "[time="
+ StringBuilder result = new StringBuilder(getClass().getName() + "[time="
+ (isTimeSet ? String.valueOf(time) : "?")
+ ",areFieldsSet="
+ areFieldsSet
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Date.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Date.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Date.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Date.java Sat Jul 4 08:38:13 2009
@@ -390,7 +390,7 @@
int hour = -1, minute = -1, second = -1, zoneOffset = 0, minutesOffset = 0;
boolean zone = false;
final int PAD = 0, LETTERS = 1, NUMBERS = 2;
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
while (offset <= length) {
char next = offset < length ? string.charAt(offset) : '\r';
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/HashMap.java Sat Jul 4 08:38:13 2009
@@ -21,6 +21,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
+import java.lang.reflect.Proxy;
/**
* HashMap is an implementation of Map. All optional operations (adding and
@@ -480,8 +481,16 @@
final Entry<K,V> findNonNullKeyEntry(Object key, int index, int keyHash) {
Entry<K,V> m = elementData[index];
- while (m != null && (m.origKeyHash != keyHash || !areEqualKeys(key, m.key))) {
- m = m.next;
+ // To support proxy instance as keys
+ if (Proxy.isProxyClass(key.getClass())) {
+ while (m != null && (m.origKeyHash != keyHash || key != m.key)) {
+ m = m.next;
+ }
+ } else {
+ while (m != null
+ && (m.origKeyHash != keyHash || !key.equals(m.key))) {
+ m = m.next;
+ }
}
return m;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Locale.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Locale.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Locale.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Locale.java Sat Jul 4 08:38:13 2009
@@ -483,7 +483,7 @@
*/
public String getDisplayName(Locale locale) {
int count = 0;
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
if (languageCode.length() > 0) {
buffer.append(getDisplayLanguage(locale));
count++;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Properties.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Properties.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Properties.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Properties.java Sat Jul 4 08:38:13 2009
@@ -197,7 +197,7 @@
if (out == null) {
throw new NullPointerException();
}
- StringBuffer buffer = new StringBuffer(80);
+ StringBuilder buffer = new StringBuilder(80);
Enumeration<?> keys = propertyNames();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
@@ -233,7 +233,7 @@
if (writer == null) {
throw new NullPointerException();
}
- StringBuffer buffer = new StringBuffer(80);
+ StringBuilder buffer = new StringBuilder(80);
Enumeration<?> keys = propertyNames();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
@@ -552,7 +552,7 @@
case '\r':
mode = NONE;
firstChar = true;
- if (offset > 0) {
+ if (offset > 0 || (offset == 0 && keyLength == 0)) {
if (keyLength == -1) {
keyLength = offset;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TimeZone.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TimeZone.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TimeZone.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TimeZone.java Sat Jul 4 08:38:13 2009
@@ -385,7 +385,7 @@
}
private static String formatTimeZoneName(String name, int offset) {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
int index = offset, length = name.length();
buf.append(name.substring(0, offset));
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Timer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Timer.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Timer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Timer.java Sat Jul 4 08:38:13 2009
@@ -431,7 +431,7 @@
* @param task
* the task to schedule.
* @param delay
- * amount of time before execution.
+ * amount of time in milliseconds before execution.
* @throws IllegalArgumentException
* if {@code delay < 0}.
* @throws IllegalStateException
@@ -451,9 +451,9 @@
* @param task
* the task to schedule.
* @param delay
- * amount of time before first execution.
+ * amount of time in milliseconds before first execution.
* @param period
- * amount of time between subsequent executions.
+ * amount of time in milliseconds between subsequent executions.
* @throws IllegalArgumentException
* if {@code delay < 0} or {@code period < 0}.
* @throws IllegalStateException
@@ -476,7 +476,7 @@
* @param when
* time of first execution.
* @param period
- * amount of time between subsequent executions.
+ * amount of time in milliseconds between subsequent executions.
* @throws IllegalArgumentException
* if {@code when.getTime() < 0} or {@code period < 0}.
* @throws IllegalStateException
@@ -498,9 +498,9 @@
* @param task
* the task to schedule.
* @param delay
- * amount of time before first execution.
+ * amount of time in milliseconds before first execution.
* @param period
- * amount of time between subsequent executions.
+ * amount of time in milliseconds between subsequent executions.
* @throws IllegalArgumentException
* if {@code delay < 0} or {@code period < 0}.
* @throws IllegalStateException
@@ -523,7 +523,7 @@
* @param when
* time of first execution.
* @param period
- * amount of time between subsequent executions.
+ * amount of time in milliseconds between subsequent executions.
* @throws IllegalArgumentException
* if {@code when.getTime() < 0} or {@code period < 0}.
* @throws IllegalStateException
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Vector.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Vector.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Vector.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Vector.java Sat Jul 4 08:38:13 2009
@@ -1009,7 +1009,7 @@
return "[]"; //$NON-NLS-1$
}
int length = elementCount - 1;
- StringBuffer buffer = new StringBuffer(elementCount * 16);
+ StringBuilder buffer = new StringBuilder(elementCount * 16);
buffer.append('[');
for (int i = 0; i < length; i++) {
if (elementData[i] == this) {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/ftp/FtpURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/ftp/FtpURLConnection.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/ftp/FtpURLConnection.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/ftp/FtpURLConnection.java Sat Jul 4 08:38:13 2009
@@ -396,7 +396,7 @@
* Read a line of text and return it for possible parsing
*/
private String readLine() throws IOException {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
int c;
while ((c = ctrlInput.read()) != '\n') {
sb.append((char) c);
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java Sat Jul 4 08:38:13 2009
@@ -986,7 +986,7 @@
*/
String readln() throws IOException {
boolean lastCr = false;
- StringBuffer result = new StringBuffer(80);
+ StringBuilder result = new StringBuilder(80);
int c = is.read();
if (c < 0) {
return null;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/Handler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/Handler.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/Handler.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/Handler.java Sat Jul 4 08:38:13 2009
@@ -99,7 +99,7 @@
*/
@Override
protected String toExternalForm(URL url) {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("jar:"); //$NON-NLS-1$
sb.append(url.getFile());
String ref = url.getRef();
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyClassFile.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyClassFile.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyClassFile.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyClassFile.java Sat Jul 4 08:38:13 2009
@@ -101,7 +101,7 @@
static char[] getConstantPoolName(Constructor<?> method) /* (ILjava/lang/Thread;)V */{
Class[] parameters = method.getParameterTypes();
- StringBuffer buffer = new StringBuffer(parameters.length + 1 * 20);
+ StringBuilder buffer = new StringBuilder(parameters.length + 1 * 20);
buffer.append('(');
for (Class<?> element : parameters) {
buffer.append(getConstantPoolName(element));
@@ -113,7 +113,7 @@
static char[] getConstantPoolName(Method method) /* (ILjava/lang/Thread;)Ljava/lang/Object; */{
Class[] parameters = method.getParameterTypes();
- StringBuffer buffer = new StringBuffer(parameters.length + 1 * 20);
+ StringBuilder buffer = new StringBuilder(parameters.length + 1 * 20);
buffer.append('(');
for (Class<?> element : parameters) {
buffer.append(getConstantPoolName(element));
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/IMemorySystem.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/IMemorySystem.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/IMemorySystem.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/IMemorySystem.java Sat Jul 4 08:38:13 2009
@@ -26,11 +26,23 @@
*/
public interface IMemorySystem {
- public final int MMAP_READ_ONLY = 1;
-
- public final int MMAP_READ_WRITE = 2;
-
- public final int MMAP_WRITE_COPY = 4;
+ /**
+ * The constant representing read-only access to data in a memory map
+ * request.
+ */
+ public final int MMAP_READ_ONLY = 1;
+
+ /**
+ * The constant representing read-write access to data in a memory map
+ * request.
+ */
+ public final int MMAP_READ_WRITE = 2;
+
+ /**
+ * The constant representing copy-on-write access to data in a memory map
+ * request.
+ */
+ public final int MMAP_WRITE_COPY = 4;
/**
* Answers true if the platform is little endian, otherwise it may be
@@ -173,7 +185,17 @@
public void setByteArray(long address, byte[] bytes, int offset, int length)
throws NullPointerException, IndexOutOfBoundsException;
- // Primitive get & set methods
+ /**
+ * Returns the value of a single byte at the given address.
+ * <p>
+ * The behavior is unspecified if <code>address</code> is not in the range
+ * that was previously allocated using <code>malloc()</code>.
+ * </p>
+ *
+ * @param address
+ * the address at which to get the byte value.
+ * @return the value of the byte.
+ */
public byte getByte(long address);
/**
@@ -205,6 +227,21 @@
*/
public short getShort(long address);
+ /**
+ * Gets the value of the signed two-byte integer stored in the given byte
+ * order at the given address.
+ * <p>
+ * The behavior is unspecified if <code>(address ... address + 2)</code> is
+ * not wholly within the range that was previously allocated using
+ * <code>malloc()</code>.
+ * </p>
+ *
+ * @param address
+ * the platform address of the start of the two-byte value.
+ * @param endianness
+ * the required interpretation of the short endianness.
+ * @return the value of the two-byte integer as a Java <code>short</code>.
+ */
public short getShort(long address, Endianness endianness);
/**
@@ -404,17 +441,25 @@
public void setAddress(long address, long value);
/**
- * TODO: JavaDoc
- *
- * @param fileDescriptor
- * @param alignment
- * @param size
- * @param mapMode
- * @return
- * @throws IOException
- */
- public long mmap(long fileDescriptor, long alignment, long size,
- int mapMode) throws IOException;
+ * Map file content into memory.
+ *
+ * @param fileDescriptor
+ * a handle to the file that is to be memory mapped.
+ * @param alignment
+ * the offset in the file where the mapping should begin.
+ * @param size
+ * the number of bytes that are requested to map.
+ * @param mapMode
+ * the desired access mode as defined by one of the constants
+ * {@link IMemorySystem#MMAP_READ_ONLY},
+ * {@link IMemorySystem#MMAP_READ_WRITE},
+ * {@link IMemorySystem#MMAP_WRITE_COPY}
+ * @return the start address of the mapped memory area.
+ * @throws IOException
+ * if an exception occurs mapping the file into memory.
+ */
+ public long mmap(long fileDescriptor, long alignment, long size, int mapMode)
+ throws IOException;
/**
* TODO: JavaDoc
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java Sat Jul 4 08:38:13 2009
@@ -346,8 +346,8 @@
* all sockets interested in write and connect
* @param timeout
* timeout in milliseconds
- * @returns each element describes the corresponding state of the descriptor
- * in the read and write arrays.
+ * @return each element describes the corresponding state of the descriptor
+ * in the read and write arrays.
* @throws SocketException
*/
public int[] select(FileDescriptor[] readFDs, FileDescriptor[] writeFDs,
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/Util.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/Util.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/Util.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/Util.java Sat Jul 4 08:38:13 2009
@@ -121,7 +121,7 @@
int year = -1, month = -1, date = -1;
int hour = -1, minute = -1, second = -1;
final int PAD = 0, LETTERS = 1, NUMBERS = 2;
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
while (offset <= length) {
char next = offset < length ? string.charAt(offset) : '\r';
@@ -270,7 +270,7 @@
public static String decode(String s, boolean convertPlus) {
if (!convertPlus && s.indexOf('%') == -1)
return s;
- StringBuffer result = new StringBuffer(s.length());
+ StringBuilder result = new StringBuilder(s.length());
ByteArrayOutputStream out = new ByteArrayOutputStream();
for (int i = 0; i < s.length();) {
char c = s.charAt(i);
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/fdlibm/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/fdlibm/unix/makefile?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/fdlibm/unix/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/fdlibm/unix/makefile Sat Jul 4 08:38:13 2009
@@ -44,15 +44,16 @@
$(FDLIBM_DIST)w_log.o $(FDLIBM_DIST)w_log10.o $(FDLIBM_DIST)w_pow.o $(FDLIBM_DIST)w_remainder.o \
$(FDLIBM_DIST)w_scalb.o $(FDLIBM_DIST)w_sinh.o $(FDLIBM_DIST)w_sqrt.o
+DEFINES += -D_IEEE_LIBM
+
+LIBNAME = $(LIBPATH)libhyfdlibm.a
+
# OPT is overriden except on zOS (fpic, for example, is not an option on zOS)
ifneq ($(HY_OS),zos)
ifneq ($(HY_OS),aix)
-OPT = -O0 -ffloat-store -fPIC
+OPT = -O0 -ffloat-store
endif
endif
-
-DEFINES += -D_IEEE_LIBM
-
-LIBNAME = $(LIBPATH)libhyfdlibm.a
+PLATFORM := $(subst -fpic,-fPIC,$(PLATFORM))
include $(HY_HDK)/build/make/rules.mk
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/file.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/file.c?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/file.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/file.c Sat Jul 4 08:38:13 2009
@@ -23,6 +23,14 @@
#include "helpers.h"
#include "jclprots.h"
+void
+throwPathTooLongIOException(JNIEnv *env, jsize length)
+{
+ char errorString[100];
+ sprintf(errorString, "Path length of %d characters exceeds maximum supported length of %d", length, HyMaxPath-1);
+ throwJavaIoIOException(env, errorString);
+}
+
JNIEXPORT jboolean JNICALL
Java_java_io_File_deleteFileImpl (JNIEnv * env, jobject recv, jbyteArray path)
{
@@ -31,7 +39,7 @@
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -48,7 +56,7 @@
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -80,7 +88,7 @@
currentEntry = NULL;
if (length >= HyMaxPath) {
- throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -161,7 +169,7 @@
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -178,7 +186,7 @@
char pathCopy[HyMaxPath];
jsize length = (*env)->GetArrayLength (env, path);
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -243,7 +251,7 @@
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -261,7 +269,7 @@
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -279,7 +287,7 @@
char pathCopy[HyMaxPath];
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -330,7 +338,7 @@
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path length exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -347,16 +355,19 @@
I_32 result;
jsize length;
char pathExistCopy[HyMaxPath], pathNewCopy[HyMaxPath];
+ char errorString[100];
length = (*env)->GetArrayLength (env, pathExist);
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "old path exceeds maximum supported length");
+ sprintf(errorString, "Old path length of %d characters exceeds maximum supported length of %d", length, HyMaxPath-1);
+ throwJavaIoIOException(env, errorString);
return 0;
}
((*env)->GetByteArrayRegion (env, pathExist, 0, length, (jbyte *)pathExistCopy));
pathExistCopy[length] = '\0';
length = (*env)->GetArrayLength (env, pathNew);
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "new path exceeds maximum supported length");
+ sprintf(errorString, "New path length of %d characters exceeds maximum supported length of %d", length, HyMaxPath-1);
+ throwJavaIoIOException(env, errorString);
return 0;
}
((*env)->GetByteArrayRegion (env, pathNew, 0, length, (jbyte *)pathNewCopy));
@@ -376,7 +387,7 @@
char pathCopy[HyMaxPath];
U_32 length = (U_32) (*env)->GetArrayLength (env, path);
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
(*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy);
@@ -399,7 +410,7 @@
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -469,7 +480,7 @@
char pathCopy[HyMaxPath];
jsize length = (*env)->GetArrayLength (env, path);
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -486,7 +497,7 @@
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -504,7 +515,7 @@
jsize length = (*env)->GetArrayLength (env, path);
char pathCopy[HyMaxPath];
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -568,7 +579,7 @@
char pathCopy[HyMaxPath];
jsize length = (*env)->GetArrayLength (env, path);
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -585,7 +596,7 @@
char pathCopy[HyMaxPath];
jsize length = (*env)->GetArrayLength (env, path);
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
((*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy));
@@ -602,7 +613,7 @@
char pathCopy[HyMaxPath];
U_32 length = (U_32) (*env)->GetArrayLength (env, path);
if (length > HyMaxPath-1) {
- throwJavaIoIOException(env, "path exceeds maximum supported length");
+ throwPathTooLongIOException(env, length);
return 0;
}
(*env)->GetByteArrayRegion (env, path, 0, length, (jbyte *)pathCopy);
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java Sat Jul 4 08:38:13 2009
@@ -611,6 +611,20 @@
assertEquals("Incorrect double max value", -2.0, Math.max(-2.0,
-1908897.6000089), 0D);
+ // Compare toString representations here since -0.0 = +0.0, and
+ // NaN != NaN and we need to distinguish
+ assertEquals("Max failed for NaN",
+ Double.toString(Double.NaN), Double.toString(Math.max(Double.NaN, 42.0d)));
+ assertEquals("Max failed for NaN",
+ Double.toString(Double.NaN), Double.toString(Math.max(42.0d, Double.NaN)));
+ assertEquals("Max failed for 0.0",
+ Double.toString(+0.0d), Double.toString(Math.max(+0.0d, -0.0d)));
+ assertEquals("Max failed for 0.0",
+ Double.toString(+0.0d), Double.toString(Math.max(-0.0d, +0.0d)));
+ assertEquals("Max failed for -0.0d",
+ Double.toString(-0.0d), Double.toString(Math.max(-0.0d, -0.0d)));
+ assertEquals("Max failed for 0.0",
+ Double.toString(+0.0d), Double.toString(Math.max(+0.0d, +0.0d)));
}
/**
@@ -624,6 +638,21 @@
Math.max(2.0f, 1908897.600f) == 1908897.600f);
assertTrue("Incorrect float max value",
Math.max(-2.0f, -1908897.600f) == -2.0f);
+
+ // Compare toString representations here since -0.0 = +0.0, and
+ // NaN != NaN and we need to distinguish
+ assertEquals("Max failed for NaN",
+ Float.toString(Float.NaN), Float.toString(Math.max(Float.NaN, 42.0f)));
+ assertEquals("Max failed for NaN",
+ Float.toString(Float.NaN), Float.toString(Math.max(42.0f, Float.NaN)));
+ assertEquals("Max failed for 0.0",
+ Float.toString(+0.0f), Float.toString(Math.max(+0.0f, -0.0f)));
+ assertEquals("Max failed for 0.0",
+ Float.toString(+0.0f), Float.toString(Math.max(-0.0f, +0.0f)));
+ assertEquals("Max failed for -0.0f",
+ Float.toString(-0.0f), Float.toString(Math.max(-0.0f, -0.0f)));
+ assertEquals("Max failed for 0.0",
+ Float.toString(+0.0f), Float.toString(Math.max(+0.0f, +0.0f)));
}
/**
@@ -662,6 +691,21 @@
2.0, Math.min(2.0, 1908897.6000089), 0D);
assertEquals("Incorrect double min value", -1908897.6000089, Math.min(-2.0,
-1908897.6000089), 0D);
+
+ // Compare toString representations here since -0.0 = +0.0, and
+ // NaN != NaN and we need to distinguish
+ assertEquals("Min failed for NaN",
+ Double.toString(Double.NaN), Double.toString(Math.min(Double.NaN, 42.0d)));
+ assertEquals("Min failed for NaN",
+ Double.toString(Double.NaN), Double.toString(Math.min(42.0d, Double.NaN)));
+ assertEquals("Min failed for -0.0",
+ Double.toString(-0.0d), Double.toString(Math.min(+0.0d, -0.0d)));
+ assertEquals("Min failed for -0.0",
+ Double.toString(-0.0d), Double.toString(Math.min(-0.0d, +0.0d)));
+ assertEquals("Min failed for -0.0d",
+ Double.toString(-0.0d), Double.toString(Math.min(-0.0d, -0.0d)));
+ assertEquals("Min failed for 0.0",
+ Double.toString(+0.0d), Double.toString(Math.min(+0.0d, +0.0d)));
}
/**
@@ -675,6 +719,21 @@
Math.min(2.0f, 1908897.600f) == 2.0f);
assertTrue("Incorrect float min value",
Math.min(-2.0f, -1908897.600f) == -1908897.600f);
+
+ // Compare toString representations here since -0.0 = +0.0, and
+ // NaN != NaN and we need to distinguish
+ assertEquals("Min failed for NaN",
+ Float.toString(Float.NaN), Float.toString(Math.min(Float.NaN, 42.0f)));
+ assertEquals("Min failed for NaN",
+ Float.toString(Float.NaN), Float.toString(Math.min(42.0f, Float.NaN)));
+ assertEquals("Min failed for -0.0",
+ Float.toString(-0.0f), Float.toString(Math.min(+0.0f, -0.0f)));
+ assertEquals("Min failed for -0.0",
+ Float.toString(-0.0f), Float.toString(Math.min(-0.0f, +0.0f)));
+ assertEquals("Min failed for -0.0f",
+ Float.toString(-0.0f), Float.toString(Math.min(-0.0f, -0.0f)));
+ assertEquals("Min failed for 0.0",
+ Float.toString(+0.0f), Float.toString(Math.min(+0.0f, +0.0f)));
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/String2Test.java Sat Jul 4 08:38:13 2009
@@ -529,11 +529,9 @@
hwHashCode += hw1.charAt(counter) * powerOfThirtyOne;
powerOfThirtyOne *= 31;
}
- assertTrue("String did not hash to correct value--got: "
- + String.valueOf(hw1.hashCode()) + " but wanted: "
- + String.valueOf(hwHashCode), hw1.hashCode() == hwHashCode);
- assertTrue("The empty string \"\" did not hash to zero", 0 == ""
- .hashCode());
+ assertEquals("String did not hash to correct value", hwHashCode, hw1.hashCode());
+ assertEquals("The empty string \"\" did not hash to zero", 0, "".hashCode());
+ assertEquals("Calculated wrong string hashcode", -1933545242, "Harmony".hashCode());
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLTest.java Sat Jul 4 08:38:13 2009
@@ -1092,7 +1092,7 @@
System.setSecurityManager(null);
}
}
-
+
/**
* @tests java.net.URL#openConnection()
*/
@@ -1237,6 +1237,33 @@
}
+ // Regression test for HARMONY-6254
+
+ // Bogus handler forces file part of URL to be null
+ static class MyHandler2 extends URLStreamHandler {
+
+ @Override
+ protected URLConnection openConnection(URL arg0) throws IOException {
+ return null;
+ }
+
+ @Override
+ protected void setURL(URL u, String protocol, String host, int port,
+ String authority, String userInfo, String file, String query,
+ String ref) {
+ super.setURL(u, protocol, host, port, authority, userInfo,
+ (String) null, query, ref);
+ }
+ }
+
+ // Test special case of external form with null file part (HARMONY-6254)
+ public void test_toExternalForm_Null() throws IOException {
+ URLStreamHandler myHandler = new MyHandler2();
+ URL url = new URL(null, "foobar://example.com/foobar", myHandler);
+ String s = url.toExternalForm();
+ assertEquals("Got wrong URL external form", "foobar://example.com", s);
+ }
+
static class MockProxySelector extends ProxySelector {
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashMapTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashMapTest.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashMapTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashMapTest.java Sat Jul 4 08:38:13 2009
@@ -17,6 +17,9 @@
package org.apache.harmony.luni.tests.java.util;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
@@ -52,6 +55,44 @@
}
}
+ interface MockInterface {
+ public String mockMethod();
+ }
+
+ class MockClass implements MockInterface {
+ public String mockMethod() {
+ return "This is a MockClass";
+ }
+ }
+
+ class MockHandler implements InvocationHandler {
+
+ Object obj;
+
+ public MockHandler(Object o) {
+ obj = o;
+ }
+
+ public Object invoke(Object proxy, Method m, Object[] args)
+ throws Throwable {
+
+ Object result = null;
+
+ try {
+
+ result = m.invoke(obj, args);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+
+ }
+ return result;
+ }
+
+ }
+
+
HashMap hm;
final static int hmSize = 1000;
@@ -295,6 +336,17 @@
k.setKey(17);
assertNull(map.get(k));
+
+ // Regression for HARMONY-6237
+ MockInterface proxyInstance = (MockInterface) Proxy.newProxyInstance(
+ MockInterface.class.getClassLoader(),
+ new Class[] { MockInterface.class }, new MockHandler(
+ new MockClass()));
+
+ hm.put(proxyInstance, "value2");
+
+ assertEquals("Failed with proxy object key", "value2", hm
+ .get(proxyInstance));
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java?rev=791082&r1=791081&r2=791082&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java Sat Jul 4 08:38:13 2009
@@ -382,6 +382,25 @@
prop.load(new ByteArrayInputStream("a=\\q".getBytes()));
assertEquals("Failed to read slash value #3", expected, prop);
}
+
+ /**
+ * @tests java.util.Properties#load(java.io.InputStream)
+ */
+ public void test_loadLjava_io_InputStream_Special() throws IOException {
+ // Test for method void java.util.Properties.load(java.io.InputStream)
+ Properties prop = null;
+ prop = new Properties();
+ prop.load(new ByteArrayInputStream("=".getBytes()));
+ assertTrue("Failed to add empty key", prop.get("").equals(""));
+
+ prop = new Properties();
+ prop.load(new ByteArrayInputStream("=\r\n".getBytes()));
+ assertTrue("Failed to add empty key", prop.get("").equals(""));
+
+ prop = new Properties();
+ prop.load(new ByteArrayInputStream("=\n\r".getBytes()));
+ assertTrue("Failed to add empty key", prop.get("").equals(""));
+ }
/**
* @throws IOException