UsesReflectionToAccessMethod


@Retention(value = AnnotationRetention.BINARY)
@Repeatable
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.FIELD, AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR])
public annotation UsesReflectionToAccessMethod


The annotated code uses reflection to indirectly access a method of the specified class/interface, or its subclasses / interface implementers.

This annotation indicates to optimizers or shrinkers that the target method should be preserved if the annotated code is reachable in the final application build.

Summary

Public constructors

UsesReflectionToAccessMethod(
    @NonNull KClass<@NonNull ?> classConstant,
    @NonNull String className,
    @NonNull String methodName,
    @NonNull KClass[] parameterTypes,
    @NonNull String[] parameterTypeNames,
    @NonNull KClass<@NonNull ?> returnType,
    @NonNull String returnTypeName
)

Public methods

final @NonNull KClass<@NonNull ?>

Class containing the method accessed by reflection.

final @NonNull String

Class name (or class name pattern) containing the method accessed by reflection.

final @NonNull String

Name (or name pattern) of method accessed by reflection.

final @NonNull String[]

Defines which method to keep by specifying set of parameter classes passed.

final @NonNull KClass[]

Defines which method to keep by specifying set of parameter classes passed.

final @NonNull KClass<@NonNull ?>

Return type of the method accessed by reflection.

final @NonNull String

Return type (or type pattern) of the method accessed by reflection.

Public constructors

UsesReflectionToAccessMethod

public UsesReflectionToAccessMethod(
    @NonNull KClass<@NonNull ?> classConstant,
    @NonNull String className,
    @NonNull String methodName,
    @NonNull KClass[] parameterTypes,
    @NonNull String[] parameterTypeNames,
    @NonNull KClass<@NonNull ?> returnType,
    @NonNull String returnTypeName
)

Public methods

getClassConstant

public final @NonNull KClass<@NonNull ?> getClassConstant()

Class containing the method accessed by reflection.

Mutually exclusive with className.

getClassName

public final @NonNull String getClassName()

Class name (or class name pattern) containing the method accessed by reflection.

Mutually exclusive with classConstant.

getMethodName

public final @NonNull String getMethodName()

Name (or name pattern) of method accessed by reflection.

getParameterTypeNames

public final @NonNull String[] getParameterTypeNames()

Defines which method to keep by specifying set of parameter classes passed.

If neither parameterTypes nor parameterTypeNames is specified then methods with all parameter lists are kept.

Mutually exclusive with parameterTypes.

getParameterTypes

public final @NonNull KClass[] getParameterTypes()

Defines which method to keep by specifying set of parameter classes passed.

If neither parameterTypes nor parameterTypeNames is specified then methods with all parameter lists are kept.

Mutually exclusive with parameterTypeNames.

getReturnType

public final @NonNull KClass<@NonNull ?> getReturnType()

Return type of the method accessed by reflection.

Ignored if not specified.

Mutually exclusive with returnTypeName.

getReturnTypeName

public final @NonNull String getReturnTypeName()

Return type (or type pattern) of the method accessed by reflection.

Ignored if not specified.

Mutually exclusive with returnType.