Well, that is a matter of opinion. But I do not believe that you should do it. Firstly, your logic distorts the meaning of exception handling (exceptions for "exceptions" are not for logic), other programmers will have problems interpreting your code.
In addition, you should not catch "Erros", which indicate problems while working in the environment. You should ask yourself if you should forget about good practices. Perhaps you could try to tweak the runtime configuration to fit the application or add additional validation logic ... your call is there ... but since security is being considered, you cannot say that everything is fine, as we donβt know like the state of the stack now, and different JRE implementations may vary there.
Finally, for the question at the bottom: this is bad practice, and it is not safe.
Quote from https://softwareengineering.stackexchange.com/questions/209099/is-it-ever-okay-to-catch-stackoverflowerrorror-in-java :
Of course, there are situations when a stack overflow can leave an application inconsistent, like running out of memory. Imagine that some object is constructed and then initialized using nested calls of internal methods - if one of them throws, the object may well be in a state that should not be possible, just as if the distribution was unsuccessful. But this does not mean that your decision cannot be the best.
This has a reason to be called Error, not Exception ...
From the docs:
open abstract class VirtualMachineError extends Error: It is thrown to indicate that the Java virtual machine is damaged or it does not have enough resources necessary to continue working
public class Error extends Throwable: Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most of these errors are abnormal conditions. The ThreadDeath error, although it is a βnormalβ condition, is also a subclass of Error, since most applications should not try to catch it. The method is not required to declare in the throws property any subclasses of Error that may be thrown during the execution of the method, but not caught, because these errors are abnormal conditions that should never occur. That is, the error and its subclasses are considered as unchecked exceptions for the purpose of checking compile-time exceptions.