From: chiba Date: Fri, 12 Apr 2013 09:21:45 +0000 (+0000) Subject: fixed JASSIST-186 X-Git-Tag: log~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d5500a2a6f5703f10a703ad6498e28c52c367104;p=javassist.git fixed JASSIST-186 git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@702 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java index 28697715..f34a565a 100644 --- a/src/main/javassist/CtClass.java +++ b/src/main/javassist/CtClass.java @@ -69,7 +69,7 @@ public abstract class CtClass { /** * The version number of this release. */ - public static final String version = "3.17.1-GA"; + public static final String version = "3.18.0-GA"; /** * Prints the version number and the copyright notice. @@ -80,7 +80,7 @@ public abstract class CtClass { */ public static void main(String[] args) { System.out.println("Javassist version " + CtClass.version); - System.out.println("Copyright (C) 1999-2012 Shigeru Chiba." + System.out.println("Copyright (C) 1999-2013 Shigeru Chiba." + " All Rights Reserved."); } diff --git a/src/main/javassist/bytecode/Bytecode.java b/src/main/javassist/bytecode/Bytecode.java index bea7b6fa..fb4d3ec9 100644 --- a/src/main/javassist/bytecode/Bytecode.java +++ b/src/main/javassist/bytecode/Bytecode.java @@ -1083,7 +1083,7 @@ public class Bytecode extends ByteVector implements Cloneable, Opcode { public void addInvokevirtual(int clazz, String name, String desc) { add(INVOKEVIRTUAL); addIndex(constPool.addMethodrefInfo(clazz, name, desc)); - growStack(Descriptor.dataSize(desc)); // assume CosntPool#REF_invokeStatic + growStack(Descriptor.dataSize(desc) - 1); } /** @@ -1170,7 +1170,7 @@ public class Bytecode extends ByteVector implements Cloneable, Opcode { add(INVOKEDYNAMIC); addIndex(dyn); add(0, 0); - growStack(Descriptor.dataSize(desc) - 1); + growStack(Descriptor.dataSize(desc)); // assume ConstPool#REF_invokeStatic } /** diff --git a/src/test/javassist/JvstTest4.java b/src/test/javassist/JvstTest4.java index 7cf6178a..768b7400 100644 --- a/src/test/javassist/JvstTest4.java +++ b/src/test/javassist/JvstTest4.java @@ -817,4 +817,15 @@ public class JvstTest4 extends JvstTestRoot { assertEquals(10, invoke(obj, "test33")); assertEquals(100, invoke(obj, "test44")); } + + public void testJIRA186() throws Exception { + CtClass cc = sloader.get("test4.JIRA186"); + cc.getDeclaredMethod("test").insertBefore("{" + + " java.util.List l = new java.util.ArrayList();" + + " l.add(this.toString());" + + "}"); + cc.writeFile(); + Object obj = make(cc.getName()); + assertEquals(1, invoke(obj, "test")); + } }