Class MethodPartition


  • final class MethodPartition
    extends java.lang.Object
    Accumulates methods with the same name and number of parameters. 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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<java.lang.reflect.Method> candidates
      Reverse order of declaration; super-methods appear later in the list.
    • Constructor Summary

      Constructors 
      Constructor Description
      MethodPartition​(java.lang.reflect.Method first, java.lang.reflect.Method second)
      Each partition starts off with at least two methods.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MethodPartition addCandidate​(java.lang.reflect.Method method)
      Add a new method to this partition for resolution.
      void collectEnhanceableMethods​(TypeLiteral<?> hostType, java.util.function.Consumer<java.lang.reflect.Method> methodVisitor, java.util.Map<java.lang.reflect.Method,​java.lang.reflect.Method> bridgeDelegates)
      Resolve and collect enhanceable methods into the given list; one per method-signature.
      private static java.lang.String parametersKey​(java.lang.Class<?>[] parameterTypes)
      Each method is uniquely identified in the partition by its actual parameter types.
      private static boolean resolvedParametersMatch​(java.lang.reflect.Method subMethod, TypeLiteral<?> host, java.lang.reflect.Method superMethod)
      Compares a sub-method with a generic super-method by resolving it against the host class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • candidates

        private final java.util.List<java.lang.reflect.Method> candidates
        Reverse order of declaration; super-methods appear later in the list.
    • Constructor Detail

      • MethodPartition

        public MethodPartition​(java.lang.reflect.Method first,
                               java.lang.reflect.Method second)
        Each partition starts off with at least two methods.
    • Method Detail

      • addCandidate

        public MethodPartition addCandidate​(java.lang.reflect.Method method)
        Add a new method to this partition for resolution.
      • collectEnhanceableMethods

        public void collectEnhanceableMethods​(TypeLiteral<?> hostType,
                                              java.util.function.Consumer<java.lang.reflect.Method> methodVisitor,
                                              java.util.Map<java.lang.reflect.Method,​java.lang.reflect.Method> bridgeDelegates)
        Resolve and collect enhanceable methods into the given list; one per method-signature. Methods declared in sub-classes are preferred over those in super-classes with the same signature. (Unless it's a bridge method, in which case we prefer to report the non-bridge method from the super-class as a convenience to AOP method matchers that always ignore synthetic methods.)

        At the same time we use generic type resolution to match resolved bridge methods to the methods they delegate to (this avoids the need to crack open the original class resource for in-depth analysis by ASM, especially since the class bytes might not be accessible.)

      • parametersKey

        private static java.lang.String parametersKey​(java.lang.Class<?>[] parameterTypes)
        Each method is uniquely identified in the partition by its actual parameter types.
      • resolvedParametersMatch

        private static boolean resolvedParametersMatch​(java.lang.reflect.Method subMethod,
                                                       TypeLiteral<?> host,
                                                       java.lang.reflect.Method superMethod)
        Compares a sub-method with a generic super-method by resolving it against the host class.