You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-user@jakarta.apache.org by Frank McCarey <fr...@ucd.ie> on 2004/02/02 12:00:11 UTC
Analysing Method Invocations
Hi All,
2 questions, Firstly I tried to download BCEL 5.1 from http://jakarta.apache.org/site/binindex.cgi, but when I tried to open the bcel-5.1 jar file I got the following error: "Failed to load Main-Class manifest attribute from C:\....." Is this because I am running Windows XP? Instead I downloaded the source code and compile it using Eclipse which worked fine.
Secondly, I have been looking at the BCELifier class. What I am trying to do is to analyse the .class file, looking for methods, fields and in particular method invocations. It is straight forward to determine methods and fields but I am having problems with method invocations. From looking at the documentation on the bcel webpage, it would appear that method invocations are stored as ConstantMethodRef's which is stored in the ConstantPool and thus I have been paying attention to getting the class Constant Pool. But I am unsure how to extract method invocations from this. Any help would be gratefully appreciated.
>From the website there only appears to be a one page manual and the only other documentation is java docs. If you could point me to further detailed documentation that also contains examples then that would be great.
Thanks a lot for time and any suggestions.
Cheers,
Frank.
Re: Analysing Method Invocations
Posted by Laurent Martelli <la...@aopsys.com>.
>>>>> "Frank" == Frank McCarey <fr...@ucd.ie> writes:
[...]
Frank> Secondly, I have been looking at the BCELifier class. What I
Frank> am trying to do is to analyse the .class file, looking for
Frank> methods, fields and in particular method invocations. It is
Frank> straight forward to determine methods and fields but I am
Frank> having problems with method invocations. From looking at the
Frank> documentation on the bcel webpage, it would appear that
Frank> method invocations are stored as ConstantMethodRef's which is
Frank> stored in the ConstantPool and thus I have been paying
Frank> attention to getting the class Constant Pool.
It only stores the signature of mehods. If you want the invocations,
you'll have to walk through the bytecode and look for INVOKESPECIAL,
INVOKEVIRTUAL or INVOKESTATIC instructions.
You may have a look at JAC for some sample code, but it may no be the
clearest thing since it does many other things besides looking for
method invocations:
http://cvs.forge.objectweb.org/cgi-bin/cvsweb.cgi/jac/src/org/objectweb/jac/core/translators/?cvsroot=jac
See the method WrappeeTranslator_BCEL.fillRTTI().
--
Laurent Martelli
laurent@aopsys.com Java Aspect Components
http://www.aopsys.com/ http://jac.aopsys.com
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org