AsmClassVisitorFactory

public interface AsmClassVisitorFactory<ParametersT extends InstrumentationParameters> extends Serializable


A factory to create class visitor objects to instrument classes.

The implementation of this interface must be an abstract class where the parameters and instrumentationContext are left unimplemented. The class must have an empty constructor which will be used to construct the factory object.

Summary

Public methods

abstract @NonNull ClassVisitor
createClassVisitor(
    @NonNull ClassContext classContext,
    @NonNull ClassVisitor nextClassVisitor
)

Creates a class visitor object that will visit a class with the given classContext.

abstract @NonNull InstrumentationContext

Contains parameters to help instantiate the visitor objects.

abstract @NonNull Property<@NonNull ParametersT>

The parameters that will be instantiated, configured using the given config when registering the visitor, and injected on instantiation.

abstract boolean

Whether the factory wants to instrument the class with the given classData.

Public methods

createClassVisitor

abstract @NonNull ClassVisitor createClassVisitor(
    @NonNull ClassContext classContext,
    @NonNull ClassVisitor nextClassVisitor
)

Creates a class visitor object that will visit a class with the given classContext. The returned class visitor must delegate its calls to nextClassVisitor. If at this point the factory is not interested in instrumenting the class with given classContext, then return nextClassVisitor.

The given classContext contains static information about the classes before starting the instrumentation process. Any changes in interfaces or superclasses for the class with the given classContext or for any other class in its classpath by a previous visitor will not be reflected in the classContext object.

classContext can also be used to get the data for classes that are in the runtime classpath of the class being visited.

This method must handle asynchronous calls.

Parameters
@NonNull ClassContext classContext

contains information about the class that will be instrumented by the returned class visitor.

@NonNull ClassVisitor nextClassVisitor

the ClassVisitor to which the created ClassVisitor must delegate method calls.

getInstrumentationContext

@Nested
abstract @NonNull InstrumentationContext getInstrumentationContext()

Contains parameters to help instantiate the visitor objects.

This field must be left unimplemented.

getParameters

@Nested
abstract @NonNull Property<@NonNull ParametersT> getParameters()

The parameters that will be instantiated, configured using the given config when registering the visitor, and injected on instantiation.

This field must be left unimplemented.

isInstrumentable

abstract boolean isInstrumentable(@NonNull ClassData classData)

Whether the factory wants to instrument the class with the given classData.

If returned true, createClassVisitor will be called and the returned class visitor will visit the class.

This method must handle asynchronous calls.