예제

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();
}

솔루션
super.finalize()에 대한 호출을 finalize() 메소드의 최종 명령문으로 삽입하십시오.

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();
}