Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import java.util.*;
public class EmptyFinalizer {
static class A {
protected void finalize() {
System.out.println(this + " was finalized");
}
}
static class B extends A {
}
static class C extends B {
protected void finalize() { }
}
static class D extends C {
}
static class E extends D {
protected void finalize() {
System.out.println(this + " was finalized");
}
}
public static void main(String[] args) {
for (int i = 0; i < 5; i++) {
new A();
new B();
new C();
new D();
new E();
}
for (int i = 0; i < 10; i++) {
System.gc();
try {
Thread.sleep(100L);
} catch (InterruptedException ie) { }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment