ShowDeps

ShowDeps is a simple tool to print out the static dependenices for a given set of JAR, class files, or combinations of. This tool supports a -id option to specify the given module identifier and it will generate the module declaration (module-info). It also supports an -ignore option to ignore references to classes listed in the file (including .classlists created by the ClassAnalyzer tool).
java ShowDeps [-L ] [-id ] file...
   where  is a class or JAR file, or a directory
If -id option is specified, it will generate the module declaration.

Example usages:
  java ShowDeps Foo.jar
  java ShowDeps -id "foo@1.0" Foo.jar
  java ShowDeps -L modulelibrary Foo.jar
  java ShowDeps -ignore base.classlist Foo.jar
  java ShowDeps -ignore base.classlist -ignore jaxp-parsers.classlist <dir>
For example, to generate module declaration for SwingSet3:
$ java ShowDeps -id "swingset3 @ 1.0" swingx.jar swing-worker.jar AnimatedTransitions.jar TimingFramework.jar AppFramework.jar          
module swingset3 @ 1.0 {
    requires jdk.base;
    requires jdk.desktop;
    requires jdk.jdbc;
    requires jdk.jndi;
    requires jdk.logging;
    requires jdk.prefs;
}

ClassAnalyzer

The ClassAnalyzer tool analyzes the class dependencies among the input class files. It parses the class files, finds all class references, assigns classes to modules per the specified configuration files and then generates a set of reports for each module, including the list of classes, the list of resource files, and its dependencies on classes from another module. This tool supports a -config option to group classes in more than one modules and also a -moduleinfo option to generate module-info.java source files.

Input:

  1. Class files to be analyzed
  2. Input configuration file to include/exclude classes in modules
Output:
  1. ClassAnalyzer generated reports: *.classlist, *.resources, *.dependencies
  2. module-info.java for modules
The ClassAnalyzer can only find static dependencies from the bytecode but not implicit dependencies which include classes loaded by Class.forName, service providers, constants inlined by the compiler, and JNI_FindClass. In addition, it does not parse the annotations.

ClassAnalyzer's Configuration File

Example:
module swingset3 {
    // include classes in this module
    include com.sun.swingset3.**;

    // include resource files in this module
    include META-INF/demolist;

    // main entry point
    class com.sun.swingset3.SwingSet3;
}
The syntax is similar to module-info.java. Directives are:

JDK Modularization

The ClassAnalyzer tool is used in the jigsaw modules build to analyze the class dependencies amongst the JDK classes and generate the module-info.java files for JDK modules as a post-processing step. This is an interim solution enabling us prototype a modular JDK and make change to the module definitions during the course of our development, for example, synchronizing the on-going JDK development with the jdk8 repository. Utimately, we will restructure the source tree so that JDK modules will be compiled in the modulepath that can be used for development and the image build. Source tree restructuring has a big impact on all JDK engineers and thus we should do this when the module definitions and graph are close to final to minimize the disruption to the teams.

The configuration file for JDK is at: modules.config and modules.group.

Help

Usage: ClassAnalyzer <options>
Options: 
        -classpath     classpath where classes and jars will be parsed
        -config        config file
                       This option can be repeated to specify multiple config files.
        -jigsawLibrary module-library-path
                       Default is the system module library if present.
        -moduleinfo    output dir for module-info.java.
                       If not specified, no module-info.java will be generated.
        -output        output dir for the generated reports
        -properties    module's properties
        -version       version of the modules