• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// SPDX-License-Identifier: EPL-2.0 and Apache-2.0
2// These patches apply to JaCoCo (https://github.com/jacoco/jacoco) and are hereby made available under the terms of the
3// Eclipse Public License 2.0 available at:
4//   http://www.eclipse.org/legal/epl-2.0
5diff --git org.jacoco.core/src/org/jacoco/core/analysis/Analyzer.java org.jacoco.core/src/org/jacoco/core/analysis/Analyzer.java
6index 0cc06ada..b65efb03 100644
7--- org.jacoco.core/src/org/jacoco/core/analysis/Analyzer.java
8+++ org.jacoco.core/src/org/jacoco/core/analysis/Analyzer.java
9@@ -31,6 +31,8 @@ import org.jacoco.core.internal.analysis.ClassCoverageImpl;
10 import org.jacoco.core.internal.analysis.StringPool;
11 import org.jacoco.core.internal.data.CRC64;
12 import org.jacoco.core.internal.flow.ClassProbesAdapter;
13+import org.jacoco.core.internal.flow.ClassProbesVisitor;
14+import org.jacoco.core.internal.flow.IClassProbesAdapterFactory;
15 import org.jacoco.core.internal.instr.InstrSupport;
16 import org.objectweb.asm.ClassReader;
17 import org.objectweb.asm.ClassVisitor;
18@@ -52,6 +54,8 @@ public class Analyzer {
19
20 	private final StringPool stringPool;
21
22+	private final IClassProbesAdapterFactory classProbesAdapterFactory;
23+
24 	/**
25 	 * Creates a new analyzer reporting to the given output.
26 	 *
27@@ -63,9 +67,21 @@ public class Analyzer {
28 	 */
29 	public Analyzer(final ExecutionDataStore executionData,
30 			final ICoverageVisitor coverageVisitor) {
31+		this(executionData, coverageVisitor, new IClassProbesAdapterFactory() {
32+			@Override
33+			public ClassProbesAdapter makeClassProbesAdapter(ClassProbesVisitor cv, boolean trackFrames) {
34+				return new ClassProbesAdapter(cv, trackFrames);
35+			};
36+		});
37+	}
38+
39+	public Analyzer(final ExecutionDataStore executionData,
40+			final ICoverageVisitor coverageVisitor,
41+			final IClassProbesAdapterFactory classProbesAdapterFactory) {
42 		this.executionData = executionData;
43 		this.coverageVisitor = coverageVisitor;
44 		this.stringPool = new StringPool();
45+		this.classProbesAdapterFactory = classProbesAdapterFactory;
46 	}
47
48 	/**
49@@ -99,7 +115,7 @@ public class Analyzer {
50 				coverageVisitor.visitCoverage(coverage);
51 			}
52 		};
53-		return new ClassProbesAdapter(analyzer, false);
54+		return classProbesAdapterFactory.makeClassProbesAdapter(analyzer, false);
55 	}
56
57 	private void analyzeClass(final byte[] source) {
58diff --git org.jacoco.core/src/org/jacoco/core/internal/flow/IClassProbesAdapterFactory.java org.jacoco.core/src/org/jacoco/core/internal/flow/IClassProbesAdapterFactory.java
59new file mode 100644
60index 00000000..45fc2709
61--- /dev/null
62+++ org.jacoco.core/src/org/jacoco/core/internal/flow/IClassProbesAdapterFactory.java
63@@ -0,0 +1,6 @@
64+package org.jacoco.core.internal.flow;
65+
66+public interface IClassProbesAdapterFactory {
67+	ClassProbesAdapter makeClassProbesAdapter(ClassProbesVisitor cv,
68+			boolean trackFrames);
69+}
70