Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DvdDatabaseImpl implementing DvdDatabaseRemote

 
Gareth Llewellyn
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question for Andrew Monkhouse:
In SCJD Exam with J2SE 5, Second Edition

By implementing DvdDatabaseRemote, the DvdDatabaseImpl class is required to implement its super interface, DBClient. Trouble is, DvdDatabaseImpl throws new and broader checked exceptions than the interface its implementing - which is not allowed - and indeed the compiler prevents.

How can DvdDatabaseImpl implement DvdDatabaseRemote (and therefore DBClient) and still throw the RemoteExceptions required by the Remote interface?

Naturally we are trying to achieve some factory class (in the book's case, individual DvdConnector classes rather than a factory) returning DBClient objects. But given the above problem, DvdDatabaseImpl CAN'T implement DBClient...
...I guess I must be missing something in the implementation.
 
Gareth Llewellyn
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay, so I've answered my own question, but RemoteException is not broader than the base DBClient's thrown IOException - it's a child of IOException, so the code will compile and we are not obliged to declare RemoteException explicity.
Sorry to waste space on the forum!

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.io.IOException
java.rmi.RemoteException
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic