Is it possible to save the state of the call stack during execution and later restore the stack to that state, restarting at the top-most method call?
I strongly suggest to change your paradigm. Instead of manipulating the call stack (and very probably corrupting your JVM), think about incorporating the "call stack" somehow in your algorithm.
You may use the Strategy/Command/Undo design pattern and store the objects to your own logical stack, over which you have full control.
There is a related question Way to go from recursion to iteration with a lot of good answers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With