GC stress fixes and other bugfixes; classpath progress

This commit is contained in:
Joel Dice
2007-07-29 17:32:23 -06:00
parent d5a00c4556
commit a2bd7d0668
27 changed files with 463 additions and 75 deletions

View File

@ -9,6 +9,54 @@ public final class Long extends Number {
this.value = value;
}
public boolean equals(Object o) {
return o instanceof Long && ((Long) o).value == value;
}
public int hashCode() {
return (int) ((value >> 32) ^ (value & 0xFF));
}
public String toString() {
return String.valueOf(value);
}
public static String toString(long v, int radix) {
if (radix < 1 || radix > 36) {
throw new IllegalArgumentException("radix " + radix + " not in [1,36]");
}
if (v == 0) {
return "0";
}
int size = (v < 0 ? 1 : 0);
for (long n = v; n > 0; n /= radix) ++size;
char[] array = new char[size];
int i = array.length - 1;
for (long n = v; n > 0; n /= radix) {
long digit = n % radix;
if (digit >= 0 && digit <= 9) {
array[i] = (char) ('0' + digit);
} else {
array[i] = (char) ('a' + (digit - 10));
}
--i;
}
if (v < 0) {
array[i] = '-';
}
return new String(array);
}
public static String toString(long v) {
return toString(v, 10);
}
public byte byteValue() {
return (byte) value;
}
@ -49,7 +97,7 @@ public final class Long extends Number {
long digit = ((c >= '0' && c <= '9') ? (c - '0') : (c - 'a' + 10));
number += digit * pow(radix, (s.length() - i - 1));
} else {
throw new NumberFormatException("Invalid character " + c + " code " +
throw new NumberFormatException("invalid character " + c + " code " +
(int) c);
}
}