How do I make the JVM exit on ANY OutOfMemoryException even when bad people try to catch it

后端 未结 10 564
醉梦人生
醉梦人生 2020-12-09 16:32

An OOME is of the class of errors which generally you shouldn\'t recover from. But if it is buried in a thread, or someone catches it, it is possible for an application to g

10条回答
  •  清歌不尽
    2020-12-09 16:50

    1. edit OutOfMemoryError.java, add System.exit() in its constructors.

    2. compile it. (interestingly javac doesn't care it's in package java.lang)

    3. add the class into JRE rt.jar

    4. now jvm will use this new class. (evil laughs)

    This is a possibility you might want to be aware of. Whether it's a good idea, or even legal, is another question.

提交回复
热议问题