title: java ASM create try catch dynamic
body: <p>I have to instrument a java class file by changing some instructions. More precisely, goto instructions have to be replaced with invokestatic instructions. Now the method that is called with invokestatic can throw an exception but in the original code there is (of course) no try/catch.</p>
  
  <p>Is it somehow possible with ASM to put a try/catch around that new invokestatic instruction?
  (The goal is to add a goto in the catch and redirect the flow to the target of the original goto, as if nothing has happened)</p>
  
  <p>I have already tried to achieve this with Javassist but was not able to do get it working. There are quite some things to consider, like a updated exception table, new stack frames, a changed amount of locals and maybe even more. My hope is that ASM can simplify all this.</p>
  
  <p>Any help would be greatly appreciated.</p>