Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Additional runtime exceptions in DB interface

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

Maybe I'm paranoid, but:

My DB interface has these methods:

and these cannot be changed. I would like to throw IllegalArgumentException for find() and update() if criteria or data length is not equal to number of fields in file.
But can I do that in my implementation class? update() and unlock() explictly define SecurityException, which is a runtime exception, so throwing additional runtime exceptions seems to be violation of specification. Am I right or wrong?
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RuntimeExceptions don't need to be declared in the throws clause of a method, nor do they need to be mentioned in the Javadoc.

IOW, you can throw them from an implementing class without changing the interface definition.

You will possibly also find that you will need to throw additional checked exceptions (somewhat dependent upon your design decisions) which will require a different solution, as you can indeed not change this particular interface (but the assignment says nothing about implementing it DIRECTLY, which should give you a hint as to a possible solution for that).
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!