Re: Accessing OBJECT names on which methods are called from within other methods

Atam <[email protected]> Wed, 30 Nov 2005 22:24:50 +0530
Newsgroups gmane.comp.jakarta.bcel.user
Message-ID <[email protected]>
haha nice,
i will look into it,

Many Thanks

Atam


On 11/30/05, Andrew Huntwork <[email protected]> wrote:
>
> do you need to do this in a static context, or can you instrument your
> application and then run it?  If you can run it, you can write a very
> basic
> aspect (maybe using aspectj, http://eclipse.org/aspectj) that will print
> anything you want, including this.toString() and the invoked method name,
> whenever a method is invoked.  it's not exactly what you're asking for,
> but
> your problem is likely to be undecidable in general in any case :)
>
> sandmark (http://cgi.cs.arizona.edu/~sandmark/download.html) has a
> StackSimulator class (maybe
> sandmark.analysis.stacksimulator.StackSimulator,
> but it's been a while) that can tell you at any point in a method what's
> on
> the stack and what instructions might have put it there.  that might get
> you
> pretty far.
>
> On 11/30/05, Atam <[email protected]> wrote:
> >
> > Hi Nam,
> >
> > thanks for the reply,
> > i realy appreciate your time and help for this.
> >
> > First, the var table is not in the code segment of the method. I read
> that
> > that is available if you compile with a debogging option.
> > If that is not true, that it wil help me further. I will look into that.
> >
> > Apart from that, to know the local varaibl slot is very tricky. For
> every
> > different invokation instruction, these are placed at different points.
> > So this will be very tricky to do, and to asure 100% good behaviour i
> will
> > need to investigate the specification of java.class to know all the
> > possible
> > ways.
> > I hoped that there was a easier way. if you get an idea for me, plz tell
> > me.
> >
> > Thanks again,
> >
> > Atam
> >
> >
> >
> > On 11/30/05, Nam T. Nguyen <[email protected]> wrote:
> > >
> > > Hello Atam,
> > >
> > > Wednesday, November 30, 2005, 10:43:00 PM, you wrote:
> > >
> > > > Hi all,
> > >
> > > > i am also newbie here, but i read alot first about BCEL. My goal is
> to
> > > > extra from within a method, which other methods are called, and to
> > > > which objects these messages are send.
> > >
> > > > eg
> > >
> > > > public voud m1()
> > > > {
> > > >   c2 c2obj = new c2();
> > > >   c2obj.m2();
> > > > }
> > >
> > > > Here, wihin m1() there are 2 messages: <init> and  m2().
> > > > This information i can extract with the code below.  What i cannot
> do
> > > > yet, is to know that these messages are sent to the c2obj object.
> So,
> > > > i need the name of the OBJECT to which the messages are sent. If it
> is
> > > > a static call, name of object is not needed.
> > >
> > > > If anyone can please help me with this, i would appreciate it very
> > much.
> > >
> > > > With kind regards,
> > >
> > > Basiclly, you'll need two things:
> > > 1. the LocalVariables attribute of that Code section
> > > 2. the object (variable slot) that invoke instructions are operated on
> > >
> > > The first is easily obtainable. The later is more tricky.
> > >
> > > Normally, we would have patterns like:
> > >
> > > load xx
> > > invokevirtual yy
> > >
> > > XX is then the local variable slot. Looking it up in the
> > > LocalVariables table would then give you its name.
> > >
> > > However, this doesn't always hold true. In rare cases, the load and
> > > invoke instructions are very far apart.
> > >
> > > Nam
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [email protected]
> > > For additional commands, e-mail: [email protected]
> > >
> > >
> >
> >
>
>