Class MethodDescription.AbstractBase
- All Implemented Interfaces:
AnnotationSource,ByteCodeElement,ByteCodeElement.Member,ByteCodeElement.TypeDependant<MethodDescription.InDefinedShape,,MethodDescription.Token> DeclaredByType,DeclaredByType.WithMandatoryDeclaration,MethodDescription,ModifierReviewable,ModifierReviewable.ForFieldDescription,ModifierReviewable.ForMethodDescription,ModifierReviewable.ForParameterDescription,ModifierReviewable.ForTypeDefinition,ModifierReviewable.OfAbstraction,ModifierReviewable.OfByteCodeElement,ModifierReviewable.OfEnumeration,NamedElement,NamedElement.WithDescriptor,NamedElement.WithGenericName,NamedElement.WithRuntimeName,TypeVariableSource
- Direct Known Subclasses:
MethodDescription.InDefinedShape.AbstractBase,MethodDescription.TypeSubstituting,Transformer.ForMethod.TransformedMethod
- Enclosing interface:
MethodDescription
-
Nested Class Summary
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.method.MethodDescription
MethodDescription.AbstractBase, MethodDescription.ForLoadedConstructor, MethodDescription.ForLoadedMethod, MethodDescription.InDefinedShape, MethodDescription.InGenericShape, MethodDescription.Latent, MethodDescription.SignatureToken, MethodDescription.Token, MethodDescription.TypeSubstituting, MethodDescription.TypeTokenNested classes/interfaces inherited from interface net.bytebuddy.description.ModifierReviewable
ModifierReviewable.AbstractBase, 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.AbstractBase, TypeVariableSource.Visitor<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intA merger of all method modifiers that are visible in the Java source code.Fields inherited from interface net.bytebuddy.description.method.MethodDescription
CONSTRUCTOR_INTERNAL_NAME, TYPE_INITIALIZER_INTERNAL_NAME, TYPE_INITIALIZER_MODIFIER, UNDEFINEDFields 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_SIGNATUREFields inherited from interface net.bytebuddy.description.TypeVariableSource
UNDEFINED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(TypeVariableSource.Visitor<T> visitor) Applies a visitor on this type variable source.Returns a signature token representing this method.asToken(ElementMatcher<? super TypeDescription> matcher) Returns a token representative of this type dependant.Returns a type token that represents this method's raw return and parameter types.booleanintReturns 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.Returns the display name of this element as it is found in the source code.<T> TgetDefaultValue(Class<T> type) Returns the default value but casts it to the given type.Returns the descriptor of this byte code element.Returns the enclosing source of type variables that are valid in the scope of this type variable source.Returns the generic signature of this byte code element.getName()Returns the binary name of this byte code element.intReturns the size of the local variable array that is required for this method, i.e.inthashCode()booleanisAccessibleTo(TypeDescription typeDescription) Checks if this element is accessible from a given type.private static booleanisAnnotationType(TypeDescription annotationType, AnnotationDescription... annotationDescription) Checks if the supplied enumeration descriptions describe the correct annotation type.private booleanisBootstrap(TypeDescription bootstrapped) Checks if this method is a bootstrap method while expecting the supplied type as a type representation.private booleanisBootstrapping(List<? extends TypeDefinition> arguments) Checks if this method is a bootstrap method given the supplied arguments.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.private static booleanisEnumerationType(TypeDescription enumerationType, EnumerationDescription... enumerationDescription) Checks if the supplied enumeration descriptions describe the correct enumeration type.booleanChecks if this type variable source has a generic declaration.booleanReturnstrueif type variables declared by this type variable source allow dynamic type inference.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 targetType) 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.booleanisVisibleTo(TypeDescription typeDescription) Checks if this element is visible from a given type.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.Returns a generic string of this byte code element.protected StringReturns aObject.toString()representation that does not attempt to resolve any type variables to avoid stack overflow exceptions.toString()Methods inherited from class net.bytebuddy.description.TypeVariableSource.AbstractBase
findExpectedVariable, findVariableMethods 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, isVolatileMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.bytebuddy.description.annotation.AnnotationSource
getDeclaredAnnotationsMethods inherited from interface net.bytebuddy.description.ByteCodeElement.TypeDependant
asDefinedMethods inherited from interface net.bytebuddy.description.DeclaredByType.WithMandatoryDeclaration
getDeclaringTypeMethods inherited from interface net.bytebuddy.description.method.MethodDescription
getDefaultValue, getExceptionTypes, getParameters, getReceiverType, getReturnTypeMethods 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.WithRuntimeName
getInternalNameMethods inherited from interface net.bytebuddy.description.TypeVariableSource
findExpectedVariable, findVariable, getTypeVariables
-
Field Details
-
SOURCE_MODIFIERS
private static final int SOURCE_MODIFIERSA merger of all method modifiers that are visible in the Java source code.- See Also:
-
-
Constructor Details
-
AbstractBase
public AbstractBase()
-
-
Method Details
-
getStackSize
public 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.- Specified by:
getStackSizein interfaceMethodDescription- Returns:
- The size of this method on the operand stack.
-
isMethod
public boolean isMethod()Checks if this method description represents a method, i.e. not a constructor or a type initializer.- Specified by:
isMethodin interfaceMethodDescription- Returns:
trueif this method description represents a Java method.
-
isConstructor
public boolean isConstructor()Checks if this method description represents a constructor.- Specified by:
isConstructorin interfaceMethodDescription- Returns:
trueif this method description represents a constructor.
-
isTypeInitializer
public boolean isTypeInitializer()Checks if this method is a type initializer.- Specified by:
isTypeInitializerin interfaceMethodDescription- Returns:
trueif this method description represents a type initializer.
-
represents
Verifies if a method description represents a given loaded method.- Specified by:
representsin interfaceMethodDescription- 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.- Specified by:
representsin interfaceMethodDescription- Parameters:
constructor- The constructor to be checked.- Returns:
trueif this method description represents the given loaded constructor.
-
getName
Returns the binary name of this byte code element. If no well-defined internal name is known for this element, the actual name is returned.- Specified by:
getNamein interfaceNamedElement.WithRuntimeName- Returns:
- The binary ame of this byte code element as visible from within a running Java application.
-
getActualName
Returns the display name of this element as it is found in the source code. If no such name exists, an empty string is returned.- Specified by:
getActualNamein interfaceNamedElement- Returns:
- The name of this element as given in a Java program's source code.
-
getDescriptor
Returns the descriptor of this byte code element.- Specified by:
getDescriptorin interfaceNamedElement.WithDescriptor- Returns:
- The descriptor of this byte code element.
-
getGenericSignature
Returns the generic signature of this byte code element. If this element does not reference generic types or references malformed generic types,nullis returned as a signature.- Specified by:
getGenericSignaturein interfaceNamedElement.WithDescriptor- Returns:
- The generic signature or
nullif this element is not generic.
-
getActualModifiers
public 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.- Specified by:
getActualModifiersin interfaceMethodDescription- Returns:
- The method's actual modifiers.
-
getActualModifiers
public 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.- Specified by:
getActualModifiersin interfaceMethodDescription- 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.- Specified by:
getActualModifiersin interfaceMethodDescription- 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.
-
isVisibleTo
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:
isVisibleToin interfaceByteCodeElement- Parameters:
typeDescription- The type which is checked for its visibility of this element.- Returns:
trueif this element is visible fortypeDescription.
-
isAccessibleTo
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:
isAccessibleToin interfaceByteCodeElement- Parameters:
typeDescription- The type which is checked for its accessibility of this element.- Returns:
trueif this element is accessible fortypeDescription.
-
isVirtual
public boolean isVirtual()Verifies if this method describes a virtual method, i.e. a method that is inherited by a sub type of this type.- Specified by:
isVirtualin interfaceMethodDescription- Returns:
trueif this method is virtual.
-
isDefaultMethod
public boolean isDefaultMethod()Checks if this method represents a default (defender) method.- Specified by:
isDefaultMethodin interfaceMethodDescription- Returns:
trueif this method is a default method.
-
isSpecializableFor
Checks if this method can be called using theINVOKESPECIALfor a given type.- Specified by:
isSpecializableForin interfaceMethodDescription- Parameters:
targetType- The type o- Returns:
trueif this method can be called using theINVOKESPECIALinstruction using the given type.
-
getDefaultValue
Returns the default value but casts it to the given type. If the type differs from the value, aClassCastExceptionis thrown.- Specified by:
getDefaultValuein 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
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:
isInvokableOnin interfaceMethodDescription- Parameters:
typeDescription- The type to check.- Returns:
trueif this method is invokable on an instance of the given type.
-
isBootstrap
Checks if this method is a bootstrap method while expecting the supplied type as a type representation.- Parameters:
bootstrapped- The type of the bootstrap method's type representation.- Returns:
trueif this method is a bootstrap method assuming the supplied type representation.
-
isBootstrapping
Checks if this method is a bootstrap method given the supplied arguments. This method does not implement a full check but assumes thatisBootstrap(TypeDescription)is invoked, as well.- Parameters:
arguments- The types of the explicit arguments that are supplied to the bootstrap method.- Returns:
trueif this method is a bootstrap method for the supplied arguments.
-
isInvokeBootstrap
public boolean isInvokeBootstrap()Checks if this method is a valid bootstrap method for an invokedynamic call.- Specified by:
isInvokeBootstrapin interfaceMethodDescription- 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.- Specified by:
isInvokeBootstrapin interfaceMethodDescription- 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
public boolean isConstantBootstrap()Checks if this method is a valid bootstrap method for an constantdynamic call.- Specified by:
isConstantBootstrapin interfaceMethodDescription- 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.- Specified by:
isConstantBootstrapin interfaceMethodDescription- 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
public boolean isDefaultValue()Checks if this method is capable of defining a default annotation value.- Specified by:
isDefaultValuein interfaceMethodDescription- 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.- Specified by:
isDefaultValuein interfaceMethodDescription- 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.
-
isEnumerationType
private static boolean isEnumerationType(TypeDescription enumerationType, EnumerationDescription... enumerationDescription) Checks if the supplied enumeration descriptions describe the correct enumeration type.- Parameters:
enumerationType- The enumeration type to check for.enumerationDescription- The enumeration descriptions to check.- Returns:
trueif all enumeration descriptions represent the enumeration type in question.
-
isAnnotationType
private static boolean isAnnotationType(TypeDescription annotationType, AnnotationDescription... annotationDescription) Checks if the supplied enumeration descriptions describe the correct annotation type.- Parameters:
annotationType- The annotation type to check for.annotationDescription- The annotation descriptions to check.- Returns:
trueif all annotation descriptions represent the annotation type in question.
-
getEnclosingSource
Returns the enclosing source of type variables that are valid in the scope of this type variable source.- Specified by:
getEnclosingSourcein interfaceTypeVariableSource- Returns:
- The enclosing source or
nullif no such source exists.
-
isInferrable
public boolean isInferrable()Returnstrueif type variables declared by this type variable source allow dynamic type inference.- Specified by:
isInferrablein interfaceTypeVariableSource- Returns:
trueif type variables declared by this type variable source allow dynamic type inference.
-
accept
Applies a visitor on this type variable source.- Specified by:
acceptin 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()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.
- A type is a class that is declared within a method with a generic declaration.
- Specified by:
isGenerifiedin interfaceTypeVariableSource- Returns:
trueif this type code element has a generic declaration.
-
asToken
Returns a token representative of this type dependant. All types that are matched by the supplied matcher are replaced byTargetTypedescriptions.- Specified by:
asTokenin interfaceByteCodeElement.TypeDependant<MethodDescription.InDefinedShape,MethodDescription.Token> - Parameters:
matcher- A matcher to identify types to be replaced byTargetTypedescriptions.- Returns:
- A token representative of this type dependant.
-
asSignatureToken
Returns a signature token representing this method.- Specified by:
asSignatureTokenin interfaceMethodDescription- Returns:
- A signature token representing this method.
-
asTypeToken
Returns a type token that represents this method's raw return and parameter types.- Specified by:
asTypeTokenin interfaceMethodDescription- 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.- Specified by:
isBridgeCompatiblein interfaceMethodDescription- 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.
-
hashCode
-
equals
-
toGenericString
Returns a generic string of this byte code element.- Specified by:
toGenericStringin interfaceNamedElement.WithGenericName- Returns:
- A generic string of this byte code element.
-
toString
-
toSafeString
Description copied from class:TypeVariableSource.AbstractBaseReturns aObject.toString()representation that does not attempt to resolve any type variables to avoid stack overflow exceptions.- Specified by:
toSafeStringin classTypeVariableSource.AbstractBase- Returns:
- A safe string representation.
-