Interface Invoker

  • All Known Implementing Classes:
    JavaDispatcher.DirectInvoker

    public interface Invoker
    An invoker is a deliberate indirection to wrap indirect calls. This way, reflective call are never dispatched from Byte Buddy's context but always from a synthetic layer that does not own any privileges. This might not be the case if such security measures are not supported on the current platform, for example on Android. To support the Java module system and other class loader with explicit exports such as OSGi, this interface is placed in an exported package while intended for use with JavaDispatcher.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.Object invoke​(java.lang.reflect.Method method, java.lang.Object instance, java.lang.Object[] argument)
      Invokes a method via Method.invoke(Object, Object...).
      java.lang.Object newInstance​(java.lang.reflect.Constructor<?> constructor, java.lang.Object[] argument)
      Creates a new instance via Constructor.newInstance(Object...).
    • Method Detail

      • newInstance

        java.lang.Object newInstance​(java.lang.reflect.Constructor<?> constructor,
                                     java.lang.Object[] argument)
                              throws java.lang.InstantiationException,
                                     java.lang.IllegalAccessException,
                                     java.lang.reflect.InvocationTargetException
        Creates a new instance via Constructor.newInstance(Object...).
        Parameters:
        constructor - The constructor to invoke.
        argument - The constructor arguments.
        Returns:
        The constructed instance.
        Throws:
        java.lang.InstantiationException - If the instance cannot be constructed.
        java.lang.IllegalAccessException - If the constructor is accessed illegally.
        java.lang.reflect.InvocationTargetException - If the invocation causes an error.
      • invoke

        @MaybeNull
        java.lang.Object invoke​(java.lang.reflect.Method method,
                                @MaybeNull
                                java.lang.Object instance,
                                @MaybeNull
                                java.lang.Object[] argument)
                         throws java.lang.IllegalAccessException,
                                java.lang.reflect.InvocationTargetException
        Invokes a method via Method.invoke(Object, Object...).
        Parameters:
        method - The method to invoke.
        instance - The instance upon which to invoke the method or null if the method is static.
        argument - The method arguments.
        Returns:
        The return value of the method or null if the method is void.
        Throws:
        java.lang.IllegalAccessException - If the method is accessed illegally.
        java.lang.reflect.InvocationTargetException - If the invocation causes an error.