Methods Summary |
---|
private void | add()
synchronized (lock) {
if (unfinalized != null) {
this.next = unfinalized;
unfinalized.prev = this;
}
unfinalized = this;
}
|
private static void | forkSecondaryFinalizer(java.lang.Runnable proc)
PrivilegedAction pa = new PrivilegedAction() {
public Object run() {
ThreadGroup tg = Thread.currentThread().getThreadGroup();
for (ThreadGroup tgn = tg;
tgn != null;
tg = tgn, tgn = tg.getParent());
Thread sft = new Thread(tg, proc, "Secondary finalizer");
sft.start();
try {
sft.join();
} catch (InterruptedException x) {
/* Ignore */
}
return null;
}};
AccessController.doPrivileged(pa);
|
private boolean | hasBeenFinalized()
return (next == this);
|
static native void | invokeFinalizeMethod(java.lang.Object o)
|
static void | register(java.lang.Object finalizee)
new Finalizer(finalizee);
|
private void | remove()
synchronized (lock) {
if (unfinalized == this) {
if (this.next != null) {
unfinalized = this.next;
} else {
unfinalized = this.prev;
}
}
if (this.next != null) {
this.next.prev = this.prev;
}
if (this.prev != null) {
this.prev.next = this.next;
}
this.next = this; /* Indicates that this has been finalized */
this.prev = this;
}
|
static void | runAllFinalizers()
forkSecondaryFinalizer(new Runnable() {
public void run() {
for (;;) {
Finalizer f;
synchronized (lock) {
f = unfinalized;
if (f == null) break;
unfinalized = f.next;
}
f.runFinalizer();
}}});
|
static void | runFinalization()
forkSecondaryFinalizer(new Runnable() {
public void run() {
for (;;) {
Finalizer f = (Finalizer)queue.poll();
if (f == null) break;
f.runFinalizer();
}
}
});
|
private void | runFinalizer()
synchronized (this) {
if (hasBeenFinalized()) return;
remove();
}
try {
Object finalizee = this.get();
if (finalizee != null && !(finalizee instanceof java.lang.Enum)) {
invokeFinalizeMethod(finalizee);
/* Clear stack slot containing this variable, to decrease
the chances of false retention with a conservative GC */
finalizee = null;
}
} catch (Throwable x) { }
super.clear();
|