diff --git a/classpath/java/io/ObjectInputStream.java b/classpath/java/io/ObjectInputStream.java index 531058b943..15394c5d0b 100644 --- a/classpath/java/io/ObjectInputStream.java +++ b/classpath/java/io/ObjectInputStream.java @@ -204,7 +204,11 @@ public class ObjectInputStream extends InputStream { for (Field f: c.getFields()) { int modifiers = f.getModifiers(); if ((modifiers & (Modifier.TRANSIENT | Modifier.STATIC)) == 0) { - f.set(o, deserialize(map)); + try { + f.set(o, deserialize(map)); + } catch (Exception e) { + throw new RuntimeException(e); + } } } diff --git a/classpath/java/io/ObjectOutputStream.java b/classpath/java/io/ObjectOutputStream.java index 25b20adeae..330a3e0c98 100644 --- a/classpath/java/io/ObjectOutputStream.java +++ b/classpath/java/io/ObjectOutputStream.java @@ -155,7 +155,14 @@ public class ObjectOutputStream extends OutputStream { int modifiers = f.getModifiers(); if ((modifiers & (Modifier.TRANSIENT | Modifier.STATIC)) == 0) { out.print(" "); - Object v = f.get(o); + Object v; + + try { + v = f.get(o); + } catch (Exception e) { + throw new RuntimeException(e); + } + Class t = f.getType(); if (t.equals(boolean.class)) { writeBoolean((Boolean) v); diff --git a/classpath/java/util/HashMap.java b/classpath/java/util/HashMap.java index d5f860ad93..abb559279f 100644 --- a/classpath/java/util/HashMap.java +++ b/classpath/java/util/HashMap.java @@ -53,8 +53,8 @@ public class HashMap implements Map { for (Cell c = array[i]; c != null; c = next) { next = c.next(); int index = c.hashCode() & (capacity - 1); - c.setNext(array[index]); - array[index] = c; + c.setNext(newArray[index]); + newArray[index] = c; } } } diff --git a/classpath/java/util/LinkedList.java b/classpath/java/util/LinkedList.java index f521940778..5deae40931 100644 --- a/classpath/java/util/LinkedList.java +++ b/classpath/java/util/LinkedList.java @@ -127,8 +127,7 @@ public class LinkedList implements List { public T removeFirst() { if (front != null) { T v = front.value; - front = front.next; - if (front != null) front.prev = null; + remove(front); return v; } else { throw new NoSuchElementException(); @@ -138,8 +137,7 @@ public class LinkedList implements List { public T removeLast() { if (rear != null) { T v = rear.value; - rear = rear.prev; - if (rear != null) rear.next = null; + remove(rear); return v; } else { throw new NoSuchElementException(); diff --git a/src/builtin.cpp b/src/builtin.cpp index 1d63e19240..1780014946 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -627,16 +627,16 @@ Throwable_trace(Thread* t, jclass, jint skipCount) frame = frameNext(t, frame); } - if (methodClass(t, frameMethod(t, frame)) - == arrayBody(t, t->vm->types, Machine::ThrowableType)) + // skip Throwable constructors + while (frame >= 0 + and isAssignableFrom + (t, arrayBody(t, t->vm->types, Machine::ThrowableType), + methodClass(t, frameMethod(t, frame))) + and strcmp(reinterpret_cast(""), + &byteArrayBody(t, methodName(t, frameMethod(t, frame)), 0)) + == 0) { - // skip Throwable constructors - while (strcmp(reinterpret_cast(""), - &byteArrayBody(t, methodName(t, frameMethod(t, frame)), 0)) - == 0) - { - frame = frameNext(t, frame); - } + frame = frameNext(t, frame); } return pushReference(t, makeTrace(t, frame)); diff --git a/src/machine.cpp b/src/machine.cpp index 849ea0c418..c933a790bc 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -271,8 +271,7 @@ postVisit(Thread* t, Heap::Visitor* v) if (m->heap->status(*p) == Heap::Unreachable) { // reference is unreachable referenceUnreachable(t, p, v); - } else if (jreferenceTarget(t, *p) == 0 - or m->heap->status(jreferenceTarget(t, *p)) + } else if (m->heap->status(jreferenceTarget(t, *p)) == Heap::Unreachable) { // target is unreachable @@ -318,8 +317,7 @@ postVisit(Thread* t, Heap::Visitor* v) if (m->heap->status(*p) == Heap::Unreachable) { // reference is unreachable referenceUnreachable(t, p, v); - } else if (jreferenceTarget(t, *p) == 0 - or m->heap->status(jreferenceTarget(t, *p)) + } else if (m->heap->status(jreferenceTarget(t, *p)) == Heap::Unreachable) { // target is unreachable