blob: aa38a2d9391278e189a6fc7c59198192806a703d [file] [log] [blame]
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +02001<?xml version="1.0" encoding="UTF-8" ?>
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=UTF-8" />
Evgeny Mandrikov8b212982016-06-12 17:55:49 +02006 <link rel="stylesheet" href="resources/doc.css" charset="UTF-8" type="text/css" />
7 <link rel="shortcut icon" href="resources/report.gif" type="image/gif" />
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +02008 <title>JaCoCo - FAQ</title>
9</head>
10<body>
11
12<div class="breadcrumb">
13 <a href="../index.html" class="el_report">JaCoCo</a> &gt;
14 <a href="index.html" class="el_group">Documentation</a> &gt;
15 <span class="el_source">FAQ</span>
16</div>
17<div id="content">
18
19<h1>FAQ</h1>
20
21<p>
22 This is a compilation of questions that have been asked by JaCoCo users
23 before.
24</p>
25
26<h3>Does JaCoCo have a plug-in for [Eclipse|Netbeans|Whatever...]?</h3>
27<p>
28 See <a href="integrations.html">this list</a> for current integrations with
29 various tools.
Marc R. Hoffmann08db74b2013-01-16 07:58:13 +010030</p>
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +020031
Marc R. Hoffmann2cd6b612014-03-12 22:36:32 +010032<h3>What Java versions are supported by JaCoCo?</h3>
33<p>
Marc R. Hoffmann5c230162014-07-08 20:59:54 +020034 JaCoCo supports Java class files from version 1.0 to 1.8. However the minimum
Marc R. Hoffmann2cd6b612014-03-12 22:36:32 +010035 JRE version required by the JaCoCo runtime (e.g. the agent) and the JaCoCo
36 tools is 1.5. Also note that class files under test from version 1.6 and above
37 have to contain valid stackmap frames.
38</p>
39
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +020040<h3>Why do I get the error "Can't add different class with same name"?</h3>
41<p>
42 For coverage report generation all classes within a group must have unique
43 names. You get this error during report generation if JaCoCo is supplied with
44 multiple different class files with the same name. To fix this remove those
45 duplicate classes or create separate reports or report groups for each version.
Marc R. Hoffmann08db74b2013-01-16 07:58:13 +010046</p>
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +020047
Marc R. Hoffmann87311452015-02-16 09:09:25 +010048<h3>Source code lines with exceptions show no coverage. Why?</h3>
Marc R. Hoffmannf6787ed2012-11-13 23:03:55 +010049<p>
50 JaCoCo determines code execution with so called probes. Probes are inserted
51 into the control flow at certain positions. Code is considered as executed
52 when a subsequent probe has been executed. In case of exceptions such a
Marc R. Hoffmann87311452015-02-16 09:09:25 +010053 sequence of instructions is aborted somewhere in the middle and the
54 corresponding line of source code is not marked as covered.
Marc R. Hoffmannf6787ed2012-11-13 23:03:55 +010055</p>
56
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +020057<h3>Why does the coverage report not show line coverage figures?</h3>
58<p>
Marc R. Hoffmann9a7379b2012-09-21 21:48:35 +020059 JaCoCo is based on class files analysis. To calculate line coverage class
60 files must contain line number attributes. For this your code must be compiled
61 with debug information.
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +020062</p>
63
Marc R. Hoffmannfa48e772014-03-13 12:31:30 +010064<h3>Why does the coverage report not show highlighted source code?</h3>
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +020065<p>
66 Make sure the following prerequisites are fulfilled to get source code
67 highlighting in JaCoCo coverage reports:
68</p>
69<ul>
70 <li>Class files must be compiled with debug information to contain line numbers.</li>
71 <li>Source files must be properly supplied at report generation time. I.e.
72 specified source folders must be the direct parent of the folders that
73 define the Java packages.</li>
74</ul>
75
76<h3>Why does a class show as not covered although it has been executed?</h3>
77<p>
78 First make sure execution data has been collected. For this select the
79 <i>Sessions</i> link on the top right corner of the HTML report and check
80 whether the class in question is listed. If it is listed but not linked the
81 class at execution time is a different class file. Make sure you're using the
Marc R. Hoffmann9a7379b2012-09-21 21:48:35 +020082 exact same class file at runtime as for report generation. Note that some
83 tools (e.g. EJB containers, mocking frameworks) might modify your class files
Marc R. Hoffmannfa48e772014-03-13 12:31:30 +010084 at runtime. Please see the chapter about <a href="classids.html"> class
85 ids</a> for a detailed discussion.
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +020086</p>
87
88<h3>Why are Java interface types not shown in the coverage reports?</h3>
89<p>
90 Java interface methods do not contain code, therefore code coverage cannot
91 be evaluated. Indeed code coverage is recorded for the implementation classes.
92 The same applies to abstract methods in abstract classes.
93</p>
94
Marc R. Hoffmann9a7379b2012-09-21 21:48:35 +020095<h3>Can I collect coverage information without stopping the JVM?</h3>
96<p>
Marc R. Hoffmann0974a252014-12-14 11:46:00 +010097 Yes, there are two possible ways: The JaCoCo <a href="agent.html">agent</a>
98 can be configured for remote control via TCP/IP sockets. This allows to
99 collect execution data at any point in time from a running JVM. The
100 <a href="ant.html#dump"><code>dump</code> Ant task</a> or the
101 <a href="dump-mojo.html"><code>dump</code> Maven goal</a> can be used to
102 request dumps. The remote control feature also allows you to reset execution
103 data.
104</p>
105<p>
106 Alternatively the JaCoCo <a href="agent.html">agent</a> can be configured to
107 expose some functionality via JMX (<code>jmx=true</code>). The bean
108 <code><a href="./api/org/jacoco/agent/rt/IAgent.html">org.jacoco:type=Runtime</a></code>
109 provides operations to dump and reset execution data at any point in time.
Marc R. Hoffmann9a7379b2012-09-21 21:48:35 +0200110</p>
111
Marc R. Hoffmann08db74b2013-01-16 07:58:13 +0100112<h3>My code uses reflection. Why does it fail when I execute it with JaCoCo?</h3>
113<p>
114 To collect execution data JaCoCo instruments the classes under test which adds
115 two members to the classes: A private static field <code>$jacocoData</code>
116 and a private static method <code>$jacocoInit()</code>. Both members are
117 marked as synthetic.
118</p>
119<p>
120 Please change your code to ignore synthetic members. This is a good practice
121 anyways as also the Java compiler creates synthetic members in certain
122 situation.
123</p>
124
Marc R. Hoffmann0974a252014-12-14 11:46:00 +0100125<h3>Why do I get an error while instrumenting certain Java classes?</h3>
126<p>
127 JaCoCo can instrument valid class files only. Class files with syntactical or
128 semantical error will typically lead to exceptions. In certain areas JaCoCo is
129 more restrictive then the JVM: JaCoCo expects valid so-called "stackmap
130 frame" information in class files of version 1.6 or higher. In turn JaCoCo
131 instrumented classes are expected to conform the specification.
132</p>
133<p>
134 Invalid class files are typically created by some frameworks which do not
135 properly adjust stackmap frames when manipulating bytecode.
136</p>
137
Marc R. Hoffmann2ed0ccb2014-10-31 07:56:34 +0100138<h3>Does JaCoCo run on the IBM JRE J9 and WebSphere?</h3>
139<p>
140 It does. To make the JaCoCo agent work please set the VM option
Marc R. Hoffmannf6bcb212014-12-16 02:56:17 +0100141 <code>-Xshareclasses:none</code>.
Marc R. Hoffmann2ed0ccb2014-10-31 07:56:34 +0100142</p>
143
Marc R. Hoffmann0b8331b2012-09-19 20:45:37 +0200144</div>
145<div class="footer">
146 <span class="right"><a href="@jacoco.home.url@">JaCoCo</a> @qualified.bundle.version@</span>
147 <a href="license.html">Copyright</a> &copy; @copyright.years@ Mountainminds GmbH &amp; Co. KG and Contributors
148</div>
149
150</body>
151</html>