### Start Execution Data Server Source: https://www.jacoco.org/jacoco/trunk/doc/examples/java/ExecutionDataServer.java This is the main method that starts the server. It creates an ExecutionDataWriter to save data to a file and a ServerSocket to listen for incoming connections. It then enters an infinite loop to accept client connections and handle them in separate threads. ```java public static void main(final String[] args) throws IOException { final ExecutionDataWriter fileWriter = new ExecutionDataWriter( new BufferedOutputStream(new FileOutputStream(DESTFILE))); final ServerSocket server = new ServerSocket(PORT, 0, InetAddress.getByName(ADDRESS)); while (true) { final Handler handler = new Handler(server.accept(), fileWriter); new Thread(handler).start(); } } ``` -------------------------------- ### CoreTutorial Main Execution Source: https://www.jacoco.org/jacoco/trunk/doc/examples/java/CoreTutorial.java Entry point for running the CoreTutorial example as a Java application. ```java public static void main(final String[] args) throws Exception { new CoreTutorial(System.out).execute(); } ``` -------------------------------- ### Example Java Method for Control Flow Analysis Source: https://www.jacoco.org/jacoco/trunk/doc/flow.html This Java method serves as an example for demonstrating control flow analysis. It includes a conditional branch. ```Java public static void example() { a(); if (cond()) { b(); } else { c(); } d(); } ``` -------------------------------- ### startup Method Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/IRuntime.html Starts the coverage runtime. This method MUST be called before any class instrumented for this runtime is loaded. ```APIDOC ## startup ```java void startup(RuntimeData data) throws Exception ``` ### Description Starts the coverage runtime. This method MUST be called before any class instrumented for this runtime is loaded. ### Parameters * **data** (RuntimeData) - the execution data for this runtime ### Throws * **Exception** - any internal problem during startup ``` -------------------------------- ### IRuntime startup Method Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/IRuntime.html Starts the coverage runtime. This method must be invoked before any instrumented classes are loaded to ensure proper initialization of coverage data collection. ```java void **startup**(RuntimeData data) throws Exception ``` -------------------------------- ### SessionInfo Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/SessionInfo.html Creates an immutable session info object with the provided session identifier, start time, and dump time. The parameters are the session ID, the start timestamp of data recording, and the timestamp when data was collected. ```java public SessionInfo(String id, long start, long dump) ``` -------------------------------- ### Generated Bytecode for Example Java Method Source: https://www.jacoco.org/jacoco/trunk/doc/flow.html This is the Java bytecode generated from the example Java method. It illustrates the linear sequence of instructions and the use of jump opcodes for control flow. ```Java Bytecode public static example()V INVOKESTATIC a()V INVOKESTATIC cond()Z IFEQ L1 INVOKESTATIC b()V GOTO L2 L1: INVOKESTATIC c()V L2: INVOKESTATIC d()V RETURN ``` -------------------------------- ### Describe JaCoCo Maven Plugin Goals Source: https://www.jacoco.org/jacoco/trunk/doc/maven.html Use the maven-help-plugin to get a full list of goals and parameters for the JaCoCo Maven plug-in. ```bash mvn help:describe -Dplugin=org.jacoco:jacoco-maven-plugin -Ddetail ``` -------------------------------- ### getStartTimeStamp() Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/SessionInfo.html Retrieves the timestamp indicating when the execution data recording for this session started. ```APIDOC ## getStartTimeStamp() ### Description Gets the timestamp when execution data recording has been started. ### Returns * `long` - the epoc based time stamp when execution data recording has been started ``` -------------------------------- ### Run Full JaCoCo Build Source: https://www.jacoco.org/jacoco/trunk/doc/build.html Execute the standard Maven build process to clean, verify, and build the JaCoCo project. Ensure you have JDK 21 installed and run this from the './org.jacoco.build/' directory. ```bash ../mvnw clean verify ``` -------------------------------- ### version Source: https://www.jacoco.org/jacoco/trunk/doc/cli.html Prints the JaCoCo version information. This command is useful for verifying the installed JaCoCo version. ```APIDOC ## version ### Description Print JaCoCo version information. ### Method ``` java -jar jacococli.jar version [--help] [--quiet] ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Options - `--help`: show help - `--quiet`: suppress all output on stdout ``` -------------------------------- ### Get Start Time Stamp Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/SessionInfo.html Retrieves the epoch-based timestamp indicating when the execution data recording for this session was started. This is useful for ordering sessions by their start time. ```java public long getStartTimeStamp() ``` -------------------------------- ### startup Method Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/LoggerRuntime.html Initializes the runtime with execution data. Subclasses must call this method when overwriting it. ```APIDOC ## startup ```java public void startup(RuntimeData data) throws Exception ``` ### Description Subclasses must call this method when overwriting it. ### Parameters * `data` (RuntimeData) - the execution data for this runtime ### Throws * `Exception` - any internal problem during startup ``` -------------------------------- ### Get JaCoCo Version Source: https://www.jacoco.org/jacoco/trunk/doc/cli.html Print the JaCoCo version information. This command is useful for verifying the installed JaCoCo version. ```bash java -jar jacococli.jar version [--help] [--quiet] ``` -------------------------------- ### startup Method Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/InjectedClassRuntime.html Initializes the coverage runtime with execution data. Subclasses must call this method when overwriting it. ```APIDOC ## startup(RuntimeData data) ### Description Subclasses must call this method when overwriting it. ### Specified by: `startup` in interface `IRuntime` ### Overrides: `startup` in class `AbstractRuntime` ### Parameters: - **data** (RuntimeData) - the execution data for this runtime ### Throws: - Exception - any internal problem during startup ``` -------------------------------- ### Get JaCoCo Agent Instance Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/agent/rt/RT.html Retrieve the active JaCoCo agent instance from the current JVM. This method will throw an IllegalStateException if the agent has not yet been started. ```java public static IAgent getAgent() throws IllegalStateException ``` -------------------------------- ### startup Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/SystemPropertiesRuntime.html Initializes the runtime with execution data. Subclasses must call this method when overwriting it. ```APIDOC ## startup(RuntimeData data) ### Description Subclasses must call this method when overwriting it. ### Method `public void startup(RuntimeData data) throws Exception` ### Parameters #### Path Parameters - **data** (RuntimeData) - the execution data for this runtime ### Throws - Exception - any internal problem during startup ``` -------------------------------- ### getSessionId() Source: https://www.jacoco.org/jacoco/trunk/doc/api/index-all.html Gets the current session identifier for this runtime. ```APIDOC ## getSessionId() ### Description Get the current session identifier for this runtime. ### Method N/A (Method Signature) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### startup Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/ModifiedSystemClassRuntime.html Subclasses must call this method when overwriting it. Initializes the coverage runtime with execution data. ```APIDOC ## startup(RuntimeData data) ### Description Subclasses must call this method when overwriting it. Initializes the coverage runtime with execution data. ### Parameters * **data** (RuntimeData) - the execution data for this runtime ### Throws * Exception - any internal problem during startup ``` -------------------------------- ### accept(IExecutionDataVisitor visitor) Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/ExecutionDataStore.html Writes the entire content of the store to the provided IExecutionDataVisitor. This allows processing or exporting the stored execution data. ```APIDOC ## accept(IExecutionDataVisitor visitor) ### Description Writes the content of the store to the given visitor interface. ### Method ```java public void accept(IExecutionDataVisitor visitor) ``` ### Parameters #### Path Parameters - **visitor** (IExecutionDataVisitor) - Required - The visitor to accept the execution data. ``` -------------------------------- ### getSessionId Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/RuntimeData.html Gets the current session identifier for this runtime. ```APIDOC ## getSessionId() ### Description Get the current a session identifier for this runtime. ### Method `public String getSessionId()` ### Returns - **String** - The current session identifier. ### See Also - `setSessionId(String)` ``` -------------------------------- ### startup(RuntimeData data) Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/AbstractRuntime.html Initializes the runtime with execution data. Subclasses must call this method during their own startup procedures. ```APIDOC ## startup(RuntimeData data) ### Description Subclasses must call this method when overwriting it. It initializes the runtime with the provided execution data. ### Method Signature ```java public void startup(RuntimeData data) throws Exception ``` ### Parameters - `data` (RuntimeData) - Required - The execution data for this runtime. ### Throws - `Exception` - Any internal problem during startup. ``` -------------------------------- ### IncompatibleExecDataException getActualVersion() Source: https://www.jacoco.org/jacoco/trunk/doc/api/index-all.html Gets the actual version found in the execution data. ```APIDOC ## getActualVersion() ### Description Gets the actual version found in the execution data. ### Method `getActualVersion()` ### Exception `org.jacoco.core.data.IncompatibleExecDataVersionException` ``` -------------------------------- ### AbstractRuntime Startup Method Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/AbstractRuntime.html Subclasses must call this method when overwriting it to initialize runtime data. ```java public void startup(RuntimeData data) throws Exception ``` -------------------------------- ### Get Class VM Name Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/ExecutionData.html Retrieves the VM name of the class. ```java public String getName() ``` -------------------------------- ### IRuntime Interface Definition Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/IRuntime.html Defines the methods for starting and shutting down the JaCoCo runtime. ```APIDOC ## Interface IRuntime This interface represents a particular mechanism to collect execution information in the target VM at runtime. ### Methods - **startup**(RuntimeData data) Starts the coverage runtime. This method MUST be called before any class instrumented for this runtime is loaded. - **shutdown**() Allows the coverage runtime to cleanup internals. This class should be called when classes instrumented for this runtime are not used any more. ``` -------------------------------- ### visitInfo Method Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/MultiReportVisitor.html Initializes the report with global information, including session details and execution data. This method must be called before any other visitor methods. ```java public void visitInfo(List sessionInfos, Collection executionData) throws IOException ``` -------------------------------- ### accept Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/ExecutionDataStore.html Writes the content of the store to the provided visitor interface. ```APIDOC ## accept ### Description Writes the content of the store to the given visitor interface. ### Method public ### Parameters #### Path Parameters - **visitor** (IExecutionDataVisitor) - Required - interface to write content to ### Returns - void ``` -------------------------------- ### Get Session Info Store Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/tools/ExecFileLoader.html Retrieves the SessionInfoStore containing all loaded sessions. ```java public SessionInfoStore getSessionInfoStore() ``` -------------------------------- ### SystemPropertiesRuntime Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/SystemPropertiesRuntime.html Creates a new instance of the SystemPropertiesRuntime. ```APIDOC ## SystemPropertiesRuntime() ### Description Creates a new runtime. ### Constructor `public SystemPropertiesRuntime()` ``` -------------------------------- ### visitInfo Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/IReportVisitor.html Initializes the report with global information. This method must be called before any other method. ```APIDOC ## visitInfo ### Description Initializes the report with global information. This method has to be called before any other method can be called. ### Method void ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **sessionInfos** (List) - Required - list of chronological ordered `SessionInfo` objects where execution data has been collected for this report. - **executionData** (Collection) - Required - collection of all `ExecutionData` objects that are considered for this report ### Throws - **IOException** - in case of IO problems with the report writer ``` -------------------------------- ### Get Target Class Resource Source: https://www.jacoco.org/jacoco/trunk/doc/examples/java/CoreTutorial.java Retrieves the InputStream for a given class resource. ```java private InputStream getTargetClass(final String name) { final String resource = '/' + name.replace('.', '/') + ".class"; return getClass().getResourceAsStream(resource); } ``` -------------------------------- ### ExecDumpClient Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/tools/ExecDumpClient.html Initializes a new instance of ExecDumpClient with default settings. By default, a dump is requested, execution data is not reset, and no retries are configured with a 1-second delay between attempts. ```APIDOC ## ExecDumpClient() ### Description New instance with the defaults `dump==true`, `reset==false`, `retryCount==0` and `retryDelay=1000`. ### Constructor `ExecDumpClient()` ``` -------------------------------- ### ExecutionDataStore get(long) Source: https://www.jacoco.org/jacoco/trunk/doc/api/index-all.html Returns the ExecutionData entry with the given ID if it exists in the store. ```APIDOC ## get(long) ### Description Returns the `ExecutionData` entry with the given id if it exists in this store. ### Method `get(long)` ### Class `org.jacoco.core.data.ExecutionDataStore` ``` -------------------------------- ### Get Execution Data Store Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/tools/ExecFileLoader.html Retrieves the ExecutionDataStore containing data for all loaded classes. ```java public ExecutionDataStore getExecutionDataStore() ``` -------------------------------- ### Main Method for Report Generation in Java Source: https://www.jacoco.org/jacoco/trunk/doc/examples/java/ReportGenerator.java Entry point for the report generation application. It iterates through command-line arguments, treating each as a project directory, and creates a report for each. ```java public static void main(final String[] args) throws IOException { for (int i = 0; i < args.length; i++) { final ReportGenerator generator = new ReportGenerator( new File(args[i])); generator.create(); } } ``` -------------------------------- ### visitInfo Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/MultiReportVisitor.html Initializes the report with global information, including session details and execution data. This method must be called before any other reporting methods. ```APIDOC ## visitInfo ### Description Initializes the report with global information. This method has to be called before any other method can be called. ### Method `void visitInfo(List sessionInfos, Collection executionData)` ### Parameters - **sessionInfos** (List) - List of chronological ordered SessionInfo objects where execution data has been collected for this report. - **executionData** (Collection) - Collection of all ExecutionData objects that are considered for this report. ### Throws - `IOException` - In case of IO problems with the report writer. ``` -------------------------------- ### AgentOptions getAddress() Source: https://www.jacoco.org/jacoco/trunk/doc/api/index-all.html Gets the hostname or IP address to listen to or connect to for TCP server/client outputs. ```APIDOC ## getAddress() ### Description Gets the hostname or IP address to listen to when output is `tcpserver` or connect to when output is `tcpclient`. ### Method `getAddress()` ### Class `org.jacoco.core.runtime.AgentOptions` ``` -------------------------------- ### ExecutionDataStore get(Long, String, int) Source: https://www.jacoco.org/jacoco/trunk/doc/api/index-all.html Returns the coverage data for the class with the given identifier. ```APIDOC ## get(Long, String, int) ### Description Returns the coverage data for the class with the given identifier. ### Method `get(Long, String, int)` ### Class `org.jacoco.core.data.ExecutionDataStore` ``` -------------------------------- ### Startup Runtime Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/LoggerRuntime.html Initializes the runtime with execution data. Subclasses must call this method when overwriting it to ensure proper initialization. ```java public void startup(RuntimeData data) throws Exception ``` -------------------------------- ### Instantiate ExecFileLoader Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/tools/ExecFileLoader.html Creates a new instance of ExecFileLoader to combine session infos and execution data from multiple files. ```java public ExecFileLoader() ``` -------------------------------- ### AgentOptions - Destfile Configuration Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/AgentOptions.html Methods for setting and getting the destination file for JaCoCo coverage data. ```APIDOC ## getDestfile() ### Description Returns the output file location. ### Returns - String - output file location ### Method `public String getDestfile()` ``` ```APIDOC ## setDestfile(String destfile) ### Description Sets the output file location. ### Parameters - `destfile` (String) - output file location ### Method `public void setDestfile(String destfile)` ``` -------------------------------- ### Get Class Identifier Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/ExecutionData.html Retrieves the unique identifier for the class, which is the CRC64 checksum of its raw definition. ```java public long getId() ``` -------------------------------- ### MultiSourceFileLocator Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/MultiSourceFileLocator.html Creates a new empty MultiSourceFileLocator with a specified tab width. ```APIDOC ## MultiSourceFileLocator(int tabWidth) ### Description Creates a new empty locator. ### Parameters * **tabWidth** (int) - The tab width in source files, represented as the number of blanks used for all source files. ``` -------------------------------- ### Getting Counter Values Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/analysis/class-use/ICounter.CounterValue.html Details on how to retrieve the specific counter value for a given ICounter.CounterValue type. ```APIDOC ## double getValue(ICounter.CounterValue value) ### Description Returns the counter value of the given type. ### Method `double` ### Parameters #### Path Parameters - **value** (ICounter.CounterValue) - The type of counter value to retrieve. ``` -------------------------------- ### Instantiate ExecDumpClient Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/tools/ExecDumpClient.html Creates a new instance of ExecDumpClient with default settings: dump enabled, reset disabled, zero retries, and a 1000ms retry delay. ```java public ExecDumpClient() ``` -------------------------------- ### AgentOptions.prependVMArguments(String, File) Source: https://www.jacoco.org/jacoco/trunk/doc/api/index-all.html Generates and prepends required JVM arguments based on current configuration to a given command line. ```APIDOC ## prependVMArguments(String, File) ### Description Generate required quotes JVM argument based on current configuration and prepends it to the given argument command line. ### Method Method ### Class org.jacoco.core.runtime.AgentOptions ``` -------------------------------- ### LoggerRuntime Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/LoggerRuntime.html Creates a new instance of the LoggerRuntime. This is the basic setup for using the logger-based runtime. ```java public LoggerRuntime() ``` -------------------------------- ### Analyzer Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/class-use/ExecutionDataStore.html Demonstrates the instantiation of the Analyzer class, which requires an ExecutionDataStore. ```APIDOC ## Analyzer(ExecutionDataStore executionData, ICoverageVisitor coverageVisitor) ### Description Creates a new analyzer reporting to the given output. ### Parameters #### Path Parameters - **executionData** (ExecutionDataStore) - Required - The execution data store to be used by the analyzer. - **coverageVisitor** (ICoverageVisitor) - Required - The visitor to report coverage results to. ``` -------------------------------- ### SystemPropertiesRuntime Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/SystemPropertiesRuntime.html Creates a new instance of the SystemPropertiesRuntime. This is the primary way to initialize the runtime. ```java public SystemPropertiesRuntime() ``` -------------------------------- ### MultiReportVisitor Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/MultiReportVisitor.html Initializes a new MultiReportVisitor by delegating to a list of provided report visitors. This is the primary way to set up the visitor for multiple report outputs. ```java public MultiReportVisitor(List visitors) ``` -------------------------------- ### Reset Coverage Information Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/agent/rt/IAgent.html Resets all collected coverage information. This is useful for starting fresh coverage measurements. ```java void reset() ``` -------------------------------- ### getPort Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/AgentOptions.html Gets the network port configured for the agent. This port is used for `tcpserver` output or `tcpclient` connections. ```APIDOC ## getPort ### Description Returns the port on which to listen to when the output is `tcpserver` or the port to connect to when output is `tcpclient`. ### Method public int getPort() ### Returns - port to listen on or connect to (int) ``` -------------------------------- ### Initialize ExecutionDataStore Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/ExecutionDataStore.html Creates a new, empty in-memory store for execution data. This is the primary way to instantiate the store. ```java public ExecutionDataStore() ``` -------------------------------- ### Enum constants and utility methods for ICoverageNode.ElementType Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/analysis/class-use/ICoverageNode.ElementType.html Details on how to get enum constants and retrieve all available constants. ```APIDOC ## `static ICoverageNode.ElementType` `ICoverageNode.ElementType.valueOf(String name)` ### Description Returns the enum constant of this type with the specified name. ## `static ICoverageNode.ElementType[]` `ICoverageNode.ElementType.values()` ### Description Returns an array containing the constants of this enum type, in the order they're declared. ``` -------------------------------- ### Get JaCoCo Version Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/agent/rt/IAgent.html Retrieves the version of the JaCoCo agent. This method is useful for compatibility checks or logging. ```java String getVersion() ``` -------------------------------- ### add Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/MultiSourceFileLocator.html Adds an ISourceFileLocator to the MultiSourceFileLocator. Locators are queried in the order they are added. ```APIDOC ## add(ISourceFileLocator locator) ### Description Adds the given locator. Locators are queried in the sequence they have been added. ### Parameters * **locator** (ISourceFileLocator) - The additional locator to query. ``` -------------------------------- ### get Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/ExecutionDataStore.html Retrieves the coverage data for a specific class. If no data exists for the given ID, a new entry is created. ```APIDOC ## get ### Description Returns the coverage data for the class with the given identifier. If there is no data available under the given id a new entry is created. ### Method public ### Parameters #### Path Parameters - **id** (Long) - Required - class identifier - **name** (String) - Required - VM name of the class - **probecount** (int) - Required - probe data length ### Returns - execution data (ExecutionData) ``` -------------------------------- ### createFile Method Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/FileMultiReportOutput.html Creates a file at the specified local path and returns an OutputStream for writing content. The stream must be closed after use. ```APIDOC ## createFile(String path) ### Description Creates a file at the given local path. The returned `OutputStream` has to be closed before the next document is created. ### Method public OutputStream ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters * **path** (String) - Required - The local path to the new document. ### Returns * **OutputStream** - An output stream for the content of the created file. ### Throws * **IOException** - If the file creation fails. ``` -------------------------------- ### IPackageCoverage.getSourceFiles() Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/analysis/class-use/ISourceFileCoverage.html Returns all source files in this package. ```APIDOC ## IPackageCoverage.getSourceFiles() ### Description Returns all source files in this package. ### Method N/A (Method signature) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response - **return value** (Collection) - A collection of ISourceFileCoverage objects. ``` -------------------------------- ### Get Probe Data Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/ExecutionData.html Returns the array representing probe execution status. 'true' indicates a probe was hit. ```java public boolean[] getProbes() ``` -------------------------------- ### Check overall instruction coverage and missed classes Source: https://www.jacoco.org/jacoco/trunk/doc/check-mojo.html This configuration requires an overall instruction coverage of 80% and ensures no class is missed. It uses the 'rules' parameter to define these constraints. ```xml BUNDLE INSTRUCTION COVEREDRATIO 0.80 CLASS MISSEDCOUNT 0 ``` -------------------------------- ### Enum Constants and Values Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/analysis/class-use/ICounter.CounterValue.html Provides information on how to get specific enum constants by name and how to retrieve all declared constants. ```APIDOC ## static ICounter.CounterValue valueOf(String name) ### Description Returns the enum constant of this type with the specified name. ### Method `static` ### Parameters #### Path Parameters - **name** (String) - The name of the enum constant to return. ## static ICounter.CounterValue[] values() ### Description Returns an array containing the constants of this enum type, in the order they're declared. ### Method `static` ### Parameters None ``` -------------------------------- ### Class Hierarchy for org.jacoco.core.tools Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/tools/package-tree.html This snippet shows the direct and indirect inheritance of classes within the org.jacoco.core.tools package, starting from java.lang.Object. ```APIDOC ## Class Hierarchy * java.lang.Object * org.jacoco.core.tools.ExecDumpClient * org.jacoco.core.tools.ExecFileLoader ``` -------------------------------- ### createFile Method Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/IMultiReportOutput.html Creates a file at the given local path. The returned OutputStream has to be closed before the next document is created. ```APIDOC ## createFile ### Description Creates a file at the given local path. The returned `OutputStream` has to be closed before the next document is created. ### Method ```java OutputStream createFile(String path) ``` ### Parameters #### Path Parameters - **path** (String) - Required - local path to the new document ### Returns - OutputStream - output for the content ### Throws - IOException - if the creation fails ``` -------------------------------- ### SessionInfo Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/SessionInfo.html Creates an immutable session info object with the provided session identifier, start time, and dump time. ```APIDOC ## SessionInfo Constructor ### Description Create an immutable session info with the given data. ### Parameters * `id` (String) - arbitrary session identifier, must not be `null` * `start` (long) - the epoc based time stamp when execution data recording has been started * `dump` (long) - the epoc based time stamp when execution data was collected ``` -------------------------------- ### SessionInfoStore Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/SessionInfoStore.html Initializes a new instance of the SessionInfoStore class. This class is not thread-safe. ```APIDOC ## SessionInfoStore() ### Description Initializes a new instance of the SessionInfoStore class. An instance of this class is not thread-safe. ### Method Constructor ### Parameters None ``` -------------------------------- ### Get Coverage Status Color Source: https://www.jacoco.org/jacoco/trunk/doc/examples/java/CoreTutorial.java Returns a string representation ('red', 'yellow', 'green') based on the coverage status code. ```java private String getColor(final int status) { switch (status) { case ICounter.NOT_COVERED: return "red"; case ICounter.PARTLY_COVERED: return "yellow"; case ICounter.FULLY_COVERED: return "green"; } return ""; } ``` -------------------------------- ### Create HTML Coverage Report in Java Source: https://www.jacoco.org/jacoco/trunk/doc/examples/java/ReportGenerator.java Generates an HTML coverage report. It loads execution data, analyzes class structures, and then uses an HTMLFormatter to create a report visitor. The visitor is initialized with session information and coverage data, then populated with bundle coverage and source file information before finalizing the report. ```java public void create() throws IOException { // Read the jacoco.exec file. Multiple data files could be merged // at this point loadExecutionData(); // Run the structure analyzer on a single class folder to build up // the coverage model. The process would be similar if your classes // were in a jar file. Typically you would create a bundle for each // class folder and each jar you want in your report. If you have // more than one bundle you will need to add a grouping node to your // report final IBundleCoverage bundleCoverage = analyzeStructure(); createReport(bundleCoverage); } private void createReport(final IBundleCoverage bundleCoverage) throws IOException { // Create a concrete report visitor based on some supplied // configuration. In this case we use the defaults final HTMLFormatter htmlFormatter = new HTMLFormatter(); final IReportVisitor visitor = htmlFormatter .createVisitor(new FileMultiReportOutput(reportDirectory)); // Initialize the report with all of the execution and session // information. At this point the report doesn't know about the // structure of the report being created visitor.visitInfo(execFileLoader.getSessionInfoStore().getInfos(), execFileLoader.getExecutionDataStore().getContents()); // Populate the report structure with the bundle coverage information. // Call visitGroup if you need groups in your report. visitor.visitBundle(bundleCoverage, new DirectorySourceFileLocator(sourceDirectory, "utf-8", 4)); // Signal end of structure information to allow report to write all // information out visitor.visitEnd(); } ``` -------------------------------- ### Filtering Class Files in JaCoCo Report Source: https://www.jacoco.org/jacoco/trunk/doc/ant.html Example of filtering class files within the 'classfiles' element to narrow the scope of the coverage report. ```xml ``` -------------------------------- ### createVisitor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/html/HTMLFormatter.html Creates a new visitor to write a report to the given output. This visitor is used for emitting report data. ```APIDOC ## createVisitor ### Description Creates a new visitor to write a report to the given output. ### Method Signature ```java public IReportVisitor createVisitor(IMultiReportOutput output) throws IOException ``` ### Parameters * `output` (IMultiReportOutput) - The output stream to write the report to. ### Returns * `IReportVisitor` - A visitor object used to emit the report data. ### Throws * `IOException` - If there are any problems with the output stream. ``` -------------------------------- ### ICoverageNode.ElementType Enum Source: https://www.jacoco.org/jacoco/trunk/doc/api/index-all.html Specifies the different element types within a coverage node. Provides methods to get constants by name and an array of all constants. ```APIDOC ## ICoverageNode.ElementType Enum ### Description Specifies the different element types within a coverage node. ### Methods - **valueOf(String name)**: Returns the enum constant of this type with the specified name. - **values()**: Returns an array containing the constants of this enum type, in the order they're declared. ### Parameters #### valueOf(String name) - **name** (String) - Required - The name of the enum constant to return. ``` -------------------------------- ### AgentOptions Constructors Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/AgentOptions.html Provides different ways to instantiate the AgentOptions class, either with default values, from a string, or from a Properties object. ```APIDOC ## AgentOptions() ### Description New instance with all values set to default. ### Constructor `public AgentOptions()` ``` ```APIDOC ## AgentOptions(String optionstr) ### Description New instance parsed from the given option string. ### Parameters - `optionstr` (String) - string to parse or null ### Constructor `public AgentOptions(String optionstr)` ``` ```APIDOC ## AgentOptions(Properties properties) ### Description New instance read from the given `Properties` object. ### Parameters - `properties` (Properties) - Properties object to read configuration options from ### Constructor `public AgentOptions(Properties properties)` ``` -------------------------------- ### Get Session ID Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/SessionInfo.html Retrieves the arbitrary session identifier associated with this session info. This method returns the unique ID assigned to the session. ```java public String getId() ``` -------------------------------- ### AgentOptions Constructors Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/AgentOptions.html Provides different ways to instantiate AgentOptions: using default values, from a Properties object, or by parsing an option string. ```java new **AgentOptions**() ``` ```java new **AgentOptions**(Properties properties) ``` ```java new **AgentOptions**(String optionstr) ``` -------------------------------- ### Get and Reset Execution Data Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/agent/rt/IAgent.html Retrieves the current execution data and optionally clears it afterwards. Use this to obtain coverage information during runtime. ```java byte[] getExecutionData(boolean reset) ``` -------------------------------- ### MultiReportVisitor.visitInfo() Source: https://www.jacoco.org/jacoco/trunk/doc/api/index-all.html Initializes the aggregated report visitors with global session and execution data. ```APIDOC ## MultiReportVisitor.visitInfo(List sessionInfos, Collection executionData) ### Description Initializes the aggregated report visitors with global session and execution data. ### Method - **visitInfo(List sessionInfos, Collection executionData)**: Initializes the report with global information. ### Parameters #### visitInfo(List sessionInfos, Collection executionData) - **sessionInfos** (List) - Required - A list of session information. - **executionData** (Collection) - Required - A collection of execution data. ``` -------------------------------- ### Get Dump Time Stamp Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/SessionInfo.html Retrieves the epoch-based timestamp indicating when the execution data for this session was collected or dumped. This timestamp is used for sorting sessions. ```java public long getDumpTimeStamp() ``` -------------------------------- ### createVisitor Method Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/check/RulesChecker.html Creates a new visitor to process the configured checks. ```APIDOC ## createVisitor(IViolationsOutput output) ### Description Creates a new visitor to process the configured checks. ### Method public IReportVisitor ### Parameters #### Path Parameters - **output** (IViolationsOutput) - Required - call-back to report violations to ### Returns visitor to emit the report data to ``` -------------------------------- ### AgentOptions toString Method Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/AgentOptions.html Creates a string representation of agent options suitable for command-line arguments. Returns an empty string if no options are set. ```java public String toString() ``` -------------------------------- ### Get Execution Data by ID Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/ExecutionDataStore.html Retrieves the `ExecutionData` object associated with a specific class ID. Returns `null` if no data exists for the given ID. ```java public ExecutionData get(long id) ``` -------------------------------- ### Get All Enum Constants - ICounter.CounterValue.values() Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/analysis/ICounter.CounterValue.html Retrieves an array of all constants declared in the ICounter.CounterValue enum. This method is useful for iterating through all possible counter value types. ```java public static final ICounter.CounterValue[] **values**() Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows: ``` for(ICounter.CounterValue c : ICounter.CounterValue.values()) System.out.println(c); ``` ``` -------------------------------- ### Methods Using ICoverageNode.CounterEntity Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/analysis/class-use/ICoverageNode.CounterEntity.html Demonstrates methods that accept ICoverageNode.CounterEntity as a parameter, used for accessing specific counters or creating comparators. ```APIDOC ## `ICounter` getCounter(ICoverageNode.CounterEntity entity) ### Description Retrieves the counter for a specific entity type. ### Method (Implicitly public within its class) ### Parameters #### Path Parameters - **entity** (ICoverageNode.CounterEntity) - The type of counter to retrieve. ## `ICounter` getCounter(ICoverageNode.CounterEntity entity) ### Description Generic access to the counters. ### Method (Implicitly public within its class) ### Parameters #### Path Parameters - **entity** (ICoverageNode.CounterEntity) - The entity for which to get the counter. ## `NodeComparator` on(ICoverageNode.CounterEntity entity) ### Description Creates a new comparator for `ICoverageNode` counters of the given entity based on this counter sorting criteria. ### Method (Implicitly public within its class) ### Parameters #### Path Parameters - **entity** (ICoverageNode.CounterEntity) - The entity type for which to create the comparator. ``` -------------------------------- ### SessionInfoStore Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/index-all.html Default constructor for SessionInfoStore. ```APIDOC ## SessionInfoStore() ### Description Default constructor for SessionInfoStore. ### Method SessionInfoStore ``` -------------------------------- ### ExecFileLoader Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/tools/ExecFileLoader.html Creates a new instance of ExecFileLoader to combine session information and execution data from multiple files. ```APIDOC ## ExecFileLoader() ### Description New instance to combine session infos and execution data from multiple files. ### Constructor ```java public ExecFileLoader() ``` ``` -------------------------------- ### get(long id) Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/ExecutionDataStore.html Returns the ExecutionData entry associated with the given class ID, if it exists in the store. Returns null if no data is found for the specified ID. ```APIDOC ## get(long id) ### Description Returns the `ExecutionData` entry with the given id if it exists in this store. ### Method ```java public ExecutionData get(long id) ``` ### Parameters #### Path Parameters - **id** (long) - Required - class id ### Returns - execution data or `null` ``` -------------------------------- ### Get Agent JAR Resource as InputStream Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/agent/AgentJar.html Returns the content of the JaCoCo agent JAR file as an InputStream. This allows reading the JAR's content directly. ```java public static InputStream getResourceAsStream() ``` -------------------------------- ### MultiReportVisitor Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/MultiReportVisitor.html Initializes a new MultiReportVisitor by delegating to a list of provided report visitors. ```APIDOC ## MultiReportVisitor Constructor ### Description New visitor delegating to all given visitors. ### Parameters - **visitors** (List) - The list of visitors to delegate to. ``` -------------------------------- ### Get JaCoCo Class Information Source: https://www.jacoco.org/jacoco/trunk/doc/cli.html Print information about Java class files. This command can display method and line number details if the --verbose option is used. ```bash java -jar jacococli.jar classinfo [ ...] [--help] [--quiet] [--verbose] ``` -------------------------------- ### Instrumenter Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/class-use/IExecutionDataAccessorGenerator.html Demonstrates the creation of an Instrumenter instance, which requires an IExecutionDataAccessorGenerator for runtime operations. ```APIDOC ## Instrumenter(IExecutionDataAccessorGenerator runtime) ### Description Creates a new instance of the `Instrumenter` class, which is used for instrumenting Java class files for code coverage. It requires an implementation of `IExecutionDataAccessorGenerator` to handle runtime data access. ### Method Constructor ### Parameters #### Path Parameters - **runtime** (IExecutionDataAccessorGenerator) - Required - The runtime accessor generator to be used by the instrumenter. ``` -------------------------------- ### AbstractRuntime Class Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/runtime/package-summary.html A base implementation of the IRuntime interface, providing common functionality for runtime data collection. ```APIDOC ## Class AbstractRuntime ### Description Base `IRuntime` implementation. ### Methods (No specific methods documented in the source) ``` -------------------------------- ### Getting ElementType by Name Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/analysis/ICoverageNode.ElementType.html Shows how to retrieve a specific enum constant by its name using the valueOf() method. This method requires an exact match of the constant's identifier. ```java ICoverageNode.ElementType.valueOf(String name) ``` -------------------------------- ### Get JaCoCo Agent Instance Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/agent/rt/RT.html Retrieves the active agent instance of the JaCoCo runtime in the current JVM. This method is the primary way to interact with the JaCoCo agent at runtime. ```APIDOC ## getAgent ### Description Returns the agent instance of the JaCoCo runtime in this JVM. ### Method `static IAgent getAgent()` ### Throws `IllegalStateException` - if no Agent has been started yet. ``` -------------------------------- ### visitBundle Method Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/MultiReportVisitor.html Adds a bundle of coverage data to the report. This method is called to include a specific bundle and its associated source files. ```java public void visitBundle(IBundleCoverage bundle, ISourceFileLocator locator) throws IOException ``` -------------------------------- ### InputStreamSourceFileLocator Constructor Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/InputStreamSourceFileLocator.html Initializes a new InputStreamSourceFileLocator with the specified encoding and tab width. ```APIDOC ## InputStreamSourceFileLocator(String encoding, int tabWidth) ### Description Creates a new locator with the given specification. ### Parameters - **encoding** (String) - encoding of the source files, `null` for platform default encoding - **tabWidth** (int) - tab width in source files as number of blanks ``` -------------------------------- ### Get Agent JAR Resource URL Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/agent/AgentJar.html Retrieves a URL pointing to the JaCoCo agent JAR file. This is useful for accessing the agent JAR as a resource without extracting it. ```java public static URL getResource() ``` -------------------------------- ### getFileHeader Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/ExecutionDataWriter.html Returns the first bytes of a file that represents a valid execution data file. Every execution data file starts with the three bytes 0x01 0xC0 0xC0. ```APIDOC ## getFileHeader ### Description Returns the first bytes of a file that represents a valid execution data file. In any case every execution data file starts with the three bytes `0x01 0xC0 0xC0`. ### Method ```java public static byte[] getFileHeader() ``` ### Returns - `byte[]`: first bytes of an execution data file ``` -------------------------------- ### createFile Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/ZipMultiReportOutput.html Creates a file at the given local path within the ZIP archive. The returned OutputStream must be closed after writing. ```APIDOC ## createFile ### Description Creates a file at the given local path. The returned `OutputStream` has to be closed before the next document is created. ### Method public OutputStream createFile(String path) throws IOException ### Parameters - **path** (String) - local path to the new document ### Returns - OutputStream - output for the content ### Throws - IOException - if the creation fails ``` -------------------------------- ### Get Enum Constant by Name - ICounter.CounterValue.valueOf() Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/analysis/ICounter.CounterValue.html Retrieves the enum constant of type ICounter.CounterValue with the specified name. The name must exactly match an identifier used to declare an enum constant. ```java public static ICounter.CounterValue **valueOf**(String name) Returns the enum constant of this type with the specified name. The string must match _exactly_ an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.) ``` -------------------------------- ### Constructor: ZipMultiReportOutput(ZipOutputStream) Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/ZipMultiReportOutput.html Creates a new instance of ZipMultiReportOutput using an existing ZipOutputStream. This is useful when you already have a ZipOutputStream open and want to write report files into it. ```java public ZipMultiReportOutput(ZipOutputStream zip) ``` -------------------------------- ### ExecutionDataStore.accept Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/data/class-use/IExecutionDataVisitor.html Writes the content of the ExecutionDataStore to the provided IExecutionDataVisitor. ```APIDOC ## ExecutionDataStore.accept ### Description Writes the content of the store to the given visitor interface. ### Method Signature `void accept(IExecutionDataVisitor visitor)` ### Parameters * **visitor** (IExecutionDataVisitor) - The visitor to which the execution data will be written. ``` -------------------------------- ### Visit Bundle Method Source: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/report/IReportGroupVisitor.html Call this method to add a coverage bundle to the report. Requires a bundle object and a source file locator. This method can throw an IOException. ```java void **visitBundle**(IBundleCoverage bundle, ISourceFileLocator locator) throws IOException ``` -------------------------------- ### Compile with JDK 11 and ECJ Source: https://www.jacoco.org/jacoco/trunk/doc/build.html This command compiles using JDK 11 and the Eclipse Compiler for Java (ECJ), targeting bytecode version 11. It's an example of combining multiple configuration options. ```bash ../mvnw clean verify -Djdk.version=11 -Dbytecode.version=11 -Decj ``` -------------------------------- ### ZipMultiReportOutput Constructor (ZipOutputStream) Source: https://www.jacoco.org/jacoco/trunk/doc/api/index-all.html Creates a new ZipMultiReportOutput instance based on the given ZipOutputStream. ```APIDOC ## ZipMultiReportOutput(ZipOutputStream) ### Description Creates a new instance based on the given `ZipOutputStream`. ### Constructor `org.jacoco.report.ZipMultiReportOutput(ZipOutputStream zipOutputStream)` ```