I think there is a way to do this with SecurityManager, but I don't want to introduce it in an App just for this.
Is there a way to catch and log stacktrace of what called exit() using some other solution?
I think there is a way to do this with SecurityManager, but I don't want to introduce it in an App just for this.
Is there a way to catch and log stacktrace of what called exit() using some other solution?
How about using shutdown hook? It could be like this:
You can add this code somewhere in your application (where it will be executed). Then on shutdown
printStackTracesOnShutdownHookwill write to logs all stackTraces. And you will be able to find from these stackTraces whereSystem.exit()was called.