Package com.google.inject.internal.aop
Class FastClass
- java.lang.Object
-
- com.google.inject.internal.aop.AbstractGlueGenerator
-
- com.google.inject.internal.aop.FastClass
-
final class FastClass extends AbstractGlueGenerator
Generates fast-classes.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; } }
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String[]FAST_CLASS_APIprivate booleanhostIsInterfaceprivate static org.objectweb.asm.TypeINDEX_TO_INVOKER_METHOD_TYPEprivate static java.lang.StringINVOKERS_DESCRIPTORprivate static java.lang.StringINVOKERS_NAMEprivate static java.lang.StringOBJECT_ARRAY_TYPEprivate static java.lang.StringRAW_INVOKER_DESCRIPTOR-
Fields inherited from class com.google.inject.internal.aop.AbstractGlueGenerator
GENERATED_SOURCE, hostClass, hostName, proxyName, TRAMPOLINE_DESCRIPTOR, TRAMPOLINE_NAME
-
-
Constructor Summary
Constructors Constructor Description FastClass(java.lang.Class<?> hostClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidgenerateConstructorInvoker(org.objectweb.asm.MethodVisitor mv, java.lang.reflect.Constructor<?> constructor)Generate invoker that takes a context and an argument array and calls the constructor.protected byte[]generateGlue(java.util.Collection<java.lang.reflect.Executable> members)Generates enhancer/fast-class bytecode for the given constructors/methods.protected voidgenerateMethodInvoker(org.objectweb.asm.MethodVisitor mv, java.lang.reflect.Method method)Generate invoker that takes an instance and an argument array and calls the method.protected java.lang.invoke.MethodHandlelookupInvokerTable(java.lang.Class<?> glueClass)Lookup the invoker table; this may be represented by a function or a trampoline.private voidsetupInvokerTable(org.objectweb.asm.ClassWriter cw)Generate static initializer to setup invoker table based on the fast-class constructor.-
Methods inherited from class com.google.inject.internal.aop.AbstractGlueGenerator
generateTrampoline, glue
-
-
-
-
Field Detail
-
FAST_CLASS_API
private static final java.lang.String[] FAST_CLASS_API
-
INVOKERS_NAME
private static final java.lang.String INVOKERS_NAME
- See Also:
- Constant Field Values
-
INVOKERS_DESCRIPTOR
private static final java.lang.String INVOKERS_DESCRIPTOR
- See Also:
- Constant Field Values
-
INDEX_TO_INVOKER_METHOD_TYPE
private static final org.objectweb.asm.Type INDEX_TO_INVOKER_METHOD_TYPE
-
RAW_INVOKER_DESCRIPTOR
private static final java.lang.String RAW_INVOKER_DESCRIPTOR
- See Also:
- Constant Field Values
-
OBJECT_ARRAY_TYPE
private static final java.lang.String OBJECT_ARRAY_TYPE
-
hostIsInterface
private final boolean hostIsInterface
-
-
Method Detail
-
generateGlue
protected byte[] generateGlue(java.util.Collection<java.lang.reflect.Executable> members)
Description copied from class:AbstractGlueGeneratorGenerates enhancer/fast-class bytecode for the given constructors/methods.- Specified by:
generateGluein classAbstractGlueGenerator
-
setupInvokerTable
private void setupInvokerTable(org.objectweb.asm.ClassWriter cw)
Generate static initializer to setup invoker table based on the fast-class constructor.
-
generateConstructorInvoker
protected void generateConstructorInvoker(org.objectweb.asm.MethodVisitor mv, java.lang.reflect.Constructor<?> constructor)Description copied from class:AbstractGlueGeneratorGenerate invoker that takes a context and an argument array and calls the constructor.- Specified by:
generateConstructorInvokerin classAbstractGlueGenerator
-
generateMethodInvoker
protected void generateMethodInvoker(org.objectweb.asm.MethodVisitor mv, java.lang.reflect.Method method)Description copied from class:AbstractGlueGeneratorGenerate invoker that takes an instance and an argument array and calls the method.- Specified by:
generateMethodInvokerin classAbstractGlueGenerator
-
lookupInvokerTable
protected java.lang.invoke.MethodHandle lookupInvokerTable(java.lang.Class<?> glueClass) throws java.lang.ThrowableDescription copied from class:AbstractGlueGeneratorLookup the invoker table; this may be represented by a function or a trampoline.- Specified by:
lookupInvokerTablein classAbstractGlueGenerator- Throws:
java.lang.Throwable
-
-