Enum MethodVariableAccess
- java.lang.Object
-
- java.lang.Enum<MethodVariableAccess>
-
- net.bytebuddy.implementation.bytecode.member.MethodVariableAccess
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<MethodVariableAccess>
public enum MethodVariableAccess extends java.lang.Enum<MethodVariableAccess>
A stack assignment that loads a method variable from a given index of the local variable array.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MethodVariableAccess.MethodLoading
A stack manipulation that loads all parameters of a given method onto the operand stack.protected static class
MethodVariableAccess.OffsetIncrementing
A stack manipulation that increments an integer variable.protected class
MethodVariableAccess.OffsetLoading
A stack manipulation for loading a variable of a method's local variable array onto the operand stack.protected class
MethodVariableAccess.OffsetWriting
A stack manipulation for storing a variable into a method's local variable array.
-
Field Summary
Fields Modifier and Type Field Description private int
loadOpcode
The opcode for loading this variable type.private StackSize
size
The size of the local variable on the JVM stack.private int
storeOpcode
The opcode for storing a local variable type.
-
Constructor Summary
Constructors Modifier Constructor Description private
MethodVariableAccess(int loadOpcode, int storeOpcode, StackSize stackSize)
Creates a new method variable access for a given JVM type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MethodVariableAccess.MethodLoading
allArgumentsOf(MethodDescription methodDescription)
Loads all arguments of the provided method onto the operand stack.StackManipulation
increment(int offset, int value)
Creates a stack assignment for incrementing the given offset of the local variable array.static StackManipulation
increment(ParameterDescription parameterDescription, int value)
Increments the value of the supplied parameter.static StackManipulation
load(ParameterDescription parameterDescription)
Loads a parameter's value onto the operand stack.StackManipulation
loadFrom(int offset)
Creates a stack assignment for a reading given offset of the local variable array.static StackManipulation
loadThis()
Loads a reference to thethis
reference what is only meaningful for a non-static method.static MethodVariableAccess
of(TypeDefinition typeDefinition)
Locates the correct accessor for a variable of a given type.static StackManipulation
store(ParameterDescription parameterDescription)
Stores the top operand stack value at the supplied parameter.StackManipulation
storeAt(int offset)
Creates a stack assignment for writing to a given offset of the local variable array.static MethodVariableAccess
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static MethodVariableAccess[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
INTEGER
public static final MethodVariableAccess INTEGER
The accessor handler for a JVM-integer.
-
LONG
public static final MethodVariableAccess LONG
The accessor handler for along
.
-
FLOAT
public static final MethodVariableAccess FLOAT
The accessor handler for afloat
.
-
DOUBLE
public static final MethodVariableAccess DOUBLE
The accessor handler for adouble
.
-
REFERENCE
public static final MethodVariableAccess REFERENCE
The accessor handler for a reference type.
-
-
Field Detail
-
loadOpcode
private final int loadOpcode
The opcode for loading this variable type.
-
storeOpcode
private final int storeOpcode
The opcode for storing a local variable type.
-
size
private final StackSize size
The size of the local variable on the JVM stack.
-
-
Constructor Detail
-
MethodVariableAccess
private MethodVariableAccess(int loadOpcode, int storeOpcode, StackSize stackSize)
Creates a new method variable access for a given JVM type.- Parameters:
loadOpcode
- The opcode for loading this variable type.storeOpcode
- The opcode for storing this variable type.stackSize
- The size of the JVM type.
-
-
Method Detail
-
values
public static MethodVariableAccess[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (MethodVariableAccess c : MethodVariableAccess.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static MethodVariableAccess valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
of
public static MethodVariableAccess of(TypeDefinition typeDefinition)
Locates the correct accessor for a variable of a given type.- Parameters:
typeDefinition
- The type of the variable to be loaded.- Returns:
- An accessor for the given type.
-
allArgumentsOf
public static MethodVariableAccess.MethodLoading allArgumentsOf(MethodDescription methodDescription)
Loads all arguments of the provided method onto the operand stack.- Parameters:
methodDescription
- The method for which all parameters are to be loaded onto the operand stack.- Returns:
- A stack manipulation that loads all parameters of the provided method onto the operand stack.
-
loadThis
public static StackManipulation loadThis()
Loads a reference to thethis
reference what is only meaningful for a non-static method.- Returns:
- A stack manipulation loading the
this
reference.
-
loadFrom
public StackManipulation loadFrom(int offset)
Creates a stack assignment for a reading given offset of the local variable array.- Parameters:
offset
- The offset of the variable wheredouble
andlong
types count two slots.- Returns:
- A stack manipulation representing the variable read.
-
storeAt
public StackManipulation storeAt(int offset)
Creates a stack assignment for writing to a given offset of the local variable array.- Parameters:
offset
- The offset of the variable wheredouble
andlong
types count two slots.- Returns:
- A stack manipulation representing the variable write.
-
increment
public StackManipulation increment(int offset, int value)
Creates a stack assignment for incrementing the given offset of the local variable array.- Parameters:
offset
- The offset of the variable wheredouble
andlong
types count two slots.value
- The incremented value.- Returns:
- A stack manipulation representing the variable write.
-
load
public static StackManipulation load(ParameterDescription parameterDescription)
Loads a parameter's value onto the operand stack.- Parameters:
parameterDescription
- The parameter which to load onto the operand stack.- Returns:
- A stack manipulation loading a parameter onto the operand stack.
-
store
public static StackManipulation store(ParameterDescription parameterDescription)
Stores the top operand stack value at the supplied parameter.- Parameters:
parameterDescription
- The parameter which to store a value for.- Returns:
- A stack manipulation storing the top operand stack value at this parameter.
-
increment
public static StackManipulation increment(ParameterDescription parameterDescription, int value)
Increments the value of the supplied parameter.- Parameters:
parameterDescription
- The parameter which to increment.value
- The value to increment with.- Returns:
- A stack manipulation incrementing the supplied parameter.
-
-