We need to debug a Java application that randomly does stuff it should not do.
To understand the root cause of the issue, we would need to get a stacktrace whenever a specific method is called. This sounds easy (add Thread.dumpStack() in this specific method), however this is a code class from the JDK, hence we do not really want to mess with it (even if we indeed could).
Does anybody know if we can implement some kind of "listener" in the JVM that would detect when a specific method is called and dump the stack trace?
This is a production system, so if the solution is a debugger we would need to have something that has very limited impact on performance.
Thank you for your input.