Wednesday, 10 December 2008

Exceptions to Java java.lang.Exceptions

The compile error: "unreported exception java.lang.Exception; must be caught or declared to be thrown" forces you to add a throws clause to a method that can throw an exception.

That's not the end of the story. If this class overrides an interface method, the throws clause must be declared at the interface level. Using Eclipse compiler it gives: "Exception is not compatible with throws clause in Interface.method()". Using Sun compiler you get a slightly different message but the intent is the same. Irritating.

No comments:

Blog Archive