aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorchibash <chiba@javassist.org>2017-11-15 07:02:05 +0900
committerchibash <chiba@javassist.org>2017-11-15 07:02:05 +0900
commit40d3223b128887dffafb8d6f28438628ad72e039 (patch)
tree9767c69e56b4fb49d22c877b06f353ae6f278d77 /src/test
parentbdc2b3784c99c5ca54a549af8f2015aaa15699dd (diff)
downloadjavassist-40d3223b128887dffafb8d6f28438628ad72e039.tar.gz
javassist-40d3223b128887dffafb8d6f28438628ad72e039.zip
fixes a bug reported in issue #155 (Javassist Incorrect Code when wrapping with try/catch)
Diffstat (limited to 'src/test')
-rw-r--r--src/test/javassist/JvstTest5.java17
-rw-r--r--src/test/test5/Issue155.java22
2 files changed, 39 insertions, 0 deletions
diff --git a/src/test/javassist/JvstTest5.java b/src/test/javassist/JvstTest5.java
index e7fdb28c..6f6eb075 100644
--- a/src/test/javassist/JvstTest5.java
+++ b/src/test/javassist/JvstTest5.java
@@ -10,6 +10,7 @@ import javassist.bytecode.ClassFile;
import javassist.bytecode.ConstPool;
import javassist.bytecode.InnerClassesAttribute;
import javassist.expr.ExprEditor;
+import javassist.expr.Handler;
import javassist.expr.MethodCall;
@SuppressWarnings({"rawtypes","unchecked","unused"})
@@ -399,4 +400,20 @@ public class JvstTest5 extends JvstTestRoot {
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"));
+ }
}
diff --git a/src/test/test5/Issue155.java b/src/test/test5/Issue155.java
new file mode 100644
index 00000000..3782e10d
--- /dev/null
+++ b/src/test/test5/Issue155.java
@@ -0,0 +1,22 @@
+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();
+ }
+}