Class RebaseImplementationTarget
- java.lang.Object
-
- net.bytebuddy.implementation.Implementation.Target.AbstractBase
-
- net.bytebuddy.dynamic.scaffold.inline.RebaseImplementationTarget
-
- All Implemented Interfaces:
Implementation.Target
@Enhance public class RebaseImplementationTarget extends Implementation.Target.AbstractBase
An implementation target for redefining a given type while preserving the original methods within the instrumented type.
Super method calls are merely emulated by thisImplementation.Targetin order to preserve Java's super call semantics a user would expect when invoking asuper-prefixed method. This means that original methods are either moved to renamedprivatemethods which are never dispatched virtually or they are invoked directly via theINVOKESPECIALinvocation to explicitly forbid a virtual dispatch.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRebaseImplementationTarget.FactoryA factory for creating aRebaseImplementationTarget.protected static classRebaseImplementationTarget.RebasedMethodInvocationAImplementation.SpecialMethodInvocationwhich invokes a rebased method as given by aMethodRebaseResolver.-
Nested classes/interfaces inherited from class net.bytebuddy.implementation.Implementation.Target.AbstractBase
Implementation.Target.AbstractBase.DefaultMethodInvocation
-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.Implementation.Target
Implementation.Target.AbstractBase
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<MethodDescription.SignatureToken,MethodRebaseResolver.Resolution>rebaseableMethodsA mapping of the instrumented type's declared methods by each method's token.-
Fields inherited from class net.bytebuddy.implementation.Implementation.Target.AbstractBase
defaultMethodInvocation, instrumentedType, methodGraph
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRebaseImplementationTarget(TypeDescription instrumentedType, MethodGraph.Linked methodGraph, Implementation.Target.AbstractBase.DefaultMethodInvocation defaultMethodInvocation, java.util.Map<MethodDescription.SignatureToken,MethodRebaseResolver.Resolution> rebaseableMethods)Creates a rebase implementation target.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TypeDescriptiongetOriginType()Identifies the origin type of an implementation.Implementation.SpecialMethodInvocationinvokeSuper(MethodDescription.SignatureToken token)Creates a special method invocation for invoking the super method of the given method.private Implementation.SpecialMethodInvocationinvokeSuper(MethodRebaseResolver.Resolution resolution)Creates a special method invocation for the given rebase resolution.private Implementation.SpecialMethodInvocationinvokeSuper(MethodGraph.Node node)Creates a special method invocation for the given node.protected static Implementation.Targetof(TypeDescription instrumentedType, MethodGraph.Linked methodGraph, ClassFileVersion classFileVersion, MethodRebaseResolver methodRebaseResolver)Creates a new rebase implementation target.-
Methods inherited from class net.bytebuddy.implementation.Implementation.Target.AbstractBase
getInstrumentedType, invokeDefault, invokeDefault, invokeDominant
-
-
-
-
Field Detail
-
rebaseableMethods
private final java.util.Map<MethodDescription.SignatureToken,MethodRebaseResolver.Resolution> rebaseableMethods
A mapping of the instrumented type's declared methods by each method's token.
-
-
Constructor Detail
-
RebaseImplementationTarget
protected RebaseImplementationTarget(TypeDescription instrumentedType, MethodGraph.Linked methodGraph, Implementation.Target.AbstractBase.DefaultMethodInvocation defaultMethodInvocation, java.util.Map<MethodDescription.SignatureToken,MethodRebaseResolver.Resolution> rebaseableMethods)
Creates a rebase implementation target.- Parameters:
instrumentedType- The instrumented type.methodGraph- A method graph of the instrumented type.defaultMethodInvocation- The default method invocation mode to apply.rebaseableMethods- A mapping of the instrumented type's declared methods by each method's token.
-
-
Method Detail
-
of
protected static Implementation.Target of(TypeDescription instrumentedType, MethodGraph.Linked methodGraph, ClassFileVersion classFileVersion, MethodRebaseResolver methodRebaseResolver)
Creates a new rebase implementation target.- Parameters:
instrumentedType- The instrumented type.methodGraph- A method graph of the instrumented type.classFileVersion- The type's class file version.methodRebaseResolver- A method rebase resolver to be used when calling a rebased method.- Returns:
- An implementation target for the given input.
-
invokeSuper
public Implementation.SpecialMethodInvocation invokeSuper(MethodDescription.SignatureToken token)
Creates a special method invocation for invoking the super method of the given method.- Parameters:
token- A token of the method that is to be invoked as a super method.- Returns:
- The corresponding special method invocation which might be illegal if the requested invocation is not legal.
-
invokeSuper
private Implementation.SpecialMethodInvocation invokeSuper(MethodGraph.Node node)
Creates a special method invocation for the given node.- Parameters:
node- The node for which a special method invocation is to be created.- Returns:
- A special method invocation for the provided node.
-
invokeSuper
private Implementation.SpecialMethodInvocation invokeSuper(MethodRebaseResolver.Resolution resolution)
Creates a special method invocation for the given rebase resolution.- Parameters:
resolution- The resolution for which a special method invocation is to be created.- Returns:
- A special method invocation for the provided resolution.
-
getOriginType
public TypeDescription 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:
- The origin type of this implementation.
-
-