blob: e72f00c71a5cda5ae5a31aeabcdf441e4527922d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*******************************************************************************
* Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
*
*******************************************************************************/
package org.jacoco.core.runtime;
import org.jacoco.core.JaCoCo;
import org.jacoco.core.internal.instr.InstrSupport;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
/**
* This implementation of {@link IExecutionDataAccessorGenerator} generate a
* direct dependency to the JaCoCo runtime agent to initialize the runtime and
* obtain probe arrays. This generator is designed for offline instrumentation
* only.
*/
public class OfflineInstrumentationAccessGenerator
implements IExecutionDataAccessorGenerator {
private final String runtimeClassName;
/**
* Creates a new instance for offline instrumentation.
*/
public OfflineInstrumentationAccessGenerator() {
this(JaCoCo.RUNTIMEPACKAGE.replace('.', '/') + "/Offline");
}
/**
* Creates a new instance with the given runtime class name for testing
* purposes
*
* @param runtimeClassName
* VM name of the runtime class
*/
OfflineInstrumentationAccessGenerator(final String runtimeClassName) {
this.runtimeClassName = runtimeClassName;
}
public int generateDataAccessor(final long classid, final String classname,
final int probecount, final MethodVisitor mv) {
mv.visitLdcInsn(Long.valueOf(classid));
mv.visitLdcInsn(classname);
InstrSupport.push(mv, probecount);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeClassName, "getProbes",
"(JLjava/lang/String;I)[Z", false);
return 4;
}
}
|