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 @@ *
• {@code abs(-infinity) = +infinity}
• *
• {@code abs(NaN) = NaN}
• * - * + * * @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 @@ *
• {@code abs(-infinity) = +infinity}
• *
• {@code abs(NaN) = NaN}
• * - * + * * @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. *

* 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 @@ *

• {@code acos((anything < -1) = NaN}
• *
• {@code acos(NaN) = NaN}
• * - * + * * @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 @@ *
• {@code asin((anything < -1)) = NaN}
• *
• {@code asin(NaN) = NaN}
• * - * + * * @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 @@ *
• {@code atan(-infinity) = -pi/2}
• *
• {@code atan(NaN) = NaN}
• * - * + * * @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. *

* Special cases: *

@@ -220,12 +219,12 @@ *
• {@code atan2(-infinity, +infinity ) = -pi/4}
• *
• {@code atan2(+infinity, -infinity ) = +3pi/4}
• *
• {@code atan2(-infinity, -infinity ) = -3pi/4}
• - *
• {@code atan2(+infinity, (anything but,0, NaN, and infinity))} - * {@code =} {@code +pi/2}
• - *
• {@code atan2(-infinity, (anything but,0, NaN, and infinity))} - * {@code =} {@code -pi/2}
• + *
• {@code atan2(+infinity, (anything but,0, NaN, and infinity))} {@code + * =} {@code +pi/2}
• + *
• {@code atan2(-infinity, (anything but,0, NaN, and infinity))} {@code + * =} {@code -pi/2}
• *
- * + * * @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 @@ *
• {@code cbrt(-infinity) = -infinity}
• *
• {@code cbrt(NaN) = NaN}
• * - * + * * @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. *

* Special cases: *

@@ -266,16 +265,16 @@ *
• {@code ceil(-infinity) = -infinity}
• *
• {@code ceil(NaN) = NaN}
• *
- * + * * @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 @@ *
• {@code cos(-infinity) = NaN}
• *
• {@code cos(NaN) = NaN}
• * - * + * * @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 @@ *
• {@code cosh(-infinity) = +infinity}
• *
• {@code cosh(NaN) = NaN}
• * - * + * * @param d * the value whose hyperbolic cosine has to be computed. * @return the hyperbolic cosine of the argument. @@ -322,17 +321,17 @@ *
• {@code exp(-infinity) = +0.0}
• *
• {@code exp(NaN) = NaN}
• * - * + * * @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 {@code e} - * {@code d}{@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 {@code e} {@code + * d}{@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. *

@@ -347,12 +346,12 @@ *

• {@code expm1(-infinity) = -1.0}
• *
• {@code expm1(NaN) = NaN}
• * - * + * * @param d - * the value to compute the {@code e}{@code d} - * {@code - 1} of. - * @return the {@code e}{@code d}{@code - 1} value - * of the argument. + * the value to compute the {@code e}{@code d} + * {@code - 1} of. + * @return the {@code e}{@code d}{@code - 1} value of the + * argument. */ public static native double expm1(double d); @@ -368,25 +367,25 @@ *
• {@code floor(-infinity) = -infinity}
• *
• {@code floor(NaN) = NaN}
• * - * + * * @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(}{@code x}{@code 2}{@code +} - * {@code y}{@code 2}{@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(}{@code x}{@code 2}{@code +} + * {@code y}{@code 2}{@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. *

* Special cases: *

@@ -396,7 +395,7 @@ *
• {@code hypot((anything including NaN), -infinity) = +infinity}
• *
• {@code hypot(NaN, NaN) = NaN}
• *
- * + * * @param x * a double number. * @param y @@ -425,7 +424,7 @@ *
• {@code IEEEremainder(x, -infinity) = x } where x is anything but * +/-infinity
• * - * + * * @param x * the numerator of the operation. * @param y @@ -448,7 +447,7 @@ *
• {@code log(-infinity) = NaN}
• *
• {@code log(NaN) = NaN}
• * - * + * * @param d * the value whose log has to be computed. * @return the natural logarithm of the argument. @@ -469,13 +468,13 @@ *
• {@code log10(-infinity) = NaN}
• *
• {@code log10(NaN) = NaN}
• * - * + * * @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 @@ *
• {@code log1p(-infinity) = NaN}
• *
• {@code log1p(NaN) = NaN}
• * - * + * * @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 @@ *
• {@code max(+0.0, -0.0) = +0.0}
• *
• {@code max(-0.0, +0.0) = +0.0}
• * - * + * * @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 @@ *
• {@code max(+0.0, -0.0) = +0.0}
• *
• {@code max(-0.0, +0.0) = +0.0}
• * - * + * * @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 @@ *
• {@code min(+0.0, -0.0) = -0.0}
• *
• {@code min(-0.0, +0.0) = -0.0}
• * - * + * * @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 @@ *
• {@code min(+0.0, -0.0) = -0.0}
• *
• {@code min(-0.0, +0.0) = -0.0}
• * - * + * * @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}. *

* Special cases: *

@@ -710,11 +725,11 @@ *
• {@code pow(+infinity, (+anything except 0, NaN)) = +infinity}
• *
• {@code pow(+infinity, (-anything except 0, NaN)) = +0.0}
• *
• {@code pow(-infinity, (anything)) = -pow(0, (-anything))}
• - *
• {@code pow((-anything), (integer))} {@code =} - * {@code pow(-1,(integer))*pow(+anything,integer) }
• + *
• {@code pow((-anything), (integer))} {@code =} {@code + * pow(-1,(integer))*pow(+anything,integer) }
• *
• {@code pow((-anything except 0 and inf), (non-integer)) = NAN}
• *
- * + * * @param x * the base of the operation. * @param y @@ -735,20 +750,20 @@ *
• {@code rint(-infinity) = -infinity}
• *
• {@code rint(NaN) = NaN}
• * - * + * * @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)}. *

@@ -762,17 +777,18 @@ *

• {@code round(-infintiy) = Long.MIN_VALUE}
• *
• {@code round(NaN) = +0.0}
• * - * + * * @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 @@ *
• {@code round(-infintiy) = Integer.MIN_VALUE}
• *
• {@code round(NaN) = +0.0}
• * - * + * * @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 @@ *
• {@code signum(-infinity) = -1.0}
• *
• {@code signum(NaN) = NaN}
• * - * + * * @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 @@ *
• {@code signum(-infinity) = -1.0}
• *
• {@code signum(NaN) = NaN}
• * - * + * * @param f * the value whose signum has to be computed. * @return the value of the signum function. @@ -859,13 +876,13 @@ *
• {@code sin(-infinity) = NaN}
• *
• {@code sin(NaN) = NaN}
• * - * + * * @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 @@ *
• {@code sinh(-infinity) = -infinity}
• *
• {@code sinh(NaN) = NaN}
• * - * + * * @param d * the value whose hyperbolic sine has to be computed. * @return the hyperbolic sine of the argument. @@ -898,7 +915,7 @@ *
• {@code sqrt(+infinity) = +infinity}
• *
• {@code sqrt(NaN) = NaN}
• * - * + * * @param d * the value whose square root has to be computed. * @return the square root of the argument. @@ -918,13 +935,13 @@ *
• {@code tan(-infinity) = NaN}
• *
• {@code tan(NaN) = NaN}
• * - * + * * @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 @@ *
• {@code tanh(-infinity) = -1.0}
• *
• {@code tanh(NaN) = NaN}
• * - * + * * @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 @@ *
• *
• * - * + * * @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 @@ *
• {@code toDegrees(-infinity) = -infinity}
• *
• {@code toDegrees(NaN) = NaN}
• * - * + * * @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)}. *

* Special cases: *

@@ -1016,7 +1033,7 @@ *
• {@code ulp(-infintiy) = infinity}
• *
• {@code ulp(NaN) = NaN}
• *
- * + * * @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)}. *

* Special cases: *

@@ -1046,7 +1063,7 @@ *
• {@code ulp(-infintiy) = infinity}
• *
• {@code ulp(NaN) = NaN}
• *
+ * The behavior is unspecified if `address` is not in the range + * that was previously allocated using `malloc()`. + *
+ * The behavior is unspecified if `(address ... address + 2)` is + * not wholly within the range that was previously allocated using + * `malloc()`. + *
+ * + * @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 `short`. + */ 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