Package net.bytebuddy.utility.dispatcher
Class JavaDispatcher.DirectInvoker
java.lang.Object
net.bytebuddy.utility.dispatcher.JavaDispatcher.DirectInvoker
- All Implemented Interfaces:
Invoker
- Enclosing class:
JavaDispatcher<T>
An
Invoker
that uses Byte Buddy's invocation context to use if dynamic class loading is not supported, for example on Android,
and that do not use secured contexts, where this security measure is obsolete to begin with.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionInvokes a method viaMethod.invoke(Object, Object...)
.newInstance
(Constructor<?> constructor, Object[] argument) Creates a new instance viaConstructor.newInstance(Object...)
.
-
Constructor Details
-
DirectInvoker
private DirectInvoker()
-
-
Method Details
-
newInstance
public Object newInstance(Constructor<?> constructor, Object[] argument) throws InstantiationException, IllegalAccessException, InvocationTargetException Creates a new instance viaConstructor.newInstance(Object...)
.- Specified by:
newInstance
in interfaceInvoker
- Parameters:
constructor
- The constructor to invoke.argument
- The constructor arguments.- Returns:
- The constructed instance.
- Throws:
InstantiationException
- If the instance cannot be constructed.IllegalAccessException
- If the constructor is accessed illegally.InvocationTargetException
- If the invocation causes an error.
-
invoke
public Object invoke(Method method, @MaybeNull Object instance, @MaybeNull Object[] argument) throws IllegalAccessException, InvocationTargetException Invokes a method viaMethod.invoke(Object, Object...)
.- Specified by:
invoke
in interfaceInvoker
- Parameters:
method
- The method to invoke.instance
- The instance upon which to invoke the method ornull
if the method is static.argument
- The method arguments.- Returns:
- The return value of the method or
null
if the method isvoid
. - Throws:
IllegalAccessException
- If the method is accessed illegally.InvocationTargetException
- If the invocation causes an error.
-