Class 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 Details

    • FAST_CLASS_API

      private static final String[] FAST_CLASS_API
    • INVOKERS_NAME

      private static final String INVOKERS_NAME
      See Also:
    • INVOKERS_DESCRIPTOR

      private static final String INVOKERS_DESCRIPTOR
      See Also:
    • INDEX_TO_INVOKER_METHOD_TYPE

      private static final org.objectweb.asm.Type INDEX_TO_INVOKER_METHOD_TYPE
    • RAW_INVOKER_DESCRIPTOR

      private static final String RAW_INVOKER_DESCRIPTOR
      See Also:
    • OBJECT_ARRAY_TYPE

      private static final String OBJECT_ARRAY_TYPE
    • hostIsInterface

      private final boolean hostIsInterface
  • Constructor Details

    • FastClass

      FastClass(Class<?> hostClass)
  • Method Details