The catch blocks for try-catch statements are generated inline. This means
that we can end up with a goto in the middle of a loop that does
a try-catch. This penalizes the use of try-catch even when it is not used.
Don't believe me? Compile and disassemble the following code:
public class TryLoop {
public static void foobar() throws Exception {
System.out.println("hello");
}
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
System.out.println(i);
try {
foobar();
} catch (Exception ee) {
System.out.println("Exception");
}
System.out.println(i);
}
}
}
that we can end up with a goto in the middle of a loop that does
a try-catch. This penalizes the use of try-catch even when it is not used.
Don't believe me? Compile and disassemble the following code:
public class TryLoop {
public static void foobar() throws Exception {
System.out.println("hello");
}
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
System.out.println(i);
try {
foobar();
} catch (Exception ee) {
System.out.println("Exception");
}
System.out.println(i);
}
}
}