• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Clarification

 
Ranch Hand
Posts: 982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

From khalid 's book ..


When the garbage collector calls the finalize() method, it will ignore any exceptions thrown by the finalize() method. In all other cases, normal exception handling occurs when an exception is thrown during the execution of the finalize() method, that is, exceptions are not simply ignored.


Can you please clarify ...?? the statement in bold..


Tx
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


In all other cases, normal exception handling occurs when an exception is thrown during the execution of the finalize() method, that is, exceptions are not simply ignored.



hi kumar

I am not sure........but to my understandings

Normally exception is handled in catch block or throws to calling method

In the background GC calls finalize method,if any exception in that method GC should handle it

Correct me if i am wrong
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In all other cases, normal exception handling occurs when an exception is thrown during the execution of the finalize() method, that is, exceptions are not simply ignored.


According to Java API,
If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.
 
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can infer that if any exception is thrown in finalize method and is not handled, then that exception has no effect and the object is Colleced by GC.
 
A Kumar
Ranch Hand
Posts: 982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In the API it has been mentioned...





Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.




Sorry ...But am not clear with the above explanations of my doubt

Can you be more clear..



The above doubt..

When the garbage collector calls the finalize() method, it will ignore any exceptions thrown by the finalize() method. In all other cases, normal exception handling occurs when an exception is thrown during the execution of the finalize() method, that is, exceptions are not simply ignored.



 
vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


When the garbage collector calls the finalize() method, it will ignore any exceptions thrown by the finalize() method.



When an exception is raised in finalize() method GC ignores that exception
and collect the object.(i.e ...The objective of finalize method is fullfilled invariable to exception is raised or not)


In all other cases, normal exception handling occurs when an exception is thrown during the execution of the finalize() method, that is, exceptions are not simply ignored.



But in all cases, when exception is raised it will throws to calling method
or catched in the catch block of that method or to the calling method.
In this type of situations simply control will transfer.
(for ex.. suppose a method int a() has to return a number to its calling method,when Exception is occured(provided if it is not catched and return a int) it simply returns control without a number.....here objective is not fullfilled when exception occured)
 
A Kumar
Ranch Hand
Posts: 982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




quote:

In all other cases, normal exception handling occurs when an exception is thrown during the execution of the finalize() method, that is, exceptions are not simply ignored.



But in all cases, when exception is raised it will throws to calling method
or catched in the catch block of that method or to the calling method.
In this type of situations simply control will transfer.
(for ex.. suppose a method int a() has to return a number to its calling method,when Exception is occured(provided if it is not catched and return a int) it simply returns control without a number.....here objective is not fullfilled when exception occured)






But here the author mentions in the context of the finalize method ...

and there wasnt any mention of the same above..

Regards
 
vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May be GC has some Exception handling mechanism......i am not sure

Any one come with some explanation for this it will highly appreciable
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic