Home arrow static arrow Java Programming [Archive] - How to Analyse a Class ?
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - How to Analyse a Class ?
This topic has 2 replies on 1 page.

Posts:40
Registered: 6/25/02
How to Analyse a Class ?  
Jul 31, 2004 4:09 PM



 
Hi all,
I need to analyse a class (dynamically during classloading or runtime, or statically with .java or .class) to identify, for all methods of this class, if a method read or update a class field. How to achieve that? What are my options?
Thanks
Jean
 

Posts:2,830
Registered: 9/1/03
Re: How to Analyse a Class ?  
Jul 31, 2004 4:47 PM (reply 1 of 2)



 
Reflection is a neat feature that lets you analyse some
components of classes at runtime.

However, it can't (afaik) analyse what a method actually does.

For this you would ned to analyse the .class file itself with some tool
like BCEL (from apache; search their site for it, or google).

If you wanted to analyse a .java then a java processor would help
you here; consider something like JavaCC (google again).
 

Posts:3,183
Registered: 10.09.03
Re: How to Analyse a Class ?  
Aug 1, 2004 3:36 AM (reply 2 of 2)



 
Well, you could fake it.

1) get all methods
2) get all attributes
3) invoke a method and check which attribute changes.

Not easy, but I think it's possible.
 
This topic has 2 replies on 1 page.