aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test/src/org/jacoco/core
diff options
context:
space:
mode:
authorEvgeny Mandrikov <138671+Godin@users.noreply.github.com>2019-03-04 23:49:02 +0100
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2019-03-04 23:49:02 +0100
commitfaf49f9418f7bc8f1a198de3afd941ff953d3abe (patch)
treefc051dc8368ffe891c3a65a8ad8ef8f0c083bf46 /org.jacoco.core.test/src/org/jacoco/core
parentc30eb290f7958dce50c072527fbe6234e8388dd2 (diff)
downloadjacoco-faf49f9418f7bc8f1a198de3afd941ff953d3abe.tar.gz
Remove `instrument(ClassReader)` and `analyzeClass(ClassReader)` (#850)
* they use field `ClassReader.b` which is marked as deprecated in ASM 7.1 * they don't work when field contains more than just bytes of one class (see `ClassReader(byte[] classFileBuffer, int classFileOffset, int classFileLength)`)
Diffstat (limited to 'org.jacoco.core.test/src/org/jacoco/core')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/perf/ExecuteInstrumentedCodeScenario.java5
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/perf/InstrumentationSizeSzenario.java9
2 files changed, 6 insertions, 8 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/perf/ExecuteInstrumentedCodeScenario.java b/org.jacoco.core.test/src/org/jacoco/core/test/perf/ExecuteInstrumentedCodeScenario.java
index 8637212a..20bd02a6 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/perf/ExecuteInstrumentedCodeScenario.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/perf/ExecuteInstrumentedCodeScenario.java
@@ -18,7 +18,6 @@ import org.jacoco.core.runtime.IRuntime;
import org.jacoco.core.runtime.LoggerRuntime;
import org.jacoco.core.runtime.RuntimeData;
import org.jacoco.core.test.TargetLoader;
-import org.objectweb.asm.ClassReader;
/**
* This scenario runs a given scenario twice and reports the execution time:
@@ -37,11 +36,11 @@ public class ExecuteInstrumentedCodeScenario extends TimedScenario {
@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 byte[] original = TargetLoader.getClassDataAsBytes(target);
+ final byte[] instrumentedBuffer = instr.instrument(original, "");
final TargetLoader loader = new TargetLoader();
return (Callable<Void>) loader.add(target, instrumentedBuffer)
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/perf/InstrumentationSizeSzenario.java b/org.jacoco.core.test/src/org/jacoco/core/test/perf/InstrumentationSizeSzenario.java
index a4d8adc9..27e05455 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/perf/InstrumentationSizeSzenario.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/perf/InstrumentationSizeSzenario.java
@@ -15,7 +15,6 @@ import org.jacoco.core.instr.Instrumenter;
import org.jacoco.core.runtime.IRuntime;
import org.jacoco.core.runtime.LoggerRuntime;
import org.jacoco.core.test.TargetLoader;
-import org.objectweb.asm.ClassReader;
/**
* Scenario to measure the overhead in terms of additional byte code size
@@ -31,11 +30,11 @@ public class InstrumentationSizeSzenario implements IPerfScenario {
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);
+ final byte[] original = TargetLoader.getClassDataAsBytes(target);
+ final byte[] instrumented = instr.instrument(original, "");
+ output.writeByteResult("instrumented class", instrumented.length,
+ original.length);
}
}