diff --git a/classpath/java/io/ByteArrayInputStream.java b/classpath/java/io/ByteArrayInputStream.java new file mode 100644 index 0000000000..0b649e3c9b --- /dev/null +++ b/classpath/java/io/ByteArrayInputStream.java @@ -0,0 +1,25 @@ +package java.io; + +public class ByteArrayInputStream extends InputStream { + private final byte[] array; + private int position; + private final int length; + + public ByteArrayInputStream(byte[] array, int offset, int length) { + this.array = array; + position = offset; + this.length = length; + } + + public int read() { + if (position < length) { + return array[position++] & 0xff; + } else { + return -1; + } + } + + public int available() { + returns length - position; + } +} diff --git a/classpath/java/lang/Enum.java b/classpath/java/lang/Enum.java new file mode 100644 index 0000000000..5d9b65b655 --- /dev/null +++ b/classpath/java/lang/Enum.java @@ -0,0 +1,38 @@ +package java.lang; + +import java.lang.reflect.Method; + +public abstract class Enum> { + private final String name; + private final int ordinal; + + public Enum(String name, int ordinal) { + this.name = name; + this.ordinal = ordinal; + } + + public int compareTo(E other) { + return ordinal - other.ordinal; + } + + public static > T valueOf(Class enumType, String name) { + if (name != null) { + try { + Method method = enumType.getMethod("values"); + Enum values[] = (Enum[])(method.invoke(null)); + for (Enum value : values) { + if (name.equals(value.name)) { + return (T) value; + } + } + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + return null; + } + + public int ordinal() { + return ordinal; + } +} diff --git a/classpath/java/lang/IncompatibleClassChangeError.java b/classpath/java/lang/IncompatibleClassChangeError.java new file mode 100644 index 0000000000..88234d574f --- /dev/null +++ b/classpath/java/lang/IncompatibleClassChangeError.java @@ -0,0 +1,11 @@ +package java.lang; + +public class IncompatibleClassChangeError extends LinkageError { + public IncompatibleClassChangeError(String message) { + super(message); + } + + public IncompatibleClassChangeError() { + super(); + } +} diff --git a/classpath/java/lang/NoSuchFieldError.java b/classpath/java/lang/NoSuchFieldError.java new file mode 100644 index 0000000000..77634a27b6 --- /dev/null +++ b/classpath/java/lang/NoSuchFieldError.java @@ -0,0 +1,11 @@ +package java.lang; + +public class NoSuchFieldError extends IncompatibleClassChangeError { + public NoSuchFieldError(String message) { + super(message); + } + + public NoSuchFieldError() { + super(); + } +} diff --git a/classpath/java/lang/annotation/Annotation.java b/classpath/java/lang/annotation/Annotation.java new file mode 100644 index 0000000000..cea69c8d4e --- /dev/null +++ b/classpath/java/lang/annotation/Annotation.java @@ -0,0 +1,4 @@ +package java.lang.annotation; + +public interface Annotation { +} diff --git a/classpath/java/util/Comparator.java b/classpath/java/util/Comparator.java new file mode 100644 index 0000000000..b7d84cda37 --- /dev/null +++ b/classpath/java/util/Comparator.java @@ -0,0 +1,5 @@ +package java.util; + +public interface Comparator { + public int compare(T o1, T o2); +} diff --git a/classpath/java/util/Date.java b/classpath/java/util/Date.java new file mode 100644 index 0000000000..6dc0372d96 --- /dev/null +++ b/classpath/java/util/Date.java @@ -0,0 +1,17 @@ +package java.util; + +public class Date { + public final long when; + + public Date() { + when = System.currentTimeMillis(); + } + + public Date(long when) { + this.when = when; + } + + public long getTime() { + return when; + } +}