Guardian Finalizer

I went through the example of a finalizer guardian published on Stack Overflow, I have a few questions regarding this:

  • Why do we need to create a Guardian object? Why not just override the finalizer? (since all classes are subclasses of the class Object).

  • At what point is the Guardian object created? I assume this is during class loading.

  • I did not understand the syntax of the generated guardian object. A function with a variable declaration is declared. What is this paradigm called in Java?

+4
source share
1 answer
  • Correctly overriding finalize () will certainly work. I believe the keeper trick should make sure that even your overridden finalize () does not call super.finalize (), the operand calls the parent finalizer before the finalizer of the child class.

  • When an instance of an object is created. A guardian object is nothing more than an instance variable

  • This is an anonymous (inner) class. I believe this is described in most books or tutorials on Java. Try Google with the "java anonymous class", which will provide you with quite a few resources, for example http://docstore.mik.ua/orelly/java-ent/jnut/ch03_12.htm

+4
source

All Articles