Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can System.exit() return without terminating the JVM?

Tags:

java

jvm

In practice of course it is very unlikely to happen, but: Is there any reason for this method call not to terminate the JVM?

Is it possible for example, that an OutOfMemoryError is thrown immediately after (or while) calling System.exit(0) or that a StackOverflowError occurs when calling this method, because the stack is just overflowing in that moment?

like image 652
Ercksen Avatar asked Jan 07 '23 04:01

Ercksen


1 Answers

Is there any reason for this method call not to terminate the JVM?

Yes.

From the docs:

Throws:

SecurityException - if a security manager exists and its checkExit method doesn't allow exit with the specified status.

like image 59
resueman Avatar answered Jan 12 '23 00:01

resueman