Each fast-class has a single constructor that takes an index. It also has an instance method that takes a context object and an array of argument objects which it combines with the index to call the shared static trampoline. Each fast-class instance therefore acts like a bound invoker to the appropriate constructor or method of the host class.
A handle to the fast-class constructor is used as the invoker table, mapping index to invoker.
Fast-classes have the following pseudo-Java structure:
public final class HostClass$$FastClassByGuice
implements BiFunction // each fast-class instance represents a bound invoker
{
private final int index; // the bound trampoline index
public HostClass$$FastClassByGuice(int index) {
this.index = index;
}
public Object apply(Object context, Object args) {
return GUICE$TRAMPOLINE(index, context, (Object[]) args);
}
public static Object GUICE$TRAMPOLINE(int index, Object context, Object[] args) {
switch (index) {
case 0: {
return new HostClass(...);
}
case 1: {
return ((HostClass) context).instanceMethod(...);
}
case 2: {
return HostClass.staticMethod(...);
}
}
return null;
}
}
| Modifier and Type | Field and Description |
|---|---|
| private static final String[] | |
| private final boolean | |
| private static final Type | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String |
| Modifier and Type | Method and Description |
|---|---|
| protected void | generateConstructorInvoker(MethodVisitor mv, Constructor<?> constructor)
Implements abstract com. |
| protected byte[] | generateGlue(Collection<Executable> members)
Implements abstract com. |
| protected void | generateMethodInvoker(MethodVisitor mv, Method method)
Implements abstract com. |
| protected MethodHandle | lookupInvokerTable(Class<?> glueClass)
Implements abstract com. |
| private void | setupInvokerTable(ClassWriter cw)
Generate static initializer to setup invoker table based on the fast-class constructor. |
| FAST_CLASS_API | back to summary |
|---|---|
| private static final String[] FAST_CLASS_API | |
| hostIsInterface | back to summary |
|---|---|
| private final boolean hostIsInterface | |
| INDEX_TO_INVOKER_METHOD_TYPE | back to summary |
|---|---|
| private static final Type INDEX_TO_INVOKER_METHOD_TYPE | |
| INVOKERS_DESCRIPTOR | back to summary |
|---|---|
| private static final String INVOKERS_DESCRIPTOR | |
| INVOKERS_NAME | back to summary |
|---|---|
| private static final String INVOKERS_NAME | |
| OBJECT_ARRAY_TYPE | back to summary |
|---|---|
| private static final String OBJECT_ARRAY_TYPE | |
| RAW_INVOKER_DESCRIPTOR | back to summary |
|---|---|
| private static final String RAW_INVOKER_DESCRIPTOR | |
| FastClass | back to summary |
|---|---|
| pack-priv FastClass(Class<?> hostClass) | |
| generateConstructorInvoker | back to summary |
|---|---|
| protected void generateConstructorInvoker(MethodVisitor mv, Constructor<?> constructor) Implements abstract com. Doc from com. Generate invoker that takes a context and an argument array and calls the constructor.
| |
| generateGlue | back to summary |
|---|---|
| protected byte[] generateGlue(Collection<Executable> members) Implements abstract com. Doc from com. Generates enhancer/fast-class bytecode for the given constructors/methods.
| |
| generateMethodInvoker | back to summary |
|---|---|
| protected void generateMethodInvoker(MethodVisitor mv, Method method) Implements abstract com. Doc from com. Generate invoker that takes an instance and an argument array and calls the method.
| |
| lookupInvokerTable | back to summary |
|---|---|
| protected MethodHandle lookupInvokerTable(Class<?> glueClass) throws Throwable Implements abstract com. Doc from com. Lookup the invoker table; this may be represented by a function or a trampoline.
| |
| setupInvokerTable | back to summary |
|---|---|
| private void setupInvokerTable(ClassWriter cw) Generate static initializer to setup invoker table based on the fast-class constructor. | |