Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 1 | <?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" />
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 6 | <link rel="stylesheet" href=".resources/doc.css" charset="ISO-8859-1" type="text/css" />
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 7 | <title>JaCoCo - Implementation Design</title>
|
| 8 | </head>
|
| 9 | <body>
|
| 10 |
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 11 | <div class="breadcrumb">
|
| 12 | <a href="../index.html" class="el_session">JaCoCo</a> >
|
| 13 | <a href="index.html" class="el_group">Documentation</a> >
|
| 14 | <span class="el_source">Implementation Design</span>
|
| 15 | </div>
|
Marc R. Hoffmann | 17be269 | 2010-02-02 05:44:47 +0000 | [diff] [blame] | 16 | <div id="content">
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 17 |
|
| 18 | <h1>Implementation Design</h1>
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 19 |
|
| 20 | <p>
|
| 21 | This is a unordered list of implementation design decisions. Each topic tries
|
| 22 | to follow this structure:
|
| 23 | </p>
|
| 24 |
|
| 25 | <ul>
|
| 26 | <li>Problem statement</li>
|
| 27 | <li>Proposed Solution</li>
|
| 28 | <li>Alternatives and Discussion</li>
|
| 29 | </ul>
|
| 30 |
|
| 31 |
|
| 32 | <h2>Coverage Analysis Mechanism</h2>
|
| 33 |
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 34 | <p class="intro">
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 35 | Coverage information has to be collected at runtime. For this purpose JaCoCo
|
| 36 | creates instrumented versions of the original class definitions. The
|
| 37 | instrumentation process happens on-the-fly during class loading using so
|
| 38 | called Java agents.
|
| 39 | </p>
|
| 40 |
|
| 41 | <p>
|
| 42 | There are several different approaches to collect coverage information. For
|
| 43 | each approach different implementation techniques are known. The following
|
| 44 | diagram gives an overview with the techniques used by JaCoCo highlighted:
|
| 45 | </p>
|
| 46 |
|
| 47 | <ul>
|
| 48 | <li>Runtime Profiling
|
| 49 | <ul>
|
| 50 | <li>Java Virtual Machine Profiler Interface (JVMPI), until Java 1.4</li>
|
| 51 | <li>Java Virtual Machine Tool Interface (JVMTI), since Java 1.5</li>
|
| 52 | </ul>
|
| 53 | </li>
|
Marc R. Hoffmann | e52a0ef | 2009-06-16 20:28:45 +0000 | [diff] [blame] | 54 | <li><span class="high">Instrumentation*</span>
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 55 | <ul>
|
| 56 | <li>Java Source Instrumentation</li>
|
Marc R. Hoffmann | c4b2078 | 2009-10-02 13:28:46 +0000 | [diff] [blame] | 57 | <li><span class="high">Byte Code Instrumentation*</span>
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 58 | <ul>
|
| 59 | <li>Offline
|
| 60 | <ul>
|
| 61 | <li>Replace Original Classes In-Place</li>
|
| 62 | <li>Inject Instrumented Classes into the Class Path</li>
|
| 63 | </ul>
|
| 64 | </li>
|
Marc R. Hoffmann | e52a0ef | 2009-06-16 20:28:45 +0000 | [diff] [blame] | 65 | <li><span class="high">On-The-Fly*</span>
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 66 | <ul>
|
| 67 | <li>Special Classloader Implementions or Framework Specific Hooks</li>
|
Marc R. Hoffmann | e52a0ef | 2009-06-16 20:28:45 +0000 | [diff] [blame] | 68 | <li><span class="high">Java Agent*</span></li>
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 69 | </ul>
|
| 70 | </li>
|
| 71 | </ul>
|
| 72 | </li>
|
| 73 | </ul>
|
| 74 | </li>
|
| 75 | </ul>
|
| 76 |
|
| 77 | <p>
|
| 78 | Byte code instrumentation is very fast, can be implemented in pure Java and
|
| 79 | works with every Java VM. On-the-fly instrumentation with the Java agent
|
| 80 | hook can be added to the JVM without any modification of the target
|
| 81 | application.
|
| 82 | </p>
|
| 83 |
|
| 84 | <p>
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 85 | The Java agent hook requires at least 1.5 JVMs. Class files compiled with
|
| 86 | debug information (line numbers) allow for source code highlighting. Unluckily
|
| 87 | some Java language constructs get compiled to byte code that produces
|
| 88 | unexpected highlighting results, especially in case of implicitly generated
|
| 89 | code like default constructors or control structures for finally statements.
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 90 | </p>
|
| 91 |
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 92 |
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 93 | <h2>Instrumentation Approach</h2>
|
| 94 |
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 95 | <p class="intro">
|
Marc R. Hoffmann | 872290a | 2009-07-06 15:33:15 +0000 | [diff] [blame] | 96 | Instrumentation means inserting probes at certain check points in the Java
|
Marc R. Hoffmann | c4b2078 | 2009-10-02 13:28:46 +0000 | [diff] [blame] | 97 | byte code. A probe is a generated piece of byte code that records the fact
|
| 98 | that it has been executed. JaCoCo inserts probes at the end of every basic
|
| 99 | block.
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 100 | </p>
|
| 101 |
|
| 102 | <p>
|
Marc R. Hoffmann | 872290a | 2009-07-06 15:33:15 +0000 | [diff] [blame] | 103 | A basic block is a piece of byte code that has a single entry point (the first
|
| 104 | byte code instruction) and a single exit point (like <code>jump</code>,
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 105 | <code>throw</code> or <code>return</code>). A basic block must not contain jump
|
Marc R. Hoffmann | 872290a | 2009-07-06 15:33:15 +0000 | [diff] [blame] | 106 | targets except the entry point. One can think of basic blocks as the nodes in
|
| 107 | a control flow graph of a method. Using basic block boundaries to insert code
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 108 | coverage probes has been very successfully utilized by
|
Marc R. Hoffmann | 872290a | 2009-07-06 15:33:15 +0000 | [diff] [blame] | 109 | <a href="http://emma.sourceforge.net/">EMMA</a>.
|
| 110 | </p>
|
| 111 |
|
| 112 | <p>
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 113 | Basic block instrumentation works regardless of whether the class files have been
|
Marc R. Hoffmann | 872290a | 2009-07-06 15:33:15 +0000 | [diff] [blame] | 114 | compiled with debug information for source lines. Source code highlighting
|
| 115 | will of course not be possible without this debug information, but percentages
|
| 116 | on method level can still be calculated. Basic block probes result in
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 117 | reasonable overhead regarding class file size and performance. Partial line
|
| 118 | coverage can occur if a line contains more than one statement or a statement
|
| 119 | gets compiled into byte code forming more than one basic block (e.g. boolean
|
| 120 | assignments). Calculating basic block relies on the Java byte code only, therefore
|
Marc R. Hoffmann | 872290a | 2009-07-06 15:33:15 +0000 | [diff] [blame] | 121 | JaCoCo is independent of the source language and should also work with other
|
| 122 | Java VM based languages like <a href="http://www.scala-lang.org/">Scala</a>.
|
| 123 | </p>
|
| 124 |
|
| 125 | <p>
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 126 | The huge drawback of this approach is the fact that basic blocks are
|
Marc R. Hoffmann | 872290a | 2009-07-06 15:33:15 +0000 | [diff] [blame] | 127 | actually much smaller in the Java VM: Nearly every byte code instruction
|
| 128 | (especially method invocations) can result in an exception. In this case the
|
| 129 | block is left somewhere in the middle without hitting the probe, which leads
|
| 130 | to unexpected results for example in case of negative tests. A possible
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 131 | solution would be to add exception handlers that trigger special probes.
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 132 | </p>
|
| 133 |
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 134 | <h2>Coverage Agent Isolation</h2>
|
| 135 |
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 136 | <p class="intro">
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 137 | The Java agent is loaded by the application class loader. Therefore the
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 138 | classes of the agent live in the same name space like the application classes
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 139 | which can result in clashes especially with the third party library ASM. The
|
| 140 | JoCoCo build therefore moves all agent classes into a unique package.
|
| 141 | </p>
|
| 142 |
|
| 143 | <p>
|
| 144 | The JaCoCo build renames all classes contained in the
|
| 145 | <code>jacocoagent.jar</code> into classes with a
|
Marc R. Hoffmann | a942c89 | 2010-03-10 21:33:26 +0000 | [diff] [blame^] | 146 | <code>org.jacoco.agent.rt_<randomid></code> prefix, including the
|
| 147 | required ASM library classes. The identifier is created from a random number.
|
| 148 | As the agent does not provide any API, no one should be affected by this
|
| 149 | renaming. This trick also allows that JaCoCo tests can be verified with
|
| 150 | JaCoCo.
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 151 | </p>
|
| 152 |
|
| 153 |
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 154 | <h2>Minimal Java Version</h2>
|
| 155 |
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 156 | <p class="intro">
|
Marc R. Hoffmann | e52a0ef | 2009-06-16 20:28:45 +0000 | [diff] [blame] | 157 | JaCoCo requires Java 1.5.
|
| 158 | </p>
|
| 159 |
|
| 160 | <p>
|
| 161 | The Java agent mechanism used for on-the-fly instrumentation became available
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 162 | with Java 1.5 VMs. Coding and testing with Java 1.5 language level is more
|
| 163 | efficient, less error-prone – and more fun than with older versions.
|
| 164 | JaCoCo will still allow to run against Java code compiled for these.
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 165 | </p>
|
| 166 |
|
| 167 |
|
| 168 | <h2>Byte Code Manipulation</h2>
|
| 169 |
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 170 | <p class="intro">
|
Marc R. Hoffmann | e52a0ef | 2009-06-16 20:28:45 +0000 | [diff] [blame] | 171 | Instrumentation requires mechanisms to modify and generate Java byte code.
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 172 | JaCoCo uses the ASM library for this purpose internally.
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 173 | </p>
|
| 174 |
|
Marc R. Hoffmann | e52a0ef | 2009-06-16 20:28:45 +0000 | [diff] [blame] | 175 | <p>
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 176 | Implementing the Java byte code specification would be an extensive and
|
Marc R. Hoffmann | e52a0ef | 2009-06-16 20:28:45 +0000 | [diff] [blame] | 177 | error-prone task. Therefore an existing library should be used. The
|
| 178 | <a href="http://asm.objectweb.org/">ASM</a> library is lightweight, easy to
|
| 179 | use and very efficient in terms of memory and CPU usage. It is actively
|
| 180 | maintained and includes as huge regression test suite. Its simplified BSD
|
| 181 | license is approved by the Eclipse Foundation for usage with EPL products.
|
| 182 | </p>
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 183 |
|
| 184 | <h2>Java Class Identity</h2>
|
| 185 |
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 186 | <p class="intro">
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 187 | Each class loaded at runtime needs a unique identity to associate coverage data with.
|
| 188 | JaCoCo creates such identities by a CRC64 hash code of the raw class definition.
|
| 189 | </p>
|
| 190 |
|
| 191 | <p>
|
| 192 | In multi-classloader environments the plain name of a class does not
|
| 193 | unambiguously identify a class. For example OSGi allows to use different
|
| 194 | versions of the same class to be loaded within the same VM. In complex
|
| 195 | deployment scenarios the actual version of the test target might be different
|
| 196 | from current development version. A code coverage report should guarantee that
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 197 | the presented figures are extracted from a valid test target. A hash code of
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 198 | the class definitions allows to differentiate between classes and versions of
|
| 199 | classes. The CRC64 hash computation is simple and fast resulting in a small 64
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 200 | bit identifier.
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 201 | </p>
|
| 202 |
|
| 203 | <p>
|
| 204 | The same class definition might be loaded by class loaders which will result
|
| 205 | in different classes for the Java runtime system. For coverage analysis this
|
| 206 | distinction should be irrelevant. Class definitions might be altered by other
|
| 207 | instrumentation based technologies (e.g. AspectJ). In this case the hash code
|
| 208 | will change and identity gets lost. On the other hand code coverage analysis
|
| 209 | based on classes that have been somehow altered will produce unexpected
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 210 | results. The CRC64 code might produce so called <i>collisions</i>, i.e.
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 211 | creating the same hash code for two different classes. Although CRC64 is not
|
| 212 | cryptographically strong and collision examples can be easily computed, for
|
| 213 | regular class files the collision probability is very low.
|
| 214 | </p>
|
| 215 |
|
| 216 | <h2>Coverage Runtime Dependency</h2>
|
| 217 |
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 218 | <p class="intro">
|
Marc R. Hoffmann | e52a0ef | 2009-06-16 20:28:45 +0000 | [diff] [blame] | 219 | Instrumented code typically gets a dependency to a coverage runtime which is
|
| 220 | responsible for collecting and storing execution data. JaCoCo uses JRE types
|
Marc R. Hoffmann | a942c89 | 2010-03-10 21:33:26 +0000 | [diff] [blame^] | 221 | only in generated instrumentation code.
|
Marc R. Hoffmann | e52a0ef | 2009-06-16 20:28:45 +0000 | [diff] [blame] | 222 | </p>
|
| 223 |
|
| 224 | <p>
|
| 225 | Making a runtime library available to all instrumented classes can be a
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 226 | painful or impossible task in frameworks that use their own class loading
|
Marc R. Hoffmann | 9263b7b | 2010-01-31 10:20:30 +0000 | [diff] [blame] | 227 | mechanisms. Since Java 1.6 <code>java.lang.instrument.Instrumentation</code>
|
| 228 | has an API to extends the bootsstrap loader. As our minimum target is Java 1.5
|
| 229 | JaCoCo decouples the instrumented classes and the coverage runtime through
|
Marc R. Hoffmann | a942c89 | 2010-03-10 21:33:26 +0000 | [diff] [blame^] | 230 | official JRE API types only. The instrumented classes communicate through the
|
| 231 | <code>Object.equals(Object)</code> method with the runtime. A instrumented
|
| 232 | class can retrieve its probe array instance with the following code. Note
|
| 233 | that only JRE APIs are used:
|
| 234 | </p>
|
| 235 |
|
| 236 |
|
| 237 | <pre class="source">
|
| 238 | <span class="nr"> 1</span>Object access = ... // Retrieve instance
|
| 239 | <span class="nr"> 2</span>
|
| 240 | <span class="nr"> 3</span>Object[] args = new Object[3];
|
| 241 | <span class="nr"> 4</span>args[0] = Long.valueOf(8060044182221863588); // class id
|
| 242 | <span class="nr"> 5</span>args[1] = "com/example/MyClass"; // class name
|
| 243 | <span class="nr"> 6</span>args[2] = Integer.valueOf(24); // probe count
|
| 244 | <span class="nr"> 7</span>
|
| 245 | <span class="nr"> 8</span>access.equals(args);
|
| 246 | <span class="nr"> 9</span>
|
| 247 | <span class="nr"> 10</span>boolean[] probes = (boolean[]) args[0];
|
| 248 | </pre>
|
| 249 |
|
| 250 | <p>
|
| 251 | The most tricky part takes place in line 1 and is not shown in the snippet
|
| 252 | above. The object instance providing access to the coverage runtime through
|
| 253 | its <code>equals()</code> method has to be obtained. Different approaches have
|
| 254 | been implemented and tested so far:
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 255 | </p>
|
| 256 |
|
Marc R. Hoffmann | 402370f | 2009-08-10 14:02:23 +0000 | [diff] [blame] | 257 | <ul>
|
Marc R. Hoffmann | a942c89 | 2010-03-10 21:33:26 +0000 | [diff] [blame^] | 258 | <li><b><code>SystemPropertiesRuntime</code></b>: This approach stores the
|
| 259 | object instance under a system property. This solution breaks the contract
|
| 260 | that system properties must only contain <code>java.lang.String</code>
|
| 261 | values and therefore causes trouble in applications that rely on this
|
| 262 | definition (e.g. Ant).</li>
|
Marc R. Hoffmann | 9263b7b | 2010-01-31 10:20:30 +0000 | [diff] [blame] | 263 | <li><b><code>LoggerRuntime</code></b>: Here we use a shared
|
Marc R. Hoffmann | a942c89 | 2010-03-10 21:33:26 +0000 | [diff] [blame^] | 264 | <code>java.util.logging.Logger</code> and communicate through the logging
|
| 265 | parameter array instead of a <code>equals()</code> method. The coverage
|
| 266 | runtime registers a custom <code>Handler</code> to receive the parameter
|
| 267 | array. This approach might break environments that install their own log
|
Marc R. Hoffmann | 9263b7b | 2010-01-31 10:20:30 +0000 | [diff] [blame] | 268 | managers (e.g. Glassfish).</li>
|
Marc R. Hoffmann | a942c89 | 2010-03-10 21:33:26 +0000 | [diff] [blame^] | 269 | <li><b><code>ModifiedSystemClassRuntime</code></b>: This approach adds a
|
| 270 | public static field to an existing JRE class through instrumentation. Unlike
|
| 271 | the other methods above this is only possible for environments where a Java
|
Marc R. Hoffmann | 9263b7b | 2010-01-31 10:20:30 +0000 | [diff] [blame] | 272 | agent is active.</li>
|
Marc R. Hoffmann | 402370f | 2009-08-10 14:02:23 +0000 | [diff] [blame] | 273 | </ul>
|
| 274 |
|
Marc R. Hoffmann | 9263b7b | 2010-01-31 10:20:30 +0000 | [diff] [blame] | 275 | <p>
|
| 276 | The current JaCoCo Java agent implementation uses the
|
Marc R. Hoffmann | a942c89 | 2010-03-10 21:33:26 +0000 | [diff] [blame^] | 277 | <code>ModifiedSystemClassRuntime</code> adding a field to the class
|
Marc R. Hoffmann | 6751fe4 | 2010-02-01 18:18:24 +0000 | [diff] [blame] | 278 | <code>java.sql.Types</code>.
|
Marc R. Hoffmann | 9263b7b | 2010-01-31 10:20:30 +0000 | [diff] [blame] | 279 | </p>
|
| 280 |
|
Marc R. Hoffmann | 402370f | 2009-08-10 14:02:23 +0000 | [diff] [blame] | 281 |
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 282 | <h2>Memory Usage</h2>
|
| 283 |
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 284 | <p class="intro">
|
Marc R. Hoffmann | 58d7621 | 2009-10-08 15:40:46 +0000 | [diff] [blame] | 285 | Coverage analysis for huge projects with several thousand classes or hundred
|
| 286 | thousand lines of code should be possible. To allow this with reasonable
|
| 287 | memory usage the coverage analysis is based on streaming patterns and
|
| 288 | "depth first" traversals.
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 289 | </p>
|
| 290 |
|
| 291 | <p>
|
Marc R. Hoffmann | 58d7621 | 2009-10-08 15:40:46 +0000 | [diff] [blame] | 292 | The complete data tree of a huge coverage report is too big to fit into a
|
| 293 | reasonable heap memory configuration. Therefore the coverage analysis and
|
| 294 | report generation is implemented as "depth first" traversals. Which means that
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 295 | at any point in time only the following data has to be held in working memory:
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 296 | </p>
|
| 297 |
|
Marc R. Hoffmann | 58d7621 | 2009-10-08 15:40:46 +0000 | [diff] [blame] | 298 | <ul>
|
| 299 | <li>A single class which is currently processed.</li>
|
| 300 | <li>The summary information of all parents of this class (package, groups).</li>
|
| 301 | </ul>
|
| 302 |
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 303 | <h2>Java Element Identifiers</h2>
|
| 304 |
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 305 | <p class="intro">
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 306 | The Java language and the Java VM use different String representation formats
|
| 307 | for Java elements. For example while a type reference in Java reads like
|
| 308 | <code>java.lang.Object</code>, the VM references the same type as
|
| 309 | <code>Ljava/lang/Object;</code>. The JaCoCo API is based on VM identifiers only.
|
| 310 | </p>
|
| 311 |
|
| 312 | <p>
|
| 313 | Using VM identifiers directly does not cause any transformation overhead at
|
| 314 | runtime. There are several programming languages based on the Java VM that
|
| 315 | might use different notations. Specific transformations should therefore only
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 316 | happen at the user interface level, for example during report generation.
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 317 | </p>
|
| 318 |
|
| 319 | <h2>Modularization of the JaCoCo implementation</h2>
|
| 320 |
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 321 | <p class="intro">
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 322 | JaCoCo is implemented in several modules providing different functionality.
|
| 323 | These modules are provided as OSGi bundles with proper manifest files. But
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 324 | there are no dependencies on OSGi itself.
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 325 | </p>
|
| 326 |
|
| 327 | <p>
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 328 | Using OSGi bundles allows well defined dependencies at development time and
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 329 | at runtime in OSGi containers. As there are no dependencies on OSGi, the
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 330 | bundles can also be used like regular JAR files.
|
Marc R. Hoffmann | 5267b6c | 2009-07-05 16:34:27 +0000 | [diff] [blame] | 331 | </p>
|
| 332 |
|
Marc R. Hoffmann | 17be269 | 2010-02-02 05:44:47 +0000 | [diff] [blame] | 333 | </div>
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 334 | <div class="footer">
|
Marc R. Hoffmann | afe929b | 2009-08-05 09:19:00 +0000 | [diff] [blame] | 335 | <div class="versioninfo"><a href="@HOMEURL@">JaCoCo</a> @VERSION@</div>
|
Marc R. Hoffmann | 889d62b | 2010-01-26 20:08:15 +0000 | [diff] [blame] | 336 | <a href="license.html">Copyright</a> © 2009, 2010 Mountainminds GmbH & Co. KG and Contributors
|
Marc R. Hoffmann | 1588849 | 2009-07-30 11:46:53 +0000 | [diff] [blame] | 337 | </div>
|
Marc R. Hoffmann | a2af15d | 2009-06-07 21:15:05 +0000 | [diff] [blame] | 338 |
|
| 339 | </body>
|
| 340 | </html> |