1<?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" /> 6 <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" /> 8 <title>JaCoCo - FAQ</title> 9</head> 10<body> 11 12<div class="breadcrumb"> 13 <a href="../index.html" class="el_report">JaCoCo</a> > 14 <a href="index.html" class="el_group">Documentation</a> > 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>When will feature X be released?</h3> 27<p> 28 JaCoCo is maintained by volunteers in their free time. Since we cannot 29 guarantee free capacity, we do not commit to particular release dates. 30 Typically, you can expect a couple of releases every year. 31</p> 32<p> 33 In the <a href="changes.html">change log</a>, you can see all features 34 that have been implemented in master branch and will be available 35 with the next release. And in the meantime you can test latest build 36 of master branch (<a href="repo.html">Maven SNAPSHOT</a>) and provide 37 <a href="support.html">feedback</a> to us. 38</p> 39 40<h3>Does JaCoCo have a plug-in for [Eclipse|Netbeans|Whatever...]?</h3> 41<p> 42 See <a href="integrations.html">this list</a> for current integrations with 43 various tools. 44</p> 45 46<h3>What Java versions are supported by JaCoCo?</h3> 47<p> 48 JaCoCo supports Java class files from version 1.0 to 16. However the minimum 49 JRE version required by the JaCoCo runtime (e.g. the agent) and the JaCoCo 50 tools is 1.5. Also note that class files under test from version 1.6 and above 51 have to contain valid stackmap frames. 52</p> 53 54<h3>Why do I get the error "Can't add different class with same name"?</h3> 55<p> 56 For coverage report generation all classes within a group must have unique 57 names. You get this error during report generation if JaCoCo is supplied with 58 multiple different class files with the same name. To fix this remove those 59 duplicate classes or create separate reports or report groups for each version. 60</p> 61 62<h3>Source code lines with exceptions show no coverage. Why?</h3> 63<p> 64 JaCoCo determines code execution with so called probes. Probes are inserted 65 into the control flow at certain positions. Code is considered as executed 66 when a subsequent probe has been executed. In case of exceptions such a 67 sequence of instructions is aborted somewhere in the middle and the 68 corresponding line of source code is not marked as covered. 69</p> 70 71<h3>Why does the coverage report not show line coverage figures?</h3> 72<p> 73 JaCoCo is based on class files analysis. To calculate line coverage class 74 files must contain line number attributes. For this your code must be compiled 75 with debug information. 76</p> 77 78<h3>Why does the coverage report not show highlighted source code?</h3> 79<p> 80 Make sure the following prerequisites are fulfilled to get source code 81 highlighting in JaCoCo coverage reports: 82</p> 83<ul> 84 <li>Class files must be compiled with debug information to contain line numbers.</li> 85 <li>Source files must be properly supplied at report generation time. I.e. 86 specified source folders must be the direct parent of the folders that 87 define the Java packages.</li> 88</ul> 89 90<h3>Why does a class show as not covered although it has been executed?</h3> 91<p> 92 First make sure execution data has been collected. For this select the 93 <i>Sessions</i> link on the top right corner of the HTML report and check 94 whether the class in question is listed. If it is listed but not linked the 95 class at execution time is a different class file. Make sure you're using the 96 exact same class file at runtime as for report generation. Note that some 97 tools (e.g. EJB containers, mocking frameworks) might modify your class files 98 at runtime. Please see the chapter about <a href="classids.html"> class 99 ids</a> for a detailed discussion. 100</p> 101 102<h3>Why are abstract methods not shown in coverage reports?</h3> 103<p> 104 Abstract methods do not contain code, therefore code coverage cannot be 105 evaluated. Indeed code coverage is recorded for subclasses implementing these 106 methods. The same applies to non-default methods in interfaces. 107</p> 108 109<h3>Can I collect coverage information without stopping the JVM?</h3> 110<p> 111 Yes, there are three possible ways: The JaCoCo <a href="agent.html">agent</a> 112 can be configured for remote control via TCP/IP sockets. This allows to 113 collect execution data at any point in time from a running JVM. The 114 <a href="ant.html#dump"><code>dump</code> Ant task</a>, the 115 <a href="dump-mojo.html"><code>dump</code> Maven goal</a> and the 116 <a href="cli.html">command line interface</a> can be used to request dumps. 117 The remote control feature also allows you to reset execution data. 118</p> 119<p> 120 Alternatively the JaCoCo <a href="agent.html">agent</a> can be configured to 121 expose some functionality via JMX (<code>jmx=true</code>). The bean 122 <code><a href="./api/org/jacoco/agent/rt/IAgent.html">org.jacoco:type=Runtime</a></code> 123 provides operations to dump and reset execution data at any point in time. 124</p> 125<p> 126 In addition JaCoCo provides a <a href="./api/org/jacoco/agent/rt/RT.html">Java API</a> 127 to directly access the runtime within the JVM executing the tests. 128</p> 129 130<h3>My code uses reflection. Why does it fail when I execute it with JaCoCo?</h3> 131<p> 132 To collect execution data JaCoCo instruments the classes under test which adds 133 two members to the classes: A private static field <code>$jacocoData</code> 134 and a private static method <code>$jacocoInit()</code>. Both members are 135 marked as synthetic. 136</p> 137<p> 138 Please change your code to ignore synthetic members. This is a good practice 139 anyways as also the Java compiler creates synthetic members in certain 140 situation. 141</p> 142 143<h3>Why do I get an error while instrumenting certain Java classes?</h3> 144<p> 145 JaCoCo can instrument valid class files only. Class files with syntactical or 146 semantical error will typically lead to exceptions. In certain areas JaCoCo is 147 more restrictive then the JVM: JaCoCo expects valid so-called "stackmap 148 frame" information in class files of version 1.6 or higher. In turn JaCoCo 149 instrumented classes are expected to conform the specification. 150</p> 151<p> 152 Invalid class files are typically created by some frameworks which do not 153 properly adjust stackmap frames when manipulating bytecode. 154</p> 155 156<h3>Does JaCoCo run on the IBM JRE J9 and WebSphere?</h3> 157<p> 158 It does. To make the JaCoCo agent work please set the VM option 159 <code>-Xshareclasses:none</code>. 160</p> 161 162<h3>Why do I get a <code>NoClassDefFoundError</code> or 163 <code>ClassNotFoundException</code> for class 164 <code>org.jacoco.agent[...]Offline</code>?</h3> 165<p> 166 If you use <a href="offline.html">offline instrumentation</a> the instrumented 167 classes get a direct dependency on the JaCoCo runtime. Therefore 168 <code>jacocoagent.jar</code> of the same JaCoCo version must be on the 169 classpath and accessible from by the instrumented classes. 170</p> 171 172<h3>Why do I get a <code>StackOverflowError</code> during code coverage analysis?</h3> 173<p> 174 There are two known reasons for this: 175</p> 176<ul> 177 <li>Misconfiguration: If you configure two JaCoCo agents of different releases 178 they will instrument each other and cause a endless recursion. Check the 179 effective java command line and avoid such configurations.</li> 180 <li>Heavy stack usage: JaCoCo instrumentation adds a small runtime overhead 181 by adding a local variable to each method. If your application is already 182 close to the maximum stack size this can eventually lead to an 183 <code>StackOverflowError</code>. Increase the maximum java stack size with 184 the <code>-Xss</code> JVM option.</li> 185</ul> 186 187<h3>Why do I see classes in the coverage report although I excluded them in the JaCoCo agent configuration?</h3> 188<p> 189 The <code>includes</code> and <code>excludes</code> options of the 190 <a href="agent.html">JaCoCo agent</a> determine for which classes execution 191 data is collected. Except for technical corner cases these options are 192 normally not required. If you exclude classes, no execution data is collected 193 for them. 194</p> 195<p> 196 Report creation is a separate step where all class files which should show up 197 in the report are explicitly provided. Coverage is determined from the 198 provided execution data. If execution data is missing for a particular class, 199 this class is shown as not covered because the report generator cannot 200 distinguish whether the class was excluded from instrumentation or not executed. 201</p> 202 203<p> 204 If you want to exclude classes from the report please configure the 205 respective report generation tool accordingly. 206</p> 207 208</div> 209<div class="footer"> 210 <span class="right"><a href="${jacoco.home.url}">JaCoCo</a> ${qualified.bundle.version}</span> 211 <a href="license.html">Copyright</a> © ${copyright.years} Mountainminds GmbH & Co. KG and Contributors 212</div> 213 214</body> 215</html> 216