public abstract static class MethodDescription.AbstractBase extends TypeVariableSource.AbstractBase implements MethodDescription
MethodDescription.AbstractBase, MethodDescription.ForLoadedConstructor, MethodDescription.ForLoadedMethod, MethodDescription.InDefinedShape, MethodDescription.InGenericShape, MethodDescription.Latent, MethodDescription.SignatureToken, MethodDescription.Token, MethodDescription.TypeSubstituting, MethodDescription.TypeToken
TypeVariableSource.Visitor<T>
ModifierReviewable.ForFieldDescription, ModifierReviewable.ForMethodDescription, ModifierReviewable.ForParameterDescription, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumeration
ByteCodeElement.TypeDependant<T extends ByteCodeElement.TypeDependant<?,S>,S extends ByteCodeElement.Token<S>>
NamedElement.WithDescriptor, NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeName
DeclaredByType.WithMandatoryDeclaration
AnnotationSource.Empty, AnnotationSource.Explicit
CONSTRUCTOR_INTERNAL_NAME, TYPE_INITIALIZER_INTERNAL_NAME, TYPE_INITIALIZER_MODIFIER, UNDEFINED
EMPTY_MASK
NON_GENERIC_SIGNATURE
EMPTY_NAME, NO_NAME
Constructor and Description |
---|
AbstractBase() |
Modifier and Type | Method and 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(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.
|
String |
getActualName()
Returns the display name of this element as it is found in the source code.
|
<T> T |
getDefaultValue(Class<T> type)
Returns the default value but casts it to the given type.
|
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.
|
String |
getGenericSignature()
Returns the generic signature of this byte code element.
|
String |
getName()
Returns the binary name 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 |
isBridgeCompatible(MethodDescription.TypeToken typeToken)
Validates that the supplied type token can implement a bridge method to this method.
|
boolean |
isConstantBootstrap()
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 an constantdynamic call.
|
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 |
isInferrable()
Returns
true if type variables declared by this type variable source allow dynamic type inference. |
boolean |
isInvokableOn(TypeDescription typeDescription)
Asserts if this method is invokable on an instance of the given type, i.e.
|
boolean |
isInvokeBootstrap()
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 targetType)
Checks if this method can be called using the
INVOKESPECIAL 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(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.
|
String |
toGenericString()
Returns a generic string of this byte code element.
|
protected String |
toSafeString()
Returns a
Object.toString() representation that does not attempt to resolve any
type variables to avoid stack overflow exceptions. |
String |
toString() |
findExpectedVariable, findVariable
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
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getDefaultValue, getExceptionTypes, getParameters, getReceiverType, getReturnType
findExpectedVariable, findVariable, getTypeVariables
getDeclaringType
getMethodManifestation, getMethodStrictness, getSynchronizationState, isBridge, isNative, isStrict, isSynchronized, isVarArgs
isAbstract
getOwnership, getVisibility, isDeprecated, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic
getModifiers, getSyntheticState, isFinal, isSynthetic
getInternalName
getDeclaredAnnotations
asDefined
public int getStackSize()
this
if this method represented a non-static
method.getStackSize
in interface MethodDescription
public boolean isMethod()
isMethod
in interface MethodDescription
true
if this method description represents a Java method.public boolean isConstructor()
isConstructor
in interface MethodDescription
true
if this method description represents a constructor.public boolean isTypeInitializer()
isTypeInitializer
in interface MethodDescription
true
if this method description represents a type initializer.public boolean represents(Method method)
represents
in interface MethodDescription
method
- The method to be checked.true
if this method description represents the given loaded method.public boolean represents(Constructor<?> constructor)
represents
in interface MethodDescription
constructor
- The constructor to be checked.true
if this method description represents the given loaded constructor.public String getName()
getName
in interface NamedElement.WithRuntimeName
public String getActualName()
getActualName
in interface NamedElement
public String getDescriptor()
getDescriptor
in interface NamedElement.WithDescriptor
@MaybeNull public String getGenericSignature()
null
is returned as a signature.getGenericSignature
in interface NamedElement.WithDescriptor
null
if this element is not generic.public int getActualModifiers()
Deprecated
.getActualModifiers
in interface MethodDescription
public int getActualModifiers(boolean manifest)
Deprecated
and adjusts the modifiers for being abstract or not.getActualModifiers
in interface MethodDescription
manifest
- true
if the method should be treated as non-abstract.public int getActualModifiers(boolean manifest, Visibility visibility)
Deprecated
and adjusts the modifiers for being abstract or not. Additionally, this method
resolves a required minimal visibility.getActualModifiers
in interface MethodDescription
manifest
- true
if the method should be treated as non-abstract.visibility
- The minimal visibility to enforce for this method.public boolean isVisibleTo(TypeDescription typeDescription)
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.
isVisibleTo
in interface ByteCodeElement
typeDescription
- The type which is checked for its visibility of this element.true
if this element is visible for typeDescription
.public boolean isAccessibleTo(TypeDescription typeDescription)
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.
isAccessibleTo
in interface ByteCodeElement
typeDescription
- The type which is checked for its accessibility of this element.true
if this element is accessible for typeDescription
.public boolean isVirtual()
isVirtual
in interface MethodDescription
true
if this method is virtual.public boolean isDefaultMethod()
isDefaultMethod
in interface MethodDescription
true
if this method is a default method.public boolean isSpecializableFor(TypeDescription targetType)
INVOKESPECIAL
for a given type.isSpecializableFor
in interface MethodDescription
targetType
- The type otrue
if this method can be called using the INVOKESPECIAL
instruction
using the given type.@MaybeNull public <T> T getDefaultValue(Class<T> type)
ClassCastException
is thrown.getDefaultValue
in interface MethodDescription
T
- The type to cast the default value to.type
- The type to cast the default value to.public boolean isInvokableOn(TypeDescription typeDescription)
isInvokableOn
in interface MethodDescription
typeDescription
- The type to check.true
if this method is invokable on an instance of the given type.public boolean isInvokeBootstrap()
isInvokeBootstrap
in interface MethodDescription
true
if this method is a valid bootstrap method for an invokedynamic call.public boolean isInvokeBootstrap(List<? extends TypeDefinition> arguments)
isInvokeBootstrap
in interface MethodDescription
arguments
- The types of the explicit arguments that are supplied to the bootstrap method.true
if this method is a valid bootstrap method for an invokedynamic call.public boolean isConstantBootstrap()
isConstantBootstrap
in interface MethodDescription
true
if this method is a valid bootstrap method for an constantdynamic call.public boolean isConstantBootstrap(List<? extends TypeDefinition> arguments)
isConstantBootstrap
in interface MethodDescription
arguments
- The types of the explicit arguments that are supplied to the bootstrap method.true
if this method is a valid bootstrap method for an constantdynamic call.public boolean isDefaultValue()
isDefaultValue
in interface MethodDescription
true
if it is possible to define a default annotation value for this method.public boolean isDefaultValue(AnnotationValue<?,?> annotationValue)
isDefaultValue
in interface MethodDescription
annotationValue
- The value that describes the default annotation value for this method.true
if the given value can describe a default annotation value for this method.@MaybeNull public TypeVariableSource getEnclosingSource()
getEnclosingSource
in interface TypeVariableSource
null
if no such source exists.public boolean isInferrable()
true
if type variables declared by this type variable source allow dynamic type inference.isInferrable
in interface TypeVariableSource
true
if type variables declared by this type variable source allow dynamic type inference.public <T> T accept(TypeVariableSource.Visitor<T> visitor)
accept
in interface TypeVariableSource
T
- The visitor's return type.visitor
- The visitor to apply.public boolean isGenerified()
isGenerified
in interface TypeVariableSource
true
if this type code element has a generic declaration.public MethodDescription.Token asToken(ElementMatcher<? super TypeDescription> matcher)
TargetType
descriptions.asToken
in interface ByteCodeElement.TypeDependant<MethodDescription.InDefinedShape,MethodDescription.Token>
matcher
- A matcher to identify types to be replaced by TargetType
descriptions.public MethodDescription.SignatureToken asSignatureToken()
asSignatureToken
in interface MethodDescription
public MethodDescription.TypeToken asTypeToken()
asTypeToken
in interface MethodDescription
public boolean isBridgeCompatible(MethodDescription.TypeToken typeToken)
isBridgeCompatible
in interface MethodDescription
typeToken
- A type token representing a potential bridge method to this method.true
if the supplied type token can represent a bridge method to this method.@CachedReturnPlugin.Enhance(value="hashCode") public int hashCode()
public boolean equals(@MaybeNull Object other)
public String toGenericString()
toGenericString
in interface NamedElement.WithGenericName
protected String toSafeString()
TypeVariableSource.AbstractBase
Object.toString()
representation that does not attempt to resolve any
type variables to avoid stack overflow exceptions.toSafeString
in class TypeVariableSource.AbstractBase
Copyright © 2014–2023. All rights reserved.