Home | Forums


This tool copies and instruments a set of Java source files specified on the command line. The output of the instrumentation process is instrumented java source; you will then need to compile the instrumented source using a standard Java compiler.


 java com.cenqua.clover.CloverInstr [OPTIONS] PARAMS [FILES...]


-i, --initstring <file> Clover initstring. This is the full path to the dbfile that will be used to construct/update to store coverage data.
-s, --srcdir <dir> Directory containing source files to be instrumented. If omitted individual source files should be specified on the command line.
-d, --destdir <dir> Directory where Clover should place the instrumented sources. Note that files will be overwritten in the desination directory.


-p, --flushpolicy <policy> Tell Clover which flushpolicy to use when flushing coverage data to disk. Valid values are "directed", "interval" and "threaded". With "interval" or "threaded", you must also specify a flushinterval using -f. The default value is "directed".
-f, --flushinterval <int> Tell Clover how often to flush coverage data when using either "interval" or "threaded" flushpolicy. Value in milliseconds.
--instrumentation <policy> Set the instrumentation strategy. Valid values are "field" and "class". Default is "class".
-e, --encoding <encoding> Specify the file encoding for source files. If not specified, the platform default encoding is used.
-jdk14 Direct Clover to parse sources using the JDK1.4 grammar.
-jdk15 Direct Clover to parse sources using the JDK1.5 grammar.
-v, --verbose Enable verbose logging.

API Usage

CloverInstr provides a simple API that accepts an array of strings representing the command line arguments and returns an integer result code. The following fragment illustrates use of the API:

 import com.cenqua.clover.CloverInstr;
    String [] cliArgs = { "-jdk14", "-i", "clover.db", "-d", "build/instr", "Money.java" };
    int result = CloverInstr.mainImpl(cliArgs);
    if (result != 0) {
           // problem during instrumentation


 java com.cenqua.clover.CloverInstr -i clover.db -s src -d build/instr

Find all java source files in the directory "src", copy and instrument them into the directory "build/instr", which will be constructed if it does not exist. Coverage database "clover.db" is initialised.

 java com.cenqua.clover.CloverInstr -jdk14 -i clover.db -d ../../build/instr \
            Money.java IMoney.java

Copy and instrument the source files "Money.java" and "IMoney.java" into the directory "../../build/instr". Use the JDK1.4 grammar (ie. support the 'assert' keyword).