diff options
author | chibash <chiba@javassist.org> | 2015-01-25 18:16:48 +0900 |
---|---|---|
committer | chibash <chiba@javassist.org> | 2015-01-25 18:16:48 +0900 |
commit | e59339343a538699b632bd9fa0cf4f251ab6f3ee (patch) | |
tree | 3a0f9f1c3d8d9058a787057b519377f43d3e1775 /src/test/test5 | |
parent | e8c023af06f04877ccc83911c6f6900574486a6c (diff) | |
download | javassist-e59339343a538699b632bd9fa0cf4f251ab6f3ee.tar.gz javassist-e59339343a538699b632bd9fa0cf4f251ab6f3ee.zip |
fixed JIRA JASSIST-241
Diffstat (limited to 'src/test/test5')
-rw-r--r-- | src/test/test5/JIRA241.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/test5/JIRA241.java b/src/test/test5/JIRA241.java new file mode 100644 index 00000000..e6f8e957 --- /dev/null +++ b/src/test/test5/JIRA241.java @@ -0,0 +1,33 @@ +package test5; + +import java.util.Random; +import javassist.*; + +public class JIRA241 { + public int run() { + test(this); + return 10; + } + + public static void test(Object o) { + //part 1 + if (o == null) { + return; + } + + //part 2 + int oper = new Random().nextInt(); + switch (oper) { + case 1: + break; + } + } + + public static void main(String[] args) throws Exception { + ClassPool pool = ClassPool.getDefault(); + CtClass cc = pool.get("test5.JIRA241"); + CtMethod testMethod = cc.getMethod("test", "(Ljava/lang/Object;)V"); + testMethod.insertAfter("System.out.println(\"inserted!\");"); + cc.writeFile(); + } +} |