T
- The resolved type.@HashCodeAndEqualsPlugin.Enhance public class JavaDispatcher<T> extends Object implements PrivilegedAction<T>
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.
Modifier and Type | Class and Description |
---|---|
static interface |
JavaDispatcher.Container
Indicates that the method is supposed to return an array of the proxied type.
|
static interface |
JavaDispatcher.Defaults
Indicates that a method is supposed to return a default value if a method or type could not be resolved.
|
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
JavaDispatcher . |
static interface |
JavaDispatcher.Instance
Indicates that a method is supposed to perform an instance check.
|
static interface |
JavaDispatcher.IsConstructor
Indicates that a proxied method is a constructor.
|
static interface |
JavaDispatcher.IsStatic
Indicates that a proxied method is static.
|
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 |
---|---|
static String |
GENERATE_PROPERTY
A property to determine, that if
true , dispatcher classes will be generated natively and not by using a Proxy . |
Modifier | Constructor and Description |
---|---|
protected |
JavaDispatcher(Class<T> proxy,
ClassLoader classLoader,
boolean generate)
Creates a new dispatcher.
|
Modifier and Type | Method and Description |
---|---|
static <T> PrivilegedAction<T> |
of(Class<T> type)
Resolves an action for creating a dispatcher for the provided type where the proxied type is resolved from the bootstrap loader.
|
protected static <T> PrivilegedAction<T> |
of(Class<T> type,
ClassLoader classLoader)
Resolves an action for creating a dispatcher for the provided type.
|
protected static <T> PrivilegedAction<T> |
of(Class<T> type,
ClassLoader classLoader,
boolean generate)
Resolves an action for creating a dispatcher for the provided type.
|
T |
run() |
public static final String GENERATE_PROPERTY
true
, dispatcher classes will be generated natively and not by using a Proxy
.protected JavaDispatcher(Class<T> proxy, ClassLoader classLoader, boolean generate)
proxy
- The proxy type.classLoader
- The class loader to resolve the proxied type from or null
if the bootstrap loader should be used.generate
- true
if a proxy class should be manually generated.public static <T> PrivilegedAction<T> of(Class<T> type)
T
- The resolved type.type
- The type for which a dispatcher should be resolved.protected static <T> PrivilegedAction<T> of(Class<T> type, ClassLoader classLoader)
T
- The resolved type.type
- The type for which a dispatcher should be resolved.classLoader
- The class loader to resolve the proxied type from.protected static <T> PrivilegedAction<T> of(Class<T> type, ClassLoader classLoader, boolean generate)
T
- The resolved type.type
- The type for which a dispatcher should be resolved.classLoader
- The class loader to resolve the proxied type from.generate
- true
if a proxy class should be manually generated.public T run()
run
in interface PrivilegedAction<T>
Copyright © 2014–2021. All rights reserved.