The reason of that exception is that $_ is not initialized if an OutOfMemoryError exception is thrown.
So the problem should be fixed if you assign some value to $_ in the catch block.
I have also modified Javassist so that $_ is automatically initialized. If you use Javassist directly downloaded from the CVS head (or use an upcoming beta 3 or later), your code above should run without any problem.
During last week I made instrumentaton of a large project.
And some time I have seen java.lang.VerifyError at run time.
Is it posible to run code verification before saving class file?
I'm putting error checking code to avoid
wrong instrumentation, but it is not a simple
thing to produce useful error messages.
Also, I have to consider the range of possible
instrumentation. For example, changing
a public method to be private would cause
VerifyError if some methods in another
class access that method. Detecting this
error before saving a class file is a complicated
task under the current architecture of Javassist.
It would be great if you give me back your
experiences of VerifyError. I can improve
erorr checking code.