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

deadly diamond of death syndrome :)

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, have a look:


The second one:


Compiler allows you to declare the common exception from within multiple interfaces. If the interfaces' exceptions are uncommon you will not be allowed to declare any checked exception.

I only wanted to figure this out.
Correct me if I am wrong.

 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That makes sense

For common exception hierarchies




If InterfaceC is allowed to throw IOException then a statement like InterfaceB ref = new SubClassThatThrowsIOExAndImplementsC(); will get into trouble since the Exception scope does not allow this. IOException is wider than FileNotFoundException and the InterfaceB contract only allows you to throw FileNotFoundException

So InterfaceC can only throw FileNotFoundException

For the scenario



InterfaceC is in trouble. For case



So InterfaceC cannot throw anything, since the contract provided by InterfaceA or InterfaceB can be broken

Does that make sense ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic