ClassMetrics

Description

Computes numbers from a JAR file, such as number of packages, classes and interfaces, average number of methods per class, number of static, synchronized, or abstract methods, etc.

This is a simple tally of how many classses, interfaces, methods, publics, statics, finals, etc. there are in a given codebase. These tallies are not as powerful as the metrics of OOMetrics, but they can give you a rough idea of the size and complexity of a piece of software.

Parameters

Attribute Description Required
destfile where to write the output. If the file does not exists, it is created. If it already exists, its content is overwritten. Yes
list lists the programming elements under each measurement. No
instructioncounts shows the number of times each instruction in the Java virtual machine instruction set is used in the codebase. No

Nested elements

path

Use nested path elements to specify file names of JAR files, Zip files, and .class files for the tool to read. You can also give directory names, the tool will search it for .class files and read them. It is a path-like structures.

Examples

To scan the current directory and its subdirectories for .class files to analyze and save the resulting metrics report to df.metrics.txt:

  <classmetrics destfile="df.metrics.txt">
    <path>
      <pathelement location="."/>
    </path>
  </classmetrics>

To scan DependencyFinder.jar and rt.jar for .class files to analyze and save the resulting metrics report to df.metrics.txt:

  <classmetrics destfile="df.metrics.txt">
    <path>
      <pathelement location="DependencyFinder.jar"/>
      <pathelement location="rt.jar"/>
    </path>
  </classmetrics>

To scan DependencyFinder.jar and rt.jar for .class files to analyze and save the resulting metrics report to df.metrics.txt, listing all programming elements:

  <classmetrics destfile="df.metrics.txt" list="yes">
    <path>
      <pathelement location="DependencyFinder.jar"/>
      <pathelement location="rt.jar"/>
    </path>
  </classmetrics>

Copyright © 2001-2023 Jean Tessier. All rights reserved.