Class TypeDescription.AbstractBase
- All Implemented Interfaces:
Iterable<TypeDefinition>,AnnotationSource,ByteCodeElement,DeclaredByType,ModifierReviewable,ModifierReviewable.ForFieldDescription,ModifierReviewable.ForMethodDescription,ModifierReviewable.ForParameterDescription,ModifierReviewable.ForTypeDefinition,ModifierReviewable.OfAbstraction,ModifierReviewable.OfByteCodeElement,ModifierReviewable.OfEnumeration,NamedElement,NamedElement.WithDescriptor,NamedElement.WithRuntimeName,TypeDefinition,TypeDescription,TypeVariableSource
- Direct Known Subclasses:
TypeDescription.AbstractBase.OfSimpleType,TypeDescription.ArrayProjection,TypeDescription.ForLoadedType,TypeDescription.SuperTypeLoading
- Enclosing interface:
TypeDescription
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn adapter implementation of aTypeDescriptionthat describes any type that is not an array or a primitive type.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.Token<T extends ByteCodeElement.Token<T>>, 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.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.type.TypeDefinition
TypeDefinition.Sort, TypeDefinition.SuperClassIteratorNested classes/interfaces inherited from interface net.bytebuddy.description.type.TypeDescription
TypeDescription.AbstractBase, TypeDescription.ArrayProjection, TypeDescription.ForLoadedType, TypeDescription.ForPackageDescription, TypeDescription.Generic, TypeDescription.Latent, TypeDescription.LazyProxy, TypeDescription.SuperTypeLoadingNested classes/interfaces inherited from interface net.bytebuddy.description.TypeVariableSource
TypeVariableSource.AbstractBase, TypeVariableSource.Visitor<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanTheTypeDefinition.RAW_TYPES_PROPERTYproperty.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_SIGNATUREFields inherited from interface net.bytebuddy.description.type.TypeDefinition
RAW_TYPES_PROPERTYFields inherited from interface net.bytebuddy.description.type.TypeDescription
ARRAY_INTERFACES, CLASS, OBJECT, STRING, THROWABLE, UNDEFINED, VOIDFields 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.asBoxed()Returns a description of this type that represents this type as a boxed type for primitive types, unless itsvoid.Returns the erasure of this type.Returns this type definition as a generic type.Returns a description of this type that represents this type as an unboxed type for boxing types, unless itsVoid.private static <T> TdoPrivileged(PrivilegedAction<T> action) A proxy forjava.security.AccessController#doPrivilegedthat is activated if available.booleanintgetActualModifiers(boolean superFlag) Returns the type's actual modifiers as present in the class file.Returns the display name of this element as it is found in the source code.Attempts to resolve the class file version of this type.Returns the default value for this type, i.e.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.Returns the annotations that this type declares or inherits from super types.intReturns the amount of outer classes this type defines.Returns the internal name of this byte code element.Returns a form of a type's simple name which only shortens the package name but not the names of outer classes.getSort()Returns the sort of the generic type this instance represents.Returns the name of the type.inthashCode()booleanisAccessibleTo(TypeDescription typeDescription) Checks if this element is accessible from a given type.booleanChecks if instances of this type can be returned from an annotation method.booleanChecks if instances of this type can be used for describing an annotation value.booleanisAnnotationValue(Object value) Checks if instances of this type can be used for describing the given annotation value.private static booleanisAssignable(TypeDescription sourceType, TypeDescription targetType) Checks if a specific type is assignable to another type where the source type must be a super type of the target type.booleanisAssignableFrom(Class<?> type) Checks if this type is assignable from the type described by this instance, for example forclass Fooandclass Bar extends Foo, this method would returntrueforFoo.class.isAssignableFrom(Bar.class).booleanisAssignableFrom(TypeDescription typeDescription) Checks if this type is assignable from the type described by this instance, for example forclass Fooandclass Bar extends Foo, this method would returntrueforFoo.class.isAssignableFrom(Bar.class).booleanisAssignableTo(Class<?> type) Checks if this type is assignable from the type described by this instance, for example forclass Fooandclass Bar extends Foo, this method would returntrueforBar.class.isAssignableTo(Foo.class).booleanisAssignableTo(TypeDescription typeDescription) Checks if this type is assignable from the type described by this instance, for example forclass Fooandclass Bar extends Foo, this method would returntrueforBar.class.isAssignableFrom(Foo.class).booleanIndicates if this type represents a compile-time constant, i.e.booleanChecks if this type variable source has a generic declaration.booleanReturnstrueif type variables declared by this type variable source allow dynamic type inference.booleanisInHierarchyWith(Class<?> type) Returnstrueif this type and the supplied type are in a type hierarchy with each other, i.e.booleanisInHierarchyWith(TypeDescription typeDescription) Returnstrueif this type and the supplied type are in a type hierarchy with each other, i.e.booleanIndicates if this class is an inner class.booleanisInstance(Object value) Checks ifvalueis an instance of the type represented by this instance.booleanChecks if this type description represents a member type.booleanIndicates if this class is a nested class.booleanChecks if this class is the host of a nest group.booleanisNestMateOf(Class<?> type) Checks if this type and the supplied type are members of the same nest group.booleanisNestMateOf(TypeDescription typeDescription) Checks if this type and the supplied type are members of the same nest group.booleanChecks if this type represents a class that is a place holder for a package description.booleanChecks if this type represents a wrapper type for a primitive type.booleanisSamePackage(TypeDescription typeDescription) Checks if two types are defined in the same package.booleanisSealed()Returnstrueif this class is a sealed class that only permitts a specified range of subclasses.booleanisVisibleTo(TypeDescription typeDescription) Checks if this element is visible from a given type.iterator()booleanrepresents(Type type) Checks if the type described by this instance representstype.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 java.lang.Iterable
forEach, spliteratorMethods inherited from interface net.bytebuddy.description.ModifierReviewable
getModifiers, getSyntheticState, isFinal, isSyntheticMethods inherited from interface net.bytebuddy.description.ModifierReviewable.ForTypeDefinition
getTypeManifestation, isAnnotation, isInterfaceMethods 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.ModifierReviewable.OfEnumeration
getEnumerationState, isEnumMethods inherited from interface net.bytebuddy.description.NamedElement.WithDescriptor
getDescriptorMethods inherited from interface net.bytebuddy.description.NamedElement.WithRuntimeName
getNameMethods inherited from interface net.bytebuddy.description.type.TypeDefinition
getInterfaces, getStackSize, getSuperClass, isArray, isPrimitive, isRecordMethods inherited from interface net.bytebuddy.description.type.TypeDescription
getCanonicalName, getComponentType, getDeclaredFields, getDeclaredMethods, getDeclaredTypes, getDeclaringType, getEnclosingMethod, getEnclosingType, getNestHost, getNestMembers, getPackage, getPermittedSubtypes, getRecordComponents, getSimpleName, isAnonymousType, isLocalTypeMethods inherited from interface net.bytebuddy.description.TypeVariableSource
findExpectedVariable, findVariable, getTypeVariables
-
Field Details
-
RAW_TYPES
public static final boolean RAW_TYPESTheTypeDefinition.RAW_TYPES_PROPERTYproperty.
-
-
Constructor Details
-
AbstractBase
public AbstractBase()
-
-
Method Details
-
doPrivileged
A proxy forjava.security.AccessController#doPrivilegedthat is activated if available.- Type Parameters:
T- The type of the action's resolved value.- Parameters:
action- The action to execute from a privileged context.- Returns:
- The action's resolved value.
-
isAssignable
Checks if a specific type is assignable to another type where the source type must be a super type of the target type.- Parameters:
sourceType- The source type to which another type is to be assigned to.targetType- The target type that is to be assigned to the source type.- Returns:
trueif the target type is assignable to the source type.
-
isAssignableFrom
Checks if this type is assignable from the type described by this instance, for example forclass Fooandclass Bar extends Foo, this method would returntrueforFoo.class.isAssignableFrom(Bar.class).- Specified by:
isAssignableFromin interfaceTypeDescription- Parameters:
type- The type of interest.- Returns:
trueif this type is assignable fromtype.
-
isAssignableFrom
Checks if this type is assignable from the type described by this instance, for example forclass Fooandclass Bar extends Foo, this method would returntrueforFoo.class.isAssignableFrom(Bar.class).
Implementations of this methods are allowed to delegate toTypeDescription.isAssignableFrom(Class)- Specified by:
isAssignableFromin interfaceTypeDescription- Parameters:
typeDescription- The type of interest.- Returns:
trueif this type is assignable fromtype.
-
isAssignableTo
Checks if this type is assignable from the type described by this instance, for example forclass Fooandclass Bar extends Foo, this method would returntrueforBar.class.isAssignableTo(Foo.class).- Specified by:
isAssignableToin interfaceTypeDescription- Parameters:
type- The type of interest.- Returns:
trueif this type is assignable totype.
-
isAssignableTo
Checks if this type is assignable from the type described by this instance, for example forclass Fooandclass Bar extends Foo, this method would returntrueforBar.class.isAssignableFrom(Foo.class).
Implementations of this methods are allowed to delegate toTypeDescription.isAssignableTo(Class)- Specified by:
isAssignableToin interfaceTypeDescription- Parameters:
typeDescription- The type of interest.- Returns:
trueif this type is assignable totype.
-
isInHierarchyWith
Returnstrueif this type and the supplied type are in a type hierarchy with each other, i.e. if this type is assignable to the supplied type or the other way around.- Specified by:
isInHierarchyWithin interfaceTypeDescription- Parameters:
type- The type of interest.- Returns:
trueif this type and the supplied type are in a type hierarchy with each other.
-
isInHierarchyWith
Returnstrueif this type and the supplied type are in a type hierarchy with each other, i.e. if this type is assignable to the supplied type or the other way around.- Specified by:
isInHierarchyWithin interfaceTypeDescription- Parameters:
typeDescription- The type of interest.- Returns:
trueif this type and the supplied type are in a type hierarchy with each other.
-
asErasure
Returns the erasure of this type. Wildcard types (TypeDefinition.Sort.WILDCARD) do not have a well-defined erasure and cause anIllegalStateExceptionto be thrown.- Specified by:
asErasurein interfaceTypeDefinition- Returns:
- The erasure of this type.
-
asGenericType
Returns this type definition as a generic type.- Specified by:
asGenericTypein interfaceTypeDefinition- Returns:
- This type definition represented as a generic type.
-
getSort
Returns the sort of the generic type this instance represents.- Specified by:
getSortin interfaceTypeDefinition- Returns:
- The sort of the generic type.
-
isInstance
Checks ifvalueis an instance of the type represented by this instance.- Specified by:
isInstancein interfaceTypeDescription- Parameters:
value- The object of interest.- Returns:
trueif the object is an instance of the type described by this instance.
-
isAnnotationValue
Checks if instances of this type can be used for describing the given annotation value.- Specified by:
isAnnotationValuein interfaceTypeDescription- Parameters:
value- The value that is supposed to describe the annotation value for this instance.- Returns:
trueif instances of this type can be used for describing the given annotation value..
-
getInternalName
Returns the internal name of this byte code element. If no well-defined internal name is known for this element, the actual name is returned.- Specified by:
getInternalNamein interfaceNamedElement.WithRuntimeName- Returns:
- The internal name of this byte code element as used within the Java class file format.
-
getActualModifiers
public int getActualModifiers(boolean superFlag) Returns the type's actual modifiers as present in the class file. For example, a type cannot beprivate. but it modifiers might reflect this property nevertheless if a class was defined as a private inner class. The returned modifiers take also into account if the type is marked asDeprecated. Anonymous classes that are enclosed in a static method or the type initializer are additionally marked asfinalas it is also done by the Java compiler.- Specified by:
getActualModifiersin interfaceTypeDescription- Parameters:
superFlag-trueif the modifier's super flag should be set.- Returns:
- The type's actual modifiers.
-
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.
-
isSamePackage
Checks if two types are defined in the same package.- Specified by:
isSamePackagein interfaceTypeDescription- Parameters:
typeDescription- The type of interest.- Returns:
trueif this type and the given type are in the same package.
-
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.
-
getInheritedAnnotations
Returns the annotations that this type declares or inherits from super types.- Specified by:
getInheritedAnnotationsin interfaceTypeDescription- Returns:
- A list of all inherited annotations.
-
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.
-
getLongSimpleName
Returns a form of a type's simple name which only shortens the package name but not the names of outer classes.- Specified by:
getLongSimpleNamein interfaceTypeDescription- Returns:
- The long form of the simple name of this type.
-
isPrimitiveWrapper
public boolean isPrimitiveWrapper()Checks if this type represents a wrapper type for a primitive type. TheVoidtype is not considered to be a wrapper type.- Specified by:
isPrimitiveWrapperin interfaceTypeDescription- Returns:
trueif this type represents a wrapper type.
-
isAnnotationReturnType
public boolean isAnnotationReturnType()Checks if instances of this type can be returned from an annotation method.- Specified by:
isAnnotationReturnTypein interfaceTypeDescription- Returns:
trueif instances of this type can be returned from an annotation method.
-
isAnnotationValue
public boolean isAnnotationValue()Checks if instances of this type can be used for describing an annotation value.- Specified by:
isAnnotationValuein interfaceTypeDescription- Returns:
trueif instances of this type can be used for describing an annotation value.
-
represents
Checks if the type described by this instance representstype.- Specified by:
representsin interfaceTypeDefinition- Parameters:
type- The type of interest.- Returns:
trueif the type described by this instance representstype.
-
getTypeName
Returns the name of the type. For generic types, this name is theirObject.toString()representations. For a non-generic type, it is the fully qualified binary name of the type.- Specified by:
getTypeNamein interfaceTypeDefinition- Returns:
- The name of this type.
-
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.
-
isPackageType
public boolean isPackageType()Checks if this type represents a class that is a place holder for a package description.- Specified by:
isPackageTypein interfaceTypeDescription- Returns:
trueif this type represents a package description.
-
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.
-
getInnerClassCount
public int getInnerClassCount()Returns the amount of outer classes this type defines. If this type is not an inner type of another class,0is returned.- Specified by:
getInnerClassCountin interfaceTypeDescription- Returns:
- The number of outer classes relatively to this type.
-
isInnerClass
public boolean isInnerClass()Indicates if this class is an inner class.- Specified by:
isInnerClassin interfaceTypeDescription- Returns:
trueif this class is an inner class.
-
isNestedClass
public boolean isNestedClass()Indicates if this class is a nested class.- Specified by:
isNestedClassin interfaceTypeDescription- Returns:
trueif this class is a nested class.
-
asBoxed
Returns a description of this type that represents this type as a boxed type for primitive types, unless itsvoid.- Specified by:
asBoxedin interfaceTypeDescription- Returns:
- A description of this type in its boxed form.
-
asUnboxed
Returns a description of this type that represents this type as an unboxed type for boxing types, unless itsVoid.- Specified by:
asUnboxedin interfaceTypeDescription- Returns:
- A description of this type in its unboxed form.
-
getDefaultValue
Returns the default value for this type, i.e. the zero value for a primitive type andnullfor a reference type. Forvoid,nullis returned.- Specified by:
getDefaultValuein interfaceTypeDescription- Returns:
- This types default value.
-
isNestHost
public boolean isNestHost()Checks if this class is the host of a nest group.- Specified by:
isNestHostin interfaceTypeDescription- Returns:
trueif this class is a nest group's host.
-
isNestMateOf
Checks if this type and the supplied type are members of the same nest group.- Specified by:
isNestMateOfin interfaceTypeDescription- Parameters:
type- The type for which to check if it is a member of the same nest group.- Returns:
trueif this type and the supplied type are members of the same nest group.
-
isNestMateOf
Checks if this type and the supplied type are members of the same nest group.- Specified by:
isNestMateOfin interfaceTypeDescription- Parameters:
typeDescription- The type for which to check if it is a member of the same nest group.- Returns:
trueif this type and the supplied type are members of the same nest group.
-
isMemberType
public boolean isMemberType()Checks if this type description represents a member type.- Specified by:
isMemberTypein interfaceTypeDescription- Returns:
trueif this type description represents a member type.
-
isCompileTimeConstant
public boolean isCompileTimeConstant()Indicates if this type represents a compile-time constant, i.e.int,long,float,double,String,Classorjava.lang.invoke.MethodHandleorjava.lang.invoke.MethodType. Since Java 11's *constantdynamic* any type can be considered a constant value; this method does however only consider classical compile time constants.- Specified by:
isCompileTimeConstantin interfaceTypeDescription- Returns:
trueif this type represents a compile-time constant.
-
isSealed
public boolean isSealed()Returnstrueif this class is a sealed class that only permitts a specified range of subclasses.- Specified by:
isSealedin interfaceTypeDescription- Returns:
trueif this class is a sealed class that only permitts a specified range of subclasses.
-
getClassFileVersion
Attempts to resolve the class file version of this type. If this description is not based on a class file or if the class file version cannot be resolved,nullis returned.- Specified by:
getClassFileVersionin interfaceTypeDescription- Returns:
- This type's class file version or
nullif it cannot be resolved.
-
iterator
- Specified by:
iteratorin interfaceIterable<TypeDefinition>
-
hashCode
-
equals
-
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.
-