• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Garbage Collection

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Can anybody tell me what will happen if uncaught exception occurs in finalilze() method?

I got the following from API
"...If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates. ..... Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored".

Does it mean that the object will NOT be eligible for garbage collection now,may be later some othertime it will be Garbage collected without calling the finalize() again (as finalize() can be called only ONCE for that object)?
 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Does it mean that the object will NOT be eligible for garbage collection now,may be later some othertime it will be Garbage collected without calling the finalize() again (as finalize() can be called only ONCE for that object)?


Yeah absolutely, it means that the garbage collection for that object terminates but still the object remains eligible and will be garbage collected sometime later, without calling finalize() all over again.
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Every Exception that is uncaught are handeled by Default Exception
Handler,regardless it is thrown in try block or finilally.As per my
knowledge of JLS
 
deshdeep divakar
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry the reply is
Every Exception that is uncaught are handeled by Default Exception
Handler,regardless it is thrown in try block or finilize.As per my
knowledge of JLS
 
deshdeep divakar
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry the reply is
Every Exception that is uncaught are handeled by Default Exception
Handler,regardless it is thrown in try block or finalize.As per my
knowledge of JLS
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the Finalisze method terminate"NOramlly" or is it Halted...if it throws an uncaught exception..
 
Animesh Shrivastava
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Does the Finalisze method terminate"NOramlly" or is it Halted...if it throws an uncaught exception..


The finalize method gets halted. But the object is still eligible for GC and can be collected at a later stage
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And when later , it will be collected at this time finalize() method will get called or not ...

I think not , otherwise again exception , then interrupt , and again object will not collected ...

Right ?

Thanks .
 
Animesh Shrivastava
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No it will not get called, it will just collect the object because finalize() can be called only once for any object
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Animesh .
When you are giving exam .
I think you are well prepared at this time also .
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic