net.sourceforge.cobertura.instrument

Class Main


public class Main
extends java.lang.Object

Add coverage instrumentation to existing classes.

What does that mean, exactly?

It means Cobertura will look at each class you give it. It loads the bytecode into memory. For each line of source, Cobertura adds a few extra instructions. These instructions do the following:

  1. Get an instance of the ProjectData class.
  2. Call a method in this ProjectData class that increments a counter for this line of code.

After every line in a class has been "instrumented," Cobertura edits the bytecode for the class one more time and adds "implements net.sourceforge.cobertura.coveragedata.HasBeenInstrumented" This is basically just a flag used internally by Cobertura to determine whether a class has been instrumented or not, so as not to instrument the same class twice.

Field Summary

private File
baseDir
private File
destinationDirectory
private Pattern
ignoreRegex
private static Logger
logger
private ProjectData
projectData

Method Summary

private void
addInstrumentation(File file)
private void
addInstrumentation(String filename)
private void
addInstrumentationToArchive(File archive)
private void
addInstrumentationToArchive(ZipInputStream archive, ZipOutputStream output)
private void
addInstrumentationToSingleClass(File file)
private static boolean
isArchive(File file)
private static boolean
isClass(File file)
private static boolean
isClass(ZipEntry entry)
static void
main(String[] args)
private void
parseArguments(String[] args)

Field Details

baseDir

private File baseDir


destinationDirectory

private File destinationDirectory


ignoreRegex

private Pattern ignoreRegex


logger

private static final Logger logger


projectData

private ProjectData projectData

Method Details

addInstrumentation

private void addInstrumentation(File file)


addInstrumentation

private void addInstrumentation(String filename)


addInstrumentationToArchive

private void addInstrumentationToArchive(File archive)


addInstrumentationToArchive

private void addInstrumentationToArchive(ZipInputStream archive,
                                         ZipOutputStream output)
            throws Exception


addInstrumentationToSingleClass

private void addInstrumentationToSingleClass(File file)


isArchive

private static boolean isArchive(File file)

Returns:
True if file has an extension that matches one of the standard java archives, false otherwise.


isClass

private static boolean isClass(File file)

Parameters:
file - A file.

Returns:
True if the specified file has "class" as its extension, false otherwise.


isClass

private static boolean isClass(ZipEntry entry)

Parameters:
entry - A zip entry.

Returns:
True if the specified entry has "class" as its extension, false otherwise.


main

public static void main(String[] args)


parseArguments

private void parseArguments(String[] args)