Classpath Inspector:
Command Line Application

Description

Classpath Inspector inspects a classpath, looking for duplicate class files and for incompatible class files. The tool examines each entry in the classpath, traversing the directory tree or the archive structure looking for class files. The tool reports the location of the effective class and the location of the classes that are overridden by the effective class, whether or not the overridden class is identical to the effective class. The tool is also available as an Ant task.

Classes are considered to be duplicates if they have the same fully-qualified class name. The size of each class file is reported, but no attempt is made to determine if the classes have the same bytecode.>/p>

The application returns the number of duplicated class files (0 for no duplicates), or various negative numbers for failure of one sort or another.

The application can be configured to produce a report, either to the console or to a file. The report can be generated in a standard format, either plain (ASCII text) or XML, or in a custom format.

Usage

Windows:
    cpcheck [flags] classpath [classpath]*

Unix:
    ./cpcheck.sh [flags] classpath [classpath]*

Java:
    java -jar cpcheck.jar [flags] classpath [classpath]*

The classpath argument controls which classpaths are inspected for duplicate classes. The classpath arguments are specified in the local system-specific format (on Unix-like systems as a colon-separated list, on Windows systems as a semicolon-separated list). The classpath arguments do not expand wildcard characters.

Flag Description Required
-a Inspect and report all class files, whether duplicated or not. No (defaults to -a)
-d Inspect and report only duplicated class files.
-p=pattern Specify a regular expression to select the class files for inspection. If omitted, all class files will be inspected. No
-t=title Give this title to any reports produced. No
-txt[=filename] Produce a text report, writing the results to the file if specified, or to standard output if no filename is specified. No
-xml[=filename] Produce an XML report, writing the results to the file if specified, or to standard output if no filename is specified. No
-rpt=class[=filename] Produce a custom report, writing the results to the file if specified, or to standard output if no filename is specified. The custom report formatter must implement com.bennettconsulting.cpcheck.Formatter. No

Examples

(Unix) >cpcheck -d -txt ./classes:/usr/Java/jdk1.5.0/jre/lib/rt.jar
(Windows) >cpcheck -d -txt ".\classes;C:\Program Files\Java\jdk1.5.0\jre\lib\rt.jar"

Check the subdirectory of the current directory named 'classes' and an archive file for all classes. Write a text-formatted report of the duplicates to the console.

License

This tool is distributed under the Apache 2.0 License. The license is also available on the web.