{ by david linsin }

September 07, 2009

No Improved Exception Handling

Last week Joe Darcy announced the Project Coin finalists. There will be 7 "improvements" to the Java Language for the upcoming JDK 7 release. Unfortunately, one of my favorite proposals "Improved Exception Handling" didn't make it. Don't worry, I promise this is not gonna be a rant post, rather my personal view on what I have to work with for the next couple of years.

I have to admit I was a little pissed at first, when I read, that "Improved Exception Handling" didn't get in. Especially, because it was one of the most requested proposals. However, after reading Joe's explanation on his blog, I do see, that it is not easy to prefer one proposal over the other:

Improved exception handling would be a fine change for the language, but it ventures near the type system and we do not estimate we have resources to fully develop the feature within JDK 7. I would like to see improved exception handling reconsidered in subsequent efforts to evolve the language.

At this point I would start the ranting on how Sun couldn't have enough resources, but I made a promise I wouldn't. There's another reason I shouldn't start ranting:

If there are frustrations waiting for Java language changes, I assure you there are also frustrations working on Java language changes. For example, I find it frustrating (and self-inconsistent) that people state "I don't have technical expertise in this area" while simultaneously expecting their preferences to be selected without any contribution on their part. [LINK]

I guess I am one of those frustrated people. I have no idea, if I lack the technical expertise, but what I do know is that I have enough technical expertise to judge that this is a PITA:

Statement stmt = null;
try {
// do stuff that uses Statement instance
} catch (SQLException e) {
// handle state
log.error("Bad database", e);
} catch (NullPointerException e) {
// handle state
log.error("Bad parameter", e);
} catch (Exception e) {
// handle state
log.error("Bad luck", e);
} finally {
try {
} catch (Exception ex) {}

It is quite irritating, that this is what Java developers have to work with for the next couple of years. It is annoying, that there is no standard in the Java Language addressing this problem. There might be workarounds or some OpenJDK whatever branch with a prototype hacked into it, which exactly solves this problem. In my opinion, that's not a solution whatsoever.

In order to reduce programming errors, I think the Java Language must address this problem with a standard solution like "Improved Exception Handling".



  • mail(dlinsin@gmail.com)
  • jabber(dlinsin@gmail.com)
  • skype(dlinsin)