Package org.jacoco.core.internal.instr
Class InstrSupport
java.lang.Object
org.jacoco.core.internal.instr.InstrSupport
Constants and utilities for byte code instrumentation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intASM API versionstatic final intAccess modifiers of the field that stores coverage information of a class.static final StringData type of the field that stores coverage information for a class (boolean[]).static final intAccess modifiers of the field that stores coverage information of a Java 8 interface.static final StringName of the field that stores coverage information of a class.static final intAccess modifiers of the initialization method.static final StringDescriptor of the initialization method.static final StringName of the initialization method. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertNotInstrumented(String member, String owner) Ensures that the given member does not correspond to a internal member created by the instrumentation process.static org.objectweb.asm.ClassReaderclassReaderFor(byte[] b) Creates aClassReaderinstance for given bytes of class even if its version not yet supported by ASM.static intgetMajorVersion(byte[] b) Gets major version number from given bytes of class (unsigned two bytes at offset 6).static intgetMajorVersion(org.objectweb.asm.ClassReader reader) Gets major version number from givenClassReader.static booleanneedsFrames(int version) Determines whether the given class file version requires stackmap frames.static voidpush(org.objectweb.asm.MethodVisitor mv, int value) Generates the instruction to push the given int value on the stack.static voidsetMajorVersion(int majorVersion, byte[] b) Sets major version number in given bytes of class (unsigned two bytes at offset 6).
-
Field Details
-
ASM_API_VERSION
public static final int ASM_API_VERSIONASM API version- See Also:
-
DATAFIELD_NAME
Name of the field that stores coverage information of a class.- See Also:
-
DATAFIELD_ACC
public static final int DATAFIELD_ACCAccess modifiers of the field that stores coverage information of a class. According to Java Virtual Machine Specification §6.5.putstatic this field must not be final:if the field is final, it must be declared in the current class, and the instruction must occur in the
<clinit>method of the current class.- See Also:
-
DATAFIELD_INTF_ACC
public static final int DATAFIELD_INTF_ACCAccess modifiers of the field that stores coverage information of a Java 8 interface. According to Java Virtual Machine Specification §4.5:Fields of interfaces must have their ACC_PUBLIC, ACC_STATIC, and ACC_FINAL flags set; they may have their ACC_SYNTHETIC flag set and must not have any of the other flags.
- See Also:
-
DATAFIELD_DESC
Data type of the field that stores coverage information for a class (boolean[]).- See Also:
-
INITMETHOD_NAME
Name of the initialization method.- See Also:
-
INITMETHOD_DESC
Descriptor of the initialization method.- See Also:
-
INITMETHOD_ACC
public static final int INITMETHOD_ACCAccess modifiers of the initialization method.- See Also:
-
-
Method Details
-
getMajorVersion
public static int getMajorVersion(byte[] b) Gets major version number from given bytes of class (unsigned two bytes at offset 6).- Parameters:
b- bytes of class- Returns:
- major version of bytecode
- See Also:
-
setMajorVersion
public static void setMajorVersion(int majorVersion, byte[] b) Sets major version number in given bytes of class (unsigned two bytes at offset 6).- Parameters:
majorVersion- major version of bytecode to setb- bytes of class- See Also:
-
getMajorVersion
public static int getMajorVersion(org.objectweb.asm.ClassReader reader) Gets major version number from givenClassReader.- Parameters:
reader- reader to get information about the class- Returns:
- major version of bytecode
- See Also:
-
needsFrames
public static boolean needsFrames(int version) Determines whether the given class file version requires stackmap frames.- Parameters:
version- class file version- Returns:
trueif frames are required
-
assertNotInstrumented
Ensures that the given member does not correspond to a internal member created by the instrumentation process. This would mean that the class is already instrumented.- Parameters:
member- name of the member to checkowner- name of the class owning the member- Throws:
IllegalStateException- thrown if the member has the same name than the instrumentation member
-
push
public static void push(org.objectweb.asm.MethodVisitor mv, int value) Generates the instruction to push the given int value on the stack. Implementation taken fromGeneratorAdapter.push(int).- Parameters:
mv- visitor to emit the instructionvalue- the value to be pushed on the stack.
-
classReaderFor
public static org.objectweb.asm.ClassReader classReaderFor(byte[] b) Creates aClassReaderinstance for given bytes of class even if its version not yet supported by ASM.- Parameters:
b- bytes of class- Returns:
ClassReader
-