aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/javassist/JvstTest5.java
diff options
context:
space:
mode:
authorchibash <chiba@javassist.org>2019-01-28 01:35:21 +0900
committerchibash <chiba@javassist.org>2019-01-28 01:35:21 +0900
commit6ea8021f1517ee2923bd5d50dc466594ac7f68bf (patch)
tree184033445d1926d0313916beb8ffdb686c696344 /src/test/javassist/JvstTest5.java
parent576b141e43b5fc3506f3a57ee4d5583486ec49a0 (diff)
downloadjavassist-6ea8021f1517ee2923bd5d50dc466594ac7f68bf.tar.gz
javassist-6ea8021f1517ee2923bd5d50dc466594ac7f68bf.zip
fixes the bug reported in Issue #241.
It makes $r available in the code given to CtBehavior#insertBefore().
Diffstat (limited to 'src/test/javassist/JvstTest5.java')
-rw-r--r--src/test/javassist/JvstTest5.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/javassist/JvstTest5.java b/src/test/javassist/JvstTest5.java
index 1a9bd666..915e1e1a 100644
--- a/src/test/javassist/JvstTest5.java
+++ b/src/test/javassist/JvstTest5.java
@@ -484,4 +484,18 @@ public class JvstTest5 extends JvstTestRoot {
Object obj = make(cc.getName());
assertEquals(1, invoke(obj, "run"));
}
+
+ // Issue #241
+ public void testInsertBeforeAndDollarR() throws Exception {
+ CtClass cc = sloader.get(test5.InsertBeforeDollarR.class.getName());
+ CtMethod m = cc.getDeclaredMethod("foo");
+ m.insertBefore("{ if ($1 == 1) return ($r)$2; }");
+ try {
+ m.insertBefore("{ $_ = \"bar\"; }");
+ assertTrue(false);
+ } catch (CannotCompileException e) {}
+ cc.writeFile();
+ Object obj = make(cc.getName());
+ assertEquals(1, invoke(obj, "run"));
+ }
}