Implementation invokes a default method for the methods it instruments.
A default method is potentially ambiguous if a method of identical signature is defined in several interfaces.
For this reason, this implementation allows for the specification of prioritized interfaces whose default
methods, if a method of equivalent signature is defined for a specific interface. All prioritized interfaces are
searched for default methods in the order of their specification. If no prioritized interface defines a default method
of equivalent signature to the given instrumented method, any non-prioritized interface is searched for a suitable
default method. If exactly one of those interfaces defines a suitable default method, this method is invoked.
If no method or more than one method is identified as a suitable default method, an exception is thrown.
When it comes to default methods, the Java programming language specifies stronger requirements for the legitimacy of invoking a default method than the Java runtime. The Java compiler requires a method to be the most specific method in its defining type's type hierarchy, i.e. the method must not be overridden by another interface or class type. Additionally, the method must be invokable from an interface type which is directly implemented by the instrumented type. The Java runtime only requires the second condition to be fulfilled which is why this implementation only checks the later condition, as well.
| Modifier and Type | Class and Description |
|---|---|
| protected static class | DefaultMethodCall.Appender
The appender for implementing a |
| Modifier and Type | Field and Description |
|---|---|
| private final List | prioritizedInterfaces
A list of prioritized interfaces in the order in which a method should be attempted to be called. |
| Access | Constructor and Description |
|---|---|
| protected | DefaultMethodCall(List<TypeDescription>
A list of prioritized interfaces in the order in which a method should be attempted to
be called. prioritizedInterfaces)Creates a new |
| Modifier and Type | Method and Description |
|---|---|
| public ByteCodeAppender | appender(Implementation.
The target of the current implementation. implementationTargetImplements net. |
| private List | Returns: A list of prioritized interfaces that are additionally implemented by the given type.The instrumented type for which the prioritized interfaces are to be filtered. typeDescription)Filters the relevant prioritized interfaces for a given type, i.e. finds the types that are directly declared on a given instrumented type. |
| public InstrumentedType | prepare(InstrumentedType
The instrumented type in its current form. instrumentedType)Implements net. |
| public static Implementation | Returns: An implementation which calls an instrumented method's compatible default method that considers the given interfaces to be prioritized in their order.A list of prioritized default method interfaces in their prioritization order. prioritizedInterface)Creates a |
| public static Implementation | Returns: An implementation which calls an instrumented method's compatible default method that considers the given interfaces to be prioritized in their order.A list of prioritized default method interfaces in their prioritization order. prioritizedInterfaces)Creates a |
| public static Implementation | Returns: An implementation which calls an instrumented method's compatible default method that considers the given interfaces to be prioritized in their order.A list of prioritized default method interfaces in their prioritization order. prioritizedInterface)Creates a |
| public static Implementation | Returns: An implementation which calls an instrumented method's compatible default method that considers the given interfaces to be prioritized in their order.A collection of prioritized default method interfaces in their prioritization order. prioritizedInterfaces)Creates a |
| public static Implementation | Returns: An implementation which calls an instrumented method's compatible default method if such a method is unambiguous.Creates a |
| prioritizedInterfaces | back to summary |
|---|---|
| private final List<TypeDescription> prioritizedInterfaces A list of prioritized interfaces in the order in which a method should be attempted to be called. | |
| DefaultMethodCall | back to summary |
|---|---|
| protected DefaultMethodCall(List<TypeDescription> prioritizedInterfaces) Creates a new
| |
| appender | back to summary |
|---|---|
| public ByteCodeAppender appender(Implementation. Implements net. Doc from net. Creates a byte code appender that determines the implementation of the instrumented type's methods.
| |
| filterRelevant | back to summary |
|---|---|
| private List Filters the relevant prioritized interfaces for a given type, i.e. finds the types that are directly declared on a given instrumented type.
| |
| prepare | back to summary |
|---|---|
| public InstrumentedType prepare(InstrumentedType instrumentedType) Implements net. Doc from net. Prepares a given instrumented type.
| |
| prioritize | back to summary |
|---|---|
| public static Implementation prioritize(Class<?>... prioritizedInterface) Creates a
| |
| prioritize | back to summary |
|---|---|
| public static Implementation prioritize(Iterable<? extends Class<?>> prioritizedInterfaces) Creates a
| |
| prioritize | back to summary |
|---|---|
| public static Implementation prioritize(TypeDescription... prioritizedInterface) Creates a
| |
| prioritize | back to summary |
|---|---|
| public static Implementation prioritize(Collection<? extends TypeDescription> prioritizedInterfaces) Creates a
| |
| unambiguousOnly | back to summary |
|---|---|
| public static Implementation unambiguousOnly() Creates a
| |
net.bytebuddy.implementation.DefaultMethodCall .
| Modifier and Type | Field and Description |
|---|---|
| private final Implementation. | implementationTarget
The implementation target of this appender. |
| private final Set | nonPrioritizedInterfaces
The relevant non-prioritized interfaces to be considered by this appender. |
| private final List | prioritizedInterfaces
The relevant prioritized interfaces to be considered by this appender. |
| Access | Constructor and Description |
|---|---|
| protected | Appender(Implementation.
The implementation target of this appender. implementationTarget,The relevant prioritized interfaces to be considered by this appender. prioritizedInterfaces)Creates a new appender for implementing a |
| Modifier and Type | Method and Description |
|---|---|
| public ByteCodeAppender. | apply(MethodVisitor
The method visitor to which the byte code appender writes its code to. methodVisitor, Implementation.The implementation context of the current type creation process. implementationContext,The method that is the target of the instrumentation. instrumentedMethod)Implements net. |
| private StackManipulation | Returns: A potentially illegal stack manipulation representing the default method invocation for the given method.The method that is currently instrumented. methodDescription)Locates a special method invocation to be invoked from a given method. |
| implementationTarget | back to summary |
|---|---|
| private final Implementation. The implementation target of this appender. | |
| nonPrioritizedInterfaces | back to summary |
|---|---|
| private final Set<TypeDescription> nonPrioritizedInterfaces The relevant non-prioritized interfaces to be considered by this appender. | |
| prioritizedInterfaces | back to summary |
|---|---|
| private final List<TypeDescription> prioritizedInterfaces The relevant prioritized interfaces to be considered by this appender. | |
| Appender | back to summary |
|---|---|
| protected Appender(Implementation. Creates a new appender for implementing a
| |
| apply | back to summary |
|---|---|
| public ByteCodeAppender. Implements net. Doc from net. Applies this byte code appender to a type creation process.
| |
| locateDefault | back to summary |
|---|---|
| private StackManipulation locateDefault(MethodDescription methodDescription) Locates a special method invocation to be invoked from a given method.
| |