Yes. Pretty much trivially, by inspecting the constant pool of the class file. All method parameters and return types, local variable definitions, and field definitions have to refer to ClassConstant definitions in the constant pool.
The only thing left after that is to recursively follow the inheritance hierarchy for each of those classes. I do this in Jace, http://jace.reyelts.com/jace, for example. As part of its proxy generation capabilities, it can build up the entire dependency tree for a class. God bless, -Toby Reyelts > OK, let's assume the reflection API is not used. > In this case, are you saying BCEL can be used to do the job? > > My ultimate goal is code mobility: Being able to package on-the-fly a class > and all of its dependencies in order to be able to load it, link it and > initialize it somewhere else on the network, without having to worry about > whether or not it references classes or resources that do not necessarily > exist in the "natural" Java runtime. > > Regards, > > L. > > ----- Original Message ----- > From: "Toby Reyelts" <[EMAIL PROTECTED]> > To: "BCEL Users List" <[EMAIL PROTECTED]>; "Laurent Therond" > <[EMAIL PROTECTED]> > Sent: Tuesday, November 05, 2002 8:29 PM > Subject: Re: Question about BCEL and class closure > > > > > > I'm sure lots of people have looked at this. Think of, for example, all of > > the static compilers for Java. Of course, you can't absolutely know the > full > > set of classes that will be used, because the class could dynamically load > > other classes using the reflection api. > > > > God bless, > > -Toby Reyelts > > > > > > ----- Original Message ----- > > From: "Laurent Therond" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > > Sent: Tuesday, November 05, 2002 10:59 PM > > Subject: Question about BCEL and class closure > > > > > > Hi, > > > > I was wondering if anyone tried to compute a full class closure using > BCEL. > > > > I mean: Given a class file, produce a list of all classes used by the > > corresponding class, including classes used in declarations of local > > variables (within methods) and classes used in declarations of local > > variables (within methods) of any parent class or any class associated by > > composition. > > > > I have seen a lot of code that computes partial class closures, but > nothing > > as complete as a real class closure. > > > > Does anyone know if that would be possible? > > Does anyone have source code showing how this could be done using BCEL? > > > > Regards, > > > > Laurent > > > -- > To unsubscribe, e-mail: <mailto:bcel-user-unsubscribe@;jakarta.apache.org> > For additional commands, e-mail: <mailto:bcel-user-help@;jakarta.apache.org> > -- To unsubscribe, e-mail: <mailto:bcel-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:bcel-user-help@;jakarta.apache.org>
