Class ClassBuilding

java.lang.Object
com.google.inject.internal.aop.ClassBuilding

public final class ClassBuilding extends Object
Entry-point for building enhanced classes and 'fast-class' invocation.
  • Field Details

    • OVERRIDABLE_OBJECT_METHODS

      private static final Method[] OVERRIDABLE_OBJECT_METHODS
  • Constructor Details

    • ClassBuilding

      private ClassBuilding()
  • Method Details

    • signature

      public static String signature(Constructor<?> constructor)
      Minimum signature needed to disambiguate constructors from the same host class.
    • signature

      public static String signature(Method method)
      Minimum signature needed to disambiguate methods from the same host class.
    • signature

      private static String signature(String name, Class<?>[] parameterTypes)
      Appends a semicolon-separated list of parameter types to the given name.
    • canEnhance

      public static boolean canEnhance(Executable member)
      Returns true if the given member can be enhanced using bytecode.
    • buildEnhancerBuilder

      public static BytecodeGen.EnhancerBuilder buildEnhancerBuilder(Class<?> hostClass)
      Builder of enhancers that provide method interception via bytecode generation.
    • partitionMethod

      private static void partitionMethod(Method method, Map<String,Object> partitions)
      Methods are partitioned by name and parameter count. This helps focus the search for bridge delegates that involve type-erasure of generic parameter types, since the parameter count will be the same for the bridge method and its delegate.
    • mergeMethods

      private static Object mergeMethods(Object existing, Object added)
      Add the new method to an existing partition or create a new one.
    • visitMethodHierarchy

      private static void visitMethodHierarchy(Class<?> hostClass, Consumer<Method> visitor)
      Visit the method hierarchy for the host class.
    • pushInterfaces

      private static void pushInterfaces(Deque<Class<?>[]> interfaceStack, Class<?>[] interfaces)
      Pushes the interface declaration onto the stack if it's not empty.
    • mergeInterface

      private static boolean mergeInterface(List<Class<?>> interfaces, Class<?> candidate)
      Attempts to merge the interface with the current flattened hierarchy.
    • packageName

      private static String packageName(String className)
      Extract the package name from a class name.
    • getOverridableObjectMethods

      private static Method[] getOverridableObjectMethods()
      Cache common overridable Object methods.
    • canFastInvoke

      public static boolean canFastInvoke(Executable member)
      Returns true if the given member can be fast-invoked.
    • isPublic

      private static boolean isPublic(Class<?> clazz)
    • buildFastClass

      public static Function<String,BiFunction<Object,Object[],Object>> buildFastClass(Class<?> hostClass)
      Builds a 'fast-class' invoker that uses bytecode generation in place of reflection.
    • visitFastConstructors

      private static void visitFastConstructors(Class<?> hostClass, Consumer<Constructor<?>> visitor)
      Visit all constructors for the host class that can be fast-invoked.
    • visitFastMethods

      private static void visitFastMethods(Class<?> hostClass, Consumer<Method> visitor)
      Visit all methods declared by the host class that can be fast-invoked.
    • visitMembers

      static <T extends Executable> void visitMembers(T[] members, boolean samePackage, Consumer<T> visitor)
      Visit all subclass accessible members in the given array.
    • canAccess

      private static boolean canAccess(Executable member, boolean samePackage)
      Can we access this member from a subclass which may be in the same package?