Package net.bytebuddy.description.method
Interface MethodDescription
- All Superinterfaces:
AnnotationSource,ByteCodeElement,ByteCodeElement.Member,ByteCodeElement.TypeDependant<MethodDescription.InDefinedShape,,MethodDescription.Token> DeclaredByType,DeclaredByType.WithMandatoryDeclaration,ModifierReviewable,ModifierReviewable.ForMethodDescription,ModifierReviewable.OfAbstraction,ModifierReviewable.OfByteCodeElement,NamedElement,NamedElement.WithDescriptor,NamedElement.WithGenericName,NamedElement.WithRuntimeName,TypeVariableSource
- All Known Subinterfaces:
MethodDescription.InDefinedShape,MethodDescription.InGenericShape
- All Known Implementing Classes:
Implementation.Context.Default.AbstractPropertyAccessorMethod,Implementation.Context.Default.AccessorMethod,Implementation.Context.Default.FieldGetter,Implementation.Context.Default.FieldSetter,MethodDescription.AbstractBase,MethodDescription.ForLoadedConstructor,MethodDescription.ForLoadedMethod,MethodDescription.InDefinedShape.AbstractBase,MethodDescription.InDefinedShape.AbstractBase.ForLoadedExecutable,MethodDescription.Latent,MethodDescription.Latent.TypeInitializer,MethodDescription.TypeSubstituting,MethodRebaseResolver.Resolution.ForRebasedConstructor.RebasedConstructor,MethodRebaseResolver.Resolution.ForRebasedMethod.RebasedMethod,Transformer.ForMethod.TransformedMethod,TypePool.Default.LazyTypeDescription.LazyMethodDescription,TypeWriter.MethodPool.Record.AccessBridgeWrapper.AccessorBridge,TypeWriter.MethodPool.Record.AccessBridgeWrapper.BridgeTarget,TypeWriter.MethodPool.Record.ForDefinedMethod.OfVisibilityBridge.VisibilityBridge
public interface MethodDescription
extends TypeVariableSource, ModifierReviewable.ForMethodDescription, DeclaredByType.WithMandatoryDeclaration, ByteCodeElement.Member, ByteCodeElement.TypeDependant<MethodDescription.InDefinedShape,MethodDescription.Token>
Implementations of this interface describe a Java method, i.e. a method or a constructor. Implementations of this
interface must provide meaningful
equal(Object) and hashCode() implementations.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classAn abstract base implementation of a method description.static classAn implementation of a method description for a loaded constructor.static classAn implementation of a method description for a loaded method.static interfaceRepresents a method in its defined shape, i.e.static interfaceRepresents a method description in its generic shape, i.e.static classA latent method description describes a method that is not attached to a declaringTypeDescription.static classA token representing a method's name and raw return and parameter types.static classA token representing a method's properties detached from a type.static classA method description that represents a given method but with substituted method types.static classA token representing a method's erased return and parameter types.Nested classes/interfaces inherited from interface net.bytebuddy.description.annotation.AnnotationSource
AnnotationSource.Empty, AnnotationSource.ExplicitNested classes/interfaces inherited from interface net.bytebuddy.description.ByteCodeElement
ByteCodeElement.Member, ByteCodeElement.TypeDependant<T extends ByteCodeElement.TypeDependant<?,S>, S extends ByteCodeElement.Token<S>> Nested classes/interfaces inherited from interface net.bytebuddy.description.DeclaredByType
DeclaredByType.WithMandatoryDeclarationNested classes/interfaces inherited from interface net.bytebuddy.description.ModifierReviewable
ModifierReviewable.ForFieldDescription, ModifierReviewable.ForMethodDescription, ModifierReviewable.ForParameterDescription, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumerationNested classes/interfaces inherited from interface net.bytebuddy.description.NamedElement
NamedElement.WithDescriptor, NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeNameNested classes/interfaces inherited from interface net.bytebuddy.description.TypeVariableSource
TypeVariableSource.Visitor<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe internal name of a Java constructor.static final StringThe internal name of a Java static initializer.static final intThe type initializer of any representation of a type initializer.static final MethodDescription.InDefinedShapeRepresents any undefined property of a type description that is instead represented asnullin order to resemble the Java reflection API which returnsnulland is intuitive to many Java developers.Fields inherited from interface net.bytebuddy.description.ModifierReviewable
EMPTY_MASKFields inherited from interface net.bytebuddy.description.NamedElement
EMPTY_NAME, NO_NAMEFields inherited from interface net.bytebuddy.description.NamedElement.WithDescriptor
NON_GENERIC_SIGNATURE -
Method Summary
Modifier and TypeMethodDescriptionReturns a signature token representing this method.Returns a type token that represents this method's raw return and parameter types.intReturns this method's actual modifiers as it is present in a class file, i.e.intgetActualModifiers(boolean manifest) Returns this method's actual modifiers as it is present in a class file, i.e.intgetActualModifiers(boolean manifest, Visibility visibility) Returns this method's actual modifiers as it is present in a class file, i.e.AnnotationValue<?, ?> Returns the method's default annotation value ornullif no default value is defined for this method.<T> TgetDefaultValue(Class<T> type) Returns the default value but casts it to the given type.Returns the exception types of the described method.Returns a list of this method's parameters.Returns this methods receiver type.Returns the return type of the described method.intReturns the size of the local variable array that is required for this method, i.e.booleanisBridgeCompatible(MethodDescription.TypeToken typeToken) Validates that the supplied type token can implement a bridge method to this method.booleanChecks if this method is a valid bootstrap method for an constantdynamic call.booleanisConstantBootstrap(List<? extends TypeDefinition> arguments) Checks if this method is a valid bootstrap method for a constantdynamic call.booleanChecks if this method description represents a constructor.booleanChecks if this method represents a default (defender) method.booleanChecks if this method is capable of defining a default annotation value.booleanisDefaultValue(AnnotationValue<?, ?> annotationValue) Checks if the given value can describe a default annotation value for this method.booleanisInvokableOn(TypeDescription typeDescription) Asserts if this method is invokable on an instance of the given type, i.e.booleanChecks if this method is a valid bootstrap method for an invokedynamic call.booleanisInvokeBootstrap(List<? extends TypeDefinition> arguments) Checks if this method is a valid bootstrap method for an invokedynamic call.booleanisMethod()Checks if this method description represents a method, i.e.booleanisSpecializableFor(TypeDescription typeDescription) Checks if this method can be called using theINVOKESPECIALfor a given type.booleanChecks if this method is a type initializer.booleanVerifies if this method describes a virtual method, i.e.booleanrepresents(Constructor<?> constructor) Verifies if a method description represents a given loaded constructor.booleanrepresents(Method method) Verifies if a method description represents a given loaded method.Methods inherited from interface net.bytebuddy.description.annotation.AnnotationSource
getDeclaredAnnotationsMethods inherited from interface net.bytebuddy.description.ByteCodeElement
isAccessibleTo, isVisibleToMethods inherited from interface net.bytebuddy.description.ByteCodeElement.TypeDependant
asDefined, asTokenMethods inherited from interface net.bytebuddy.description.DeclaredByType.WithMandatoryDeclaration
getDeclaringTypeMethods inherited from interface net.bytebuddy.description.ModifierReviewable
getModifiers, getSyntheticState, isFinal, isSyntheticMethods inherited from interface net.bytebuddy.description.ModifierReviewable.ForMethodDescription
getMethodManifestation, getMethodStrictness, getSynchronizationState, isBridge, isNative, isStrict, isSynchronized, isVarArgsMethods inherited from interface net.bytebuddy.description.ModifierReviewable.OfAbstraction
isAbstractMethods inherited from interface net.bytebuddy.description.ModifierReviewable.OfByteCodeElement
getOwnership, getVisibility, isDeprecated, isPackagePrivate, isPrivate, isProtected, isPublic, isStaticMethods inherited from interface net.bytebuddy.description.NamedElement
getActualNameMethods inherited from interface net.bytebuddy.description.NamedElement.WithDescriptor
getDescriptor, getGenericSignatureMethods inherited from interface net.bytebuddy.description.NamedElement.WithGenericName
toGenericStringMethods inherited from interface net.bytebuddy.description.NamedElement.WithRuntimeName
getInternalName, getNameMethods inherited from interface net.bytebuddy.description.TypeVariableSource
accept, findExpectedVariable, findVariable, getEnclosingSource, getTypeVariables, isGenerified, isInferrable
-
Field Details
-
CONSTRUCTOR_INTERNAL_NAME
The internal name of a Java constructor.- See Also:
-
TYPE_INITIALIZER_INTERNAL_NAME
The internal name of a Java static initializer.- See Also:
-
TYPE_INITIALIZER_MODIFIER
static final int TYPE_INITIALIZER_MODIFIERThe type initializer of any representation of a type initializer.- See Also:
-
UNDEFINED
Represents any undefined property of a type description that is instead represented asnullin order to resemble the Java reflection API which returnsnulland is intuitive to many Java developers.
-
-
Method Details
-
getReturnType
TypeDescription.Generic getReturnType()Returns the return type of the described method.- Returns:
- The return type of the described method.
-
getParameters
ParameterList<?> getParameters()Returns a list of this method's parameters.- Returns:
- A list of this method's parameters.
-
getExceptionTypes
TypeList.Generic getExceptionTypes()Returns the exception types of the described method.- Returns:
- The exception types of the described method.
-
getActualModifiers
int getActualModifiers()Returns this method's actual modifiers as it is present in a class file, i.e. includes a flag if this method is markedDeprecated.- Returns:
- The method's actual modifiers.
-
getActualModifiers
int getActualModifiers(boolean manifest) Returns this method's actual modifiers as it is present in a class file, i.e. includes a flag if this method is markedDeprecatedand adjusts the modifiers for being abstract or not.- Parameters:
manifest-trueif the method should be treated as non-abstract.- Returns:
- The method's actual modifiers.
-
getActualModifiers
Returns this method's actual modifiers as it is present in a class file, i.e. includes a flag if this method is markedDeprecatedand adjusts the modifiers for being abstract or not. Additionally, this method resolves a required minimal visibility.- Parameters:
manifest-trueif the method should be treated as non-abstract.visibility- The minimal visibility to enforce for this method.- Returns:
- The method's actual modifiers.
-
isConstructor
boolean isConstructor()Checks if this method description represents a constructor.- Returns:
trueif this method description represents a constructor.
-
isMethod
boolean isMethod()Checks if this method description represents a method, i.e. not a constructor or a type initializer.- Returns:
trueif this method description represents a Java method.
-
isTypeInitializer
boolean isTypeInitializer()Checks if this method is a type initializer.- Returns:
trueif this method description represents a type initializer.
-
represents
Verifies if a method description represents a given loaded method.- Parameters:
method- The method to be checked.- Returns:
trueif this method description represents the given loaded method.
-
represents
Verifies if a method description represents a given loaded constructor.- Parameters:
constructor- The constructor to be checked.- Returns:
trueif this method description represents the given loaded constructor.
-
isVirtual
boolean isVirtual()Verifies if this method describes a virtual method, i.e. a method that is inherited by a sub type of this type.- Returns:
trueif this method is virtual.
-
getStackSize
int getStackSize()Returns the size of the local variable array that is required for this method, i.e. the size of all parameters if they were loaded on the stack including a reference tothisif this method represented a non-static method.- Returns:
- The size of this method on the operand stack.
-
isDefaultMethod
boolean isDefaultMethod()Checks if this method represents a default (defender) method.- Returns:
trueif this method is a default method.
-
isSpecializableFor
Checks if this method can be called using theINVOKESPECIALfor a given type.- Parameters:
typeDescription- The type o- Returns:
trueif this method can be called using theINVOKESPECIALinstruction using the given type.
-
getDefaultValue
Returns the method's default annotation value ornullif no default value is defined for this method.- Returns:
- The method's default annotation value or
nullif no default value is defined for this method.
-
getDefaultValue
Returns the default value but casts it to the given type. If the type differs from the value, aClassCastExceptionis thrown.- Type Parameters:
T- The type to cast the default value to.- Parameters:
type- The type to cast the default value to.- Returns:
- The casted default value.
-
isInvokableOn
Asserts if this method is invokable on an instance of the given type, i.e. the method is an instance method or a constructor and the method is visible to the type and can be invoked on the given instance.- Parameters:
typeDescription- The type to check.- Returns:
trueif this method is invokable on an instance of the given type.
-
isInvokeBootstrap
boolean isInvokeBootstrap()Checks if this method is a valid bootstrap method for an invokedynamic call.- Returns:
trueif this method is a valid bootstrap method for an invokedynamic call.
-
isInvokeBootstrap
Checks if this method is a valid bootstrap method for an invokedynamic call.- Parameters:
arguments- The types of the explicit arguments that are supplied to the bootstrap method.- Returns:
trueif this method is a valid bootstrap method for an invokedynamic call.
-
isConstantBootstrap
boolean isConstantBootstrap()Checks if this method is a valid bootstrap method for an constantdynamic call.- Returns:
trueif this method is a valid bootstrap method for an constantdynamic call.
-
isConstantBootstrap
Checks if this method is a valid bootstrap method for a constantdynamic call.- Parameters:
arguments- The types of the explicit arguments that are supplied to the bootstrap method.- Returns:
trueif this method is a valid bootstrap method for an constantdynamic call.
-
isDefaultValue
boolean isDefaultValue()Checks if this method is capable of defining a default annotation value.- Returns:
trueif it is possible to define a default annotation value for this method.
-
isDefaultValue
Checks if the given value can describe a default annotation value for this method.- Parameters:
annotationValue- The value that describes the default annotation value for this method.- Returns:
trueif the given value can describe a default annotation value for this method.
-
getReceiverType
Returns this methods receiver type. A receiver type is undefined forstaticmethods wherenullis returned. Other than a receiver type that is provided by the Java reflection API, Byte Buddy is capable of extracting annotations on type parameters of receiver types when directly accessing a class file. Therefore, a receiver type might be parameterized.- Returns:
- This method's (annotated) receiver type.
-
asSignatureToken
MethodDescription.SignatureToken asSignatureToken()Returns a signature token representing this method.- Returns:
- A signature token representing this method.
-
asTypeToken
MethodDescription.TypeToken asTypeToken()Returns a type token that represents this method's raw return and parameter types.- Returns:
- A type token that represents this method's raw return and parameter types.
-
isBridgeCompatible
Validates that the supplied type token can implement a bridge method to this method.- Parameters:
typeToken- A type token representing a potential bridge method to this method.- Returns:
trueif the supplied type token can represent a bridge method to this method.
-