Export all classes in call graph?



I've come across this problem several times: What tools can I use to
extract all class files that are in the call graph of my main method,
or of a given set of files?

Example 1:

Imagine an application with all its classes in com.foo.app.* . Some of
these classes import classes from com.foo.lib.* . Now I want to export
all classes from com.foo.app.* and com.foo.lib.* that are imported
directly or indirectly by my (specified) main class (say
com.foo.app.Main).

Somehow I expect this to be a standard task, but haven't found support
for it yet. On the other hand, I don't see any theoretical problems
with this, so I wonder how this can be done.

Example 2:

I want to build a standalone JFace application. Unfortunately, since
Eclipse 3.0, there are some dependencies to consider: runtime.jar,
osgi.jar and core.jar. I now want to compress these into a jar that
contains all classes of JFace (easy) and all indirectly referenced
classes from the other jars (the tricky part).

I already tried to achieve this with ProGuard obfuscator (with
-dontobfuscate, -keep *, etc), but didn't get a result that I could
compile an application against; there were always some methods and
classes missing that some class needed. I might finally get this to
work, but somehow it feels like a clumsy way to go. Isn't there a
better way to do this?

Thanks,
Robert

.



Relevant Pages

  • Re: Performance issue: jar vs. bin/classes
    ... appications packed into jar files and java applications which are ... jars are more compact for transmission. ... Class files don't need to be ... With a jar you know exactly what classes are being ...
    (comp.lang.java.programmer)
  • Re: Big JARs = Big Problems?
    ... meaning they have a lot of .class files. ... even one comma in one class changes you have to send the whole jar. ... make sure they are on the classpath. ...
    (comp.lang.java.programmer)
  • Re: Accessing .class files in a Jar
    ... they won't have sufficient rights to put a file in the ext folder. ... But I tried simply jarring up the class files, ... provided you build your jar correctly. ... the filesystem within the jar matches the package structure of the class files. ...
    (comp.lang.java.help)
  • Re: icon not loading
    ... If I run my application from within Eclipse the icons show up but ... > if I take the jar and run it on another machine or even run it outside of ... > exception because it can't load the file that I'm pointing to. ... > have a set of class files and in the same directory I have a folder called ...
    (comp.lang.java.gui)
  • Re: another Java 101 question
    ... You have to put the correct directory in the path for individual class files, and you put the fill jar name in the path to access class files in the JAR. ... Abbey McA wrote: ... If I look on the as/400, according to "Java at Work" the toolbox that came ...
    (comp.sys.ibm.as400.misc)