This is very odd to me. RuntimeException
inherits from Exception
, which inherits from Throwable
.
catch(Exception exc)
The premise of the question is flawed, because catching Exception
does catch RuntimeException
. Demo code:
public class Test {
public static void main(String[] args) {
try {
throw new RuntimeException("Bang");
} catch (Exception e) {
System.out.println("I caught: " + e);
}
}
}
Output:
I caught: java.lang.RuntimeException: Bang
Your loop will have problems if:
callbacks
is nullcallbacks
while the loop is executing (if it were a collection rather than an array)Perhaps that's what you're seeing?