title: how to dump a stacktrace when a specific Java method is called?
body: <p>We need to debug a Java application that randomly does stuff it should not do.</p>
  
  <p>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 <code>Thread.dumpStack()</code> 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).</p>
  
  <p>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?</p>
  
  <p>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.</p>
  
  <p>Thank you for your input.</p>