You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by md...@apache.org on 2001/12/14 19:32:54 UTC
cvs commit: jakarta-bcel/src/java/org/apache/bcel/generic LocalVariableGen.java
mdahm 01/12/14 10:32:54
Modified: src/java/org/apache/bcel/generic LocalVariableGen.java
Log:
For local variables whose scope end at the last
instruction of the method's code, the JVM specification is ambiguous.
Revision Changes Path
1.2 +11 -1 jakarta-bcel/src/java/org/apache/bcel/generic/LocalVariableGen.java
Index: LocalVariableGen.java
===================================================================
RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/generic/LocalVariableGen.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LocalVariableGen.java 2001/10/29 20:00:23 1.1
+++ LocalVariableGen.java 2001/12/14 18:32:54 1.2
@@ -63,7 +63,7 @@
* with getLocalVariable which needs the instruction list and the constant
* pool as parameters.
*
- * @version $Id: LocalVariableGen.java,v 1.1 2001/10/29 20:00:23 jvanzyl Exp $
+ * @version $Id: LocalVariableGen.java,v 1.2 2001/12/14 18:32:54 mdahm Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @see LocalVariable
* @see MethodGen
@@ -102,12 +102,22 @@
* This relies on that the instruction list has already been dumped to byte code or
* or that the `setPositions' methods has been called for the instruction list.
*
+ * Note that for local variables whose scope end at the last
+ * instruction of the method's code, the JVM specification is ambiguous:
+ * both a start_pc+length ending at the last instruction and
+ * start_pc+length ending at first index beyond the end of the code are
+ * valid.
+ *
* @param il instruction list (byte code) which this variable belongs to
* @param cp constant pool
*/
public LocalVariable getLocalVariable(ConstantPoolGen cp) {
int start_pc = start.getPosition();
int length = end.getPosition() - start_pc;
+
+ if(length > 0)
+ length += end.getInstruction().getLength();
+
int name_index = cp.addUtf8(name);
int signature_index = cp.addUtf8(type.getSignature());
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>