Search in sources :

Example 11 with Instrumenter

use of org.jacoco.core.instr.Instrumenter 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 12 with Instrumenter

use of org.jacoco.core.instr.Instrumenter 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

Instrumenter (org.jacoco.core.instr.Instrumenter)12 IRuntime (org.jacoco.core.runtime.IRuntime)6 LoggerRuntime (org.jacoco.core.runtime.LoggerRuntime)4 OfflineInstrumentationAccessGenerator (org.jacoco.core.runtime.OfflineInstrumentationAccessGenerator)4 SystemPropertiesRuntime (org.jacoco.core.runtime.SystemPropertiesRuntime)3 ClassReader (org.objectweb.asm.ClassReader)3 File (java.io.File)2 InputStream (java.io.InputStream)2 Callable (java.util.concurrent.Callable)2 RuntimeData (org.jacoco.core.runtime.RuntimeData)2 TargetLoader (org.jacoco.core.test.TargetLoader)2 JarCreator (com.google.devtools.build.buildjar.jarhelper.JarCreator)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Path (java.nio.file.Path)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 BuildException (org.apache.tools.ant.BuildException)1 Resource (org.apache.tools.ant.types.Resource)1