Re: Re: Invocation target runtime type for virtually invoked methods
Arvid Svensson <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Consider using AspectJ instead. Make a pointcut capturing all calls to A.meth(..) and get hold of the runtime target object/type through an around advice' jointPoint. Solves your problem in less lines than this conversation. Regards, Arvid On 28 maj 2010, at 15.30, Marcin Rzeźnicki <[email protected]> wrote: > On Tue, May 25, 2010 at 6:05 PM, Kuperberg, Michael > <[email protected]> wrote: >> Hi all, >> >> >> >> I have a question about virtual methods, like in the following >> example: >> >> >> >> A a = new B(); >> >> a.meth(); >> >> >> >> meth() invoked using INVOKEVIRTUAL features the *declared* type of >> the >> invocation target in the bytecode, i.e. "INVOKEVIRTUAL a.meth()". >> But as I >> am interested in the *runtime* type of the invocation target, I >> need to >> analyse it. >> >> >> >> Of course, analysing the top element on the stack is an option (using >> getClass(), etc.), but: is there a faster and/or a more convenient >> option to >> do this using ASM? > > I think that you could track NEW instruction (InstructionAdapter is > particularly handy for this) but generally I believe that this will > turn out to be infeasible. First of all you will have to do it on the > whole system level (for methods returning super type), furthermore the > real type often depends on runtime information (as in: > if (sth) a = new A1(); else a = new A2() ) > > > -- > Greetings > Marcin Rzeźnicki > > -- > You receive this message as a subscriber of the [email protected] mailing > list. > To unsubscribe: mailto:[email protected] > For general help: mailto:[email protected]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws
message-footer.txt
(text/plain, 238 B)
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws