Top Description Inners Fields Constructors Methods
net.bytebuddy.dynamic.scaffold.inline

public Class RebaseImplementationTarget

extends AbstractBase
Class Inheritance
Annotations
@Enhance
Imports
net.bytebuddy.ClassFileVersion, net.bytebuddy.build.HashCodeAndEqualsPlugin, net.bytebuddy.description.method.MethodDescription, net.bytebuddy.description.type.TypeDescription, .TypeList, net.bytebuddy.dynamic.scaffold.MethodGraph, net.bytebuddy.implementation.Implementation, net.bytebuddy.implementation.bytecode.StackManipulation, net.bytebuddy.implementation.bytecode.constant.DefaultValue, net.bytebuddy.implementation.bytecode.member.MethodInvocation, net.bytebuddy.utility.CompoundList, .JavaConstant, net.bytebuddy.jar.asm.MethodVisitor, java.util.ArrayList, .List, .Map

An implementation target for redefining a given type while preserving the original methods within the instrumented type.

 

Super method calls are merely emulated by this Implementation.Target in order to preserve Java's super call semantics a user would expect when invoking a super-prefixed method. This means that original methods are either moved to renamed private methods which are never dispatched virtually or they are invoked directly via the INVOKESPECIAL invocation to explicitly forbid a virtual dispatch.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
protected static class

Field Summary

Modifier and TypeField and Description
private final Map<MethodDescription.SignatureToken, MethodRebaseResolver.Resolution>
rebaseableMethods

A mapping of the instrumented type's declared methods by each method's token.

Inherited from net.bytebuddy.implementation.Implementation.Target.AbstractBase:
defaultMethodInvocationinstrumentedTypemethodGraph

Constructor Summary

AccessConstructor and Description
protected
RebaseImplementationTarget(TypeDescription
The instrumented type.
instrumentedType
,
MethodGraph.Linked
A method graph of the instrumented type.
methodGraph
,
Implementation.Target.AbstractBase.DefaultMethodInvocation
The default method invocation mode to apply.
defaultMethodInvocation
,
Map<MethodDescription.SignatureToken, MethodRebaseResolver.Resolution>
A mapping of the instrumented type's declared methods by each method's token.
rebaseableMethods
)

Creates a rebase implementation target.

Method Summary

Modifier and TypeMethod and Description
public TypeDescription
getOriginType()

Implements net.bytebuddy.implementation.Implementation.Target.getOriginType.

Identifies the origin type of an implementation.
public Implementation.SpecialMethodInvocation
invokeSuper(MethodDescription.SignatureToken
A token of the method that is to be invoked as a super method.
token
)

Implements net.bytebuddy.implementation.Implementation.Target.invokeSuper.

Creates a special method invocation for invoking the super method of the given method.
private Implementation.SpecialMethodInvocation

Returns:

A special method invocation for the provided node.
invokeSuper
(MethodGraph.Node
The node for which a special method invocation is to be created.
node
)

Creates a special method invocation for the given node.

private Implementation.SpecialMethodInvocation

Returns:

A special method invocation for the provided resolution.
invokeSuper
(MethodRebaseResolver.Resolution
The resolution for which a special method invocation is to be created.
resolution
)

Creates a special method invocation for the given rebase resolution.

protected static Implementation.Target

Returns:

An implementation target for the given input.
of
(TypeDescription
The instrumented type.
instrumentedType
,
MethodGraph.Linked
A method graph of the instrumented type.
methodGraph
,
ClassFileVersion
The type's class file version.
classFileVersion
,
MethodRebaseResolver
A method rebase resolver to be used when calling a rebased method.
methodRebaseResolver
)

Creates a new rebase implementation target.

Inherited from net.bytebuddy.implementation.Implementation.Target.AbstractBase:
getInstrumentedTypeinvokeDefaultinvokeDefaultinvokeDominant

Field Detail

rebaseableMethodsback to summary
private final Map<MethodDescription.SignatureToken, MethodRebaseResolver.Resolution> rebaseableMethods

A mapping of the instrumented type's declared methods by each method's token.

Constructor Detail

RebaseImplementationTargetback to summary
protected RebaseImplementationTarget(TypeDescription instrumentedType, MethodGraph.Linked methodGraph, Implementation.Target.AbstractBase.DefaultMethodInvocation defaultMethodInvocation, Map<MethodDescription.SignatureToken, MethodRebaseResolver.Resolution> rebaseableMethods)

Creates a rebase implementation target.

Parameters
instrumentedType:TypeDescription

The instrumented type.

methodGraph:MethodGraph.Linked

A method graph of the instrumented type.

defaultMethodInvocation:Implementation.Target.AbstractBase.DefaultMethodInvocation

The default method invocation mode to apply.

rebaseableMethods:Map<MethodDescription.SignatureToken, MethodRebaseResolver.Resolution>

A mapping of the instrumented type's declared methods by each method's token.

Method Detail

getOriginTypeback to summary
public TypeDescription getOriginType()

Implements net.bytebuddy.implementation.Implementation.Target.getOriginType.

Doc from net.bytebuddy.implementation.Implementation.Target.getOriginType.

Identifies the origin type of an implementation. The origin type describes the type that is subject to any form of enhancement. If a subclass of a given type is generated, the base type of this subclass describes the origin type. If a given type is redefined or rebased, the origin type is described by the instrumented type itself.

Returns:TypeDescription

The origin type of this implementation.

invokeSuperback to summary
public Implementation.SpecialMethodInvocation invokeSuper(MethodDescription.SignatureToken token)

Implements net.bytebuddy.implementation.Implementation.Target.invokeSuper.

Doc from net.bytebuddy.implementation.Implementation.Target.invokeSuper.

Creates a special method invocation for invoking the super method of the given method.

Parameters
token:MethodDescription.SignatureToken

A token of the method that is to be invoked as a super method.

Returns:Implementation.SpecialMethodInvocation

The corresponding special method invocation which might be illegal if the requested invocation is not legal.

invokeSuperback to summary
private Implementation.SpecialMethodInvocation invokeSuper(MethodGraph.Node node)

Creates a special method invocation for the given node.

Parameters
node:MethodGraph.Node

The node for which a special method invocation is to be created.

Returns:Implementation.SpecialMethodInvocation

A special method invocation for the provided node.

invokeSuperback to summary
private Implementation.SpecialMethodInvocation invokeSuper(MethodRebaseResolver.Resolution resolution)

Creates a special method invocation for the given rebase resolution.

Parameters
resolution:MethodRebaseResolver.Resolution

The resolution for which a special method invocation is to be created.

Returns:Implementation.SpecialMethodInvocation

A special method invocation for the provided resolution.

ofback to summary
protected static Implementation.Target of(TypeDescription instrumentedType, MethodGraph.Linked methodGraph, ClassFileVersion classFileVersion, MethodRebaseResolver methodRebaseResolver)

Creates a new rebase implementation target.

Parameters
instrumentedType:TypeDescription

The instrumented type.

methodGraph:MethodGraph.Linked

A method graph of the instrumented type.

classFileVersion:ClassFileVersion

The type's class file version.

methodRebaseResolver:MethodRebaseResolver

A method rebase resolver to be used when calling a rebased method.

Returns:Implementation.Target

An implementation target for the given input.

net.bytebuddy.dynamic.scaffold.inline back to summary

public Class RebaseImplementationTarget.Factory

extends Object
implements Factory
Class Inheritance
  • java.lang.Object
  • net.bytebuddy.dynamic.scaffold.inline.RebaseImplementationTarget.Factory
All Implemented Interfaces
net.bytebuddy.implementation.Implementation.Target.Factory
Annotations
@Enhance

A factory for creating a RebaseImplementationTarget.

Field Summary

Modifier and TypeField and Description
private final MethodRebaseResolver
methodRebaseResolver

The method rebase resolver to use.

Constructor Summary

AccessConstructor and Description
public
Factory(MethodRebaseResolver
The method rebase resolver to use.
methodRebaseResolver
)

Creates a new factory for a rebase implementation target.

Method Summary

Modifier and TypeMethod and Description
public Implementation.Target
make(TypeDescription
The instrumented type.
instrumentedType
,
MethodGraph.Linked
A method graph of the instrumented type.
methodGraph
,
ClassFileVersion
The type's class file version.
classFileVersion
)

Implements net.bytebuddy.implementation.Implementation.Target.Factory.make.

Creates an implementation target.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

methodRebaseResolverback to summary
private final MethodRebaseResolver methodRebaseResolver

The method rebase resolver to use.

Constructor Detail

Factoryback to summary
public Factory(MethodRebaseResolver methodRebaseResolver)

Creates a new factory for a rebase implementation target.

Parameters
methodRebaseResolver:MethodRebaseResolver

The method rebase resolver to use.

Method Detail

makeback to summary
public Implementation.Target make(TypeDescription instrumentedType, MethodGraph.Linked methodGraph, ClassFileVersion classFileVersion)

Implements net.bytebuddy.implementation.Implementation.Target.Factory.make.

Doc from net.bytebuddy.implementation.Implementation.Target.Factory.make.

Creates an implementation target.

Parameters
instrumentedType:TypeDescription

The instrumented type.

methodGraph:MethodGraph.Linked

A method graph of the instrumented type.

classFileVersion:ClassFileVersion

The type's class file version.

Returns:Implementation.Target

An implementation target for the instrumented type.

net.bytebuddy.dynamic.scaffold.inline back to summary

protected Class RebaseImplementationTarget.RebasedMethodInvocation

extends AbstractBase
Class Inheritance

A Implementation.SpecialMethodInvocation which invokes a rebased method as given by a MethodRebaseResolver.

Field Summary

Modifier and TypeField and Description
private final TypeDescription
instrumentedType

The instrumented type on which the method should be invoked on.

private final MethodDescription.InDefinedShape
methodDescription

The method to invoke via a special method invocation.

private final TypeList
prependedParameters

Any additional arguments that are to be provided to the rebased method.

private final StackManipulation
stackManipulation

The stack manipulation to execute in order to invoke the rebased method.

Constructor Summary

AccessConstructor and Description
protected
RebasedMethodInvocation(MethodDescription.InDefinedShape
The method to invoke via a special method invocation.
methodDescription
,
TypeDescription
The instrumented type on which the method should be invoked on.
instrumentedType
,
StackManipulation
The stack manipulation to execute in order to invoke the rebased method.
stackManipulation
,
TypeList
Any additional arguments that are to be provided to the rebased method.
prependedParameters
)

Creates a new rebased method invocation.

Method Summary

Modifier and TypeMethod and Description
public StackManipulation.Size
apply(MethodVisitor
The method visitor used to write the method implementation to.
methodVisitor
,
Implementation.Context
The context of the current implementation.
implementationContext
)

Implements net.bytebuddy.implementation.bytecode.StackManipulation.apply.

Applies the stack manipulation that is described by this instance.
public MethodDescription
getMethodDescription()

Implements net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.getMethodDescription.

Returns the method that represents this special method invocation.
public TypeDescription
getTypeDescription()

Implements net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.getTypeDescription.

Returns the target type the represented method is invoked on.
protected static Implementation.SpecialMethodInvocation

Returns:

A special method invocation of the rebased method.
of
(MethodDescription.InDefinedShape
The rebased method to be invoked.
resolvedMethod
,
TypeDescription
The instrumented type on which the method is to be invoked if it is non-static.
instrumentedType
,
TypeList
Any additional arguments that are to be provided to the rebased method.
prependedParameters
)

Creates a special method invocation for the given method.

public JavaConstant.MethodHandle
toMethodHandle()

Implements net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.toMethodHandle.

Returns a method handle representing this special method invocation.
public Implementation.SpecialMethodInvocation
withCheckedCompatibilityTo(MethodDescription.TypeToken
The type token to check against.
token
)

Implements net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.withCheckedCompatibilityTo.

Checks that this special method invocation is compatible with the supplied type representation.
Inherited from net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.AbstractBase:
equalshashCode

Field Detail

instrumentedTypeback to summary
private final TypeDescription instrumentedType

The instrumented type on which the method should be invoked on.

methodDescriptionback to summary
private final MethodDescription.InDefinedShape methodDescription

The method to invoke via a special method invocation.

prependedParametersback to summary
private final TypeList prependedParameters

Any additional arguments that are to be provided to the rebased method.

stackManipulationback to summary
private final StackManipulation stackManipulation

The stack manipulation to execute in order to invoke the rebased method.

Constructor Detail

RebasedMethodInvocationback to summary
protected RebasedMethodInvocation(MethodDescription.InDefinedShape methodDescription, TypeDescription instrumentedType, StackManipulation stackManipulation, TypeList prependedParameters)

Creates a new rebased method invocation.

Parameters
methodDescription:MethodDescription.InDefinedShape

The method to invoke via a special method invocation.

instrumentedType:TypeDescription

The instrumented type on which the method should be invoked on.

stackManipulation:StackManipulation

The stack manipulation to execute in order to invoke the rebased method.

prependedParameters:TypeList

Any additional arguments that are to be provided to the rebased method.

Method Detail

applyback to summary
public StackManipulation.Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext)

Implements net.bytebuddy.implementation.bytecode.StackManipulation.apply.

Doc from net.bytebuddy.implementation.bytecode.StackManipulation.apply.

Applies the stack manipulation that is described by this instance.

Parameters
methodVisitor:MethodVisitor

The method visitor used to write the method implementation to.

implementationContext:Implementation.Context

The context of the current implementation.

Returns:StackManipulation.Size

The changes to the size of the operand stack that are implied by this stack manipulation.

getMethodDescriptionback to summary
public MethodDescription getMethodDescription()

Implements net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.getMethodDescription.

Doc from net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.getMethodDescription.

Returns the method that represents this special method invocation. This method can be different even for equal special method invocations, dependent on the method that was used to request such an invocation by the means of a Implementation.Target.

Returns:MethodDescription

The method description that describes this instances invocation target.

getTypeDescriptionback to summary
public TypeDescription getTypeDescription()

Implements net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.getTypeDescription.

Doc from net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.getTypeDescription.

Returns the target type the represented method is invoked on.

Returns:TypeDescription

The type the represented method is invoked on.

ofback to summary
protected static Implementation.SpecialMethodInvocation of(MethodDescription.InDefinedShape resolvedMethod, TypeDescription instrumentedType, TypeList prependedParameters)

Creates a special method invocation for the given method.

Parameters
resolvedMethod:MethodDescription.InDefinedShape

The rebased method to be invoked.

instrumentedType:TypeDescription

The instrumented type on which the method is to be invoked if it is non-static.

prependedParameters:TypeList

Any additional arguments that are to be provided to the rebased method.

Returns:Implementation.SpecialMethodInvocation

A special method invocation of the rebased method.

toMethodHandleback to summary
public JavaConstant.MethodHandle toMethodHandle()

Implements net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.toMethodHandle.

Doc from net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.toMethodHandle.

Returns a method handle representing this special method invocation.

Returns:JavaConstant.MethodHandle

A method handle for this special method invocation.

Annotations
@Override
withCheckedCompatibilityToback to summary
public Implementation.SpecialMethodInvocation withCheckedCompatibilityTo(MethodDescription.TypeToken token)

Implements net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.withCheckedCompatibilityTo.

Doc from net.bytebuddy.implementation.Implementation.SpecialMethodInvocation.withCheckedCompatibilityTo.

Checks that this special method invocation is compatible with the supplied type representation.

Parameters
token:MethodDescription.TypeToken

The type token to check against.

Returns:Implementation.SpecialMethodInvocation

This special method invocation or an illegal invocation if the method invocation is not applicable.