use of org.jacoco.core.internal.flow.ClassProbesAdapter in project jacoco by jacoco.
the class Instrumenter method instrument.
private byte[] instrument(final byte[] source) {
final long classId = CRC64.classId(source);
final int originalVersion = BytecodeVersion.get(source);
final byte[] b = BytecodeVersion.downgradeIfNeeded(originalVersion, source);
final ClassReader reader = new ClassReader(b);
final ClassWriter writer = new ClassWriter(reader, 0) {
@Override
protected String getCommonSuperClass(final String type1, final String type2) {
throw new IllegalStateException();
}
};
final IProbeArrayStrategy strategy = ProbeArrayStrategyFactory.createFor(classId, reader, accessorGenerator);
final ClassVisitor visitor = new ClassProbesAdapter(new ClassInstrumenter(strategy, writer), true);
reader.accept(visitor, ClassReader.EXPAND_FRAMES);
final byte[] instrumented = writer.toByteArray();
BytecodeVersion.set(instrumented, originalVersion);
return instrumented;
}
use of org.jacoco.core.internal.flow.ClassProbesAdapter in project bazel by bazelbuild.
the class BranchDetailAnalyzer method mapProbes.
// Generate the line to probeExp map so that we can evaluate the coverage.
private Map<Integer, BranchExp> mapProbes(final ClassReader reader) {
final ClassProbesMapper mapper = new ClassProbesMapper();
final ClassProbesAdapter adapter = new ClassProbesAdapter(mapper, false);
reader.accept(adapter, 0);
return mapper.result();
}
use of org.jacoco.core.internal.flow.ClassProbesAdapter in project jacoco by jacoco.
the class ProbeArrayStrategyFactory method getProbeCounter.
private static ProbeCounter getProbeCounter(final ClassReader reader) {
final ProbeCounter counter = new ProbeCounter();
reader.accept(new ClassProbesAdapter(counter, false), 0);
return counter;
}
use of org.jacoco.core.internal.flow.ClassProbesAdapter in project jacoco by jacoco.
the class Analyzer method createAnalyzingVisitor.
/**
* Creates an ASM class visitor for analysis.
*
* @param classid
* id of the class calculated with {@link CRC64}
* @param className
* VM name of the class
* @return ASM visitor to write class definition to
*/
private ClassVisitor createAnalyzingVisitor(final long classid, final String className) {
final ExecutionData data = executionData.get(classid);
final boolean[] probes;
final boolean noMatch;
if (data == null) {
probes = null;
noMatch = executionData.contains(className);
} else {
probes = data.getProbes();
noMatch = false;
}
final ClassCoverageImpl coverage = new ClassCoverageImpl(className, classid, noMatch);
final ClassAnalyzer analyzer = new ClassAnalyzer(coverage, probes, stringPool) {
@Override
public void visitEnd() {
super.visitEnd();
coverageVisitor.visitCoverage(coverage);
}
};
return new ClassProbesAdapter(analyzer, false);
}
Aggregations