A dispatcher for creating a proxy that invokes methods of a type that is possibly unknown on the current VM. Dispatchers do not use any of Byte Buddy's regular infrastructure, to avoid bootstrapping issues as these dispatchers are used by Byte Buddy itself.
By default, this dispatcher uses the Java Proxy
for creating dispatchers. By setting net.bytebuddy.generate
to
true
, Byte Buddy can generate proxies manually as byte code to mostly avoid reflection and boxing of arguments as arrays.
If a security manager is active, the net.bytebuddy.createJavaDispatcher runtime permission is required. Any dispatching
will be executed from a separate class loader and an unnamed module but with the java.
of
the JavaDispatcher
class. It is not permitted to invoke methods of the java.security.AccessController
class or
to resolve a java.lang.invoke.MethodHandle$Lookup
.
Modifier and Type | Class and Description |
---|---|
public static @interface | JavaDispatcher.Container
Indicates that the method is supposed to return an array of the proxied type. |
public static @interface | JavaDispatcher.Defaults
Indicates that a method is supposed to return a default value if a method or type could not be resolved. |
private static class | JavaDispatcher.DirectInvoker
An |
protected static interface | JavaDispatcher.Dispatcher
A dispatcher for handling a proxied method. |
protected static class | JavaDispatcher.DynamicClassLoader
A class loader for loading synthetic classes for implementing a |
public static @interface | JavaDispatcher.Instance
Indicates that a method is supposed to perform an instance check. |
private static class | JavaDispatcher.InvokerCreationAction
A privileged action for creating an |
public static @interface | JavaDispatcher.IsConstructor
Indicates that a proxied method is a constructor. |
public static @interface | JavaDispatcher.IsStatic
Indicates that a proxied method is static. |
public static @interface | JavaDispatcher.Proxied
Indicates a proxied type's name. |
protected static class | JavaDispatcher.ProxiedInvocationHandler
An invocation handler that invokes given dispatchers. |
Modifier and Type | Field and Description |
---|---|
private final ClassLoader | classLoader
The class loader to resolve the proxied type from or |
private static final boolean | |
private final boolean | generate
|
public static final String | GENERATE_PROPERTY
A property to determine, that if |
private static final Invoker | INVOKER
Contains an invoker that makes sure that reflective dispatchers make invocations from an isolated |
private final Class | proxy
The proxy type. |
private static final JavaDispatcher. | RESOLVER
A resolver to assure that a type's package and module are exported to the created class loader. |
Access | Constructor and Description |
---|---|
protected | JavaDispatcher(Class<T>
The proxy type. proxy, ClassLoader The class loader to resolve the proxied type from or classLoader, boolean null if the bootstrap loader should be used.true if a proxy class should be manually generated.Creates a new dispatcher. |
Modifier and Type | Method and Description |
---|---|
private static < The type of the action's resolved value. T> T | Returns: The action's resolved value.The action to execute from a privileged context. action)A proxy for |
public static < The resolved type. T> PrivilegedAction | |
protected static < The resolved type. T> PrivilegedAction | Returns: An action for creating an appropriate dispatcher.The type for which a dispatcher should be resolved. type, ClassLoader The class loader to resolve the proxied type from. classLoader)Resolves an action for creating a dispatcher for the provided type. |
protected static < The resolved type. T> PrivilegedAction | Returns: An action for creating an appropriate dispatcher.The type for which a dispatcher should be resolved. type, ClassLoader The class loader to resolve the proxied type from. classLoader, boolean true if a proxy class should be manually generated.Resolves an action for creating a dispatcher for the provided type. |
public T |