Sebastien Hertz | 831c256 | 2016-03-23 09:48:21 +0100 | [diff] [blame] | 1 | We build an equivalent of the jacoco-agent.jar which contains classes from org.jacoco.core, |
| 2 | org.jacoco.agent and org.jacoco.agent.rt packages but also classes from asm 5.0.1. |
| 3 | |
| 4 | However, Jacoco depends on classes that do not exist in Android (java.lang.instrument.* or |
| 5 | javax.management.*) for runtime instrumentation only. The ART compiler would reject those classes |
| 6 | when they are either in the bootclasspath (core, frameworks, ...) or system apps. |
| 7 | |
| 8 | Since we only use offline instrumentation for code coverage (using Jack) and do not execute these |
| 9 | classes at runtime, we simply not compile them here. |
| 10 | |
| 11 | We also need to modify the source code to cut dependencies to the classes that we exclude from the |
| 12 | compilation. The changes are surrounded by "BEGIN android-change" and "END android-change". Here |
| 13 | is the list of the changes: |
| 14 | |
| 15 | 1) Remove the creation of JmxRegistration in org.jacoco.agent.rt.internal.Agent. |
Allen Hair | 6d4519e | 2016-06-29 11:15:21 -0700 | [diff] [blame] | 16 | 2) Change default OutputMode to none in org.jacoco.core.runtime.AgentOptions |
Pete Gillin | 04f25e9 | 2018-01-22 18:29:50 +0000 | [diff] [blame] | 17 | 3) Change the runtime to reduce dependencies on core libraries. |
| 18 | Previously, Offline's static initializer would eagerly create an |
| 19 | Agent, a process which has lots of dependencies. With this change, |
Pete Gillin | d82e086 | 2018-02-01 13:36:40 +0000 | [diff] [blame] | 20 | Offline only eagerly creates a Map<Long, ExecutionData>, which is much |
Pete Gillin | 04f25e9 | 2018-01-22 18:29:50 +0000 | [diff] [blame] | 21 | more lightweight. The Agent is only created when it's actually |
| 22 | needed. This makes it possible to instrument a lot of more core |
| 23 | libraries without creating a circular dependency at runtime. |