Class MethodConstant

    • Field Detail

      • DO_PRIVILEGED

        protected static final MethodDescription.InDefinedShape DO_PRIVILEGED
        The java.security.AccessController#doPrivileged(PrivilegedExceptionAction) method or null if this method is not available on the current VM.
    • Constructor Detail

      • MethodConstant

        protected MethodConstant​(MethodDescription.InDefinedShape methodDescription)
        Creates a new method constant.
        Parameters:
        methodDescription - The method description for which the Method representation should be created.
    • Method Detail

      • doPrivileged

        private static MethodDescription.InDefinedShape doPrivileged()
        Resolves the java.security.AccessController#doPrivileged method if the security manager is supported on the current VM and if security manager support is not explicitly disabled.
        Returns:
        The doPrivileged method or null.
      • of

        public static MethodConstant.CanCache of​(MethodDescription.InDefinedShape methodDescription)
        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 an java.security.AccessController. If the current VM does not support the access controller API, or if net.bytebuddy.securitymanager is set to false, this method has the same effect as of(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

        protected static java.util.List<StackManipulation> typeConstantsFor​(java.util.List<TypeDescription> parameterTypes)
        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.
      • isValid

        public boolean isValid()
        Determines if this stack manipulation is valid.
        Specified by:
        isValid in interface StackManipulation
        Returns:
        If false, this manipulation cannot be applied and should throw an exception.
      • apply

        public StackManipulation.Size apply​(org.objectweb.asm.MethodVisitor methodVisitor,
                                            Implementation.Context implementationContext)
        Applies the stack manipulation that is described by this instance.
        Specified by:
        apply in interface StackManipulation
        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

        protected MethodConstant.CanCache withPrivilegedLookup()
        Returns a method constant that uses an java.security.AccessController to look up this constant.
        Returns:
        A method constant that uses an java.security.AccessController to look up this constant.
      • methodName

        protected abstract StackManipulation 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

        protected abstract MethodDescription.InDefinedShape 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()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object