jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Atam <ata...@gmail.com>
Subject Accessing OBJECT names on which methods are called from within other methods
Date Wed, 30 Nov 2005 14:43:00 GMT
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.


public voud m1()
  c2 c2obj = new c2();

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,


Code :

ClassGen classGen = new ClassGen(myclass.getJavaClass());
		MethodGen methodGen = new MethodGen(mymethod,
myclass.getClassName(), classGen.getConstantPool());
		InstructionList il = methodGen.getInstructionList();
		for (Iterator i = il.iterator(); i.hasNext(); )
			InstructionHandle handle = (InstructionHandle) i.next();
			if (handle.getInstruction() instanceof InvokeInstruction)
				InvokeInstruction invokeInstruction = (InvokeInstruction)
				String calledClass =
				String calledMethodName =
				String calledMethodSignature =
				boolean isStaticMethod = invokeInstruction.getOpcode() ==
			    String objectname;
			    if( isStaticMethod)
			    	objectname = "static";
			    	objectname = ""; ???????????

To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org

View raw message