You could get all InvokeVirtual instructions using InstructionFinder class
and then cast the Instruction to InvokeInstruction and then do a
getMethodName on it.
code snippet
InstructionList il = new InstructionList(code.getCode());
InstructionFinder instFinder = new InstructionFinder(il);
Iterator inst = instFinder.search(methodType);
boolean foundInMethod = false;
while(inst.hasNext())
{
InstructionHandle [] matchedInst = (InstructionHandle
[])inst.next();
for (int instHandleCount=0; instHandleCount <
matchedInst.length;instHandleCount++ )
{
InstructionHandle ih = matchedInst[instHandleCount];
InvokeInstruction it =
(InvokeInstruction)ih.getInstruction();
String methodN = it.getMethodName(new
ConstantPoolGen(constPool) );
String signature = it.getSignature(new
ConstantPoolGen(constPool));
String cname= it.getClassName(new
ConstantPoolGen(constPool));
regaards
Mahesh
-----Original Message-----
From: Torsten Curdt [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 17, 2003 7:24 AM
To: [EMAIL PROTECTED]
Subject: invokevirtual
If have an "invokevirtual" Instruction. How can I
obtain the information which method is actually
being called?
InstructionList il = mg.getInstructionList();
InstructionHandle[] ihs = il.getInstructionHandles();
for (int j = 1; j < ihs.length; j++) {
Instruction in = ihs[j].getInstruction();
if (in.getOpcode() == 182) {
// invoke virtual
// if (in invokes "mymethod") ...
System.out.println(in);
}
}
il.dispose();
I wanna find calls to a certain method and prefix/postfix
it with some instructions later. Or maybe even replace it.
Thanks
--
Torsten
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]