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 class
An abstract base implementation of a method description.static class
An implementation of a method description for a loaded constructor.static class
An implementation of a method description for a loaded method.static interface
Represents a method in its defined shape, i.e.static interface
Represents a method description in its generic shape, i.e.static class
A latent method description describes a method that is not attached to a declaringTypeDescription
.static class
A token representing a method's name and raw return and parameter types.static class
A token representing a method's properties detached from a type.static class
A method description that represents a given method but with substituted method types.static class
A token representing a method's erased return and parameter types.Nested classes/interfaces inherited from interface net.bytebuddy.description.annotation.AnnotationSource
AnnotationSource.Empty, AnnotationSource.Explicit
Nested 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.WithMandatoryDeclaration
Nested classes/interfaces inherited from interface net.bytebuddy.description.ModifierReviewable
ModifierReviewable.ForFieldDescription, ModifierReviewable.ForMethodDescription, ModifierReviewable.ForParameterDescription, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumeration
Nested classes/interfaces inherited from interface net.bytebuddy.description.NamedElement
NamedElement.WithDescriptor, NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeName
Nested classes/interfaces inherited from interface net.bytebuddy.description.TypeVariableSource
TypeVariableSource.Visitor<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The internal name of a Java constructor.static final String
The internal name of a Java static initializer.static final int
The type initializer of any representation of a type initializer.static final MethodDescription.InDefinedShape
Represents any undefined property of a type description that is instead represented asnull
in order to resemble the Java reflection API which returnsnull
and is intuitive to many Java developers.Fields inherited from interface net.bytebuddy.description.ModifierReviewable
EMPTY_MASK
Fields inherited from interface net.bytebuddy.description.NamedElement
EMPTY_NAME, NO_NAME
Fields 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.int
Returns this method's actual modifiers as it is present in a class file, i.e.int
getActualModifiers
(boolean manifest) Returns this method's actual modifiers as it is present in a class file, i.e.int
getActualModifiers
(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 ornull
if no default value is defined for this method.<T> T
getDefaultValue
(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.int
Returns the size of the local variable array that is required for this method, i.e.boolean
isBridgeCompatible
(MethodDescription.TypeToken typeToken) Validates that the supplied type token can implement a bridge method to this method.boolean
Checks if this method is a valid bootstrap method for an constantdynamic call.boolean
isConstantBootstrap
(List<? extends TypeDefinition> arguments) Checks if this method is a valid bootstrap method for a constantdynamic call.boolean
Checks if this method description represents a constructor.boolean
Checks if this method represents a default (defender) method.boolean
Checks if this method is capable of defining a default annotation value.boolean
isDefaultValue
(AnnotationValue<?, ?> annotationValue) Checks if the given value can describe a default annotation value for this method.boolean
isInvokableOn
(TypeDescription typeDescription) Asserts if this method is invokable on an instance of the given type, i.e.boolean
Checks if this method is a valid bootstrap method for an invokedynamic call.boolean
isInvokeBootstrap
(List<? extends TypeDefinition> arguments) Checks if this method is a valid bootstrap method for an invokedynamic call.boolean
isMethod()
Checks if this method description represents a method, i.e.boolean
isSpecializableFor
(TypeDescription typeDescription) Checks if this method can be called using theINVOKESPECIAL
for a given type.boolean
Checks if this method is a type initializer.boolean
Verifies if this method describes a virtual method, i.e.boolean
represents
(Constructor<?> constructor) Verifies if a method description represents a given loaded constructor.boolean
represents
(Method method) Verifies if a method description represents a given loaded method.Methods inherited from interface net.bytebuddy.description.annotation.AnnotationSource
getDeclaredAnnotations
Methods inherited from interface net.bytebuddy.description.ByteCodeElement
isAccessibleTo, isVisibleTo
Methods inherited from interface net.bytebuddy.description.ByteCodeElement.TypeDependant
asDefined, asToken
Methods inherited from interface net.bytebuddy.description.DeclaredByType.WithMandatoryDeclaration
getDeclaringType
Methods inherited from interface net.bytebuddy.description.ModifierReviewable
getModifiers, getSyntheticState, isFinal, isSynthetic
Methods inherited from interface net.bytebuddy.description.ModifierReviewable.ForMethodDescription
getMethodManifestation, getMethodStrictness, getSynchronizationState, isBridge, isNative, isStrict, isSynchronized, isVarArgs
Methods inherited from interface net.bytebuddy.description.ModifierReviewable.OfAbstraction
isAbstract
Methods inherited from interface net.bytebuddy.description.ModifierReviewable.OfByteCodeElement
getOwnership, getVisibility, isDeprecated, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic
Methods inherited from interface net.bytebuddy.description.NamedElement
getActualName
Methods inherited from interface net.bytebuddy.description.NamedElement.WithDescriptor
getDescriptor, getGenericSignature
Methods inherited from interface net.bytebuddy.description.NamedElement.WithGenericName
toGenericString
Methods inherited from interface net.bytebuddy.description.NamedElement.WithRuntimeName
getInternalName, getName
Methods 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 asnull
in order to resemble the Java reflection API which returnsnull
and 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 markedDeprecated
and adjusts the modifiers for being abstract or not.- Parameters:
manifest
-true
if 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 markedDeprecated
and adjusts the modifiers for being abstract or not. Additionally, this method resolves a required minimal visibility.- Parameters:
manifest
-true
if 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:
true
if 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:
true
if this method description represents a Java method.
-
isTypeInitializer
boolean isTypeInitializer()Checks if this method is a type initializer.- Returns:
true
if 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:
true
if 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:
true
if 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:
true
if 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 tothis
if 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:
true
if this method is a default method.
-
isSpecializableFor
Checks if this method can be called using theINVOKESPECIAL
for a given type.- Parameters:
typeDescription
- The type o- Returns:
true
if this method can be called using theINVOKESPECIAL
instruction using the given type.
-
getDefaultValue
Returns the method's default annotation value ornull
if no default value is defined for this method.- Returns:
- The method's default annotation value or
null
if 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, aClassCastException
is 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:
true
if 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:
true
if 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:
true
if 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:
true
if 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:
true
if 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:
true
if 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:
true
if the given value can describe a default annotation value for this method.
-
getReceiverType
Returns this methods receiver type. A receiver type is undefined forstatic
methods wherenull
is 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:
true
if the supplied type token can represent a bridge method to this method.
-