From: chiba Date: Tue, 14 Apr 2009 00:37:13 +0000 (+0000) Subject: improved the extensibility of CodeConverter X-Git-Tag: rel_3_17_1_ga~170 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=780069f8d4312a88ad580b16cc656b69ec3e23ba;p=javassist.git improved the extensibility of CodeConverter git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@477 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- diff --git a/src/main/javassist/CodeConverter.java b/src/main/javassist/CodeConverter.java index 91f5657a..44881d5d 100644 --- a/src/main/javassist/CodeConverter.java +++ b/src/main/javassist/CodeConverter.java @@ -512,16 +512,25 @@ public class CodeConverter { } int locals = 0; + int stack = 0; for (t = transformers; t != null; t = t.getNext()) { int s = t.extraLocals(); if (s > locals) locals = s; + + s = t.extraStack(); + if (s > stack) + stack = s; } for (t = transformers; t != null; t = t.getNext()) t.clean(); - codeAttr.setMaxLocals(codeAttr.getMaxLocals() + locals); + if (locals > 0) + codeAttr.setMaxLocals(codeAttr.getMaxLocals() + locals); + + if (stack > 0) + codeAttr.setMaxStack(codeAttr.getMaxStack() + stack); } /** @@ -529,7 +538,7 @@ public class CodeConverter { * as array access replacements. * * @author Kabir Khan - * @version $Revision: 1.15 $ + * @version $Revision: 1.16 $ */ public interface ArrayAccessReplacementMethodNames { @@ -638,7 +647,7 @@ public class CodeConverter { * accesses to array elements. * * @author Kabir Khan - * @version $Revision: 1.15 $ + * @version $Revision: 1.16 $ */ public static class DefaultArrayAccessReplacementMethodNames implements ArrayAccessReplacementMethodNames diff --git a/src/main/javassist/convert/Transformer.java b/src/main/javassist/convert/Transformer.java index 1095cf5b..4dd38075 100644 --- a/src/main/javassist/convert/Transformer.java +++ b/src/main/javassist/convert/Transformer.java @@ -51,4 +51,6 @@ public abstract class Transformer implements Opcode { ConstPool cp) throws CannotCompileException, BadBytecode; public int extraLocals() { return 0; } + + public int extraStack() { return 0; } }