diff options
-rw-r--r-- | Readme.html | 2 | ||||
-rw-r--r-- | javassist.jar | bin | 767009 -> 766876 bytes | |||
-rw-r--r-- | src/main/javassist/CtBehavior.java | 2 | ||||
-rw-r--r-- | src/test/javassist/JvstTest5.java | 14 | ||||
-rw-r--r-- | src/test/test5/InsertBeforeDollarR.java | 14 |
5 files changed, 30 insertions, 2 deletions
diff --git a/Readme.html b/Readme.html index f8f2e55d..dbc864f5 100644 --- a/Readme.html +++ b/Readme.html @@ -283,7 +283,7 @@ see javassist.Dump. <p>-version 3.25 <ul> - <li>GitHub Issue #72 (PR #231), #242 (PR #243). + <li>GitHub Issue #72 (PR #231), #241, #242 (PR #243). </ul> <p>-version 3.24.1 on December 9, 2018 diff --git a/javassist.jar b/javassist.jar Binary files differindex 89913dc5..c198d0e3 100644 --- a/javassist.jar +++ b/javassist.jar diff --git a/src/main/javassist/CtBehavior.java b/src/main/javassist/CtBehavior.java index 1b9dbf0b..a0738ec7 100644 --- a/src/main/javassist/CtBehavior.java +++ b/src/main/javassist/CtBehavior.java @@ -782,7 +782,7 @@ public abstract class CtBehavior extends CtMember { Modifier.isStatic(getModifiers())); jv.recordParamNames(ca, nvars); jv.recordLocalVariables(ca, 0); - jv.recordType(getReturnType0()); + jv.recordReturnType(getReturnType0(), false); jv.compileStmnt(src); Bytecode b = jv.getBytecode(); int stack = b.getMaxStack(); 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")); + } } diff --git a/src/test/test5/InsertBeforeDollarR.java b/src/test/test5/InsertBeforeDollarR.java new file mode 100644 index 00000000..a2c32aae --- /dev/null +++ b/src/test/test5/InsertBeforeDollarR.java @@ -0,0 +1,14 @@ +package test5; + +public class InsertBeforeDollarR { + public int run() { + if (foo(1, "baz").equals("baz")) + return 1; + else + return 0; + } + + public String foo(int i, Object obj) { + return String.valueOf(i); + } +} |