blob: 3f55c6f6fe9bd11b77c518493b7af22c26e68bab [file] [log] [blame]
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +00001<?xml version="1.0" encoding="ISO-8859-1" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
4<head>
5 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
6 <link rel="stylesheet" href=".resources/doc.css" charset="ISO-8859-1" type="text/css" />
Marc R. Hoffmannd7d2f752010-05-06 21:12:31 +00007 <link rel="shortcut icon" href=".resources/report.gif" type="image/gif" />
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +00008 <title>JaCoCo - Java Agent</title>
9</head>
10<body>
11
12<div class="breadcrumb">
Marc R. Hoffmannd7d2f752010-05-06 21:12:31 +000013 <a href="../index.html" class="el_report">JaCoCo</a> &gt;
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +000014 <a href="index.html" class="el_group">Documentation</a> &gt;
15 <span class="el_source">Java Agent</span>
16</div>
Marc R. Hoffmann17be2692010-02-02 05:44:47 +000017<div id="content">
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +000018
19<h1>Java Agent</h1>
20
21<p>
22 JaCoCo uses class file instrumentation to record execution coverage data.
Radek Libaad5fbc92009-10-26 13:26:53 +000023 Class files are instrumented on-the-fly using a so called Java agent. This
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +000024 mechanism allows in-memory pre-processing of all class files during class
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +000025 loading independent of the application framework.
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +000026</p>
27
28<p class="hint">
Evgeny Mandrikovc951bf22011-06-27 00:04:43 +000029 If you use the <a href="ant.html">JaCoCo Ant tasks</a> or <a href="maven.html">JaCoCo Maven plug-in</a>
30 you don't have to care about the agent and its options directly. This is
31 transparently handled by the them.
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +000032</p>
33
34<p>
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +000035 The JaCoCo agent collects execution information and dumps it on request or
36 when the JVM exits. There are three different modes for execution data ouput:
37</p>
38
39<ul>
40 <li>File System: At JVM termination execution data is written to a local file.</li>
41 <li>TCP Socket Server: External tools can connect to the JVM and retrieve execution data over the socket connection. Optional execution data reset and execution data dump on VM exit is possible.</li>
Evgeny Mandrikovc951bf22011-06-27 00:04:43 +000042 <li>TCP Socket Client: At startup the JaCoCo agent connects to a given TCP endpoint. Execution data is written to the socket connection on request. Optional execution data reset and execution data dump on VM exit is possible.</li>
43 <li>JMX: External tools can connect to the JVM and retrieve execution data over the JMX.</li>
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +000044</ul>
45
46<p>
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +000047 The agent <code>jacocoagent.jar</code> is part of the JaCoCo distribution and
48 includes all required dependencies. A Java agent can be activated with the
49 following JVM option:
50</p>
51
52<pre>
53 -javaagent:<i>[yourpath/]</i>jacocoagent.jar=<i>[option1]</i>=<i>[value1]</i>,<i>[option2]</i>=<i>[value2]</i>
54</pre>
55
56<p>
57 The JaCoCo agent accepts the following options:
58</p>
59
60<table class="coverage">
61 <thead>
62 <tr>
63 <td>Option</td>
64 <td>Description</td>
65 <td>Default</td>
66 </tr>
67 </thead>
68 <tbody>
69 <tr>
Brock Janiczak003d47c2010-01-15 00:45:17 +000070 <td><code>destfile</code></td>
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +000071 <td>Path to the output file for execution data.</td>
72 <td><code>jacoco.exec</code></td>
73 </tr>
74 <tr>
Brock Janiczak003d47c2010-01-15 00:45:17 +000075 <td><code>append</code></td>
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +000076 <td>If set to <code>true</code> and the execution data file already
Brock Janiczak003d47c2010-01-15 00:45:17 +000077 exists, coverage data is appended to the existing file. If set to
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +000078 <code>false</code>, an existing execution data file will be replaced.
79 </td>
80 <td><code>true</code></td>
81 </tr>
82 <tr>
Marc R. Hoffmanncf5345f2009-09-10 15:01:24 +000083 <td><code>includes</code></td>
Radek Libaad5fbc92009-10-26 13:26:53 +000084 <td>A list of class names that should be included in execution analysis.
Evgeny Mandrikovbab5da42011-02-20 21:43:33 +000085 The list entries are separated by a colon (<code>:</code>) and
Marc R. Hoffmanncf5345f2009-09-10 15:01:24 +000086 may use wildcard characters (<code>*</code> and <code>?</code>).
87 Except for performance optimization or technical corner cases this
88 option is normally not required.
89 </td>
90 <td><code>*</code> (all classes)</td>
91 </tr>
92 <tr>
93 <td><code>excludes</code></td>
94 <td>A list of class names that should be excluded from execution analysis.
Evgeny Mandrikovbab5da42011-02-20 21:43:33 +000095 The list entries are separated by a colon (<code>:</code>) and
Marc R. Hoffmanncf5345f2009-09-10 15:01:24 +000096 may use wildcard characters (<code>*</code> and <code>?</code>).
97 Except for performance optimization or technical corner cases this
98 option is normally not required.
99 </td>
100 <td><i>empty</i> (no excluded classes)</td>
101 </tr>
102 <tr>
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +0000103 <td><code>exclclassloader</code></td>
Marc R. Hoffmanncf5345f2009-09-10 15:01:24 +0000104 <td>A list of class loader names that should be excluded from execution
Evgeny Mandrikovbab5da42011-02-20 21:43:33 +0000105 analysis. The list entries are separated by a colon
106 (<code>:</code>) and may use wildcard characters (<code>*</code> and
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +0000107 <code>?</code>). This option might be required in case of special
108 frameworks that conflict with JaCoCo code instrumentation, in
109 particular class loaders that do not have access to the Java runtime
110 classes.
111 </td>
112 <td><code>sun.reflect.DelegatingClassLoader</code></td>
113 </tr>
Brock Janiczakf2d6f882010-05-04 06:47:40 +0000114 <tr>
Marc R. Hoffmannadfa1182010-05-05 12:59:42 +0000115 <td><code>sessionid</code></td>
116 <td>A session identifier that is written with the execution data. Without
117 this parameter a random identifier is created by the agent.
118 </td>
119 <td><i>auto-generated</i></td>
120 </tr>
121 <tr>
Brock Janiczakf2d6f882010-05-04 06:47:40 +0000122 <td><code>dumponexit</code></td>
Marc R. Hoffmannadfa1182010-05-05 12:59:42 +0000123 <td>If set to <code>true</code> coverage data will be written on VM
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +0000124 shutdown. The dump can only be written if either <code>file</code> is
125 specified or the output is <code>tcpserver</code>/<code>tcpclient</code>
126 and a connection is open at the time when the VM terminates.
Marc R. Hoffmannadfa1182010-05-05 12:59:42 +0000127 </td>
Brock Janiczakf2d6f882010-05-04 06:47:40 +0000128 <td><code>true</code></td>
129 </tr>
Brock Janiczakbd638302010-05-11 11:04:37 +0000130 <tr>
131 <td><code>output</code></td>
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +0000132 <td>Output method to use for writing coverage data. Valid options are:
Brock Janiczakbd638302010-05-11 11:04:37 +0000133 <ul>
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +0000134 <li><code>file</code>: At VM termination execution data is written to
Evgeny Mandrikov0d5cda12011-06-24 20:33:43 +0000135 the file specified in the <code>destfile</code> attribute.</li>
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +0000136 <li><code>tcpserver</code>: The agent listens for incoming connections
137 on the TCP port specified by the <code>address</code> and
138 <code>port</code> attribute. Execution data is written to this
139 TCP connection.</li>
140 <li><code>tcpclient</code>: At startup the agent connects to the TCP
141 port specified by the <code>address</code> and <code>port</code>
142 attribute. Execution data is written to this TCP connection.</li>
Marc R. Hoffmannc0658682011-06-20 06:01:37 +0000143 <li><code>mbean</code>: The agent registers an JMX MBean under the
144 name <code>org.jacoco:type=Runtime</code>.</li>
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +0000145 </ul>
Marc R. Hoffmann8e8480b2010-06-02 08:28:27 +0000146 Please see the security considerations below.
Brock Janiczakbd638302010-05-11 11:04:37 +0000147 </td>
148 <td><code>file</code></td>
149 </tr>
150 <tr>
151 <td><code>address</code></td>
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +0000152 <td>IP address or hostname to bind to when the output method is
153 <code>tcpserver</code> or connect to when the output method is
Marc R. Hoffmann1cf157a2010-06-04 05:54:48 +0000154 <code>tcpclient</code>. In <code>tcpserver</code> mode the value
155 "<code>*</code>" causes the agent to accept connections on any local
156 address.
Brock Janiczakbd638302010-05-11 11:04:37 +0000157 </td>
Marc R. Hoffmann1cf157a2010-06-04 05:54:48 +0000158 <td><i>loopback interface</i></td>
Brock Janiczakbd638302010-05-11 11:04:37 +0000159 </tr>
160 <tr>
161 <td><code>port</code></td>
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +0000162 <td>Port to bind to when the output method is <code>tcpserver</code> or
163 connect to when the output method is <code>tcpclient</code>. In
164 <code>tcpserver</code> mode the port must be available, which means
165 that if multiple JaCoCo agents should run on the same machine,
166 different ports have to be specified.
Brock Janiczakbd638302010-05-11 11:04:37 +0000167 </td>
168 <td><code>6300</code></td>
169 </tr>
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +0000170 </tbody>
171</table>
172
Marc R. Hoffmann8e8480b2010-06-02 08:28:27 +0000173<h2>Security Consideration for Remote Agent Control</h2>
174
175<p>
176 The ports and connections opened in <code>tcpserver</code> and
177 <code>tcpclient</code> mode do not provide any authentication mechanism. If
178 you run JaCoCo on production systems make sure that no untrusted sources have
179 access to the TCP server port, or JaCoCo TCP clients only connect to trusted
180 targets. Otherwise internal information of the application might be revealed
181 or DOS attacks are possible.
182</p>
183
Marc R. Hoffmann17be2692010-02-02 05:44:47 +0000184</div>
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +0000185<div class="footer">
Marc R. Hoffmannb623ffb2010-05-06 19:48:08 +0000186 <span class="right"><a href="@jacoco.home.url@">JaCoCo</a> @qualified.bundle.version@</span>
Marc R. Hoffmanndf6ff962010-04-09 15:31:22 +0000187 <a href="license.html">Copyright</a> &copy; @copyright.years@ Mountainminds GmbH &amp; Co. KG and Contributors
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +0000188</div>
189
190</body>
191</html>