Hello,
There is a class by M. Dahm called "helloify", which creates org.apache.bcel.generic.MethodGen object based on the given org.apache.bcel.classfile.Method, and then appends instructions that printout method name and some other info after the first method's instruction "INVOKESPECIAL". Look in the method "private static Method helloifyMethod(Method m)" of helloify.java, which I attach, for the illustration.
I also was working on a simple BCEL based tool that will allow me to track all variables, global and LOCAL, at the moment when they are changed. I just want to insert instructions into the Method of profiled class to printout name and the value of a variable - local variables too! - when they are changed. Any suggestions??
thanks!!
Vicki
Toby Reyelts <[EMAIL PROTECTED]> wrote:
Sounds to me like you want to use InstructionFinder. You should just give it
a pattern that matches what you're looking for, i.e. INVOKEVIRTUAL,
INVOKEINTERFACE etc... and call it on each method in the class. Every time
you get some hits, you can call getMethodName(), getReturnType(),
getArgumentTypes() to determine if the invoke is actually calling the method
you're looking for.
God bless,
-Toby Reyelts
-----Original Message-----
From: Mahesh Nair [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 11, 2003 7:51 AM
To: '[EMAIL PROTECTED]'
Subject: help required
. I am trying to create a primitive impact analysis tool for java projects.
The tool will take in as input, details about a method in a class, and then
figure out where all that method is invoked.
I am using the bcel libraries to parse through all the class files for this
purpose. I was relatively successful also. I am now able to get the classes
where this method is invoked.
I'd also like to get the method names inside the class form where the call
is made. i am not able to do it.
So my question is if i have a "org.apache.bcel.classfile.ConstantMethodref"
instance how can i figure out which method in the class invokes that method?
tia
Mahesh
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
415-668-6967 home
415-806-9093 cell
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
