diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2005-03-02 03:42:10 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2005-03-02 03:42:10 +0000 |
commit | 13ecd1542cc38d7a4699006ad9d7471fa224be0b (patch) | |
tree | b9bd4fa46eb167071e6b457a6f296a0931c87aa6 | |
parent | bf8c6f9ca9884e77b0ea328a7b49a008f7f84c39 (diff) | |
download | javassist-13ecd1542cc38d7a4699006ad9d7471fa224be0b.tar.gz javassist-13ecd1542cc38d7a4699006ad9d7471fa224be0b.zip |
fixed a bug of CtBehavior.insertAt (and a few other minor fixes)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@162 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r-- | Readme.html | 7 | ||||
-rw-r--r-- | src/main/javassist/CtBehavior.java | 7 | ||||
-rw-r--r-- | src/main/javassist/compiler/Javac.java | 19 | ||||
-rw-r--r-- | tutorial/tutorial.html | 4 | ||||
-rw-r--r-- | tutorial/tutorial2.html | 2 | ||||
-rw-r--r-- | tutorial/tutorial3.html | 18 |
6 files changed, 49 insertions, 8 deletions
diff --git a/Readme.html b/Readme.html index a707843a..913f8f84 100644 --- a/Readme.html +++ b/Readme.html @@ -255,6 +255,11 @@ see javassist.Dump. <h2>Changes</h2> +<p>- version 3.1 + +<ul> +</ul> + <p>- version 3.0 in January 18, 2005 <ul> @@ -578,7 +583,7 @@ Denis Taye, Colin Sampaleanu, Robert Bialek, Asato Shimotaki, Howard Lewis Ship, Richard Jones, Marjan Sterjev, Bruce McDonald, Mark Brennan, Vlad Skarzhevskyy, Brett Randall, Tsuyoshi Murakami, Nathan Meyers, Yoshiyuki Usui -Yutaka Sunaga, and Arjan van der Meer +Yutaka Sunaga, Arjan van der Meer, and Bruce Eckel for their contributions. <p><br> diff --git a/src/main/javassist/CtBehavior.java b/src/main/javassist/CtBehavior.java index 92759e6f..7bde7ae6 100644 --- a/src/main/javassist/CtBehavior.java +++ b/src/main/javassist/CtBehavior.java @@ -799,10 +799,12 @@ public abstract class CtBehavior extends CtMember { jv.recordLocalVariables(ca, index); jv.recordParams(getParameterTypes(), Modifier.isStatic(getModifiers())); + jv.setMaxLocals(ca.getMaxLocals()); jv.compileStmnt(src); Bytecode b = jv.getBytecode(); - int stack = b.getMaxStack(); int locals = b.getMaxLocals(); + int stack = b.getMaxStack(); + ca.setMaxLocals(locals); /* We assume that there is no values in the operand stack * at the position where the bytecode is inserted. @@ -810,9 +812,6 @@ public abstract class CtBehavior extends CtMember { if (stack > ca.getMaxStack()) ca.setMaxStack(stack); - if (locals > ca.getMaxLocals()) - ca.setMaxLocals(locals); - iterator.insert(index, b.get()); iterator.insert(b.getExceptionTable(), index); return lineNum; diff --git a/src/main/javassist/compiler/Javac.java b/src/main/javassist/compiler/Javac.java index abeb8290..88ed0ab5 100644 --- a/src/main/javassist/compiler/Javac.java +++ b/src/main/javassist/compiler/Javac.java @@ -201,6 +201,10 @@ public class Javac { Parser p = new Parser(new Lex(src)); SymbolTable stb = new SymbolTable(stable); Stmnt s = p.parseStatement(stb); + if (p.hasMore()) + throw new CompileError( + "the method/constructor body must be surrounded by {}"); + boolean callSuper = false; if (method instanceof CtConstructor) callSuper = !((CtConstructor)method).isClassInitializer(); @@ -311,6 +315,7 @@ public class Javac { * <p>This must be called before calling <code>compileStmnt()</code> and * <code>compileExpr()</code>. The correct value of * <code>isStatic</code> must be recorded before compilation. + * <code>maxLocals</code> is updated to include $0,... */ public int recordParams(CtClass[] params, boolean isStatic) throws CompileError @@ -328,6 +333,7 @@ public class Javac { * <p>This must be called before calling <code>compileStmnt()</code> and * <code>compileExpr()</code>. The correct value of * <code>isStatic</code> must be recorded before compilation. + * <code>maxLocals</code> is updated to include $0,... * * @paaram use0 true if $0 is used. * @param varNo the register number of $0 (use0 is true) @@ -347,6 +353,19 @@ public class Javac { } /** + * Sets <code>maxLocals</code> to <code>max</code>. + * This method tells the compiler the local variables that have been + * allocated for the rest of the code. When the compiler needs + * new local variables, the local variables at the index <code>max</code>, + * <code>max + 1</code>, ... are assigned. + * + * <p>This method is indirectly called by <code>recordParams</code>. + */ + public void setMaxLocals(int max) { + gen.setMaxLocals(max); + } + + /** * Prepares to use cast $r, $w, $_, and $type. * $type is made to represent the specified return type. * It also enables to write a return statement with a return value diff --git a/tutorial/tutorial.html b/tutorial/tutorial.html index 9e27fe28..4cbf6821 100644 --- a/tutorial/tutorial.html +++ b/tutorial/tutorial.html @@ -130,6 +130,8 @@ example, the data of method bodies. Thus, after a <code>CtClass</code> object is pruned, the bytecode of a method is not accessible although method names and signatures are accessible. +<p>(Note: the current version of Javassist turns pruning off by default.) + <p>To disallow pruning a <code>CtClass</code>, <code>stopPruning()</code> must be called in advance: @@ -1001,6 +1003,6 @@ binary code license.</i> <hr> Java(TM) is a trademark of Sun Microsystems, Inc.<br> -Copyright (C) 2000-2004 by Shigeru Chiba, All rights reserved. +Copyright (C) 2000-2005 by Shigeru Chiba, All rights reserved. </body> </html> diff --git a/tutorial/tutorial2.html b/tutorial/tutorial2.html index abac129a..6bc3d50b 100644 --- a/tutorial/tutorial2.html +++ b/tutorial/tutorial2.html @@ -1466,6 +1466,6 @@ write: <hr> Java(TM) is a trademark of Sun Microsystems, Inc.<br> -Copyright (C) 2000-2004 by Shigeru Chiba, All rights reserved. +Copyright (C) 2000-2005 by Shigeru Chiba, All rights reserved. </body> </html> diff --git a/tutorial/tutorial3.html b/tutorial/tutorial3.html index 635e01b6..f19e5c0d 100644 --- a/tutorial/tutorial3.html +++ b/tutorial/tutorial3.html @@ -18,6 +18,7 @@ <br><li><a href="#member">Adding and removing a member</a> <br><li><a href="#traverse">Traversing a method body</a> <br><li><a href="#bytecode">Producing a bytecode sequence</a> +<br><li><a href="#annotation">Annotations (Meta tags)</a> </ul> @@ -192,10 +193,25 @@ call <code>computeMaxStack()</code> in <code>CodeAttribute</code>. <p><br> +<a name="annotation"> +<h3>5.5 Annotations (Meta tags)</h3> + +<p>Annotations are stored in a class file +as runtime invisible (or visible) annotations attribute. +These attributes can be obtained from <code>ClassFile</code>, +<code>MethodInfo</code>, or <code>FieldInfo</code> objects. +Call <code>getAttribute(AnnotationsAttribute.invisibleTag)</code> +on those objects. For more details, see the javadoc manual +of <code>javassist.bytecode.AnnotationsAttribute</code> class +and the <code>javassist.bytecode.annotation</code> package. + + +<p><br> + <a href="tutorial2.html">Previous page</a> <hr> Java(TM) is a trademark of Sun Microsystems, Inc.<br> -Copyright (C) 2000-2004 by Shigeru Chiba, All rights reserved. +Copyright (C) 2000-2005 by Shigeru Chiba, All rights reserved. </body> </html> |