diff --git a/classpath/java/io/ByteArrayInputStream.java b/classpath/java/io/ByteArrayInputStream.java index 5ae39e08aa..633b62a4ce 100644 --- a/classpath/java/io/ByteArrayInputStream.java +++ b/classpath/java/io/ByteArrayInputStream.java @@ -21,6 +21,10 @@ public class ByteArrayInputStream extends InputStream { this.limit = offset + length; } + public ByteArrayInputStream(byte[] array) { + this(array, 0, array.length); + } + public int read() { if (position < limit) { return array[position++] & 0xff; diff --git a/classpath/java/io/InputStream.java b/classpath/java/io/InputStream.java index 68b61962d8..ade4c81015 100644 --- a/classpath/java/io/InputStream.java +++ b/classpath/java/io/InputStream.java @@ -52,5 +52,17 @@ public abstract class InputStream { return 0; } + public void mark(int limit) { + // ignore + } + + public void reset() throws IOException { + // ignore + } + + public boolean markSupported() { + return false; + } + public void close() throws IOException { } } diff --git a/classpath/java/lang/Character.java b/classpath/java/lang/Character.java index 95115c1ea2..a51008cf7d 100644 --- a/classpath/java/lang/Character.java +++ b/classpath/java/lang/Character.java @@ -11,6 +11,9 @@ package java.lang; public final class Character implements Comparable { + public static final int MIN_RADIX = 2; + public static final int MAX_RADIX = 36; + public static final Class TYPE = Class.forCanonicalName("C"); private final char value; @@ -67,6 +70,23 @@ public final class Character implements Comparable { return c >= '0' && c <= '9'; } + public static int digit(char c, int radix) { + int digit = 0; + if ((c >= '0') && (c <= '9')) { + digit = c - '0'; + } else if ((c >= 'a') && (c <= 'z')) { + digit = c - 'a' + 10; + } else { + return -1; + } + + if (digit < radix) { + return digit; + } else { + return -1; + } + } + public static boolean isLetter(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } diff --git a/classpath/java/lang/Integer.java b/classpath/java/lang/Integer.java index 4e6715c77f..8a79c9babc 100644 --- a/classpath/java/lang/Integer.java +++ b/classpath/java/lang/Integer.java @@ -58,6 +58,10 @@ public final class Integer extends Number implements Comparable { return Long.toString(((long) v) & 0xFFFFFFFFL, 16); } + public static String toBinaryString(int v) { + return Long.toString(((long) v) & 0xFFFFFFFFL, 2); + } + public byte byteValue() { return (byte) value; } diff --git a/classpath/java/lang/Long.java b/classpath/java/lang/Long.java index 79a765ab58..bfa2c28396 100644 --- a/classpath/java/lang/Long.java +++ b/classpath/java/lang/Long.java @@ -11,8 +11,10 @@ package java.lang; public final class Long extends Number implements Comparable { + public static final Long MIN_VALUE = -9223372036854775808l; + public static final Long MAX_VALUE = 9223372036854775807l; + public static final Class TYPE = Class.forCanonicalName("J"); - public static final Long MAX_VALUE = 9223372036854775807l; private final long value; @@ -131,16 +133,13 @@ public final class Long extends Number implements Comparable { for (; i < s.length(); ++i) { char c = s.charAt(i); - if (((c >= '0') && (c <= '9')) || - ((c >= 'a') && (c <= 'z'))) { - long digit = ((c >= '0' && c <= '9') ? (c - '0') : (c - 'a' + 10)); - if (digit < radix) { - number += digit * pow(radix, (s.length() - i - 1)); - continue; - } + int digit = Character.digit(c, radix); + if (digit >= 0) { + number += digit * pow(radix, (s.length() - i - 1)); + } else { + throw new NumberFormatException("invalid character " + c + " code " + + (int) c); } - throw new NumberFormatException("invalid character " + c + " code " + - (int) c); } if (negative) { diff --git a/classpath/java/util/Vector.java b/classpath/java/util/Vector.java index 20d6a8323e..acba5f7445 100644 --- a/classpath/java/util/Vector.java +++ b/classpath/java/util/Vector.java @@ -37,6 +37,10 @@ public class Vector implements List { list.add(index, element); } + public void insertElementAt(T element, int index) { + add(index, element); + } + public synchronized boolean add(T element) { return list.add(element); } @@ -57,6 +61,10 @@ public class Vector implements List { return list.set(index, value); } + public T setElementAt(T value, int index) { + return set(index, value); + } + public T elementAt(int index) { return get(index); }