When I run the code below, an OutOfMemoryError is raised, but it is not caught, despite the fact that there are sentences that should catch it:
public class SomeClass { public static void main(String[] args) { try {
The output is as follows:
'Finally' clause triggered Exception in thread "main" Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"
The fact that the exception is not caught makes no sense to me. The OutOfMemoryError documentation confirms that the exception must be caught by either Throwable, Error, or OutOfMemoryError. (Note that the qualifier βjava.lang.β Does not affect behavior.)
All other questions that I saw here in StackOverflow line by line "Why is it possible that OutOfMemoryError Out is thrown out?" were sent by people who only caught Exception objects, not Error or Throwable.
Any idea on what's going on?
source share