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>
@Enhance private static class JavaDispatcher.DirectInvoker extends java.lang.Object implements Invoker
AnInvoker
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 Modifier Constructor Description private
DirectInvoker()
-
Method Summary
All Methods Instance Methods Concrete 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 viaMethod.invoke(Object, Object...)
.java.lang.Object
newInstance(java.lang.reflect.Constructor<?> constructor, java.lang.Object[] argument)
Creates a new instance viaConstructor.newInstance(Object...)
.
-
-
-
Method Detail
-
newInstance
public 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 viaConstructor.newInstance(Object...)
.- Specified by:
newInstance
in interfaceInvoker
- 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
public java.lang.Object invoke(java.lang.reflect.Method method, java.lang.Object instance, java.lang.Object[] argument) throws java.lang.IllegalAccessException, java.lang.reflect.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:
java.lang.IllegalAccessException
- If the method is accessed illegally.java.lang.reflect.InvocationTargetException
- If the invocation causes an error.
-
-