I’m attempting to write a junit test to guard against a piece of code getting stuck in a endless iteration which will eventually cause a StackOverflow.
so i’m looking for a way to decrease the stack size at runtime so the Junittest will fail faster.
setting the max stack as a jvm argument is not possible because the test is part of a much larger test suite.
You could run a recursive method which will run itself a given number of times and then execute a given action. Sounds pretty flaky though 🙁
Something like:
EDIT: It’s possible that smart JVMs will optimise the tail call here, so it may be that we’d need to do “something” after the recursive call to stop that from happening…
Ick ‘n stuff 🙁