diff --git a/src/machine.cpp b/src/machine.cpp index 519d7ff01f..6ebb966748 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -409,11 +409,11 @@ void referenceTargetUnreachable(Thread* t, Heap::Visitor* v, GcJreference** p) (*p)->target() = 0; if (objectClass(t, *p) == type(t, GcCleaner::Type)) { - *p = cast(t, (*p)->vmNext()); - // In openjdk, sun/misc/Cleaner extends PhantomReference GcCleaner* cleaner = (*p)->as(t); + *p = cast(t, (*p)->vmNext()); + cleaner->setQueueNext(t, roots(t)->objectsToClean()); roots(t)->setObjectsToClean(t, cleaner); } else {