Példa

protected void finalize() throws Throwable {
System.out.println("Not calling super.finalize()"); //$NON-NLS-1$
}

public static void main(String[] args) {
SuperFinalize_Example sf = new SuperFinalize_Example();
sf = null;
Runtime.getRuntime().gc();
}

Megoldás
Szúrja be a super.finalize() meghívását utolsó utasításként a finalize() metódusba.

protected void finalize() throws Throwable {
try {
System.out.println("Calling super.finalize()"); //$NON-NLS-1$
} finally {
super .finalize();
}
}

public static void main(String[] args) {
SuperFinalize_Example sf = new SuperFinalize_Example();
sf = null;
Runtime.getRuntime().gc();
}