Package org.jacoco.core.instr

Examples of org.jacoco.core.instr.Instrumenter


  }

  public void run(IPerfOutput output) throws Exception {
    final IRuntime runtime = new LoggerRuntime();
    ClassReader reader = new ClassReader(TargetLoader.getClassData(target));
    final Instrumenter instr = new Instrumenter(runtime);
    instr.instrument(reader);
    output.writeByteResult("instrumented class",
        instr.instrument(reader).length, reader.b.length);
  }
View Full Code Here


  private ExecutionDataStore execute(final ClassReader reader)
      throws Exception {
    IRuntime runtime = new SystemPropertiesRuntime();
    runtime.startup();
    final byte[] bytes = new Instrumenter(runtime).instrument(reader);
    final TargetLoader loader = new TargetLoader(target, bytes);
    run(loader.getTargetClass());
    final ExecutionDataStore store = new ExecutionDataStore();
    runtime.collect(store, null, false);
    runtime.shutdown();
View Full Code Here

   *            logger for exceptions during instrumentation
   */
  public CoverageTransformer(final IRuntime runtime,
      final AgentOptions options, final IExceptionLogger logger) {
    this.runtime = runtime;
    this.instrumenter = new Instrumenter(runtime);
    this.logger = logger;
    // Class names will be reported in VM notation:
    includes = new WildcardMatcher(
        toWildcard(toVMName(options.getIncludes())));
    excludes = new WildcardMatcher(
View Full Code Here

    // to collect execution data:
    final IRuntime runtime = new LoggerRuntime();

    // The Instrumenter creates a modified version of our test target class
    // that contains additional probes for execution data recording:
    final Instrumenter instr = new Instrumenter(runtime);
    final byte[] instrumented = instr
        .instrument(getTargetClass(targetName));

    // Now we're ready to run our instrumented class and need to startup the
    // runtime first:
    runtime.startup();
View Full Code Here

  }

  @Override
  protected Callable<Void> getInstrumentedCallable() throws Exception {
    final byte[] bytes = TargetLoader.getClassDataAsBytes(target);
    final Instrumenter instr = new Instrumenter(new LoggerRuntime());
    return new Callable<Void>() {
      public Void call() throws Exception {
        for (int i = 0; i < count; i++) {
          instr.instrument(bytes, "TestTarget");
        }
        return null;
      }
    };
  }
View Full Code Here

  private void testVersion(int version, boolean frames) throws IOException {
    final byte[] original = createClass(version);

    IRuntime runtime = new SystemPropertiesRuntime();
    Instrumenter instrumenter = new Instrumenter(runtime);
    byte[] instrumented = instrumenter.instrument(original, "TestTarget");

    assertFrames(instrumented, frames);
  }
View Full Code Here

  }

  public void run(IPerfOutput output) throws Exception {
    final IRuntime runtime = new LoggerRuntime();
    ClassReader reader = new ClassReader(TargetLoader.getClassData(target));
    final Instrumenter instr = new Instrumenter(runtime);
    instr.instrument(reader);
    output.writeByteResult("instrumented class",
        instr.instrument(reader).length, reader.b.length);
  }
View Full Code Here

  @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();
  }
View Full Code Here

  }

  private void instrument(final Class<? extends Target> clazz)
      throws Exception {
    reader = new ClassReader(TargetLoader.getClassData(clazz));
    final byte[] bytes = new Instrumenter(runtime).instrument(reader);
    final TargetLoader loader = new TargetLoader();
    target = (Target) loader.add(clazz, bytes).newInstance();
  }
View Full Code Here

    testFrames(TargetLoader.getClassDataAsBytes(target));
  }

  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));
  }
View Full Code Here

TOP

Related Classes of org.jacoco.core.instr.Instrumenter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.