diff --git a/classpath/java/lang/Boolean.java b/classpath/java/lang/Boolean.java index 57137d24e8..21b75000f3 100644 --- a/classpath/java/lang/Boolean.java +++ b/classpath/java/lang/Boolean.java @@ -59,6 +59,10 @@ public final class Boolean implements Comparable { return value; } + public static boolean getBoolean(String name) { + return parseBoolean(System.getProperty(name)); + } + public static boolean parseBoolean(String string) { return string != null && string.equalsIgnoreCase("true"); } diff --git a/classpath/java/lang/Integer.java b/classpath/java/lang/Integer.java index f5e4052904..fd0483fc37 100644 --- a/classpath/java/lang/Integer.java +++ b/classpath/java/lang/Integer.java @@ -122,4 +122,21 @@ public final class Integer extends Number implements Comparable { public static int parseInt(String s, int radix) { return (int) Long.parseLong(s, radix); } + + public static Integer decode(String string) { + if (string.startsWith("-")) { + if (string.startsWith("-0") || string.startsWith("-#")) { + return new Integer(-decode(string.substring(1))); + } + } else if (string.startsWith("0")) { + char c = string.length() < 2 ? (char)-1 : string.charAt(1); + if (c == 'x' || c == 'X') { + return new Integer(parseInt(string.substring(2), 0x10)); + } + return new Integer(parseInt(string, 010)); + } else if (string.startsWith("#")) { + return new Integer(parseInt(string.substring(1), 0x10)); + } + return new Integer(parseInt(string, 10)); + } } diff --git a/classpath/java/lang/String.java b/classpath/java/lang/String.java index d49a347f98..c209c62439 100644 --- a/classpath/java/lang/String.java +++ b/classpath/java/lang/String.java @@ -602,6 +602,9 @@ public final class String } public int lastIndexOf(int ch, int lastIndex) { + if (lastIndex >= length) { + lastIndex = length - 1; + } for (int i = lastIndex ; i >= 0; --i) { if (charAt(i) == ch) { return i; diff --git a/classpath/java/lang/reflect/Method.java b/classpath/java/lang/reflect/Method.java index 8f04e7bf2b..51a64c905c 100644 --- a/classpath/java/lang/reflect/Method.java +++ b/classpath/java/lang/reflect/Method.java @@ -138,4 +138,8 @@ public class Method extends AccessibleObject implements Member { public Annotation[] getDeclaredAnnotations() { return getAnnotations(); } + + public boolean isVarArgs() { + return (getModifiers() & 0x80) != 0; + } } diff --git a/classpath/java/util/Collections.java b/classpath/java/util/Collections.java index c57c190a06..91fad0964b 100644 --- a/classpath/java/util/Collections.java +++ b/classpath/java/util/Collections.java @@ -245,6 +245,10 @@ public class Collections { } } + public static Set synchronizedSet(Set set) { + return new SynchronizedSet (new Object(), set); + } + static class SynchronizedIterator implements Iterator { private final Object lock; private final Iterator it; @@ -655,4 +659,10 @@ public class Collections { return - cmp.compare(o1, o2); } } + + public static List singletonList(T o) { + ArrayList list = new ArrayList(1); + list.add(o); + return new UnmodifiableList(list); + } } diff --git a/classpath/java/util/Vector.java b/classpath/java/util/Vector.java index e48ac52450..94ba9cbbe6 100644 --- a/classpath/java/util/Vector.java +++ b/classpath/java/util/Vector.java @@ -10,7 +10,7 @@ package java.util; -public class Vector extends AbstractList implements java.io.Serializable { +public class Vector extends AbstractList implements java.io.Serializable, Cloneable { private final ArrayList list; public Vector(int capacity) { @@ -126,5 +126,12 @@ public class Vector extends AbstractList implements java.io.Serializable { public Enumeration elements() { return new Collections.IteratorEnumeration(iterator()); } - + + public synchronized Object clone() { + Vector copy = new Vector(size()); + for (T t : this) { + copy.add(t); + } + return copy; + } } diff --git a/src/machine.cpp b/src/machine.cpp index e8d60ce2fc..3bf59a6fe9 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2512,7 +2512,11 @@ makeArrayClass(Thread* t, object loader, object spec, bool throw_, ++ s; const char* elementSpecStart = s; while (*s and *s != ';') ++ s; - + if (dimensions > 1) { + elementSpecStart -= dimensions; + ++ s; + } + elementSpec = makeByteArray(t, s - elementSpecStart + 1); memcpy(&byteArrayBody(t, elementSpec, 0), &byteArrayBody(t, spec, elementSpecStart - start), diff --git a/test/Integers.java b/test/Integers.java index bbaa710351..7c977d6136 100644 --- a/test/Integers.java +++ b/test/Integers.java @@ -314,5 +314,11 @@ public class Integers { { int b = 0xBE; int x = 0; int y = 0xFF; expect(((b >>> x) & y) == 0xBE); } + + expect(123 == Integer.decode("123").intValue()); + expect(-123 == Integer.decode("-123").intValue()); + expect(-83 == Integer.decode("-0123").intValue()); + expect(-291 == Integer.decode("-0x123").intValue()); + expect(291 == Integer.decode("#123").intValue()); } } diff --git a/test/Reflection.java b/test/Reflection.java index f71b39e81b..23d34abf7e 100644 --- a/test/Reflection.java +++ b/test/Reflection.java @@ -67,5 +67,10 @@ public class Reflection { expect(7.0 == (Double) Reflection.class.getMethod ("doubleMethod").invoke(null)); + + Class[][] array = new Class[][] { { Class.class } }; + expect("[Ljava.lang.Class;".equals(array[0].getClass().getName())); + expect(Class[].class == array[0].getClass()); + expect(array.getClass().getComponentType() == array[0].getClass()); } } diff --git a/test/Strings.java b/test/Strings.java index 30a85163c9..76815af535 100644 --- a/test/Strings.java +++ b/test/Strings.java @@ -203,6 +203,8 @@ public class Strings { System.getProperty("line.separator").getBytes()))); } + expect("abc".lastIndexOf('b', 100) == 1); + testTrivialPattern(); } }