It's best if the finaliser method exactly match what is declared in Object. Changing the exceptions thrown can disrupt subclasses. You should call the super class' finaliser even if it redefine it. In any case, it's better to move the finaliser to a guard object, so that it doesn't become part of your interface and you are not dependent on any subclasses calling their super.
Code:
public class MyResource {
private final Object guard = new Object() {
@Override
protected void finalize() throws Throwable {
Free();
super.finalize();
}
};
...
}
Bookmarks