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

pack-priv final Class MethodPartition

extends Object
Class Inheritance
Static Imports
java.lang.reflect.Modifier.FINAL

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

Field Summary

Modifier and TypeField and Description
private final List<Method>
candidates

Reverse order of declaration; super-methods appear later in the list.

Constructor Summary

AccessConstructor and Description
public
MethodPartition(Method first, Method second)

Each partition starts off with at least two methods.

Method Summary

Modifier and TypeMethod and Description
public MethodPartition
addCandidate(Method method)

Add a new method to this partition for resolution.

public void
collectEnhanceableMethods(TypeLiteral<?> hostType, Consumer<Method> methodVisitor, Map<Method, Method> bridgeDelegates)

Resolve and collect enhanceable methods into the given list; one per method-signature.

private static String
parametersKey(Class<?>[] parameterTypes)

Each method is uniquely identified in the partition by its actual parameter types.

private static boolean
resolvedParametersMatch(Method subMethod, TypeLiteral<?> host, Method superMethod)

Compares a sub-method with a generic super-method by resolving it against the host class.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

candidatesback to summary
private final List<Method> candidates

Reverse order of declaration; super-methods appear later in the list.

Constructor Detail

MethodPartitionback to summary
public MethodPartition(Method first, Method second)

Each partition starts off with at least two methods.

Method Detail

addCandidateback to summary
public MethodPartition addCandidate(Method method)

Add a new method to this partition for resolution.

collectEnhanceableMethodsback to summary
public void collectEnhanceableMethods(TypeLiteral<?> hostType, Consumer<Method> methodVisitor, Map<Method, 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.)

parametersKeyback to summary
private static String parametersKey(Class<?>[] parameterTypes)

Each method is uniquely identified in the partition by its actual parameter types.

resolvedParametersMatchback to summary
private static boolean resolvedParametersMatch(Method subMethod, TypeLiteral<?> host, Method superMethod)

Compares a sub-method with a generic super-method by resolving it against the host class.