Polymorphism and BCEL

[email protected] Tue, 21 Oct 2008 18:47:48 +0200
Newsgroups gmane.comp.jakarta.bcel.user
Message-ID <[email protected]>
Hi,

Getting the code of a method that is called through the invokevirtual instruction means lots of work. Due to polymorphism the dynamic type of the caller reference may be any type in the transitive closure of the static type.
Therefore you have to build up the a tree with all possible descendants of the static type and look into all the methods that match the signature. I'm curious  if there is any support for this in BCEL or if just everybody builds his own tree and traverse it.

zagi


here an example:

class A
  m1()

class B extends A
  m1()

used:
 A inst = new A();
 inst.m1(); // m1 of A
 inst = new B();
 inst.m1(); // m1 of B

in both cases the bytecode looks like:
invokevirtual A/m1()V

now you want to get hand on the instructionlist of any matching method i.e. m1 of A and m1 of B

-- 
"Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail