Re: Doubt regarding reference access
Eshwari PattapathuSubramanianSundaran <[email protected]> Tue, 23 Aug 2005 10:14:07 -0700 (PDT)
| Newsgroups | gmane.comp.jakarta.bcel.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Elisha, Thanks for your response. I'm able to get the names of all the local variables inside the method as an array. But I need to access the name of the variable used in a particular instruction. IÂve another question actually. How will I determine the value of a local variable within a method during run time? I wanted to know whether a variable is null or not. How will I determine this? Any help is appreciated. Thanks for your time. Thanks, Eshwari --- C E Ezeugoh <[email protected]> wrote: > 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] > > > > > ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs