Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Aditi Msc   on Dec 17 In Java Category.

  
Question Answered By: Bhanu Chidigam   on Dec 17

The Garbage collector(GC) while cleans up the object it also calls the finalize method of the respective class.
When a class derived is derived base class and if only instance for the derived class exists, and if it also miss the call to finalize version of based class from the derived finalize version. Then no way GC can call the finalize method of the base class.
As a work around this technique ensures to call clean up code for the base class. An anonymous class object as member of base class is declared, and when GC cleans up this object it calls finalize version of the anonymous version of finalize. where supposed be clean up code for the base class (GC while propagate to this anonymous object while derived class object is cleaning up).



Share: