diff options
author | Oliver Nguyen <olivernguyen@google.com> | 2020-07-09 15:11:30 -0700 |
---|---|---|
committer | Oliver Nguyen <olivernguyen@google.com> | 2020-08-11 10:58:54 -0700 |
commit | 28558ef2ec7635c0a7e10fbb1fe9b8a80d32b636 (patch) | |
tree | ff121ba8fcc1140f854ff568722192877ffeae6a /org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java | |
parent | bdbfb7047d87e8e790260a0fffb1afdf37ed3dc8 (diff) | |
download | jacoco-28558ef2ec7635c0a7e10fbb1fe9b8a80d32b636.tar.gz |
Add IExecutionData interface and move all usage to the interface.
Abstracts the underlying execution data implementation to allow for more
complex execution data storage mechanisms.
For offline instrumentation, classes store the IExecutionData object and
make calls into it to set probe data. This results in additional
overhead of looking up the vtable for the interface and making the
method call, rather than just directly setting the value in the boolean
array.
Bug: 147904124
Test: m EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true and verify
Java coverage collection and parsing
Change-Id: I41235626b1040a6a21c6aef300f2dfe064393e1f
Diffstat (limited to 'org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java')
-rw-r--r-- | org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java index 69a9909e..ee9d40b1 100644 --- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java +++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java @@ -16,6 +16,7 @@ import java.util.Map; import java.util.Properties; import org.jacoco.core.data.ExecutionData; +import org.jacoco.core.data.IExecutionData; import org.jacoco.core.data.ExecutionDataStore; import org.jacoco.core.runtime.AgentOptions; import org.jacoco.core.runtime.RuntimeData; @@ -28,7 +29,7 @@ public final class Offline { // BEGIN android-change // private static final RuntimeData DATA; - private static final Map<Long, ExecutionData> DATA = new HashMap<Long, ExecutionData>(); + private static final Map<Long, IExecutionData> DATA = new HashMap<Long, IExecutionData>(); // END android-change private static final String CONFIG_RESOURCE = "/jacoco-agent.properties"; @@ -44,6 +45,7 @@ public final class Offline { // no instances } + // BEGIN android-change /** * API for offline instrumented classes. * @@ -53,27 +55,25 @@ public final class Offline { * VM class name * @param probecount * probe count for this class - * @return probe array instance for this class + * @return IExecutionData instance for this class */ - public static boolean[] getProbes(final long classid, + public static IExecutionData getExecutionData(final long classid, final String classname, final int probecount) { - // BEGIN android-change // return DATA.getExecutionData(Long.valueOf(classid), classname, // probecount).getProbes(); synchronized (DATA) { - ExecutionData entry = DATA.get(classid); + IExecutionData entry = DATA.get(classid); if (entry == null) { entry = new ExecutionData(classid, classname, probecount); DATA.put(classid, entry); } else { entry.assertCompatibility(classid, classname, probecount); } - return entry.getProbes(); + return entry; } - // END android-change } + // END android-change - // BEGIN android-change /** * Creates a default agent, using config loaded from the classpath resource and the system * properties, and a runtime data instance populated with the execution data accumulated by @@ -87,7 +87,7 @@ public final class Offline { System.getProperties()); synchronized (DATA) { ExecutionDataStore store = new ExecutionDataStore(); - for (ExecutionData data : DATA.values()) { + for (IExecutionData data : DATA.values()) { store.put(data); } return Agent.getInstance(new AgentOptions(config), new RuntimeData(store)); |