Hi,
I'm having troubles adding ReturnaddressTypes to the LocalVariableTable.
For testing purposes I need to put some subroutines into my methods. To
do this I have written a program to inline a named method into all other
methods of the class which invoke that method using subroutines.
Note: javac output even for try{....}catch..finally seems to inline the
subroutine.
The problem I have is I am not able to add a ReturnaddressType to the
LocalVariableTable using:
method.addLocalVariable("RetAddress",
new
ReturnaddressType(ih.getNext()),
inlineInstList.getStart(),
inlineInstList.getEnd());
I need to declare a LocalVariable to hold the Returnaddress as the RET
instruction expects an index into the LocalVariableTable from which it
retrieves the returnaddress.
The exception thrown is:
Exception in thread "main" java.lang.IllegalArgumentException: Can not
use <return address targeting 228: iconst_0[3](1)> as type for local
variable
at
org.apache.bcel.generic.MethodGen.addLocalVariable(MethodGen.java:275)
at
org.apache.bcel.generic.MethodGen.addLocalVariable(MethodGen.java:295)
at Inliner.main(Inliner.java:74)
The BCEL source causing the exception to be thrown is:
*public* LocalVariableGen
<http://djvm/internal/bcel-5.2/xref/org/apache/bcel/generic/LocalVariableGen.html>
addLocalVariable( String name, Type type, *int* slot,
InstructionHandle
<http://djvm/internal/bcel-5.2/xref/org/apache/bcel/generic/InstructionHandle.html>
start, InstructionHandle
<http://djvm/internal/bcel-5.2/xref/org/apache/bcel/generic/InstructionHandle.html>
end ) {
byte t = type.getType();
*if* (t != Constants.T_ADDRESS) {
*int* add = type.getSize();
*if* (slot + add > max_locals) {
max_locals = slot + add;
}
LocalVariableGen
<http://djvm/internal/bcel-5.2/xref/org/apache/bcel/generic/LocalVariableGen.html> l
= *new* LocalVariableGen
<http://djvm/internal/bcel-5.2/xref/org/apache/bcel/generic/LocalVariableGen.html>(slot,
name, type, start, end);
*int* i;
*if* ((i = variable_vec.indexOf(l)) >= 0) {
variable_vec.set(i, l);
} *else* {
variable_vec.add(l);
}
*return* l;
} *else* {
*throw* *new* IllegalArgumentException("Can not use " + type + " as type
for local variable");
}
}
So how do I add a ReturnaddressType to the LocalVariableTable? or is
there another way of doing this?
Thanks, Bye Arrin
--
Conventional wisdom says to know your limits. To know your limits you
need to find them first. Finding you limits generally involves getting
in over your head and hoping you live long enough to benefit from the
experience. That's the fun part.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]