Introducing Exceptions in Overridden Methods

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Introducing Exceptions in Overridden Methods

J.Pena
Hello everybody! I'd like to request any comments or help on this matter:

When overriding one of the methods of the AWT Listener classes, I have
introduced (or signalled) an exception which of course is not signalled
in the parent class. Specifically, when coding an 'actionPerformed'
method of the ActionListener interface I have created an object and used
one of its methods which may throw an IOException. My compile fails
because MY version of the method signals the exception but the
ActionListener interface does NOT.

I tried moving the method call which signals the exception to another
('convenience') method but the compile still failed because of a 'forward
reference' to a method which signals the exception.

It seems that if you have a ..

  method abc()

.which does not signal any exceptions you cannot then override it with
say,

  method abc() signal IOException

.but I'm not sure yet how to resolve this--I certainly need the IO
functionality which happens to signal the exception!
Thanks!

---------------
cjpena
[hidden email]
---------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: Introducing Exceptions in Overridden Methods

Massimiliano Marsiglietti
> .but I'm not sure yet how to resolve this--I certainly need the IO
> functionality which happens to signal the exception!

Err.. What about actually catching the exception?

In NetRexx:

 do
  -- your code
 catch IOException
  -- code that handles IOException
 end

Max

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: Introducing Exceptions in Overridden Methods

Mike Cowlishaw-2
In reply to this post by J.Pena
That's the way Java works, I'm afraid.  You must catch the exception  in your
method.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Mike Cowlishaw, IBM Fellow, IBM UK Laboratories
mailto:[hidden email]   [http://www2.hursley.ibm.com]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>