use of org.jacoco.core.runtime.IRuntime in project jacoco by jacoco.
the class ExecuteInstrumentedCodeScenario method getInstrumentedCallable.
@Override
@SuppressWarnings("unchecked")
protected Callable<Void> getInstrumentedCallable() throws Exception {
ClassReader reader = new ClassReader(TargetLoader.getClassData(target));
IRuntime runtime = new LoggerRuntime();
runtime.startup(new RuntimeData());
final Instrumenter instr = new Instrumenter(runtime);
final byte[] instrumentedBuffer = instr.instrument(reader);
final TargetLoader loader = new TargetLoader();
return (Callable<Void>) loader.add(target, instrumentedBuffer).newInstance();
}
use of org.jacoco.core.runtime.IRuntime in project jacoco by jacoco.
the class FramesTest method testFrames.
private void testFrames(byte[] source) throws IOException {
IRuntime runtime = new SystemPropertiesRuntime();
Instrumenter instrumenter = new Instrumenter(runtime);
source = calculateFrames(source);
byte[] actual = instrumenter.instrument(source, "TestTarget");
byte[] expected = calculateFrames(actual);
assertEquals(dump(expected), dump(actual));
}
use of org.jacoco.core.runtime.IRuntime in project jacoco by jacoco.
the class StructuredLockingTest method assertStructuredLocking.
private void assertStructuredLocking(byte[] source) throws Exception {
IRuntime runtime = new SystemPropertiesRuntime();
Instrumenter instrumenter = new Instrumenter(runtime);
byte[] instrumented = instrumenter.instrument(source, "TestTarget");
final int version = BytecodeVersion.get(instrumented);
instrumented = BytecodeVersion.downgradeIfNeeded(version, instrumented);
ClassNode cn = new ClassNode();
new ClassReader(instrumented).accept(cn, 0);
for (MethodNode mn : cn.methods) {
assertStructuredLocking(cn.name, mn);
}
}
Aggregations