net.sourceforge.cobertura.instrument

Class Main

public class Main extends 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
ClassPatternclassPattern
FiledestinationDirectory
CollectionignoreBranchesRegexes
CollectionignoreRegexes
static Loggerlogger
ProjectDataprojectData
Method Summary
voidaddInstrumentation(CoberturaFile coberturaFile)
booleanaddInstrumentationToArchive(CoberturaFile file, InputStream archive, OutputStream output)
booleanaddInstrumentationToArchive(CoberturaFile file, ZipInputStream archive, ZipOutputStream output)
voidaddInstrumentationToArchive(Archive archive)
voidaddInstrumentationToArchive(CoberturaFile archive)
voidaddInstrumentationToSingleClass(File file)
static booleanisClass(ZipEntry entry)
static voidmain(String[] args)
voidparseArguments(String[] args)

Field Detail

classPattern

private ClassPattern classPattern

destinationDirectory

private File destinationDirectory

ignoreBranchesRegexes

private Collection ignoreBranchesRegexes

ignoreRegexes

private Collection ignoreRegexes

logger

private static final Logger logger

projectData

private ProjectData projectData

Method Detail

addInstrumentation

private void addInstrumentation(CoberturaFile coberturaFile)

addInstrumentationToArchive

private boolean addInstrumentationToArchive(CoberturaFile file, InputStream archive, OutputStream output)

addInstrumentationToArchive

private boolean addInstrumentationToArchive(CoberturaFile file, ZipInputStream archive, ZipOutputStream output)

addInstrumentationToArchive

private void addInstrumentationToArchive(Archive archive)

addInstrumentationToArchive

private void addInstrumentationToArchive(CoberturaFile archive)

addInstrumentationToSingleClass

private void addInstrumentationToSingleClass(File file)

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)