Class MethodDescription.AbstractBase
- java.lang.Object
-
- net.bytebuddy.description.ModifierReviewable.AbstractBase
-
- net.bytebuddy.description.TypeVariableSource.AbstractBase
-
- net.bytebuddy.description.method.MethodDescription.AbstractBase
-
- All Implemented Interfaces:
AnnotationSource
,ByteCodeElement
,ByteCodeElement.TypeDependant<MethodDescription.InDefinedShape,MethodDescription.Token>
,DeclaredByType
,MethodDescription
,ModifierReviewable
,ModifierReviewable.ForFieldDescription
,ModifierReviewable.ForMethodDescription
,ModifierReviewable.ForParameterDescription
,ModifierReviewable.ForTypeDefinition
,ModifierReviewable.OfAbstraction
,ModifierReviewable.OfByteCodeElement
,ModifierReviewable.OfEnumeration
,NamedElement
,NamedElement.WithGenericName
,NamedElement.WithRuntimeName
,TypeVariableSource
- Direct Known Subclasses:
MethodDescription.InDefinedShape.AbstractBase
,MethodDescription.TypeSubstituting
,Transformer.ForMethod.TransformedMethod
- Enclosing interface:
- MethodDescription
public abstract static class MethodDescription.AbstractBase extends TypeVariableSource.AbstractBase implements MethodDescription
An abstract base implementation of a method description.
-
-
Nested Class Summary
-
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.TypeDependant<T extends ByteCodeElement.TypeDependant<?,S>,S extends ByteCodeElement.Token<S>>
-
Nested classes/interfaces inherited from interface net.bytebuddy.description.method.MethodDescription
MethodDescription.AbstractBase, MethodDescription.ForLoadedConstructor, MethodDescription.ForLoadedMethod, MethodDescription.InDefinedShape, MethodDescription.InGenericShape, MethodDescription.Latent, MethodDescription.SignatureToken, MethodDescription.Token, MethodDescription.TypeSubstituting, MethodDescription.TypeToken
-
Nested classes/interfaces inherited from interface net.bytebuddy.description.ModifierReviewable
ModifierReviewable.AbstractBase, 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.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeName
-
Nested classes/interfaces inherited from interface net.bytebuddy.description.TypeVariableSource
TypeVariableSource.AbstractBase, TypeVariableSource.Visitor<T>
-
-
Field Summary
-
Fields inherited from interface net.bytebuddy.description.ByteCodeElement
NON_GENERIC_SIGNATURE
-
Fields inherited from interface net.bytebuddy.description.method.MethodDescription
CONSTRUCTOR_INTERNAL_NAME, TYPE_INITIALIZER_INTERNAL_NAME, TYPE_INITIALIZER_MODIFIER, UNDEFINED
-
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.TypeVariableSource
UNDEFINED
-
-
Constructor Summary
Constructors Constructor Description AbstractBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
accept(TypeVariableSource.Visitor<T> visitor)
Applies a visitor on this type variable source.MethodDescription.SignatureToken
asSignatureToken()
Returns a signature token representing this method.MethodDescription.Token
asToken(ElementMatcher<? super TypeDescription> matcher)
Returns a token representative of this type dependant.MethodDescription.TypeToken
asTypeToken()
Returns a type token that represents this method's raw return and parameter types.boolean
equals(java.lang.Object other)
int
getActualModifiers()
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.java.lang.String
getActualName()
Returns the name of this element as it is found in the source code.<T> T
getDefaultValue(java.lang.Class<T> type)
Returns the default value but casts it to the given type.java.lang.String
getDescriptor()
Returns the descriptor of this byte code element.TypeVariableSource
getEnclosingSource()
Returns the enclosing source of type variables that are valid in the scope of this type variable source.java.lang.String
getGenericSignature()
Returns the generic signature of this byte code element.java.lang.String
getName()
Returns the internalName of this byte code element.int
getStackSize()
Returns the size of the local variable array that is required for this method, i.e.int
hashCode()
boolean
isAccessibleTo(TypeDescription typeDescription)
Checks if this element is accessible from a given type.boolean
isBootstrap()
Checks if the method is a bootstrap method.boolean
isBootstrap(java.util.List<?> arguments)
Checks if the method is a bootstrap method that accepts the given arguments.boolean
isBridgeCompatible(MethodDescription.TypeToken typeToken)
Validates that the supplied type token can implement a bridge method to this method.boolean
isConstructor()
Checks if this method description represents a constructor.boolean
isDefaultMethod()
Checks if this method represents a default (defender) method.boolean
isDefaultValue()
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
isGenerified()
Checks if this type variable source has a generic declaration.boolean
isInvokableOn(TypeDescription typeDescription)
Asserts if this method is invokable on an instance of the given type, i.e.boolean
isMethod()
Checks if this method description represents a method, i.e.boolean
isSpecializableFor(TypeDescription targetType)
Checks if this method can be called using theINVOKESPECIAL
for a given type.boolean
isTypeInitializer()
Checks if this method is a type initializer.boolean
isVirtual()
Verifies if this method describes a virtual method, i.e.boolean
isVisibleTo(TypeDescription typeDescription)
Checks if this element is visible from a given type.boolean
represents(java.lang.reflect.Constructor<?> constructor)
Verifies if a method description represents a given loaded constructor.boolean
represents(java.lang.reflect.Method method)
Verifies if a method description represents a given loaded method.java.lang.String
toGenericString()
Returns a generic string of this byte code element.java.lang.String
toString()
-
Methods inherited from class net.bytebuddy.description.TypeVariableSource.AbstractBase
findVariable
-
Methods inherited from class net.bytebuddy.description.ModifierReviewable.AbstractBase
getEnumerationState, getFieldManifestation, getFieldPersistence, getMethodManifestation, getMethodStrictness, getOwnership, getParameterManifestation, getProvisioningState, getSynchronizationState, getSyntheticState, getTypeManifestation, getVisibility, isAbstract, isAnnotation, isBridge, isDeprecated, isEnum, isFinal, isInterface, isMandated, isNative, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isStrict, isSynchronized, isSynthetic, isTransient, isVarArgs, isVolatile
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.bytebuddy.description.annotation.AnnotationSource
getDeclaredAnnotations
-
Methods inherited from interface net.bytebuddy.description.ByteCodeElement.TypeDependant
asDefined
-
Methods inherited from interface net.bytebuddy.description.DeclaredByType
getDeclaringType
-
Methods inherited from interface net.bytebuddy.description.method.MethodDescription
getDefaultValue, getExceptionTypes, getParameters, getReceiverType, getReturnType
-
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.WithRuntimeName
getInternalName
-
Methods inherited from interface net.bytebuddy.description.TypeVariableSource
findVariable, getTypeVariables
-
-
-
-
Method Detail
-
getStackSize
public int getStackSize()
Description copied from interface:MethodDescription
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.- Specified by:
getStackSize
in interfaceMethodDescription
- Returns:
- The size of this method on the operand stack.
-
isMethod
public boolean isMethod()
Description copied from interface:MethodDescription
Checks if this method description represents a method, i.e. not a constructor or a type initializer.- Specified by:
isMethod
in interfaceMethodDescription
- Returns:
true
if this method description represents a Java method.
-
isConstructor
public boolean isConstructor()
Description copied from interface:MethodDescription
Checks if this method description represents a constructor.- Specified by:
isConstructor
in interfaceMethodDescription
- Returns:
true
if this method description represents a constructor.
-
isTypeInitializer
public boolean isTypeInitializer()
Description copied from interface:MethodDescription
Checks if this method is a type initializer.- Specified by:
isTypeInitializer
in interfaceMethodDescription
- Returns:
true
if this method description represents a type initializer.
-
represents
public boolean represents(java.lang.reflect.Method method)
Description copied from interface:MethodDescription
Verifies if a method description represents a given loaded method.- Specified by:
represents
in interfaceMethodDescription
- Parameters:
method
- The method to be checked.- Returns:
true
if this method description represents the given loaded method.
-
represents
public boolean represents(java.lang.reflect.Constructor<?> constructor)
Description copied from interface:MethodDescription
Verifies if a method description represents a given loaded constructor.- Specified by:
represents
in interfaceMethodDescription
- Parameters:
constructor
- The constructor to be checked.- Returns:
true
if this method description represents the given loaded constructor.
-
getName
public java.lang.String getName()
Description copied from interface:NamedElement.WithRuntimeName
Returns the internalName of this byte code element.- Specified by:
getName
in interfaceNamedElement.WithRuntimeName
- Returns:
- The internalName of this byte code element as visible from within a running Java application.
-
getActualName
public java.lang.String getActualName()
Description copied from interface:NamedElement
Returns the name of this element as it is found in the source code. If no such name exists, an empty string is returned.- Specified by:
getActualName
in interfaceNamedElement
- Returns:
- The name of this element as given in a Java program's source code.
-
getDescriptor
public java.lang.String getDescriptor()
Description copied from interface:ByteCodeElement
Returns the descriptor of this byte code element.- Specified by:
getDescriptor
in interfaceByteCodeElement
- Returns:
- The descriptor of this byte code element.
-
getGenericSignature
public java.lang.String getGenericSignature()
Description copied from interface:ByteCodeElement
Returns the generic signature of this byte code element. If this element does not reference generic types or references malformed generic types,null
is returned as a signature.- Specified by:
getGenericSignature
in interfaceByteCodeElement
- Returns:
- The generic signature or
null
if this element is not generic.
-
getActualModifiers
public int getActualModifiers()
Description copied from interface:MethodDescription
Returns this method's actual modifiers as it is present in a class file, i.e. includes a flag if this method is markedDeprecated
.- Specified by:
getActualModifiers
in interfaceMethodDescription
- Returns:
- The method's actual modifiers.
-
getActualModifiers
public int getActualModifiers(boolean manifest)
Description copied from interface:MethodDescription
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.- Specified by:
getActualModifiers
in interfaceMethodDescription
- Parameters:
manifest
-true
if the method should be treated as non-abstract.- Returns:
- The method's actual modifiers.
-
getActualModifiers
public int getActualModifiers(boolean manifest, Visibility visibility)
Description copied from interface:MethodDescription
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.- Specified by:
getActualModifiers
in interfaceMethodDescription
- 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.
-
isVisibleTo
public boolean isVisibleTo(TypeDescription typeDescription)
Description copied from interface:ByteCodeElement
Checks if this element is visible from a given type. Visibility is a wider criteria then accessibility which can be checked by
ByteCodeElement.isAccessibleTo(TypeDescription)
. Visibility allows the invocation of a method on itself or on external instances.Note: A method or field might define a signature that includes types that are not visible to a type. Such methods can be legally invoked from this type and can even be implemented as bridge methods by this type. It is however not legal to declare a method with invisible types in its signature that are not bridges what might require additional validation.
Important: Virtual byte code elements, i.e. virtual methods, are only considered visible if the type they are invoked upon is visible to a given type. The visibility of such virtual members can therefore not be determined by only investigating the invoked method but requires an additional check of the target type.
- Specified by:
isVisibleTo
in interfaceByteCodeElement
- Parameters:
typeDescription
- The type which is checked for its visibility of this element.- Returns:
true
if this element is visible fortypeDescription
.
-
isAccessibleTo
public boolean isAccessibleTo(TypeDescription typeDescription)
Description copied from interface:ByteCodeElement
Checks if this element is accessible from a given type. Accessibility is a more narrow criteria then visibility which can be checked by
ByteCodeElement.isVisibleTo(TypeDescription)
. Accessibility allows the invocation of a method on external instances or on itself. Methods that can be invoked from within an instance might however not be considered accessible.Note: A method or field might define a signature that includes types that are not visible to a type. Such methods can be legally invoked from this type and can even be implemented as bridge methods by this type. It is however not legal to declare a method with invisible types in its signature that are not bridges what might require additional validation.
Important: Virtual byte code elements, i.e. virtual methods, are only considered visible if the type they are invoked upon is visible to a given type. The visibility of such virtual members can therefore not be determined by only investigating the invoked method but requires an additional check of the target type.
- Specified by:
isAccessibleTo
in interfaceByteCodeElement
- Parameters:
typeDescription
- The type which is checked for its accessibility of this element.- Returns:
true
if this element is accessible fortypeDescription
.
-
isVirtual
public boolean isVirtual()
Description copied from interface:MethodDescription
Verifies if this method describes a virtual method, i.e. a method that is inherited by a sub type of this type.- Specified by:
isVirtual
in interfaceMethodDescription
- Returns:
true
if this method is virtual.
-
isDefaultMethod
public boolean isDefaultMethod()
Description copied from interface:MethodDescription
Checks if this method represents a default (defender) method.- Specified by:
isDefaultMethod
in interfaceMethodDescription
- Returns:
true
if this method is a default method.
-
isSpecializableFor
public boolean isSpecializableFor(TypeDescription targetType)
Description copied from interface:MethodDescription
Checks if this method can be called using theINVOKESPECIAL
for a given type.- Specified by:
isSpecializableFor
in interfaceMethodDescription
- Parameters:
targetType
- The type o- Returns:
true
if this method can be called using theINVOKESPECIAL
instruction using the given type.
-
getDefaultValue
public <T> T getDefaultValue(java.lang.Class<T> type)
Description copied from interface:MethodDescription
Returns the default value but casts it to the given type. If the type differs from the value, aClassCastException
is thrown.- Specified by:
getDefaultValue
in interfaceMethodDescription
- 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
public boolean isInvokableOn(TypeDescription typeDescription)
Description copied from interface:MethodDescription
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.- Specified by:
isInvokableOn
in interfaceMethodDescription
- Parameters:
typeDescription
- The type to check.- Returns:
true
if this method is invokable on an instance of the given type.
-
isBootstrap
public boolean isBootstrap()
Description copied from interface:MethodDescription
Checks if the method is a bootstrap method.- Specified by:
isBootstrap
in interfaceMethodDescription
- Returns:
true
if the method is a bootstrap method.
-
isBootstrap
public boolean isBootstrap(java.util.List<?> arguments)
Description copied from interface:MethodDescription
Checks if the method is a bootstrap method that accepts the given arguments.- Specified by:
isBootstrap
in interfaceMethodDescription
- Parameters:
arguments
- The arguments that the bootstrap method is expected to accept where primitive values are to be represented as their wrapper types, loaded types byTypeDescription
, method handles byJavaConstant.MethodHandle
instances and method types byJavaConstant.MethodType
instances.- Returns:
true
if the method is a bootstrap method that accepts the given arguments.
-
isDefaultValue
public boolean isDefaultValue()
Description copied from interface:MethodDescription
Checks if this method is capable of defining a default annotation value.- Specified by:
isDefaultValue
in interfaceMethodDescription
- Returns:
true
if it is possible to define a default annotation value for this method.
-
isDefaultValue
public boolean isDefaultValue(AnnotationValue<?,?> annotationValue)
Description copied from interface:MethodDescription
Checks if the given value can describe a default annotation value for this method.- Specified by:
isDefaultValue
in interfaceMethodDescription
- 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.
-
getEnclosingSource
public TypeVariableSource getEnclosingSource()
Description copied from interface:TypeVariableSource
Returns the enclosing source of type variables that are valid in the scope of this type variable source.- Specified by:
getEnclosingSource
in interfaceTypeVariableSource
- Returns:
- The enclosing source or
null
if no such source exists.
-
accept
public <T> T accept(TypeVariableSource.Visitor<T> visitor)
Description copied from interface:TypeVariableSource
Applies a visitor on this type variable source.- Specified by:
accept
in interfaceTypeVariableSource
- Type Parameters:
T
- The visitor's return type.- Parameters:
visitor
- The visitor to apply.- Returns:
- The visitor's return value.
-
isGenerified
public boolean isGenerified()
Description copied from interface:TypeVariableSource
Checks if this type variable source has a generic declaration. This means:- A type declares type variables or is an inner class of a type with a generic declaration.
- A method declares at least one type variable.
- Specified by:
isGenerified
in interfaceTypeVariableSource
- Returns:
true
if this type code element has a generic declaration.
-
asToken
public MethodDescription.Token asToken(ElementMatcher<? super TypeDescription> matcher)
Description copied from interface:ByteCodeElement.TypeDependant
Returns a token representative of this type dependant. All types that are matched by the supplied matcher are replaced byTargetType
descriptions.- Specified by:
asToken
in interfaceByteCodeElement.TypeDependant<MethodDescription.InDefinedShape,MethodDescription.Token>
- Parameters:
matcher
- A matcher to identify types to be replaced byTargetType
descriptions.- Returns:
- A token representative of this type dependant.
-
asSignatureToken
public MethodDescription.SignatureToken asSignatureToken()
Description copied from interface:MethodDescription
Returns a signature token representing this method.- Specified by:
asSignatureToken
in interfaceMethodDescription
- Returns:
- A signature token representing this method.
-
asTypeToken
public MethodDescription.TypeToken asTypeToken()
Description copied from interface:MethodDescription
Returns a type token that represents this method's raw return and parameter types.- Specified by:
asTypeToken
in interfaceMethodDescription
- Returns:
- A type token that represents this method's raw return and parameter types.
-
isBridgeCompatible
public boolean isBridgeCompatible(MethodDescription.TypeToken typeToken)
Description copied from interface:MethodDescription
Validates that the supplied type token can implement a bridge method to this method.- Specified by:
isBridgeCompatible
in interfaceMethodDescription
- 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.
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toGenericString
public java.lang.String toGenericString()
Description copied from interface:NamedElement.WithGenericName
Returns a generic string of this byte code element.- Specified by:
toGenericString
in interfaceNamedElement.WithGenericName
- Returns:
- A generic string of this byte code element.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-