Package net.bytebuddy.utility
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
Modifier and TypeMethodDescriptionInvokes a method viaMethod.invoke(Object, Object...)
.newInstance
(Constructor<?> constructor, Object[] argument) Creates a new instance viaConstructor.newInstance(Object...)
.
-
Method Details
-
newInstance
Object newInstance(Constructor<?> constructor, Object[] argument) throws InstantiationException, IllegalAccessException, InvocationTargetException Creates a new instance viaConstructor.newInstance(Object...)
.- 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
@MaybeNull Object invoke(Method method, @MaybeNull Object instance, @MaybeNull Object[] argument) throws IllegalAccessException, InvocationTargetException Invokes a method viaMethod.invoke(Object, Object...)
.- 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.
-