Package net.bytebuddy.utility
Interface Invoker
-
- All Known Implementing Classes:
JavaDispatcher.DirectInvoker
public interface InvokerAn 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 withJavaDispatcher.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Objectinvoke(java.lang.reflect.Method method, java.lang.Object instance, java.lang.Object[] argument)Invokes a method viaMethod.invoke(Object, Object...).java.lang.ObjectnewInstance(java.lang.reflect.Constructor<?> constructor, java.lang.Object[] argument)Creates a new instance viaConstructor.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.InvocationTargetExceptionCreates a new instance viaConstructor.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 viaMethod.invoke(Object, Object...).- Parameters:
method- The method to invoke.instance- The instance upon which to invoke the method ornullif the method is static.argument- The method arguments.- Returns:
- The return value of the method or
nullif the method isvoid. - Throws:
java.lang.IllegalAccessException- If the method is accessed illegally.java.lang.reflect.InvocationTargetException- If the invocation causes an error.
-
-