Re: exception inside constructors and finalize
- From: Tor Iver Wilhelmsen <tor.iver.wilhelmsen@xxxxxxxxxxxx>
- Date: 28 Apr 2005 08:52:36 +0200
"sarath" <mesarath@xxxxxxxxx> writes:
> 1.how can we handle exception inside constructors and finalize method?
try/catch or (for constructors) throws clause - as usual.
> 2.what will happen when an exception occur inside constructors and
> finalize()?
Same as happens when it occurs anywhere else: You need to pass it on
or catch it. Since finalize() is inherited from Object, you cannot add
any exception throws in it.
> will it be properly garbage collected ?
What do you mean? An exception object- like any other, will be a
candidate for collection as soon as it's no longer used.
> 3.can we call finalize method explicitly ? and what will happen then ?
It's a method, so you can call it yourself. What will happen is that
the code will be executed. Since you are calling it outside it's
normal lifecycle use, you might screw up your program doing so, if it
releases any resources or things like that.
.
- Follow-Ups:
- Re: exception inside constructors and finalize
- From: Ross Bamford
- Re: exception inside constructors and finalize
- References:
- exception inside constructors and finalize
- From: sarath
- exception inside constructors and finalize
- Prev by Date: Re: Redirecting error page 404...
- Next by Date: Re: Learning Java - How should I go about it?
- Previous by thread: exception inside constructors and finalize
- Next by thread: Re: exception inside constructors and finalize
- Index(es):
Relevant Pages
|
|