{ by david linsin }

June 29, 2007

Return in finally


public class Test {

public static void main(String[] args) {
try {
doSomething();
System.out.println("yikes!");
} catch (RuntimeException e) {
System.out.println("got it.");
}
}

public static void doSomething() {
try {
//Normally you would have code that doesn't explicitly appear
//to throw exceptions so it would be harder to see the problem.
throw new RuntimeException();
} finally {
return;
}
}
}


I read this today and I though this was a really interesting corner case! The funny thing is that Eclipse IDE says that the finally block does not complete normally.

0 comments:


com_channels

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

recent_postings

loading...