import javassist.bytecode.ConstPool;
import javassist.bytecode.InnerClassesAttribute;
import javassist.expr.ExprEditor;
+import javassist.expr.Handler;
import javassist.expr.MethodCall;
@SuppressWarnings({"rawtypes","unchecked","unused"})
assertTrue(Modifier.isVarArgs(cc.getDeclaredMethod("foo").getModifiers()));
assertFalse(Modifier.isVarArgs(cc.getDeclaredMethod("bar").getModifiers()));
}
+
+ public void testIssue155() throws Exception {
+ CtClass cc = sloader.get("test5.Issue155");
+ CtMethod testMethod = cc.getDeclaredMethod("foo");
+ testMethod.instrument(
+ new ExprEditor() {
+ public void edit(Handler m)
+ throws CannotCompileException {
+ m.insertBefore("throw $1;");
+ }
+ });
+
+ cc.writeFile();
+ Object obj = make(cc.getName());
+ assertEquals(1, invoke(obj, "test"));
+ }
}
--- /dev/null
+package test5;
+
+public class Issue155 {
+ public void bar() {}
+
+ public void foo() throws Throwable {
+ try {
+ bar();
+ } catch (java.lang.IllegalArgumentException e) {
+ bar();
+ }
+ }
+
+ public int test() throws Throwable {
+ foo();
+ return 1;
+ }
+
+ public static void main(String[] args) throws Throwable {
+ new Issue155().foo();
+ }
+}