Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

NX: Error overriding interface method.

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic