Top Description Inners Fields Constructors Methods
net.bytebuddy.implementation

public abstract Class InvocationHandlerAdapter

extends Object
implements Composable
Class Inheritance
All Implemented Interfaces
net.bytebuddy.implementation.Implementation.Composable, net.bytebuddy.implementation.Implementation, net.bytebuddy.dynamic.scaffold.InstrumentedType.Prepareable
Known Direct Subclasses
net.bytebuddy.implementation.InvocationHandlerAdapter.ForInstance, net.bytebuddy.implementation.InvocationHandlerAdapter.ForField
Annotations
@Enhance
Imports
net.bytebuddy.build.HashCodeAndEqualsPlugin, net.bytebuddy.description.field.FieldDescription, net.bytebuddy.description.method.MethodDescription, net.bytebuddy.description.type.TypeDescription, .TypeList, net.bytebuddy.dynamic.scaffold.FieldLocator, .InstrumentedType, net.bytebuddy.implementation.bytecode.ByteCodeAppender, .Removal, .StackManipulation, net.bytebuddy.implementation.bytecode.assign.Assigner, net.bytebuddy.implementation.bytecode.collection.ArrayFactory, net.bytebuddy.implementation.bytecode.constant.MethodConstant, .NullConstant, net.bytebuddy.implementation.bytecode.member.FieldAccess, .MethodInvocation, .MethodReturn, .MethodVariableAccess, net.bytebuddy.utility.RandomString, net.bytebuddy.jar.asm.MethodVisitor, .Opcodes, java.lang.reflect.InvocationHandler, java.util.ArrayList, .List

An adapter for adapting an java.lang.reflect.InvocationHandler. The adapter allows the invocation handler to also intercept method calls to non-interface methods.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
protected static class
InvocationHandlerAdapter.ForField

An implementation of an net.bytebuddy.implementation.InvocationHandlerAdapter that delegates method invocations to an adapter that is stored in an instance field.

protected static class
InvocationHandlerAdapter.ForInstance

An implementation of an net.bytebuddy.implementation.InvocationHandlerAdapter that delegates method invocations to an adapter that is stored in a static field.

public static interface
InvocationHandlerAdapter.WithoutPrivilegeConfiguration

Allows the configuration of privileged lookup for the resolution of java.lang.reflect.Method constants that are provided to the invocation handler.

Field Summary

Modifier and TypeField and Description
protected final Assigner
assigner

The assigner that is used for assigning the return invocation handler's return value to the intercepted method's return value.

private static final boolean
CACHED

Indicates that a java.lang.reflect.Method should be cached.

protected final boolean
cached

Determines if the java.lang.reflect.Method instances that are handed to the intercepted methods are cached in static fields.

private static final boolean
DROPPING

Indicates that a handler is dropping its return value.

protected final String
fieldName

The name of the field for storing an invocation handler.

private static final TypeDescription.Generic
INVOCATION_HANDLER_TYPE

A type description of the InvocationHandler.

private static final boolean
PRIVILEGED

Indicates that a lookup of a method constant should be looked up using an java.security.AccessController.

protected final boolean
privileged

Determines if the java.lang.reflect.Method instances are retrieved by using an java.security.AccessController.

private static final boolean
RETURNING

Indicates that a handler is returning its return value.

protected final boolean
returning

Determines if this implementation is returning the result value or is dropping it.

private static final boolean
UNCACHED

Indicates that a value should not be cached.

private static final boolean
UNPRIVILEGED

Indicates that a lookup of a method constant should not be looked up using an java.security.AccessController.

Constructor Summary

AccessConstructor and Description
protected
InvocationHandlerAdapter(String
The name of the field.
fieldName
,
boolean
Determines if the java.lang.reflect.Method instances that are handed to the intercepted methods are cached in static fields.
cached
,
boolean
Determines if the java.lang.reflect.Method instances are retrieved by using an java.security.AccessController.
privileged
,
boolean
Determines if this implementation is returning the result value or is dropping it.
returning
,
Assigner
The assigner to apply when defining this implementation.
assigner
)

Creates a new invocation handler for a given field.

Method Summary

Modifier and TypeMethod and Description
protected ByteCodeAppender.Size

Returns:

The size of the applied assignment.
apply
(MethodVisitor
The method visitor for writing the byte code to.
methodVisitor
,
Implementation.Context
The implementation context for the current implementation.
implementationContext
,
MethodDescription
The method that is instrumented.
instrumentedMethod
,
StackManipulation
A stack manipulation that applies any preparation to the operand stack.
preparingManipulation
,
FieldDescription
The field that contains the value for the invocation handler.
fieldDescription
)

Applies an implementation that delegates to a invocation handler.

private List<StackManipulation>

Returns:

A list of stack manipulation that loads all arguments of an instrumented method.
argumentValuesOf
(MethodDescription
The method that is instrumented.
instrumentedMethod
)

Returns a list of stack manipulations that loads all arguments of an instrumented method.

public static InvocationHandlerAdapter

Returns:

An implementation that delegates all method interceptions to the given invocation handler.
of
(InvocationHandler
The invocation handler to which all method calls are delegated.
invocationHandler
)

Creates an implementation for any instance of an java.lang.reflect.InvocationHandler that delegates all method interceptions to the given instance which will be stored in a static field.

public static InvocationHandlerAdapter

Returns:

An implementation that delegates all method interceptions to the given invocation handler.
of
(InvocationHandler
The invocation handler to which all method calls are delegated.
invocationHandler
,
String
The name of the field.
fieldName
)

Creates an implementation for any instance of an java.lang.reflect.InvocationHandler that delegates all method interceptions to the given instance which will be stored in a static field.

public static InvocationHandlerAdapter

Returns:

An implementation that delegates all method interceptions to an instance field of the given name.
toField
(String
The name of the field.
name
)

Creates an implementation for any java.lang.reflect.InvocationHandler that delegates all method interceptions to a field with the given name.

public static InvocationHandlerAdapter

Returns:

An implementation that delegates all method interceptions to an instance field of the given name.
toField
(String
The name of the field.
name
,
FieldLocator.Factory
The field locator factory
fieldLocatorFactory
)

Creates an implementation for any java.lang.reflect.InvocationHandler that delegates all method interceptions to a field with the given name.

public abstract Implementation

Returns:

This instrumentation with the given assigner configured.
withAssigner
(Assigner
The assigner to apply when defining this implementation.
assigner
)

Configures an assigner to use with this invocation handler adapter.

public abstract InvocationHandlerAdapter.WithoutPrivilegeConfiguration

Returns:

A similar invocation handler adapter that applies caching.
withoutMethodCache
()

By default, any java.lang.reflect.Method instance that is handed over to an java.lang.reflect.InvocationHandler is cached in a static field.

public abstract InvocationHandlerAdapter.AssignerConfigurable

Returns:

This instrumentation with a privileged lookup configured.
withPrivilegedLookup
()

Configures that the method constants supplied to the invocation handler adapter are resolved using an java.security.AccessController.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait