Re: Project reflection
From: Robert Olofsson (d94-rol_at_tjatte.nada.kth.se)
Date: 12/17/03
- Previous message: Chris Smith: "Re: Target VM Microsoft? or Java Lint to check for MS VM compatibility?"
- In reply to: Shirley: "Project reflection"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 17 Dec 2003 22:06:05 +0000 (UTC)
In comp.lang.java.programmer Shirley <sjung_99@yahoo.com> wrote:
: How would you get package and class names given the project name as a
: String? For example, given a project name I need to be able to get
: all it's contained packages and classes.
You can not get all contained packages and classes, you can get a
good approximation if you dont care about strange class loaders.
For a good approximation:
Look up the classpath, check all directories and jar/zip files in it.
For each directory: check if you have any *.class files in it, go down
in every directory and start over.
For each jar/zip file: open it and check what files it contains,
files that are called *.class are good candiates
You will have to filter out inner classes and such things...
If you have a project that uses an URL class loader (loads the class
from the internet, then this will not work, you will not be able to
search the internet) or a Random class loader (generates a class from
a ranom number generator (I have not seen this, but in principle it
could come upt))....
/robo
- Previous message: Chris Smith: "Re: Target VM Microsoft? or Java Lint to check for MS VM compatibility?"
- In reply to: Shirley: "Project reflection"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|