public interface PlasticMethod extends AnnotationAccess
Modifier and Type | Method and Description |
---|---|
PlasticMethod |
addAdvice(MethodAdvice advice)
Adds advice to the method.
|
PlasticMethod |
changeImplementation(InstructionBuilderCallback callback)
Clears the instructions for this method, and creates a new empty InstructionBuilder so that the implementation of
the method can be specified.
|
PlasticMethod |
delegateTo(PlasticField field)
Changes the implementation of the method to delegate to the provided field.
|
PlasticMethod |
delegateTo(PlasticMethod method)
Much like
delegateTo(PlasticField) , but the object to delegate to
is dynamically computed by another method of the class. |
MethodDescription |
getDescription()
Returns a representation of the method's name, return value, argument types, etc.
|
MethodHandle |
getHandle()
Returns a handle that can be used to invoke a method of a transformed class instance.
|
String |
getMethodIdentifier()
Returns a short identifier for the method that includes the class name, the method name,
and the types of all parameters.
|
List<MethodParameter> |
getParameters()
Returns access to the parameters of the method and, in particular,
the visible annotations on those parameters.
|
PlasticClass |
getPlasticClass()
Returns the PlasticClass containing this method.
|
boolean |
isAbstract()
Returns true if the method is abstract.
|
boolean |
isOverride()
Returns true if the method is an override of a method from the parent class.
|
boolean |
isVoid()
Returns true if this method is type void.
|
getAnnotation, hasAnnotation
PlasticClass getPlasticClass()
MethodDescription getDescription()
MethodHandle getHandle()
PlasticMethod changeImplementation(InstructionBuilderCallback callback)
callback
- passed the InstructionBuilder so that an implementation of the method can be createdPlasticMethod addAdvice(MethodAdvice advice)
MethodInvocation
and should invoke MethodInvocation.proceed()
to pass control to the next piece
of advice (and ultimately, to the actual method invocation).
If a method implementation is changed, using changeImplementation(InstructionBuilderCallback)
, that
change will be honored, but the logic will only be invoked at the end of the chain of MethodAdvice. Internally, a
new method is created with the same parameters, exceptions, return type and implementation (bytecode) as the
advised method, then the advised method's implementation is changed.
Note additionally that a recursive method invocation will still invoke the MethodAdvice chain on each recursive
call (this is an intended side-effect of copying the exact bytecode of the method implementation.advice
- advice to add to the methodPlasticMethod delegateTo(PlasticField field)
changeImplementation(InstructionBuilderCallback)
), method advice is retained.field
- to delegate toPlasticMethod delegateTo(PlasticMethod method)
delegateTo(PlasticField)
, but the object to delegate to
is dynamically computed by another method of the class. The method should take no parameters
and must not return null, or throw any exceptions not compatible with the method being proxied.method
- to provide the dynamic delegateList<MethodParameter> getParameters()
boolean isOverride()
boolean isAbstract()
String getMethodIdentifier()
MethodDescription.toShortString()
boolean isVoid()
5.6.3 - Copyright © 2003-2021 The Apache Software Foundation.