Top Description Fields Constructors Methods
com.google.inject.internal.aop

pack-priv final Class FastClass

extends AbstractGlueGenerator
Class Inheritance
Static Imports
com.google.inject.internal.BytecodeGen.FASTCLASS_BY_GUICE_MARKER, com.google.inject.internal.aop.BytecodeTasks.box, .BytecodeTasks.unpackArguments, java.lang.reflect.Modifier.FINAL, .Modifier.PRIVATE, .Modifier.PUBLIC, .Modifier.STATIC, org.objectweb.asm.ClassWriter.COMPUTE_MAXS, .Opcodes.ACC_SUPER, .Opcodes.ACONST_NULL, .Opcodes.ALOAD, .Opcodes.ARETURN, .Opcodes.CHECKCAST, .Opcodes.DUP, .Opcodes.GETFIELD, .Opcodes.H_NEWINVOKESPECIAL, .Opcodes.ILOAD, .Opcodes.INVOKEINTERFACE, .Opcodes.INVOKESPECIAL, .Opcodes.INVOKESTATIC, .Opcodes.INVOKEVIRTUAL, .Opcodes.NEW, .Opcodes.PUTFIELD, .Opcodes.PUTSTATIC, .Opcodes.RETURN, .Opcodes.V1_8

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;
  }
}
Author
[email protected] (Stuart McCulloch)

Field Summary

Modifier and TypeField 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
Inherited from com.google.inject.internal.aop.AbstractGlueGenerator:
GENERATED_SOURCEhostClasshostNameproxyNameTRAMPOLINE_DESCRIPTORTRAMPOLINE_NAME

Constructor Summary

AccessConstructor and Description
pack-priv
FastClass(Class<?> hostClass)

Method Summary

Modifier and TypeMethod and Description
protected void
generateConstructorInvoker(MethodVisitor mv, Constructor<?> constructor)

Implements abstract com.google.inject.internal.aop.AbstractGlueGenerator.generateConstructorInvoker.

Generate invoker that takes a context and an argument array and calls the constructor.
protected byte[]
generateGlue(Collection<Executable> members)

Implements abstract com.google.inject.internal.aop.AbstractGlueGenerator.generateGlue.

Generates enhancer/fast-class bytecode for the given constructors/methods.
protected void
generateMethodInvoker(MethodVisitor mv, Method method)

Implements abstract com.google.inject.internal.aop.AbstractGlueGenerator.generateMethodInvoker.

Generate invoker that takes an instance and an argument array and calls the method.
protected MethodHandle
lookupInvokerTable(Class<?> glueClass)

Implements abstract com.google.inject.internal.aop.AbstractGlueGenerator.lookupInvokerTable.

Lookup the invoker table; this may be represented by a function or a trampoline.
private void
setupInvokerTable(ClassWriter cw)

Generate static initializer to setup invoker table based on the fast-class constructor.

Inherited from com.google.inject.internal.aop.AbstractGlueGenerator:
generateTrampolineglue

Field Detail

FAST_CLASS_APIback to summary
private static final String[] FAST_CLASS_API
hostIsInterfaceback to summary
private final boolean hostIsInterface
INDEX_TO_INVOKER_METHOD_TYPEback to summary
private static final Type INDEX_TO_INVOKER_METHOD_TYPE
INVOKERS_DESCRIPTORback to summary
private static final String INVOKERS_DESCRIPTOR
INVOKERS_NAMEback to summary
private static final String INVOKERS_NAME
OBJECT_ARRAY_TYPEback to summary
private static final String OBJECT_ARRAY_TYPE
RAW_INVOKER_DESCRIPTORback to summary
private static final String RAW_INVOKER_DESCRIPTOR

Constructor Detail

FastClassback to summary
pack-priv FastClass(Class<?> hostClass)

Method Detail

generateConstructorInvokerback to summary
protected void generateConstructorInvoker(MethodVisitor mv, Constructor<?> constructor)

Implements abstract com.google.inject.internal.aop.AbstractGlueGenerator.generateConstructorInvoker.

Doc from com.google.inject.internal.aop.AbstractGlueGenerator.generateConstructorInvoker.

Generate invoker that takes a context and an argument array and calls the constructor.

Annotations
@Override
generateGlueback to summary
protected byte[] generateGlue(Collection<Executable> members)

Implements abstract com.google.inject.internal.aop.AbstractGlueGenerator.generateGlue.

Doc from com.google.inject.internal.aop.AbstractGlueGenerator.generateGlue.

Generates enhancer/fast-class bytecode for the given constructors/methods.

Annotations
@Override
generateMethodInvokerback to summary
protected void generateMethodInvoker(MethodVisitor mv, Method method)

Implements abstract com.google.inject.internal.aop.AbstractGlueGenerator.generateMethodInvoker.

Doc from com.google.inject.internal.aop.AbstractGlueGenerator.generateMethodInvoker.

Generate invoker that takes an instance and an argument array and calls the method.

Annotations
@Override
lookupInvokerTableback to summary
protected MethodHandle lookupInvokerTable(Class<?> glueClass) throws Throwable

Implements abstract com.google.inject.internal.aop.AbstractGlueGenerator.lookupInvokerTable.

Doc from com.google.inject.internal.aop.AbstractGlueGenerator.lookupInvokerTable.

Lookup the invoker table; this may be represented by a function or a trampoline.

Annotations
@Override
setupInvokerTableback to summary
private void setupInvokerTable(ClassWriter cw)

Generate static initializer to setup invoker table based on the fast-class constructor.