Google is committed to advancing racial equity for Black communities. See how.

AsmClassVisitorFactory

@Incubating interface AsmClassVisitorFactory<ParametersT : InstrumentationParameters> : Serializable
com.android.build.api.instrumentation.AsmClassVisitorFactory

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.

This API is experimental and subject to breaking change and we strongly suggest you don't publish plugins that depend on it yet.

Summary

Public methods

abstract ClassVisitor
createClassVisitor(classData: ClassData, nextClassVisitor: ClassVisitor)

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

abstract Boolean

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

Properties

abstract InstrumentationContext

Contains parameters to help instantiate the visitor objects.

abstract Property<ParametersT>

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

Public methods

createClassVisitor

abstract fun createClassVisitor(
    classData: ClassData,
    nextClassVisitor: ClassVisitor
): ClassVisitor

Creates a class visitor object that will visit a class with the given classData. The returned class visitor must delegate its calls to nextClassVisitor.

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

This method should handle asynchronous calls.

Parameters
classData: ClassData contains information about the class that will be instrumented by the returned class visitor.
nextClassVisitor: ClassVisitor the ClassVisitor to which the created ClassVisitor must delegate method calls.

isInstrumentable

abstract fun isInstrumentable(classData: ClassData): Boolean

Whether or not 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.

Properties

instrumentationContext

abstract val instrumentationContext: InstrumentationContext

Contains parameters to help instantiate the visitor objects.

This field must be left unimplemented.

parameters

abstract val parameters: Property<ParametersT>

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.