Package org.jacoco.agent.rt.internal
Class CoverageTransformer
- java.lang.Object
-
- org.jacoco.agent.rt.internal.CoverageTransformer
-
- All Implemented Interfaces:
java.lang.instrument.ClassFileTransformer
public class CoverageTransformer extends java.lang.Object implements java.lang.instrument.ClassFileTransformer
Class file transformer to instrument classes for code coverage analysis.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
AGENT_PREFIX
private ClassFileDumper
classFileDumper
private WildcardMatcher
exclClassloader
private WildcardMatcher
excludes
private boolean
inclBootstrapClasses
private boolean
inclNoLocationClasses
private WildcardMatcher
includes
private Instrumenter
instrumenter
private IExceptionLogger
logger
-
Constructor Summary
Constructors Constructor Description CoverageTransformer(IRuntime runtime, AgentOptions options, IExceptionLogger logger)
New transformer with the given delegates.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) boolean
filter(java.lang.ClassLoader loader, java.lang.String classname, java.security.ProtectionDomain protectionDomain)
Checks whether this class should be instrumented.private boolean
hasSourceLocation(java.security.ProtectionDomain protectionDomain)
Checks whether this protection domain is associated with a source location.private static java.lang.String
toVMName(java.lang.String srcName)
byte[]
transform(java.lang.ClassLoader loader, java.lang.String classname, java.lang.Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[] classfileBuffer)
-
-
-
Field Detail
-
AGENT_PREFIX
private static final java.lang.String AGENT_PREFIX
-
instrumenter
private final Instrumenter instrumenter
-
logger
private final IExceptionLogger logger
-
includes
private final WildcardMatcher includes
-
excludes
private final WildcardMatcher excludes
-
exclClassloader
private final WildcardMatcher exclClassloader
-
classFileDumper
private final ClassFileDumper classFileDumper
-
inclBootstrapClasses
private final boolean inclBootstrapClasses
-
inclNoLocationClasses
private final boolean inclNoLocationClasses
-
-
Constructor Detail
-
CoverageTransformer
public CoverageTransformer(IRuntime runtime, AgentOptions options, IExceptionLogger logger)
New transformer with the given delegates.- Parameters:
runtime
- coverage runtimeoptions
- configuration options for the generatorlogger
- logger for exceptions during instrumentation
-
-
Method Detail
-
transform
public byte[] transform(java.lang.ClassLoader loader, java.lang.String classname, java.lang.Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[] classfileBuffer) throws java.lang.instrument.IllegalClassFormatException
- Specified by:
transform
in interfacejava.lang.instrument.ClassFileTransformer
- Throws:
java.lang.instrument.IllegalClassFormatException
-
filter
boolean filter(java.lang.ClassLoader loader, java.lang.String classname, java.security.ProtectionDomain protectionDomain)
Checks whether this class should be instrumented.- Parameters:
loader
- loader for the classclassname
- VM name of the class to checkprotectionDomain
- protection domain for the class- Returns:
true
if the class should be instrumented
-
hasSourceLocation
private boolean hasSourceLocation(java.security.ProtectionDomain protectionDomain)
Checks whether this protection domain is associated with a source location.- Parameters:
protectionDomain
- protection domain to check (ornull
)- Returns:
true
if a source location is defined
-
toVMName
private static java.lang.String toVMName(java.lang.String srcName)
-
-