parsing classfiles contained in a jar

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

parsing classfiles contained in a jar

Bart Du Bois

I am developing an Eclipse plugin for analyzing (java) source code. To
do so, I simply write ASTVisitors that visit the AST.

However, I also need information about the type, method and attribute
signature of classes contained in jars (and with no source code

I assume that it is unrealistic to expect to construct an AST of the
content of these classfiles. However, as it is possible to have the
signatures of methods contained in such classes displayed in an
Eclipse view, I assume that I should be able to extract the following

a. name of the class
b. names of its superclasses, superinterfaces
c. for each of its methods
c.1 methodname
c.2 qualified type name of the return type
c.3 for each of its parameters
c.3.1 qualified type name of the parameter
c.4 for each of its attributes
c.4.1 attributename
c.4.2 qualified type name of the attribute

My quest so far has lead to the following results:
ToolFactory.createDefaultClassFileReader is able to provide a
ClassFileReader for a given class file, from which one can request
information regarding its methods and fields.
However, this merely results in information about {a, c.1, c.4.1}...

Can anyone provide some information on how to extract this information
from a class-file?

Kind regards,
Bart Du Bois
PhD student, Lab On Reengineering
Dept. of Mathematics and Computer Science
University of Antwerp

PS: In case anyone is interested: my plugin currently harvests the
AST, fills in a Meta-Data-Repository (MDR) with a metamodel that is
satisfactory for calculating coupling and cohesion metrics, as well as
refactoring preconditions. The goal is to provide advice on where to
apply a specific refactoring in order to improve coupling and
jdt-dev mailing list
[hidden email]
Reply | Threaded
Open this post in threaded view

Re: parsing classfiles contained in a jar

Olivier Thomann

You are on the right track.

The IClassfileReader can give you everything you need. IMethodInfo and IFieldInfo contains the information relative to method and field respectively.

If you have specific problems, please ask questions on the eclipse newsgroup:

jdt-dev mailing list
[hidden email]