| Author |
GC-can someone replyto this post?
|
sanjana narayanan
Ranch Hand
Joined: Nov 25, 2003
Posts: 142
|
|
Hi, During finalization of an object, if an exception is raised, the exception is ignored and the object is not garbage collected. IS this stmt true for all types of exceptions(caught/uncaught) or(checked/unchecked). I got a small program to understand this stmt but got confused. can someone help me? -Sanjana [ January 16, 2004: Message edited by: sanjana narayanan ]
|
 |
Jessica Sant
Sheriff
Joined: Oct 17, 2001
Posts: 4313
|
|
from Khalid/Mughal's 1st edition pg 252 The automatic garbage collector calls the finalize method in an object which is eligible for garbage collection before actually destroying the object....A finalizer can catch and throw exceptions like other moethods. However, any exception thrown but not caught by a finalizer when invoked byt the garbage collector is ignored. The finalizer is only called once on an object, regardless of being interrupted by any exception during its execution. In case of finalization failure, the object still remains eligible to be disposed of at the discretion of the garbage collector (unless it has been resurrected).
So, from what I've read above I belive ANY UNCAUGHT exception (checked or unchecked) can cause teh finalization to fail. That being said, I wouldn't stress over this for the exam. Just knowing the basic facts like these should be enough: * uncaught exceptions will be ignored * that the finalize() method is only called once * finalize() methods are not automatically chained. [ January 16, 2004: Message edited by: Jessica Sant ]
|
- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
|
 |
 |
|
|
subject: GC-can someone replyto this post?
|
|
|