The given java code is not going to the finally block, I thought these blocks were supposed to execute no matter what:
public static void main(String[] args) {
try {
System.out.println("Hello world");
System.exit(0);
} finally {
System.out.println("Goodbye world");
}
}
As stated in the Java 6
System.exit()docs:And, if you go and look at
Runtime.exit()(my bold):Basically, the only one this function can return (and hence allow the
finallyclause to run) is for it to raise aSecurityExceptionbecause whatever security manager is running disallows exiting with the given code.