Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

bytecode analysis

Thread view: 
Apple - 27 Mar 2006 06:04 GMT
i was looking for a Java library to analyze bytecode files. I tried JDK
reflection but it does not provide information about local variables. then i
looked into BCEL but unforunately it does not support Java 1.5. (i want to
extract generic info about the local variables). I read a bit about ASM
but.. it looks a little bit complicated to handle. can anyone give me any
advices or suggestions?

Thanks.
Roedy Green - 27 Mar 2006 06:25 GMT
>i was looking for a Java library to analyze bytecode files. I tried JDK
>reflection but it does not provide information about local variables. then i
>looked into BCEL but unforunately it does not support Java 1.5. (i want to
>extract generic info about the local variables). I read a bit about ASM
>but.. it looks a little bit complicated to handle. can anyone give me any
>advices or suggestions?

see http://mindprod.com/jgloss/jasm.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Piotr Kobzda - 27 Mar 2006 11:17 GMT
> i was looking for a Java library to analyze bytecode files. I tried JDK
> reflection but it does not provide information about local variables. then i
> looked into BCEL but unforunately it does not support Java 1.5. (i want to
> extract generic info about the local variables). I read a bit about ASM
> but.. it looks a little bit complicated to handle. can anyone give me any
> advices or suggestions?

ASM is not as complicated to handle as it seems to be. Key is in
understanding of Visitor design pattern.

See:
http://www.onjava.com/pub/a/onjava/2005/08/17/asm3.html
and Related Articles.
And of course carefully read Tutorial for ASM from the project's home page:
http://asm.objectweb.org/

In order to retrieve generic info of your local variables (assuming I
understand your particular requirement), you will need the signature of
each local variable, which is a part of optional Local Variable Type
Table (new in a class file format since Java 5); use -g:vars compiler
option to adds this optional info into a class file.

ASM supports local variable signature retrieval by visitLocalVariable()
method of MethodVisitor, the signature parsing can be supported with
SignatureVisitor.

Regards,
piotr
Oliver Wong - 27 Mar 2006 20:18 GMT
>i was looking for a Java library to analyze bytecode files. I tried JDK
>reflection but it does not provide information about local variables. then
>i looked into BCEL but unforunately it does not support Java 1.5. (i want
>to extract generic info about the local variables). I read a bit about ASM
>but.. it looks a little bit complicated to handle. can anyone give me any
>advices or suggestions?

   My understanding is that generic information is erased at compile time,
so you will not be able to extract any information about it by looking at
bytecode.

   - Oliver
Chris Smith - 28 Mar 2006 06:49 GMT
>     My understanding is that generic information is erased at compile time,
> so you will not be able to extract any information about it by looking at
> bytecode.

Nah, it's there in the class file.  That's how, for example the compiler
knows how many type parameters a class is supposed to take.  Without
generics info being available to the compiler, most of the remaining
uses would become impossible.

However, it is not stored in method signatures.  It's stored in special
attributes which augment the otherwise non-generic class.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.