Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Error overriding interface method.

 
Sang-Wook Kim
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am doing URLyBird and want to extend the "DBMain" interface,
but I have one problem about adding more exceptions in the
extending interface. For example, say I have the following
interfaces:

This gives a compile error complaining that overriden method
does not throw RecordNotFoundException. But if I put for
example IOException instead of RecordNotFoundException:

This compiles and I don't know exactly why.
Can somebody tell me why this is so?
Thanx in advance!
Kim
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kim,
There is an overriding rule that you don't follow in your first example:
The overriding method must not throw any new or broader checked exception, though it can throw narrower or fewer exceptions.
The second example compiles because RemoteException is an IOException (a narrower one).
Regards,
Phil.
[ March 20, 2004: Message edited by: Philippe Maquet ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic