This week's book giveaway is in the JDBC and Relational Databases forum.
We're giving away four copies of Murach's MySQL and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

In search of java class dependency utility

 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Folks,
We have developed a J2EE application where the "client" is a java
application. In other words, we have created a JAR file that a user
uses to launch our application. The manifest for this JAR file has a
"Main-Class" attribute, so the following command is used to launch the
(client side of) the application:

Our entire application (both client-side and server-side) consists of
several hundred classes. Our problem is that we don't have an accurate
list of which classes are client-side only, which classes are
server-side only, and which classes are required by both (client-side
and server-side). I want our client-side JAR to _only_ contain classes
required by the client. Currently, we are simply bundling _all_ the
classes into "our.jar".

I have found (and tried) several utilities, including:

DependencyFinder
JDepend
ImportCleaner

However, I don't think these are suitable. You need to supply a class
name, and they only tell you the classes that either depend on the
given class, or that the given class depends on. What I want is a
"recursive" dependency finder.

For example, let's say I have class "A". Class "A" depends on class "B"
(in other words, class "A" needs to import class "B"). Now class "B"
depends on class "C" and class "C" depends on class "D". Also, we have
class "E" that depends on class "A" (in other words, class "E" needs to
import class "A").

The tools I mentioned above will only return (at most), classes "B" and
"E" (when I supply them with class "A"), but what I really need them to
return is classes "B","C" and "D" (and not necessarily class "E").

Does anyone know how I can achieve this?

Thanks (in advance),
Avi.
 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're not going to like my first answer: Write unit tests and then start teasing apart your code, consistently retesting.

Second answer: use Emma (emma.sourceforge.net) which, as a code coverage tool will should help you identify code that is run as code that is not. Then step through your entire application.

Third answer: Write a custom classloader that serves as a proxy to another classloader. This proxy classloader will log all classes it opens.

You should really consider #1, cause otherwise you're flying blind.
 
reply
    Bookmark Topic Watch Topic
  • New Topic