You only need to subclass the exception if applications need to catch and handle different cases differently. But you should not fish and try to fully recover from these cases ... therefore, the need should not arise.
... but yes, I would still like to have a more descriptive cause of death on me.
The exception message indicates which of the OOME subnets has occurred. If you complain that the messages are too short, the role of exception messages in Java does not fully explain the problem they are reporting. What are javadocs and other documentation for?
@ Thorbjørn presents an equally convincing argument. In principle, different sub-services are implementation specific. Providing them with some of the standard API risks that limit the implementation of the JVM to do things in suboptimal ways to meet API requirements. And this approach risks creating unnecessary application portability barriers when creating new subclasses for new implementation-specific tweaks.
(For example, the hypothetical UnableToCreateNativeThreadError 1) assumes that thread creation failed due to lack of memory and 2) the lack of memory is qualitatively different from the normal amount of memory. 2) applies to existing Oracle JVMs, but not to all JVMs. 1) may not even be true for existing Oracle JVM devices. Creating a theme may fail due to the limited OS limit on the number of native threads.)
If you're wondering why it's a bad idea to try and recover from OOME, see the following questions:
source share