Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GC Doubt

 
vidya sagar
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whether it is True or False

If an exception is thrown during execution of the finalize method of an object,then the exception is ignored and the object is destroyed.

If it is true..............

(i taught)Jvm while executing in the middle of finalize method, if any exception raises, then it is ignored and object is not collected by GC at this time.

If it is false..........

then what is result???

Correct me what is answer to statement.......along with why??
 
Joe Sondow
Ranch Hand
Posts: 195
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True

If the finalize method throws an exception, the exception will be ignored. There is one unusual case in which the object will not then be destroyed, but in general the object will be destroyed, because the garbage collector called finalize before destroying the object.

The unusual case is when the finalize method stores a reference to the current object in some other container that is not eligible for garbage collection, thereby making the current object NO LONGER ELIGIBLE for garbage collection, even though it was about to be garbage collected.

Anyone disagree?
 
vidya sagar
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one jusify Joe statement i am looking for javagurus reply
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic