Class 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 Detail

      • AGENT_PREFIX

        private static final java.lang.String AGENT_PREFIX
      • 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 runtime
        options - configuration options for the generator
        logger - 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 interface java.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 class
        classname - VM name of the class to check
        protectionDomain - 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 (or null)
        Returns:
        true if a source location is defined
      • toVMName

        private static java.lang.String toVMName​(java.lang.String srcName)