title: Add user-specified information to java stack traces
body: <p>Is there a way to add additional information to a java stacktrace?</p>
  
  <p>I am developing an interpreter for a script language and would like to see the corresponding lines of script code in the java stacktrace.</p>
  
  <p>The output could look something like this:</p>
  
  <pre><code>java.lang.NullPointerException 
  at package.IPF_Try.execute(IPF_Try.java:76) called in script.scr:155
  at package.IPF_Block.execute(IPF_Block.java:304) 
  at package.IPF_If.execute(IPF_If.java:105)  called in script.scr:130
  at package.IPF_Block.execute(IPF_Block.java:304) 
  at package.IPF_Main.execute(IPF_Main.java:147) 
  ...
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code>java.lang.NullPointerException 
  at package.IPF_Try.execute(IPF_Try.java:76)
    --- called in script.scr:155 ---
  at package.IPF_Block.execute(IPF_Block.java:304) 
  at package.IPF_If.execute(IPF_If.java:105)
   --- called in script.scr:130---
  at package.IPF_Block.execute(IPF_Block.java:304) 
  at package.IPF_Main.execute(IPF_Main.java:147) 
  ...
  </code></pre>
  
  <p>This would make debugging a lot easier, unfortunately google could not find anything to achieve this.</p>
  
  <p>The only way I could think of was to dynamlically generate a lot of classes with methods, whose name contains the information I need and which simply call the next method in the stacktrace - but that seems like a waste of (permgen) memory and cpu cycles to me.</p>