<h2>Changes</h2>
+<p>- version 3.1
+
+<ul>
+</ul>
+
<p>- version 3.0 in January 18, 2005
<ul>
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>
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.
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;
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();
* <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
* <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)
use0, varNo, target, stable);
}
+ /**
+ * 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.
<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:
<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>
<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>
<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>
To recompute the maximum stack depth of a method body,
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>