Class MethodConstant
java.lang.Object
net.bytebuddy.implementation.bytecode.StackManipulation.AbstractBase
net.bytebuddy.implementation.bytecode.constant.MethodConstant
- All Implemented Interfaces:
StackManipulation
- Direct Known Subclasses:
MethodConstant.ForConstructor,MethodConstant.ForMethod
Represents the creation of a
Method value which can be created from a given
set of constant pool values and can therefore be considered a constant in the broader meaning.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classRepresents a cached constructor for aMethodConstant.protected static classRepresents a cached method for aMethodConstant.static interfaceRepresents aMethodConstantthat is directly loaded onto the operand stack without caching the value.protected static enumRepresents a method constant that cannot be represented by Java's reflection API.protected static classCreates aMethodConstantfor loading aConstructorinstance onto the operand stack.protected static classCreates aMethodConstantfor loading aMethodinstance onto the operand stack.protected static classPerforms a privileged lookup of a method constant by using anjava.security.AccessController.Nested classes/interfaces inherited from interface net.bytebuddy.implementation.bytecode.StackManipulation
StackManipulation.AbstractBase, StackManipulation.Compound, StackManipulation.Illegal, StackManipulation.Simple, StackManipulation.Size, StackManipulation.Trivial -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final MethodDescription.InDefinedShapeThejava.security.AccessController#doPrivileged(PrivilegedExceptionAction)method ornullif this method is not available on the current VM.protected final MethodDescription.InDefinedShapeA description of the method to be loaded onto the stack. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMethodConstant(MethodDescription.InDefinedShape methodDescription) Creates a new method constant. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract MethodDescription.InDefinedShapeReturns the method for loading a declared method or constructor onto the operand stack.apply(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext) Applies the stack manipulation that is described by this instance.private static MethodDescription.InDefinedShapeResolves thejava.security.AccessController#doPrivilegedmethod if the security manager is supported on the current VM and if security manager support is not explicitly disabled.booleaninthashCode()protected abstract StackManipulationReturns a stack manipulation that loads the method name onto the operand stack if this is required.static MethodConstant.CanCacheof(MethodDescription.InDefinedShape methodDescription) Creates a stack manipulation that loads a method constant onto the operand stack.static MethodConstant.CanCacheofPrivileged(MethodDescription.InDefinedShape methodDescription) Creates a stack manipulation that loads a method constant onto the operand stack using anjava.security.AccessController.protected static List<StackManipulation> typeConstantsFor(List<TypeDescription> parameterTypes) Returns a list of type constant load operations for the given list of parameters.protected MethodConstant.CanCacheReturns a method constant that uses anjava.security.AccessControllerto look up this constant.Methods inherited from class net.bytebuddy.implementation.bytecode.StackManipulation.AbstractBase
isValid
-
Field Details
-
DO_PRIVILEGED
Thejava.security.AccessController#doPrivileged(PrivilegedExceptionAction)method ornullif this method is not available on the current VM. -
methodDescription
A description of the method to be loaded onto the stack.
-
-
Constructor Details
-
MethodConstant
Creates a new method constant.- Parameters:
methodDescription- The method description for which theMethodrepresentation should be created.
-
-
Method Details
-
doPrivileged
Resolves thejava.security.AccessController#doPrivilegedmethod if the security manager is supported on the current VM and if security manager support is not explicitly disabled.- Returns:
- The
doPrivilegedmethod ornull.
-
of
Creates a stack manipulation that loads a method constant onto the operand stack.- Parameters:
methodDescription- The method to be loaded onto the stack.- Returns:
- A stack manipulation that assigns a method constant for the given method description.
-
ofPrivileged
public static MethodConstant.CanCache ofPrivileged(MethodDescription.InDefinedShape methodDescription) Creates a stack manipulation that loads a method constant onto the operand stack using anjava.security.AccessController. If the current VM does not support the access controller API, or ifnet.bytebuddy.securitymanageris set to false, this method has the same effect asof(MethodDescription.InDefinedShape).- Parameters:
methodDescription- The method to be loaded onto the stack.- Returns:
- A stack manipulation that assigns a method constant for the given method description.
-
typeConstantsFor
Returns a list of type constant load operations for the given list of parameters.- Parameters:
parameterTypes- A list of all type descriptions that should be represented as type constant load operations.- Returns:
- A corresponding list of type constant load operations.
-
apply
public StackManipulation.Size apply(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext) Applies the stack manipulation that is described by this instance.- Parameters:
methodVisitor- The method visitor used to write the method implementation to.implementationContext- The context of the current implementation.- Returns:
- The changes to the size of the operand stack that are implied by this stack manipulation.
-
withPrivilegedLookup
Returns a method constant that uses anjava.security.AccessControllerto look up this constant.- Returns:
- A method constant that uses an
java.security.AccessControllerto look up this constant.
-
methodName
Returns a stack manipulation that loads the method name onto the operand stack if this is required.- Returns:
- A stack manipulation that loads the method name onto the operand stack if this is required.
-
accessorMethod
Returns the method for loading a declared method or constructor onto the operand stack.- Returns:
- The method for loading a declared method or constructor onto the operand stack.
-
hashCode
public int hashCode() -
equals
-