-
1. Re: addCatch doesn't work
chiba Dec 9, 2004 10:52 AM (in response to rezahay)Ah...
Can you do
method.addCatch("{return;}", expClass);
and make sure it works?
There is a note in both the tutorial and the javadoc.Note that the inserted code fragment must end with a throw or return statement.
Thank you! -
2. Re: addCatch doesn't work
rezahay Dec 10, 2004 7:46 AM (in response to rezahay)Thank you very, chiba for your response. I used {return;} and it works. But if there are methods with non-void return types then {return;} is not enough. Therefore I used (within my addCatch) {Object result; return ($r)result;}. But I get the following javassist compiler error:
==============================================
javassist.CannotCompileException: [source error] no such class: $r
at javassist.CtBehavior.addCatch(CtBehavior.java:722)
at javassist.CtBehavior.addCatch(CtBehavior.java:670)
==============================================
It seems that the javassist compiler doesn't recognize $r. Is it not allowed to use $r in the addCatch? Or do I do something wrong?
Thanks in advance -
3. Re: addCatch doesn't work
chiba Dec 13, 2004 9:02 AM (in response to rezahay)I think it's a bug of Javassist.
I'll fix this bug within a few days. Please wait for a while.
(Fixing that bug seems very easy but it takes time to write
test code etc. I could not have time to do it today.)