Re: Doubt regarding reference access
C E Ezeugoh <[email protected]> Sat, 20 Aug 2005 22:41:48 +0100
| Newsgroups | gmane.comp.jakarta.bcel.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Eshwari,
AFAIK, you can look at the InstructionHandle to find out what sort of
instruction is in it.
System.out.println is most likely to be an InvokeInstruction of which you
can find out what parameters were passed to it by calling getArgumentTypes.
The following code illustrates this:
InstructionHandle iHnd;
Instruction ii;
ii = (Instruction)iHnd.getInstruction();
if (ii instanceof InvokeInstruction) {
argTypes = ((InvokeInstruction)ii).getArgumentTypes(cpg);
.....
If the statement is of the type str = "dfdfd";
The Instruction would be an instance of PUTSTATIC or PUTFIELD depending on
whether str is a static variable or an instance variable.
HTH
Elisha.
>
> Is it possible to read the reference variable name
> from a particular instruction? For instance, if I have
> the InstructionHandle to the statement
>
> System.out.println(str.length),
>
> is it possible to get the reference name 'str' from
> the InstructionHandle? In otherwords, how will I
> determine the reference name being used in a
> particular instruction? Any help is highly
> appreciated.
>
> Thanks,
> Eshwari
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>