Class InvokeDynamic.AbstractDelegator

    • Constructor Detail

      • AbstractDelegator

        protected AbstractDelegator​(MethodDescription.InDefinedShape bootstrap,
                                    java.util.List<?> arguments,
                                    InvokeDynamic.InvocationProvider invocationProvider,
                                    InvokeDynamic.TerminationHandler terminationHandler,
                                    Assigner assigner,
                                    Assigner.Typing typing)
        Creates a new abstract delegator for a dynamic method invocation.
        Parameters:
        bootstrap - The bootstrap method or constructor.
        arguments - The arguments that are provided to the bootstrap method or constructor.
        invocationProvider - The target provided that identifies the method to be bootstrapped.
        terminationHandler - A handler that handles the method return.
        assigner - The assigner to be used.
        typing - Indicates if dynamic type castings should be attempted for incompatible assignments.
    • Method Detail

      • materialize

        protected abstract InvokeDynamic materialize()
        Resolves the current configuration into a fully initialized invoke dynamic instance.
        Returns:
        The fully resolved invoke dynamic instance.
      • withBooleanValue

        public InvokeDynamic withBooleanValue​(boolean... value)
        Requires the bootstrap method to bootstrap a method that takes the specified boolean arguments as its next parameters.
        Overrides:
        withBooleanValue in class InvokeDynamic
        Parameters:
        value - The arguments to pass to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withByteValue

        public InvokeDynamic withByteValue​(byte... value)
        Requires the bootstrap method to bootstrap a method that takes the specified byte arguments as its next parameters.
        Overrides:
        withByteValue in class InvokeDynamic
        Parameters:
        value - The arguments to pass to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withShortValue

        public InvokeDynamic withShortValue​(short... value)
        Requires the bootstrap method to bootstrap a method that takes the specified short arguments as its next parameters.
        Overrides:
        withShortValue in class InvokeDynamic
        Parameters:
        value - The arguments to pass to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withCharacterValue

        public InvokeDynamic withCharacterValue​(char... value)
        Requires the bootstrap method to bootstrap a method that takes the specified char arguments as its next parameters.
        Overrides:
        withCharacterValue in class InvokeDynamic
        Parameters:
        value - The arguments to pass to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withIntegerValue

        public InvokeDynamic withIntegerValue​(int... value)
        Requires the bootstrap method to bootstrap a method that takes the specified int arguments as its next parameters.
        Overrides:
        withIntegerValue in class InvokeDynamic
        Parameters:
        value - The arguments to pass to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withLongValue

        public InvokeDynamic withLongValue​(long... value)
        Requires the bootstrap method to bootstrap a method that takes the specified long arguments as its next parameters.
        Overrides:
        withLongValue in class InvokeDynamic
        Parameters:
        value - The arguments to pass to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withFloatValue

        public InvokeDynamic withFloatValue​(float... value)
        Requires the bootstrap method to bootstrap a method that takes the specified float arguments as its next parameters.
        Overrides:
        withFloatValue in class InvokeDynamic
        Parameters:
        value - The arguments to pass to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withDoubleValue

        public InvokeDynamic withDoubleValue​(double... value)
        Requires the bootstrap method to bootstrap a method that takes the specified double arguments as its next parameters.
        Overrides:
        withDoubleValue in class InvokeDynamic
        Parameters:
        value - The arguments to pass to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withValue

        public InvokeDynamic withValue​(java.lang.Object... value)

        Requires the bootstrap method to bootstrap a method that takes the specified arguments as its next parameters. Note that any primitive parameters are passed as their wrapper types. Furthermore, values that can be stored in the instrumented class's constant pool might be of different object identity when passed to the bootstrapped method or might not be visible to the the created class what later results in a runtime error.

        Overrides:
        withValue in class InvokeDynamic
        Parameters:
        value - The arguments to pass to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withReference

        public InvokeDynamic.WithImplicitType withReference​(java.lang.Object value)

        Requires the bootstrap method to bootstrap a method that takes the specified argument as its next parameter while allowing to specify the value to be of a different type than the actual instance type.

        Overrides:
        withReference in class InvokeDynamic
        Parameters:
        value - The arguments to pass to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withReference

        public InvokeDynamic withReference​(java.lang.Object... value)
        Requires the bootstrap method to bootstrap a method that takes the specified arguments as its next parameters. Note that any primitive parameters are passed as their wrapper types. Any value that is passed to the bootstrapped method is guaranteed to be of the same object identity.
        Overrides:
        withReference in class InvokeDynamic
        Parameters:
        value - The arguments to pass to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withType

        public InvokeDynamic withType​(TypeDescription... typeDescription)
        Hands the provided types to the dynamically bound method. The type is stored in the generated class's constant pool and is loaded at invocation time. For this to be possible, the created class's class loader must be able to see the provided type.
        Overrides:
        withType in class InvokeDynamic
        Parameters:
        typeDescription - The classes to provide to the bound method as an argument.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified type.
      • withInstance

        public InvokeDynamic withInstance​(JavaConstant... javaConstant)
        Hands the provided Java instance to the dynamically bound method. The instance is stored in the generated class's constant pool and is loaded at invocation time. For this to be possible, the created class's class loader must be able to create the provided Java instance.
        Overrides:
        withInstance in class InvokeDynamic
        Parameters:
        javaConstant - The Java instance to provide to the bound method as an argument.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified Java instance.
      • withNullValue

        public InvokeDynamic withNullValue​(java.lang.Class<?>... type)
        Passes null values of the given types to the bootstrapped method.
        Overrides:
        withNullValue in class InvokeDynamic
        Parameters:
        type - The type that the null values should represent.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withNullValue

        public InvokeDynamic withNullValue​(TypeDescription... typeDescription)
        Passes null values of the given types to the bootstrapped method.
        Overrides:
        withNullValue in class InvokeDynamic
        Parameters:
        typeDescription - The type that the null values should represent.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withArgument

        public InvokeDynamic withArgument​(int... index)
        Passes parameters of the instrumented method to the bootstrapped method.
        Overrides:
        withArgument in class InvokeDynamic
        Parameters:
        index - The indices of the parameters that should be passed to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withArgument

        public InvokeDynamic.WithImplicitType withArgument​(int index)
        Passes a parameter of the instrumented method to the bootstrapped method.
        Overrides:
        withArgument in class InvokeDynamic
        Parameters:
        index - The index of the parameter that should be passed to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified argument with its implicit type.
      • withThis

        public InvokeDynamic withThis​(java.lang.Class<?>... type)
        Passes references to this onto the operand stack where the instance is represented as the given types.
        Overrides:
        withThis in class InvokeDynamic
        Parameters:
        type - The types as which the this reference of the intercepted method should be masked.
        Returns:
        This implementation where this references are passed as the next arguments.
      • withThis

        public InvokeDynamic withThis​(TypeDescription... typeDescription)
        Passes references to this onto the operand stack where the instance is represented as the given types.
        Overrides:
        withThis in class InvokeDynamic
        Parameters:
        typeDescription - The types as which the this reference of the intercepted method should be masked.
        Returns:
        This implementation where this references are passed as the next arguments.
      • withMethodArguments

        public InvokeDynamic withMethodArguments()
        Adds all method arguments to the the bootstrapped method.
        Overrides:
        withMethodArguments in class InvokeDynamic
        Returns:
        This invoke dynamic implementation with all parameters of the instrumented method added.
      • withImplicitAndMethodArguments

        public InvokeDynamic withImplicitAndMethodArguments()
        Adds a potential this reference and all method arguments to the the bootstrapped method.
        Overrides:
        withImplicitAndMethodArguments in class InvokeDynamic
        Returns:
        This invoke dynamic implementation with a potential this reference and all parameters of the instrumented method added.
      • withField

        public InvokeDynamic withField​(java.lang.String... fieldName)
        Passes the values of the specified fields to the bootstrap method. Any of the specified fields must already exist for the instrumented type.
        Overrides:
        withField in class InvokeDynamic
        Parameters:
        fieldName - The names of the fields to be passed to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withEnumeration

        public InvokeDynamic withEnumeration​(EnumerationDescription... enumerationDescription)
        Hands the provided enumerations to the dynamically bound method. The enumeration values are read from the enumeration class on demand. For this to be possible, the created class's class loader must be able to see the enumeration type.
        Overrides:
        withEnumeration in class InvokeDynamic
        Parameters:
        enumerationDescription - The enumeration values to provide to the bound method as an argument.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified enumerations.
      • withField

        public InvokeDynamic withField​(FieldLocator.Factory fieldLocatorFactory,
                                       java.lang.String... name)
        Passes the values of the specified fields to the bootstrap method. Any of the specified fields must already exist for the instrumented type.
        Overrides:
        withField in class InvokeDynamic
        Parameters:
        fieldLocatorFactory - The field locator factory to use.
        name - The names of the fields to be passed to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withField

        public InvokeDynamic.WithImplicitType withField​(java.lang.String name)
        Passes the values of the specified fields to the bootstrap method. Any of the specified fields must already exist for the instrumented type.
        Overrides:
        withField in class InvokeDynamic
        Parameters:
        name - The names of the fields to be passed to the bootstrapped method.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withField

        public InvokeDynamic.WithImplicitType withField​(java.lang.String name,
                                                        FieldLocator.Factory fieldLocatorFactory)
        Passes the values of the specified fields to the bootstrap method. Any of the specified fields must already exist for the instrumented type.
        Overrides:
        withField in class InvokeDynamic
        Parameters:
        name - The names of the fields to be passed to the bootstrapped method.
        fieldLocatorFactory - The field locator factory to use.
        Returns:
        This invoke dynamic implementation where the bootstrapped method is passed the specified arguments.
      • withAssigner

        public Implementation.Composable withAssigner​(Assigner assigner,
                                                      Assigner.Typing typing)
        Instructs this implementation to use the provided assigner and decides if the assigner should apply dynamic typing.
        Overrides:
        withAssigner in class InvokeDynamic
        Parameters:
        assigner - The assigner to use.
        typing - true if the assigner should attempt dynamic typing.
        Returns:
        The invoke dynamic instruction where the given assigner and dynamic-typing directive are applied.