Search in sources :

Example 6 with IRuntime

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();
}
Also used : RuntimeData(org.jacoco.core.runtime.RuntimeData) LoggerRuntime(org.jacoco.core.runtime.LoggerRuntime) TargetLoader(org.jacoco.core.test.TargetLoader) ClassReader(org.objectweb.asm.ClassReader) Instrumenter(org.jacoco.core.instr.Instrumenter) Callable(java.util.concurrent.Callable) IRuntime(org.jacoco.core.runtime.IRuntime)

Example 7 with IRuntime

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));
}
Also used : SystemPropertiesRuntime(org.jacoco.core.runtime.SystemPropertiesRuntime) Instrumenter(org.jacoco.core.instr.Instrumenter) IRuntime(org.jacoco.core.runtime.IRuntime)

Example 8 with IRuntime

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);
    }
}
Also used : ClassNode(org.objectweb.asm.tree.ClassNode) MethodNode(org.objectweb.asm.tree.MethodNode) SystemPropertiesRuntime(org.jacoco.core.runtime.SystemPropertiesRuntime) ClassReader(org.objectweb.asm.ClassReader) Instrumenter(org.jacoco.core.instr.Instrumenter) IRuntime(org.jacoco.core.runtime.IRuntime)

Aggregations

IRuntime (org.jacoco.core.runtime.IRuntime)8 Instrumenter (org.jacoco.core.instr.Instrumenter)6 LoggerRuntime (org.jacoco.core.runtime.LoggerRuntime)4 SystemPropertiesRuntime (org.jacoco.core.runtime.SystemPropertiesRuntime)3 ClassReader (org.objectweb.asm.ClassReader)3 RuntimeData (org.jacoco.core.runtime.RuntimeData)2 InputStream (java.io.InputStream)1 Callable (java.util.concurrent.Callable)1 Analyzer (org.jacoco.core.analysis.Analyzer)1 CoverageBuilder (org.jacoco.core.analysis.CoverageBuilder)1 IClassCoverage (org.jacoco.core.analysis.IClassCoverage)1 ExecutionDataStore (org.jacoco.core.data.ExecutionDataStore)1 SessionInfoStore (org.jacoco.core.data.SessionInfoStore)1 AgentOptions (org.jacoco.core.runtime.AgentOptions)1 TargetLoader (org.jacoco.core.test.TargetLoader)1 ClassNode (org.objectweb.asm.tree.ClassNode)1 MethodNode (org.objectweb.asm.tree.MethodNode)1