diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2011-10-18 16:10:30 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2011-10-18 16:10:30 +0000 |
commit | 85e2eebf17da1506fcdfe541261030e56253239c (patch) | |
tree | ba3ea4e0a45b3afae2e11a04a3db8599df7ebed9 /src/test | |
parent | 3ad4da6d8cd5f11a8009c70f59d613b52cf4b50d (diff) | |
download | javassist-85e2eebf17da1506fcdfe541261030e56253239c.tar.gz javassist-85e2eebf17da1506fcdfe541261030e56253239c.zip |
unit test for JASSIST-145
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@592 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/javassist/JvstTest4.java | 18 | ||||
-rw-r--r-- | src/test/test4/Aaload.java | 15 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/test/javassist/JvstTest4.java b/src/test/javassist/JvstTest4.java index 016420d9..9ea09743 100644 --- a/src/test/javassist/JvstTest4.java +++ b/src/test/javassist/JvstTest4.java @@ -492,6 +492,9 @@ public class JvstTest4 extends JvstTestRoot { cc = sloader.get("test4.NestedClass"); tab = cc.getNestedClasses(); + for (CtClass c: tab) { + System.err.println(c.getName()); + } assertEquals(4, tab.length); for (CtClass c: tab) { String name = c.getName(); @@ -560,10 +563,23 @@ public class JvstTest4 extends JvstTestRoot { fail("test4no was found!"); } catch (CannotCompileException e) { - System.err.println(e); + System.out.println(e); } cc.writeFile(); Object obj = make(cc.getName()); assertEquals(110, invoke(obj, "run")); } + + public void testAaload() throws Exception { + CtClass clazz = sloader.get("test4.Aaload"); + CtMethod method = clazz.getMethod("narf", "()V"); + method.instrument(new ExprEditor() { + @Override + public void edit(MethodCall call) throws CannotCompileException { + String name = call.getMethodName(); + if (name.equals("addActionListener")) + call.replace("$0." + name + "($$);"); + } + }); + } } diff --git a/src/test/test4/Aaload.java b/src/test/test4/Aaload.java new file mode 100644 index 00000000..5299b485 --- /dev/null +++ b/src/test/test4/Aaload.java @@ -0,0 +1,15 @@ +package test4; +import java.awt.MenuItem; + +public class Aaload { + static void narf() { + String[] list = null; + for (int i = 0; i < list.length; i++) { + String name = list[i]; + if (name.endsWith(".txt")) { + MenuItem item = new MenuItem(name); + item.addActionListener(null); + } + } + } +} |