mirror of
https://github.com/corda/corda.git
synced 2025-05-16 07:23:02 +00:00
GC stress fixes and other bugfixes; classpath progress
This commit is contained in:
parent
d5a00c4556
commit
a2bd7d0668
@ -11,7 +11,7 @@ public class BufferedReader extends Reader {
|
|||||||
this.buffer = new char[bufferSize];
|
this.buffer = new char[bufferSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BufferedReader(Reader in) {
|
public BufferedReader(Reader in) {
|
||||||
this(in, 32);
|
this(in, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ public class LineNumberReader extends BufferedReader {
|
|||||||
super(in, bufferSize);
|
super(in, bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LineNumberReader(Reader in) {
|
public LineNumberReader(Reader in) {
|
||||||
super(in);
|
super(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ public class PrintStream extends OutputStream {
|
|||||||
|
|
||||||
public PrintStream(OutputStream out, boolean autoFlush) {
|
public PrintStream(OutputStream out, boolean autoFlush) {
|
||||||
this.out = out;
|
this.out = out;
|
||||||
this.autoFlush = true;
|
this.autoFlush = autoFlush;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrintStream(OutputStream out) {
|
public PrintStream(OutputStream out) {
|
||||||
@ -29,6 +29,13 @@ public class PrintStream extends OutputStream {
|
|||||||
if (autoFlush) flush();
|
if (autoFlush) flush();
|
||||||
} catch (IOException e) { }
|
} catch (IOException e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void println() {
|
||||||
|
try {
|
||||||
|
out.write(newline);
|
||||||
|
if (autoFlush) flush();
|
||||||
|
} catch (IOException e) { }
|
||||||
|
}
|
||||||
|
|
||||||
public void write(int c) throws IOException {
|
public void write(int c) throws IOException {
|
||||||
out.write(c);
|
out.write(c);
|
||||||
|
@ -9,13 +9,21 @@ public class PrintWriter extends Writer {
|
|||||||
|
|
||||||
public PrintWriter(Writer out, boolean autoFlush) {
|
public PrintWriter(Writer out, boolean autoFlush) {
|
||||||
this.out = out;
|
this.out = out;
|
||||||
this.autoFlush = true;
|
this.autoFlush = autoFlush;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrintWriter(Writer out) {
|
public PrintWriter(Writer out) {
|
||||||
this(out, false);
|
this(out, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PrintWriter(OutputStream out, boolean autoFlush) {
|
||||||
|
this(new OutputStreamWriter(out), autoFlush);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrintWriter(OutputStream out) {
|
||||||
|
this(out, false);
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void print(String s) {
|
public synchronized void print(String s) {
|
||||||
try {
|
try {
|
||||||
out.write(s.toCharArray());
|
out.write(s.toCharArray());
|
||||||
@ -30,6 +38,13 @@ public class PrintWriter extends Writer {
|
|||||||
} catch (IOException e) { }
|
} catch (IOException e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void println() {
|
||||||
|
try {
|
||||||
|
out.write(newline);
|
||||||
|
if (autoFlush) flush();
|
||||||
|
} catch (IOException e) { }
|
||||||
|
}
|
||||||
|
|
||||||
public void write(char[] buffer, int offset, int length) throws IOException {
|
public void write(char[] buffer, int offset, int length) throws IOException {
|
||||||
out.write(buffer, offset, length);
|
out.write(buffer, offset, length);
|
||||||
if (autoFlush) flush();
|
if (autoFlush) flush();
|
||||||
|
@ -3,12 +3,31 @@ package java.lang;
|
|||||||
public final class Boolean {
|
public final class Boolean {
|
||||||
public static final Class TYPE = Class.forCanonicalName("Z");
|
public static final Class TYPE = Class.forCanonicalName("Z");
|
||||||
|
|
||||||
|
public static final Boolean FALSE = new Boolean(false);
|
||||||
|
public static final Boolean TRUE = new Boolean(true);
|
||||||
|
|
||||||
private final boolean value;
|
private final boolean value;
|
||||||
|
|
||||||
public Boolean(boolean value) {
|
public Boolean(boolean value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return o instanceof Boolean && ((Boolean) o).value == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return (value ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return toString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(boolean v) {
|
||||||
|
return (v ? "true" : "false");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean booleanValue() {
|
public boolean booleanValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,26 @@ public final class Byte extends Number {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return o instanceof Byte && ((Byte) o).value == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return toString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(byte v, int radix) {
|
||||||
|
return Long.toString(v, radix);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(byte v) {
|
||||||
|
return toString(v, 10);
|
||||||
|
}
|
||||||
|
|
||||||
public byte byteValue() {
|
public byte byteValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,22 @@ public final class Character {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return o instanceof Character && ((Character) o).value == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return (int) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return toString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(char v) {
|
||||||
|
return new String(new char[] { v });
|
||||||
|
}
|
||||||
|
|
||||||
public char charValue() {
|
public char charValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public final class Class <T> {
|
|||||||
} else if (name.startsWith("L")) {
|
} else if (name.startsWith("L")) {
|
||||||
return forName(name.substring(1, name.length() - 1));
|
return forName(name.substring(1, name.length() - 1));
|
||||||
} else {
|
} else {
|
||||||
if (name.length() == 0) {
|
if (name.length() == 1) {
|
||||||
return primitiveClass(name.charAt(0));
|
return primitiveClass(name.charAt(0));
|
||||||
} else {
|
} else {
|
||||||
throw new ClassNotFoundException(name);
|
throw new ClassNotFoundException(name);
|
||||||
|
3
classpath/java/lang/Cloneable.java
Normal file
3
classpath/java/lang/Cloneable.java
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public interface Cloneable { }
|
@ -1,14 +1,35 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public final class Double {
|
public final class Double extends Number {
|
||||||
public static final Class TYPE = Class.forCanonicalName("D");
|
public static final Class TYPE = Class.forCanonicalName("D");
|
||||||
|
|
||||||
private final double value;
|
private final double value;
|
||||||
|
|
||||||
|
public Double(String value) {
|
||||||
|
this.value = parseDouble(value);
|
||||||
|
}
|
||||||
|
|
||||||
public Double(double value) {
|
public Double(double value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return o instanceof Double && ((Double) o).value == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
long v = doubleToRawLongBits(value);
|
||||||
|
return (int) ((v >> 32) ^ (v & 0xFF));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return toString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(double v) {
|
||||||
|
return "todo";
|
||||||
|
}
|
||||||
|
|
||||||
public byte byteValue() {
|
public byte byteValue() {
|
||||||
return (byte) value;
|
return (byte) value;
|
||||||
}
|
}
|
||||||
@ -32,4 +53,14 @@ public final class Double {
|
|||||||
public double doubleValue() {
|
public double doubleValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double parseDouble(String s) {
|
||||||
|
// todo
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long doubleToRawLongBits(double value) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,22 @@ public final class Float extends Number {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return o instanceof Float && ((Float) o).value == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return floatToRawIntBits(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return toString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(float v) {
|
||||||
|
return "todo";
|
||||||
|
}
|
||||||
|
|
||||||
public byte byteValue() {
|
public byte byteValue() {
|
||||||
return (byte) value;
|
return (byte) value;
|
||||||
}
|
}
|
||||||
@ -32,4 +48,9 @@ public final class Float extends Number {
|
|||||||
public double doubleValue() {
|
public double doubleValue() {
|
||||||
return (double) value;
|
return (double) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int floatToRawIntBits(float value) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,35 @@ package java.lang;
|
|||||||
public final class Integer extends Number {
|
public final class Integer extends Number {
|
||||||
public static final Class TYPE = Class.forCanonicalName("I");
|
public static final Class TYPE = Class.forCanonicalName("I");
|
||||||
|
|
||||||
|
public static final int MIN_VALUE = 0x80000000;
|
||||||
|
public static final int MAX_VALUE = 0x7FFFFFFF;
|
||||||
|
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
public Integer(int value) {
|
public Integer(int value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return o instanceof Integer && ((Integer) o).value == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return toString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(int v, int radix) {
|
||||||
|
return Long.toString(v, radix);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(int v) {
|
||||||
|
return toString(v, 10);
|
||||||
|
}
|
||||||
|
|
||||||
public byte byteValue() {
|
public byte byteValue() {
|
||||||
return (byte) value;
|
return (byte) value;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,54 @@ public final class Long extends Number {
|
|||||||
this.value = value;
|
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() {
|
public byte byteValue() {
|
||||||
return (byte) value;
|
return (byte) value;
|
||||||
}
|
}
|
||||||
@ -49,7 +97,7 @@ public final class Long extends Number {
|
|||||||
long digit = ((c >= '0' && c <= '9') ? (c - '0') : (c - 'a' + 10));
|
long digit = ((c >= '0' && c <= '9') ? (c - '0') : (c - 'a' + 10));
|
||||||
number += digit * pow(radix, (s.length() - i - 1));
|
number += digit * pow(radix, (s.length() - i - 1));
|
||||||
} else {
|
} else {
|
||||||
throw new NumberFormatException("Invalid character " + c + " code " +
|
throw new NumberFormatException("invalid character " + c + " code " +
|
||||||
(int) c);
|
(int) c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
77
classpath/java/lang/Math.java
Normal file
77
classpath/java/lang/Math.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public final class Math {
|
||||||
|
private Math() { }
|
||||||
|
|
||||||
|
public static int abs(int v) {
|
||||||
|
return (v < 0 ? -v : v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long round(double v) {
|
||||||
|
return (long) (v + 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int round(float v) {
|
||||||
|
return (int) (v + 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double floor(double v) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double ceil(double v) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double exp(double v) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double log(double v) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double cos(double v) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double sin(double v) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double tan(double v) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double acos(double v) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double asin(double v) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double atan(double v) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double sqrt(double v) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double pow(double v, double e) {
|
||||||
|
// todo
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,26 @@ public final class Short extends Number {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return o instanceof Short && ((Short) o).value == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return toString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(short v, int radix) {
|
||||||
|
return Long.toString(v, radix);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(short v) {
|
||||||
|
return toString(v, 10);
|
||||||
|
}
|
||||||
|
|
||||||
public byte byteValue() {
|
public byte byteValue() {
|
||||||
return (byte) value;
|
return (byte) value;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,10 @@ public final class String implements Comparable<String> {
|
|||||||
this(data, offset, length, true);
|
this(data, offset, length, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String(char[] data) {
|
||||||
|
this(data, 0, data.length);
|
||||||
|
}
|
||||||
|
|
||||||
public String(byte[] data, int offset, int length, boolean copy) {
|
public String(byte[] data, int offset, int length, boolean copy) {
|
||||||
this((Object) data, offset, length, copy);
|
this((Object) data, offset, length, copy);
|
||||||
}
|
}
|
||||||
@ -22,6 +26,10 @@ public final class String implements Comparable<String> {
|
|||||||
this(data, offset, length, true);
|
this(data, offset, length, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String(byte[] data) {
|
||||||
|
this(data, 0, data.length);
|
||||||
|
}
|
||||||
|
|
||||||
private String(Object data, int offset, int length, boolean copy) {
|
private String(Object data, int offset, int length, boolean copy) {
|
||||||
if (copy) {
|
if (copy) {
|
||||||
Object c;
|
Object c;
|
||||||
@ -41,6 +49,10 @@ public final class String implements Comparable<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public int length() {
|
public int length() {
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
@ -91,6 +103,26 @@ public final class String implements Comparable<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int indexOf(char c) {
|
||||||
|
for (int i = 0; i < length - 1; ++i) {
|
||||||
|
if (charAt(i) == c) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int lastIndexOf(char c) {
|
||||||
|
for (int i = length - 1; i >= 0; --i) {
|
||||||
|
if (charAt(i) == c) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
public int indexOf(String s) {
|
public int indexOf(String s) {
|
||||||
if (s.length == 0) return 0;
|
if (s.length == 0) return 0;
|
||||||
|
|
||||||
@ -232,29 +264,35 @@ public final class String implements Comparable<String> {
|
|||||||
|
|
||||||
public native String intern();
|
public native String intern();
|
||||||
|
|
||||||
|
public static String valueOf(boolean v) {
|
||||||
|
return Boolean.toString(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String valueOf(byte v) {
|
||||||
|
return Byte.toString(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String valueOf(short v) {
|
||||||
|
return Short.toString(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String valueOf(char v) {
|
||||||
|
return Character.toString(v);
|
||||||
|
}
|
||||||
|
|
||||||
public static String valueOf(int v) {
|
public static String valueOf(int v) {
|
||||||
return valueOf((long) v);
|
return Integer.toString(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String valueOf(long v) {
|
public static String valueOf(long v) {
|
||||||
if (v == 0) {
|
return Long.toString(v);
|
||||||
return valueOf('0');
|
}
|
||||||
} else {
|
|
||||||
final int Max = 21;
|
|
||||||
char[] array = new char[Max];
|
|
||||||
int index = Max;
|
|
||||||
long x = (v >= 0 ? v : -v);
|
|
||||||
|
|
||||||
while (x != 0) {
|
public static String valueOf(float v) {
|
||||||
array[--index] = (char) ('0' + (x % 10));
|
return Float.toString(v);
|
||||||
x /= 10;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (v < 0) {
|
public static String valueOf(double v) {
|
||||||
array[--index] = '-';
|
return Double.toString(v);
|
||||||
}
|
|
||||||
|
|
||||||
return new String(array, index, Max - index, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public class StringBuffer {
|
public class StringBuffer {
|
||||||
private final StringBuilder sb = new StringBuilder();
|
private final StringBuilder sb;
|
||||||
|
|
||||||
|
public StringBuffer(int capacity) {
|
||||||
|
sb = new StringBuilder(capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringBuffer() {
|
||||||
|
this(0);
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized StringBuffer append(String s) {
|
public synchronized StringBuffer append(String s) {
|
||||||
sb.append(s);
|
sb.append(s);
|
||||||
|
@ -4,6 +4,12 @@ public class StringBuilder {
|
|||||||
private Cell chain;
|
private Cell chain;
|
||||||
private int length;
|
private int length;
|
||||||
|
|
||||||
|
public StringBuilder(int capacity) { }
|
||||||
|
|
||||||
|
public StringBuilder() {
|
||||||
|
this(0);
|
||||||
|
}
|
||||||
|
|
||||||
public StringBuilder append(String s) {
|
public StringBuilder append(String s) {
|
||||||
if (s.length() > 0) {
|
if (s.length() > 0) {
|
||||||
chain = new Cell(s, chain);
|
chain = new Cell(s, chain);
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package java.net;
|
package java.net;
|
||||||
|
|
||||||
public class URL {
|
public class URL {
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
public URL(String s) throws MalformedURLException {
|
||||||
|
value = s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,11 @@ public class HashSet<T> implements Set<T> {
|
|||||||
|
|
||||||
private final HashMap<T, Object> map;
|
private final HashMap<T, Object> map;
|
||||||
|
|
||||||
|
public HashSet(Collection<T> c) {
|
||||||
|
map = new HashMap(c.size());
|
||||||
|
addAll(c);
|
||||||
|
}
|
||||||
|
|
||||||
public HashSet(int capacity) {
|
public HashSet(int capacity) {
|
||||||
map = new HashMap(capacity);
|
map = new HashMap(capacity);
|
||||||
}
|
}
|
||||||
@ -21,6 +26,10 @@ public class HashSet<T> implements Set<T> {
|
|||||||
return map.containsKey(element);
|
return map.containsKey(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAll(Collection<T> c) {
|
||||||
|
for (T t: c) add(t);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean add(T element) {
|
public boolean add(T element) {
|
||||||
return map.put(element, Value) != Value;
|
return map.put(element, Value) != Value;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,12 @@ public class LinkedList<T> implements List<T> {
|
|||||||
private Cell<T> rear;
|
private Cell<T> rear;
|
||||||
private int size;
|
private int size;
|
||||||
|
|
||||||
|
public LinkedList(Collection<T> c) {
|
||||||
|
addAll(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedList() { }
|
||||||
|
|
||||||
private Cell<T> find(int index) {
|
private Cell<T> find(int index) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Cell<T> c = front; c != null; c = c.next) {
|
for (Cell<T> c = front; c != null; c = c.next) {
|
||||||
@ -75,6 +81,10 @@ public class LinkedList<T> implements List<T> {
|
|||||||
return find(element) != null;
|
return find(element) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAll(Collection<T> c) {
|
||||||
|
for (T t: c) add(t);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean add(T element) {
|
public boolean add(T element) {
|
||||||
addFirst(element);
|
addFirst(element);
|
||||||
return true;
|
return true;
|
||||||
|
@ -101,12 +101,14 @@ Class_primitiveClass(Thread* t, jclass, jchar name)
|
|||||||
return pushReference(t, arrayBody(t, t->vm->types, Machine::JfloatType));
|
return pushReference(t, arrayBody(t, t->vm->types, Machine::JfloatType));
|
||||||
case 'I':
|
case 'I':
|
||||||
return pushReference(t, arrayBody(t, t->vm->types, Machine::JintType));
|
return pushReference(t, arrayBody(t, t->vm->types, Machine::JintType));
|
||||||
case 'L':
|
case 'J':
|
||||||
return pushReference(t, arrayBody(t, t->vm->types, Machine::JlongType));
|
return pushReference(t, arrayBody(t, t->vm->types, Machine::JlongType));
|
||||||
case 'S':
|
case 'S':
|
||||||
return pushReference(t, arrayBody(t, t->vm->types, Machine::JshortType));
|
return pushReference(t, arrayBody(t, t->vm->types, Machine::JshortType));
|
||||||
case 'V':
|
case 'V':
|
||||||
return pushReference(t, arrayBody(t, t->vm->types, Machine::JvoidType));
|
return pushReference(t, arrayBody(t, t->vm->types, Machine::JvoidType));
|
||||||
|
case 'Z':
|
||||||
|
return pushReference(t, arrayBody(t, t->vm->types, Machine::JbooleanType));
|
||||||
default:
|
default:
|
||||||
t->exception = makeIllegalArgumentException(t);
|
t->exception = makeIllegalArgumentException(t);
|
||||||
return 0;
|
return 0;
|
||||||
@ -644,6 +646,8 @@ populateBuiltinMap(Thread* t, object map)
|
|||||||
reinterpret_cast<void*>(::Class_forName) },
|
reinterpret_cast<void*>(::Class_forName) },
|
||||||
{ "Java_java_lang_Class_isAssignableFrom",
|
{ "Java_java_lang_Class_isAssignableFrom",
|
||||||
reinterpret_cast<void*>(::Class_isAssignableFrom) },
|
reinterpret_cast<void*>(::Class_isAssignableFrom) },
|
||||||
|
{ "Java_java_lang_Class_primitiveClass",
|
||||||
|
reinterpret_cast<void*>(::Class_primitiveClass) },
|
||||||
|
|
||||||
{ "Java_java_lang_System_arraycopy",
|
{ "Java_java_lang_System_arraycopy",
|
||||||
reinterpret_cast<void*>(::System_arraycopy) },
|
reinterpret_cast<void*>(::System_arraycopy) },
|
||||||
|
@ -18,7 +18,7 @@ const unsigned MinimumGen2SizeInBytes = 128 * 1024;
|
|||||||
const unsigned Top = ~static_cast<unsigned>(0);
|
const unsigned Top = ~static_cast<unsigned>(0);
|
||||||
|
|
||||||
const bool Verbose = true;
|
const bool Verbose = true;
|
||||||
const bool Debug = true;
|
const bool Debug = false;
|
||||||
|
|
||||||
class Context;
|
class Context;
|
||||||
|
|
||||||
@ -1438,6 +1438,7 @@ class MyHeap: public Heap {
|
|||||||
} else if (c.nextGen2.contains(p)
|
} else if (c.nextGen2.contains(p)
|
||||||
or (c.gen2.contains(p)
|
or (c.gen2.contains(p)
|
||||||
and (c.mode == ::MinorCollection
|
and (c.mode == ::MinorCollection
|
||||||
|
or c.mode == ::OverflowCollection
|
||||||
or c.gen2.indexOf(p) >= c.gen2Base)))
|
or c.gen2.indexOf(p) >= c.gen2Base)))
|
||||||
{
|
{
|
||||||
return Tenured;
|
return Tenured;
|
||||||
|
@ -136,11 +136,24 @@ visitRoots(Thread* t, Heap::Visitor* v)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
finalizerTargetUnreachable(Thread* t, object* p, Heap::Visitor* v)
|
||||||
|
{
|
||||||
|
v->visit(&finalizerTarget(t, *p));
|
||||||
|
|
||||||
|
object finalizer = *p;
|
||||||
|
*p = finalizerNext(t, finalizer);
|
||||||
|
finalizerNext(t, finalizer) = t->vm->finalizeQueue;
|
||||||
|
t->vm->finalizeQueue = finalizer;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
referenceTargetUnreachable(Thread* t, object* p, Heap::Visitor* v)
|
referenceTargetUnreachable(Thread* t, object* p, Heap::Visitor* v)
|
||||||
{
|
{
|
||||||
// fprintf(stderr, "target %p unreachable for reference %p\n",
|
if (DebugReferences) {
|
||||||
// jreferenceTarget(t, *p), *p);
|
fprintf(stderr, "target %p unreachable for reference %p\n",
|
||||||
|
jreferenceTarget(t, *p), *p);
|
||||||
|
}
|
||||||
|
|
||||||
v->visit(p);
|
v->visit(p);
|
||||||
jreferenceTarget(t, *p) = 0;
|
jreferenceTarget(t, *p) = 0;
|
||||||
@ -164,27 +177,35 @@ referenceTargetUnreachable(Thread* t, object* p, Heap::Visitor* v)
|
|||||||
|
|
||||||
jreferenceQueue(t, *p) = 0;
|
jreferenceQueue(t, *p) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*p = jreferenceNext(t, *p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
referenceUnreachable(Thread* t, object* p, Heap::Visitor* v)
|
referenceUnreachable(Thread* t, object* p, Heap::Visitor* v)
|
||||||
{
|
{
|
||||||
// fprintf(stderr, "reference %p unreachable\n",
|
if (DebugReferences) {
|
||||||
// *p);
|
fprintf(stderr, "reference %p unreachable (target %p)\n",
|
||||||
|
*p, jreferenceTarget(t, *p));
|
||||||
|
}
|
||||||
|
|
||||||
if (jreferenceQueue(t, *p)
|
if (jreferenceQueue(t, *p)
|
||||||
and t->vm->heap->status(jreferenceQueue(t, *p)) != Heap::Unreachable)
|
and t->vm->heap->status(jreferenceQueue(t, *p)) != Heap::Unreachable)
|
||||||
{
|
{
|
||||||
// queue is reachable - add the reference
|
// queue is reachable - add the reference
|
||||||
referenceTargetUnreachable(t, p, v);
|
referenceTargetUnreachable(t, p, v);
|
||||||
|
} else {
|
||||||
|
*p = jreferenceNext(t, *p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
referenceTargetReachable(Thread* t, object* p, Heap::Visitor* v)
|
referenceTargetReachable(Thread* t, object* p, Heap::Visitor* v)
|
||||||
{
|
{
|
||||||
// fprintf(stderr, "target %p reachable for reference %p\n",
|
if (DebugReferences) {
|
||||||
// jreferenceTarget(t, *p), *p);
|
fprintf(stderr, "target %p reachable for reference %p\n",
|
||||||
|
jreferenceTarget(t, *p), *p);
|
||||||
|
}
|
||||||
|
|
||||||
v->visit(p);
|
v->visit(p);
|
||||||
v->visit(&jreferenceTarget(t, *p));
|
v->visit(&jreferenceTarget(t, *p));
|
||||||
@ -201,6 +222,16 @@ postVisit(Thread* t, Heap::Visitor* v)
|
|||||||
{
|
{
|
||||||
Machine* m = t->vm;
|
Machine* m = t->vm;
|
||||||
|
|
||||||
|
for (object* p = &(m->finalizeQueue); *p; p = &(finalizerNext(t, *p))) {
|
||||||
|
v->visit(p);
|
||||||
|
v->visit(&finalizerTarget(t, *p));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (object* p = &(m->finalizeQueue); *p; p = &(finalizerNext(t, *p))) {
|
||||||
|
v->visit(p);
|
||||||
|
v->visit(&finalizerTarget(t, *p));
|
||||||
|
}
|
||||||
|
|
||||||
object firstNewTenuredFinalizer = 0;
|
object firstNewTenuredFinalizer = 0;
|
||||||
object lastNewTenuredFinalizer = 0;
|
object lastNewTenuredFinalizer = 0;
|
||||||
|
|
||||||
@ -209,16 +240,9 @@ postVisit(Thread* t, Heap::Visitor* v)
|
|||||||
|
|
||||||
if (m->heap->status(finalizerTarget(t, *p)) == Heap::Unreachable) {
|
if (m->heap->status(finalizerTarget(t, *p)) == Heap::Unreachable) {
|
||||||
// target is unreachable - queue it up for finalization
|
// target is unreachable - queue it up for finalization
|
||||||
|
finalizerTargetUnreachable(t, p, v);
|
||||||
v->visit(&finalizerTarget(t, *p));
|
|
||||||
|
|
||||||
object finalizer = *p;
|
|
||||||
*p = finalizerNext(t, finalizer);
|
|
||||||
finalizerNext(t, finalizer) = m->finalizeQueue;
|
|
||||||
m->finalizeQueue = finalizer;
|
|
||||||
} else {
|
} else {
|
||||||
// target is reachable
|
// target is reachable
|
||||||
|
|
||||||
v->visit(&finalizerTarget(t, *p));
|
v->visit(&finalizerTarget(t, *p));
|
||||||
|
|
||||||
if (m->heap->status(*p) == Heap::Tenured) {
|
if (m->heap->status(*p) == Heap::Tenured) {
|
||||||
@ -245,17 +269,12 @@ postVisit(Thread* t, Heap::Visitor* v)
|
|||||||
for (object* p = &(m->weakReferences); *p;) {
|
for (object* p = &(m->weakReferences); *p;) {
|
||||||
if (m->heap->status(*p) == Heap::Unreachable) {
|
if (m->heap->status(*p) == Heap::Unreachable) {
|
||||||
// reference is unreachable
|
// reference is unreachable
|
||||||
|
|
||||||
referenceUnreachable(t, p, v);
|
referenceUnreachable(t, p, v);
|
||||||
*p = jreferenceNext(t, *p);
|
|
||||||
} else if (m->heap->status(jreferenceTarget(t, *p)) == Heap::Unreachable) {
|
} else if (m->heap->status(jreferenceTarget(t, *p)) == Heap::Unreachable) {
|
||||||
// target is unreachable
|
// target is unreachable
|
||||||
|
|
||||||
referenceTargetUnreachable(t, p, v);
|
referenceTargetUnreachable(t, p, v);
|
||||||
*p = jreferenceNext(t, *p);
|
|
||||||
} else {
|
} else {
|
||||||
// both reference and target are reachable
|
// both reference and target are reachable
|
||||||
|
|
||||||
referenceTargetReachable(t, p, v);
|
referenceTargetReachable(t, p, v);
|
||||||
|
|
||||||
if (m->heap->status(*p) == Heap::Tenured) {
|
if (m->heap->status(*p) == Heap::Tenured) {
|
||||||
@ -283,18 +302,10 @@ postVisit(Thread* t, Heap::Visitor* v)
|
|||||||
|
|
||||||
if (m->heap->status(finalizerTarget(t, *p)) == Heap::Unreachable) {
|
if (m->heap->status(finalizerTarget(t, *p)) == Heap::Unreachable) {
|
||||||
// target is unreachable - queue it up for finalization
|
// target is unreachable - queue it up for finalization
|
||||||
|
finalizerTargetUnreachable(t, p, v);
|
||||||
v->visit(&finalizerTarget(t, *p));
|
|
||||||
|
|
||||||
object finalizer = *p;
|
|
||||||
*p = finalizerNext(t, finalizer);
|
|
||||||
finalizerNext(t, finalizer) = m->finalizeQueue;
|
|
||||||
m->finalizeQueue = finalizer;
|
|
||||||
} else {
|
} else {
|
||||||
// target is reachable
|
// target is reachable
|
||||||
|
|
||||||
v->visit(&finalizerTarget(t, *p));
|
v->visit(&finalizerTarget(t, *p));
|
||||||
|
|
||||||
p = &finalizerNext(t, *p);
|
p = &finalizerNext(t, *p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,19 +313,14 @@ postVisit(Thread* t, Heap::Visitor* v)
|
|||||||
for (object* p = &(m->tenuredWeakReferences); *p;) {
|
for (object* p = &(m->tenuredWeakReferences); *p;) {
|
||||||
if (m->heap->status(*p) == Heap::Unreachable) {
|
if (m->heap->status(*p) == Heap::Unreachable) {
|
||||||
// reference is unreachable
|
// reference is unreachable
|
||||||
|
|
||||||
referenceUnreachable(t, p, v);
|
referenceUnreachable(t, p, v);
|
||||||
*p = jreferenceNext(t, *p);
|
|
||||||
} else if (m->heap->status(jreferenceTarget(t, *p))
|
} else if (m->heap->status(jreferenceTarget(t, *p))
|
||||||
== Heap::Unreachable)
|
== Heap::Unreachable)
|
||||||
{
|
{
|
||||||
// target is unreachable
|
// target is unreachable
|
||||||
|
|
||||||
referenceTargetUnreachable(t, p, v);
|
referenceTargetUnreachable(t, p, v);
|
||||||
*p = jreferenceNext(t, *p);
|
|
||||||
} else {
|
} else {
|
||||||
// both reference and target are reachable
|
// both reference and target are reachable
|
||||||
|
|
||||||
referenceTargetReachable(t, p, v);
|
referenceTargetReachable(t, p, v);
|
||||||
p = &jreferenceNext(t, *p);
|
p = &jreferenceNext(t, *p);
|
||||||
}
|
}
|
||||||
@ -771,7 +777,9 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
|
|||||||
if (fieldTable) {
|
if (fieldTable) {
|
||||||
for (int i = arrayLength(t, fieldTable) - 1; i >= 0; --i) {
|
for (int i = arrayLength(t, fieldTable) - 1; i >= 0; --i) {
|
||||||
object field = arrayBody(t, fieldTable, i);
|
object field = arrayBody(t, fieldTable, i);
|
||||||
if (fieldCode(t, field) == ObjectField) {
|
if ((fieldFlags(t, field) & ACC_STATIC) == 0
|
||||||
|
and fieldCode(t, field) == ObjectField)
|
||||||
|
{
|
||||||
unsigned index = fieldOffset(t, field) / BytesPerWord;
|
unsigned index = fieldOffset(t, field) / BytesPerWord;
|
||||||
intArrayBody(t, mask, (index / 32)) |= 1 << (index % 32);
|
intArrayBody(t, mask, (index / 32)) |= 1 << (index % 32);
|
||||||
sawReferenceField = true;
|
sawReferenceField = true;
|
||||||
|
@ -23,6 +23,7 @@ const bool Verbose = false;
|
|||||||
const bool DebugRun = false;
|
const bool DebugRun = false;
|
||||||
const bool DebugStack = false;
|
const bool DebugStack = false;
|
||||||
const bool DebugMonitors = false;
|
const bool DebugMonitors = false;
|
||||||
|
const bool DebugReferences = false;
|
||||||
|
|
||||||
const uintptr_t HashTakenMark = 1;
|
const uintptr_t HashTakenMark = 1;
|
||||||
const uintptr_t ExtendedMark = 2;
|
const uintptr_t ExtendedMark = 2;
|
||||||
|
@ -2118,17 +2118,13 @@ run(Thread* t)
|
|||||||
{
|
{
|
||||||
object catchType = 0;
|
object catchType = 0;
|
||||||
if (exceptionHandlerCatchType(eh)) {
|
if (exceptionHandlerCatchType(eh)) {
|
||||||
catchType = arrayBody
|
|
||||||
(t, codePool(t, code), exceptionHandlerCatchType(eh) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (catchType) {
|
|
||||||
object e = exception;
|
object e = exception;
|
||||||
exception = 0;
|
exception = 0;
|
||||||
PROTECT(t, e);
|
PROTECT(t, e);
|
||||||
|
|
||||||
PROTECT(t, eht);
|
PROTECT(t, eht);
|
||||||
catchType = resolveClass(t, catchType);
|
catchType = resolveClass
|
||||||
|
(t, codePool(t, code), exceptionHandlerCatchType(eh) - 1);
|
||||||
|
|
||||||
if (catchType) {
|
if (catchType) {
|
||||||
eh = exceptionHandlerTableBody(t, eht, i);
|
eh = exceptionHandlerTableBody(t, eht, i);
|
||||||
|
@ -178,7 +178,7 @@
|
|||||||
(extends runtimeException))
|
(extends runtimeException))
|
||||||
|
|
||||||
(type classNotFoundException java/lang/ClassNotFoundException
|
(type classNotFoundException java/lang/ClassNotFoundException
|
||||||
(extends runtimeException))
|
(extends exception))
|
||||||
|
|
||||||
(type invocationTargetException java/lang/InvocationTargetException
|
(type invocationTargetException java/lang/InvocationTargetException
|
||||||
(extends exception))
|
(extends exception))
|
||||||
@ -204,8 +204,11 @@
|
|||||||
(type unsatisfiedLinkError java/lang/UnsatisfiedLinkError
|
(type unsatisfiedLinkError java/lang/UnsatisfiedLinkError
|
||||||
(extends linkageError))
|
(extends linkageError))
|
||||||
|
|
||||||
|
(type number java/lang/Number
|
||||||
|
(extends jobject))
|
||||||
|
|
||||||
(type byte java/lang/Byte
|
(type byte java/lang/Byte
|
||||||
(extends jobject)
|
(extends number)
|
||||||
(int8_t value))
|
(int8_t value))
|
||||||
|
|
||||||
(type boolean java/lang/Boolean
|
(type boolean java/lang/Boolean
|
||||||
@ -213,7 +216,7 @@
|
|||||||
(uint8_t value))
|
(uint8_t value))
|
||||||
|
|
||||||
(type short java/lang/Short
|
(type short java/lang/Short
|
||||||
(extends jobject)
|
(extends number)
|
||||||
(int16_t value))
|
(int16_t value))
|
||||||
|
|
||||||
(type char java/lang/Character
|
(type char java/lang/Character
|
||||||
@ -221,19 +224,19 @@
|
|||||||
(uint16_t value))
|
(uint16_t value))
|
||||||
|
|
||||||
(type int java/lang/Integer
|
(type int java/lang/Integer
|
||||||
(extends jobject)
|
(extends number)
|
||||||
(int32_t value))
|
(int32_t value))
|
||||||
|
|
||||||
(type long java/lang/Long
|
(type long java/lang/Long
|
||||||
(extends jobject)
|
(extends number)
|
||||||
(int64_t value))
|
(int64_t value))
|
||||||
|
|
||||||
(type float java/lang/Float
|
(type float java/lang/Float
|
||||||
(extends jobject)
|
(extends number)
|
||||||
(uint32_t value))
|
(uint32_t value))
|
||||||
|
|
||||||
(type double java/lang/Double
|
(type double java/lang/Double
|
||||||
(extends jobject)
|
(extends number)
|
||||||
(uint64_t value))
|
(uint64_t value))
|
||||||
|
|
||||||
(type referenceQueue java/lang/ref/ReferenceQueue
|
(type referenceQueue java/lang/ref/ReferenceQueue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user