Stay organized with collections
Save and categorize content based on your preferences.
AsmClassVisitorFactory
@Incubating interface AsmClassVisitorFactory<ParametersT : InstrumentationParameters> : 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.
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 |
Creates a class visitor object that will visit a class with the given classContext.
|
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(
classContext: ClassContext,
nextClassVisitor: ClassVisitor
): ClassVisitor
Creates a class visitor object that will visit a class with the given classContext. The
returned class visitor must delegate its calls to 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 |
classContext: ClassContext |
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.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# AsmClassVisitorFactory\n======================\n\n```\n@Incubating interface AsmClassVisitorFactory\u003cParametersT : InstrumentationParameters\u003e : Serializable\n```\n\n|-------------------------------------------------------------------|\n| [com.android.build.api.instrumentation.AsmClassVisitorFactory](#) |\n\nA factory to create class visitor objects to instrument classes.\n\nThe implementation of this interface must be an abstract class where the [parameters](#parameters:org.gradle.api.provider.Property) and\n[instrumentationContext](#instrumentationContext:com.android.build.api.instrumentation.InstrumentationContext) are left unimplemented. The class must have an empty constructor which\nwill be used to construct the factory object.\n\nThis API is experimental and subject to breaking change and we strongly suggest you don't publish\nplugins that depend on it yet.\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract ClassVisitor | [createClassVisitor](#createClassVisitor(com.android.build.api.instrumentation.ClassContext,%20org.objectweb.asm.ClassVisitor))`(`classContext:` `[ClassContext](/reference/tools/gradle-api/4.2/com/android/build/api/instrumentation/ClassContext)`, `nextClassVisitor:` `ClassVisitor`)` Creates a class visitor object that will visit a class with the given [classContext](#com.android.build.api.instrumentation.AsmClassVisitorFactory$createClassVisitor(com.android.build.api.instrumentation.ClassContext,%20org.objectweb.asm.ClassVisitor)/classContext). |\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isInstrumentable](#isInstrumentable(com.android.build.api.instrumentation.ClassData))`(`classData:` `[ClassData](/reference/tools/gradle-api/4.2/com/android/build/api/instrumentation/ClassData)`)` Whether or not the factory wants to instrument the class with the given [classData](#com.android.build.api.instrumentation.AsmClassVisitorFactory$isInstrumentable(com.android.build.api.instrumentation.ClassData)/classData). |\n\n| ### Properties ||\n|---------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [InstrumentationContext](/reference/tools/gradle-api/4.2/com/android/build/api/instrumentation/InstrumentationContext) | [instrumentationContext](#instrumentationContext:com.android.build.api.instrumentation.InstrumentationContext) Contains parameters to help instantiate the visitor objects. |\n| abstract [Property](https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html)\\\u003cParametersT\\\u003e | [parameters](#parameters:org.gradle.api.provider.Property) The parameters that will be instantiated, configured using the given config when registering the visitor, and injected on instantiation. |\n\nPublic methods\n--------------\n\n### createClassVisitor\n\n```\nabstract fun createClassVisitor(\n classContext: ClassContext, \n nextClassVisitor: ClassVisitor\n): ClassVisitor\n```\n\nCreates a class visitor object that will visit a class with the given [classContext](#com.android.build.api.instrumentation.AsmClassVisitorFactory$createClassVisitor(com.android.build.api.instrumentation.ClassContext,%20org.objectweb.asm.ClassVisitor)/classContext). The\nreturned class visitor must delegate its calls to [nextClassVisitor](#com.android.build.api.instrumentation.AsmClassVisitorFactory$createClassVisitor(com.android.build.api.instrumentation.ClassContext,%20org.objectweb.asm.ClassVisitor)/nextClassVisitor).\n\nThe given [classContext](#com.android.build.api.instrumentation.AsmClassVisitorFactory$createClassVisitor(com.android.build.api.instrumentation.ClassContext,%20org.objectweb.asm.ClassVisitor)/classContext) contains static information about the classes before starting the\ninstrumentation process. Any changes in interfaces or superclasses for the class with the\ngiven [classContext](#com.android.build.api.instrumentation.AsmClassVisitorFactory$createClassVisitor(com.android.build.api.instrumentation.ClassContext,%20org.objectweb.asm.ClassVisitor)/classContext) or for any other class in its classpath by a previous visitor will\nnot be reflected in the [classContext](#com.android.build.api.instrumentation.AsmClassVisitorFactory$createClassVisitor(com.android.build.api.instrumentation.ClassContext,%20org.objectweb.asm.ClassVisitor)/classContext) object.\n\n[classContext](#com.android.build.api.instrumentation.AsmClassVisitorFactory$createClassVisitor(com.android.build.api.instrumentation.ClassContext,%20org.objectweb.asm.ClassVisitor)/classContext) can also be used to get the data for classes that are in the runtime classpath\nof the class being visited.\n\nThis method must handle asynchronous calls.\n\n| Parameters ||\n|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|\n| classContext: [ClassContext](/reference/tools/gradle-api/4.2/com/android/build/api/instrumentation/ClassContext) | contains information about the class that will be instrumented by the returned class visitor. |\n| nextClassVisitor: ClassVisitor | the [ClassVisitor](#) to which the created [ClassVisitor](#) must delegate method calls. |\n\n### isInstrumentable\n\n```\nabstract fun isInstrumentable(classData: ClassData): Boolean\n```\n\nWhether or not the factory wants to instrument the class with the given [classData](#com.android.build.api.instrumentation.AsmClassVisitorFactory$isInstrumentable(com.android.build.api.instrumentation.ClassData)/classData).\n\nIf returned true, [createClassVisitor](#createClassVisitor(com.android.build.api.instrumentation.ClassContext,%20org.objectweb.asm.ClassVisitor)) will be called and the returned class visitor will\nvisit the class.\n\nThis method must handle asynchronous calls.\n\nProperties\n----------\n\n### instrumentationContext\n\n```\nabstract val instrumentationContext: InstrumentationContext\n```\n\nContains parameters to help instantiate the visitor objects.\n\nThis field must be left unimplemented. \n\n### parameters\n\n```\nabstract val parameters: Property\u003cParametersT\u003e\n```\n\nThe parameters that will be instantiated, configured using the given config when registering\nthe visitor, and injected on instantiation.\n\nThis field must be left unimplemented."]]