Package net.bytebuddy.asm
Enum Class MemberSubstitution.Source
- All Implemented Interfaces:
Serializable
,Comparable<MemberSubstitution.Source>
,Constable
- Enclosing class:
MemberSubstitution
Identifies the source of an instruction that might describe a value of the substituted element
or the instrumented method.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Represents a value that can be loaded from a given offset.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionIndicates that an element should be loaded in context of the instrumented method.Indicates that an element should be loaded in context of the substituted method, constructor or field. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract MemberSubstitution.Source.Value
argument
(int index, TypeList.Generic parameters, Map<Integer, Integer> offsets, ByteCodeElement.Member original, MethodDescription instrumentedMethod) Resolves a value representation of the parameter of the specified index ornull
if no such parameter is available.protected abstract List
<MemberSubstitution.Source.Value> arguments
(boolean includesSelf, TypeList.Generic parameters, Map<Integer, Integer> offsets, ByteCodeElement.Member original, MethodDescription instrumentedMethod) Resolves a list of value representation of all parameters.protected abstract ByteCodeElement.Member
element
(ByteCodeElement.Member original, MethodDescription instrumentedMethod) Resolves the targeted byte code element.protected abstract JavaConstant.MethodHandle
handle
(JavaConstant.MethodHandle methodHandle, MethodDescription instrumentedMethod) Resolves a method handle.protected abstract boolean
isRepresentable
(MemberSubstitution.Substitution.Chain.Step.ForDelegation.OffsetMapping.ForOrigin.Sort sort, ByteCodeElement.Member original, MethodDescription instrumentedMethod) Validates if the supplied origin sort is representable.protected abstract StackManipulation
resolve
(MemberSubstitution.Substitution.Chain.Step.ForDelegation.OffsetMapping.ForOrigin.Sort sort, ByteCodeElement.Member original, TypeList.Generic parameters, TypeDescription.Generic result, MethodDescription instrumentedMethod) Resolves a stack manipulation that loads the supplied sort of origin onto the operand stack.protected abstract MemberSubstitution.Source.Value
self
(TypeList.Generic parameters, Map<Integer, Integer> offsets, ByteCodeElement.Member original, MethodDescription instrumentedMethod) Resolves a value representation of thethis
reference ornull
if no such reference is available.static MemberSubstitution.Source
Returns the enum constant of this class with the specified name.static MemberSubstitution.Source[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SUBSTITUTED_ELEMENT
Indicates that an element should be loaded in context of the substituted method, constructor or field. -
ENCLOSING_METHOD
Indicates that an element should be loaded in context of the instrumented method.
-
-
Constructor Details
-
Source
private Source()
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
element
protected abstract ByteCodeElement.Member element(ByteCodeElement.Member original, MethodDescription instrumentedMethod) Resolves the targeted byte code element.- Parameters:
original
- The substituted element.instrumentedMethod
- The instrumented element.- Returns:
- The byte code element that is represented by this source.
-
self
@MaybeNull protected abstract MemberSubstitution.Source.Value self(TypeList.Generic parameters, Map<Integer, Integer> offsets, ByteCodeElement.Member original, MethodDescription instrumentedMethod) Resolves a value representation of thethis
reference ornull
if no such reference is available.- Parameters:
parameters
- The list of parameters of the substituted element.offsets
- A mapping of offsets of parameter indices to offsets.original
- The substituted element.instrumentedMethod
- The instrumented method.- Returns:
- A representation of the
this
reference ornull
if no such reference is available.
-
argument
@MaybeNull protected abstract MemberSubstitution.Source.Value argument(int index, TypeList.Generic parameters, Map<Integer, Integer> offsets, ByteCodeElement.Member original, MethodDescription instrumentedMethod) Resolves a value representation of the parameter of the specified index ornull
if no such parameter is available.- Parameters:
index
- The index of the targeted parameter.parameters
- The list of parameters of the substituted element.offsets
- A mapping of offsets of parameter indices to offsets.original
- The substituted element.instrumentedMethod
- The instrumented method.- Returns:
- A representation of the parameter of the specified index or
null
if no such parameter is available.
-
arguments
protected abstract List<MemberSubstitution.Source.Value> arguments(boolean includesSelf, TypeList.Generic parameters, Map<Integer, Integer> offsets, ByteCodeElement.Member original, MethodDescription instrumentedMethod) Resolves a list of value representation of all parameters.- Parameters:
includesSelf
-true
if thethis
reference should be included if available.parameters
- The list of parameters of the substituted element.offsets
- A mapping of offsets of parameter indices to offsets.original
- The substituted element.instrumentedMethod
- The instrumented method.- Returns:
- A list of representation of all values of all parameters.
-
handle
protected abstract JavaConstant.MethodHandle handle(JavaConstant.MethodHandle methodHandle, MethodDescription instrumentedMethod) Resolves a method handle.- Parameters:
methodHandle
- A method handle of the substituted element.instrumentedMethod
- The instrumented method.- Returns:
- An appropriate method handle.
-
isRepresentable
protected abstract boolean isRepresentable(MemberSubstitution.Substitution.Chain.Step.ForDelegation.OffsetMapping.ForOrigin.Sort sort, ByteCodeElement.Member original, MethodDescription instrumentedMethod) Validates if the supplied origin sort is representable.- Parameters:
sort
- The sort of origin.original
- The substituted element.instrumentedMethod
- The instrumented method.- Returns:
true
if the supplied sort of origin is representable.
-
resolve
protected abstract StackManipulation resolve(MemberSubstitution.Substitution.Chain.Step.ForDelegation.OffsetMapping.ForOrigin.Sort sort, ByteCodeElement.Member original, TypeList.Generic parameters, TypeDescription.Generic result, MethodDescription instrumentedMethod) Resolves a stack manipulation that loads the supplied sort of origin onto the operand stack.- Parameters:
sort
- The sort of origin.original
- The substituted element.parameters
- The parameters to the substituted element.result
- The type upon which the substituted element is invoked.instrumentedMethod
- The instrumented method.- Returns:
- A stack manipulation loading the supplied sort of origin onto the operand stack.
-