Package net.bytebuddy.implementation
Class MethodCall.WithoutSpecifiedTarget
- java.lang.Object
-
- net.bytebuddy.implementation.MethodCall
-
- net.bytebuddy.implementation.MethodCall.WithoutSpecifiedTarget
-
- All Implemented Interfaces:
InstrumentedType.Prepareable
,Implementation
,Implementation.Composable
- Enclosing class:
- MethodCall
public static class MethodCall.WithoutSpecifiedTarget extends MethodCall
Represents aMethodCall
that invokes a method without specifying an invocation method. Some methods can for example be invoked both virtually or as a super method invocation. Similarly, interface methods can be invoked virtually or as an explicit invocation of a default method. If no explicit invocation type is set, a method is always invoked virtually unless the method represents a static methods or a constructor.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.bytebuddy.implementation.MethodCall
MethodCall.Appender, MethodCall.ArgumentLoader, MethodCall.FieldSetting, MethodCall.MethodInvoker, MethodCall.MethodLocator, MethodCall.TargetHandler, MethodCall.TerminationHandler, MethodCall.WithoutSpecifiedTarget
-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.Implementation
Implementation.Composable, Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.Target
-
-
Field Summary
-
Fields inherited from class net.bytebuddy.implementation.MethodCall
argumentLoaders, assigner, methodInvoker, methodLocator, targetHandler, terminationHandler, typing
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
WithoutSpecifiedTarget(MethodCall.MethodLocator.Factory methodLocator)
Creates a new method call without a specified target.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MethodCall
on(java.lang.Object target)
Invokes the specified method on the given instance.MethodCall
on(StackManipulation stackManipulation, java.lang.Class<?> type)
Invokes the specified method on an instance that is loaded by the provided stack manipulation.MethodCall
on(StackManipulation stackManipulation, TypeDescription typeDescription)
Invokes the specified method on an instance that is loaded by the provided stack manipulation.<T> MethodCall
on(T target, java.lang.Class<? super T> type)
Invokes the specified method on the given instance.MethodCall
onArgument(int index)
Invokes the specified method on the instrumented method's argument of the given index.MethodCall
onDefault()
Invokes the given method by a Java 8 default method invocation on the instance of the instrumented type.MethodCall
onField(java.lang.reflect.Field field)
Invokes a method on the object stored in the specified field.MethodCall
onField(java.lang.String name)
Invokes a method on the object stored in the specified field.MethodCall
onField(java.lang.String name, FieldLocator.Factory fieldLocatorFactory)
Invokes a method on the object stored in the specified field.MethodCall
onField(FieldDescription fieldDescription)
Invokes a method on the object stored in the specified field.MethodCall
onMethodCall(MethodCall methodCall)
Invokes a method on the method call's return value.MethodCall
onSuper()
Invokes the given method by a super method invocation on the instance of the instrumented type.-
Methods inherited from class net.bytebuddy.implementation.MethodCall
andThen, andThen, appender, call, construct, construct, invoke, invoke, invoke, invoke, invoke, invoke, invokeSelf, invokeSuper, prepare, run, setsField, setsField, setsField, with, with, with, with, with, with, with, with, withAllArguments, withArgument, withArgumentArray, withArgumentArrayElements, withArgumentArrayElements, withArgumentArrayElements, withAssigner, withField, withField, withMethodCall, withOwnType, withReference, withThis
-
-
-
-
Constructor Detail
-
WithoutSpecifiedTarget
protected WithoutSpecifiedTarget(MethodCall.MethodLocator.Factory methodLocator)
Creates a new method call without a specified target.- Parameters:
methodLocator
- The method locator to use.
-
-
Method Detail
-
on
public MethodCall on(java.lang.Object target)
Invokes the specified method on the given instance.- Parameters:
target
- The object on which the method is to be invoked upon.- Returns:
- A method call that invokes the provided method on the given object.
-
on
public <T> MethodCall on(T target, java.lang.Class<? super T> type)
Invokes the specified method on the given instance.- Type Parameters:
T
- The type of the object.- Parameters:
target
- The object on which the method is to be invoked upon.type
- The object's type.- Returns:
- A method call that invokes the provided method on the given object.
-
on
public MethodCall on(StackManipulation stackManipulation, java.lang.Class<?> type)
Invokes the specified method on an instance that is loaded by the provided stack manipulation.- Parameters:
stackManipulation
- The stack manipulation that loads the instance that the method is invoked upon.type
- The type of the loaded instance.- Returns:
- A method call that invokes the provided method on the value of the provided stack manipulation.
-
on
public MethodCall on(StackManipulation stackManipulation, TypeDescription typeDescription)
Invokes the specified method on an instance that is loaded by the provided stack manipulation.- Parameters:
stackManipulation
- The stack manipulation that loads the instance that the method is invoked upon.typeDescription
- The type of the loaded instance.- Returns:
- A method call that invokes the provided method on the value of the provided stack manipulation.
-
onArgument
public MethodCall onArgument(int index)
Invokes the specified method on the instrumented method's argument of the given index.- Parameters:
index
- The index of the method's argument on which the specified method should be invoked.- Returns:
- A method call that invokes the provided method on the given method argument.
-
onField
public MethodCall onField(java.lang.String name)
Invokes a method on the object stored in the specified field.- Parameters:
name
- The name of the field.- Returns:
- A method call that invokes the given method on an instance that is read from a field.
-
onField
public MethodCall onField(java.lang.String name, FieldLocator.Factory fieldLocatorFactory)
Invokes a method on the object stored in the specified field.- Parameters:
name
- The name of the field.fieldLocatorFactory
- The field locator factory to use for locating the field.- Returns:
- A method call that invokes the given method on an instance that is read from a field.
-
onField
public MethodCall onField(java.lang.reflect.Field field)
Invokes a method on the object stored in the specified field.- Parameters:
field
- The field on which to invoke the method upon.- Returns:
- A method call that invokes the given method on an instance that is read from a field.
-
onField
public MethodCall onField(FieldDescription fieldDescription)
Invokes a method on the object stored in the specified field.- Parameters:
fieldDescription
- The field on which to invoke the method upon.- Returns:
- A method call that invokes the given method on an instance that is read from a field.
-
onMethodCall
public MethodCall onMethodCall(MethodCall methodCall)
Invokes a method on the method call's return value.- Parameters:
methodCall
- The method call that return's value is to be used in this method call- Returns:
- A method call that invokes the given method on an instance that is returned from a method call.
-
onSuper
public MethodCall onSuper()
Invokes the given method by a super method invocation on the instance of the instrumented type. Note that the super method is resolved depending on the type of implementation when this method is called. In case that a subclass is created, the super type is invoked. If a type is rebased, the rebased method is invoked if such a method exists.- Returns:
- A method call where the given method is invoked as a super method invocation.
-
onDefault
public MethodCall onDefault()
Invokes the given method by a Java 8 default method invocation on the instance of the instrumented type.- Returns:
- A method call where the given method is invoked as a super method invocation.
-
-