Top Description Inners Fields Constructors Methods
org.jboss.jandex

public final Class ClassInfo

extends Object
implements Declaration, Descriptor, GenericSignature
Class Inheritance
All Implemented Interfaces
org.jboss.jandex.GenericSignature, org.jboss.jandex.Descriptor, org.jboss.jandex.Declaration, org.jboss.jandex.AnnotationTarget
Imports
java.lang.reflect.Modifier, java.util.AbstractList, .ArrayList, .Arrays, .Collection, .Collections, .Comparator, .IdentityHashMap, .List, .Map, .Set, java.util.function.Function

Represents a class entry in an index. A ClassInfo is only a partial view of a Java class, it is not intended as a complete replacement for Java reflection.

Global information including the parent class, implemented interfaces, and access flags are also provided since this information is often necessary. Implicitly declared (aka mandated) and synthetic members are included as well.

Note that a parent class and interface may exist outside of the scope of the index (e.g. classes in a different jar) so the references are stored as names instead of direct references. It is expected that multiple indexes may need to be queried to assemble a full hierarchy in a complex multi-jar environment (e.g. an application server).

Thread-Safety

This class is immutable and can be shared between threads without safe publication.
Author
Jason T. Greene

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ClassInfo.EnclosingMethodInfo

Provides information on the enclosing method or constructor for a local or anonymous class, if available.

private static class
public static enum
ClassInfo.NestingType

Describes the form of nesting used by a class

Field Summary

Modifier and TypeField and Description
private Map<DotName, List<AnnotationInstance>>
private static final byte[]
private byte[]
private FieldInternal[]
private short
private boolean
private Type[]
private static final int
private Set<DotName>
private byte[]
private MethodInternal[]
private final DotName
private ClassInfo.NestingInfo
private byte[]
private RecordComponentInternal[]
private Type
private Type[]

Constructor Summary

AccessConstructor and Description
pack-priv
ClassInfo(DotName name, Type superClassType, short flags, Type[] interfaceTypes)

pack-priv
ClassInfo(DotName name, Type superClassType, short flags, Type[] interfaceTypes, boolean hasNoArgsConstructor)

Method Summary

Modifier and TypeMethod and Description
public final AnnotationInstance

Returns:

the annotation instance, or null if not found
annotation
(DotName
name of the annotation type to look for, must not be null
name
)

Implements org.jboss.jandex.AnnotationTarget.annotation.

Returns the annotation instance with given name declared on this class, any of its members, or any type within the signature of the class or its members.
public final List<AnnotationInstance>

Returns:

immutable list of annotation instances, never null
annotations
(DotName
name of the annotation type, must not be null
name
)

Implements org.jboss.jandex.AnnotationTarget.annotations.

Returns the annotation instances with given name declared on this class, any of its members, or any type within the signature of the class or its members.
public final List<AnnotationInstance>

Returns:

immutable list of annotation instances, never null
annotations
()

Implements org.jboss.jandex.AnnotationTarget.annotations.

Returns the annotation instances declared on this class, any of its members, or any type within the signature of the class or its members.
public final Map<DotName, List<AnnotationInstance>>
public final Map<DotName, List<AnnotationInstance>>

Returns:

immutable map of annotations specified on this class and its elements, never null
annotationsMap
()

Returns a map indexed by annotation name, with a value list of annotation instances.

public final List<AnnotationInstance>

Returns:

immutable list of annotation instances, never null
annotationsWithRepeatable
(DotName
name of the annotation type, must not be null
name
,
IndexView
index used to obtain the annotation type, must not be null
index
)

Implements org.jboss.jandex.AnnotationTarget.annotationsWithRepeatable.

Returns the annotation instances with given name declared on this class, any of its members, or any type within the signature of the class or its members.
public ClassInfo
asClass()

Implements org.jboss.jandex.AnnotationTarget.asClass.

Casts and returns this target as a ClassInfo if it is of kind CLASS
public FieldInfo
asField()

Implements org.jboss.jandex.AnnotationTarget.asField.

Casts and returns this target as a FieldInfo if it is of kind FIELD
public MethodInfo
asMethod()

Implements org.jboss.jandex.AnnotationTarget.asMethod.

Casts and returns this target as a MethodInfo if it is of kind METHOD
public MethodParameterInfo
asMethodParameter()

Implements org.jboss.jandex.AnnotationTarget.asMethodParameter.

Casts and returns this target as a MethodParameterInfo if it is of kind METHOD_PARAMETER
public RecordComponentInfo
asRecordComponent()

Implements org.jboss.jandex.AnnotationTarget.asRecordComponent.

Casts and returns this target as a RecordComponentInfo if it is of kind RECORD_COMPONENT
public TypeTarget
asType()

Implements org.jboss.jandex.AnnotationTarget.asType.

Casts and returns this target as a TypeTarget if it is of kind TYPE
public final AnnotationInstance

Returns:

the declared annotation or null if not found
classAnnotation
(DotName
the annotation name to look for
name
)

Returns the annotation with the specified name directly declared on this class.
public final Collection<AnnotationInstance>

Returns:

immutable list of annotations declared on this class
classAnnotations
()

Deprecated use declaredAnnotations()
Returns a list of all annotations directly declared on this class.
public final List<AnnotationInstance>

Returns:

immutable list of annotation instances declared on this class, or an empty list if none
classAnnotationsWithRepeatable
(DotName
the name of the annotation
name
,
IndexView
the index used to obtain the annotation class
index
)

Retrieves annotation instances declared on this class, by the name of the annotation.
public final List<MethodInfo>

Returns:

the list of constructors declared in this class
constructors
()

Returns a list of all constructors declared in this class (which have the special name <init>).

pack-priv final Type[]
public static ClassInfo

Returns:

a new mock class representation
create
(DotName
the name of this class
name
,
DotName
the name of the parent class
superName
,
short
the class attributes
flags
,
DotName[]
the interfaces this class implements
interfaces
,
Map<DotName, List<AnnotationInstance>>
the annotations on this class
annotations
,
boolean
whether this class has a no arg constructor
hasNoArgsConstructor
)

Deprecated
Constructs a "mock" ClassInfo using the passed values.
public final AnnotationInstance

Returns:

the annotation instance, or null if not found
declaredAnnotation
(DotName
name of the annotation type to look for, must not be null
name
)

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotation.

Returns the annotation instance with given name declared on this class.
public final List<AnnotationInstance>

Returns:

immutable list of annotation instances, never null
declaredAnnotations
()

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotations.

Returns the annotation instances declared on this class.
public final List<AnnotationInstance>

Returns:

immutable list of annotation instances, never null
declaredAnnotationsWithRepeatable
(DotName
name of the annotation type, must not be null
name
,
IndexView
index used to obtain the annotation type, must not be null
index
)

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotationsWithRepeatable.

Returns the annotation instances with given name declared on this class.
public String

Returns:

the bytecode descriptor of this class's type
descriptor
(Function<String, Type>
a substitution function from type variable identifiers to types
typeVariableSubstitution
)

Implements org.jboss.jandex.Descriptor.descriptor.

Returns a bytecode descriptor of the type introduced by this class.
public DotName

Returns:

the enclosing class if this class is a member class
enclosingClass
()

Returns the enclosing class if this is a member class, or null if this is a top-level, local or anonymous class.

public ClassInfo.EnclosingMethodInfo

Returns:

the enclosing method/constructor, if this class is a local or anonymous class declared within a method or constructor, otherwise null
enclosingMethod
()

Returns the enclosing method of this class if it is a local or anonymous class declared within the body of a method or constructor.

pack-priv final int
public final List<FieldInfo>

Returns:

immutable list of enum constants, never null
enumConstants
()

Returns a list of enum constants declared by this enum class, represented as FieldInfo.

public final FieldInfo

Returns:

the field
field
(String
the name of the field
name
)

Retrieves a field by the given name.

pack-priv final FieldInternal[]
pack-priv final byte[]
public final List<FieldInfo>

Returns:

a list of fields
fields
()

Returns a list of all available fields.

public final MethodInfo

Returns:

the first discovered method matching this name, or null if no match is found
firstMethod
(String
the name of the method
name
)

Retrieves the "first" occurrence of a method by the given name.

public final short

Returns:

the access flags
flags
()

Returns the access flags for this class.

public String

Returns:

a generic signature of this class with type variables substituted, never null
genericSignature
(Function<String, Type>
a substitution function from type variable identifiers to types
typeVariableSubstitution
)

Implements org.jboss.jandex.GenericSignature.genericSignature.

Returns a generic signature of this class, possibly without any generic-related information.
public final boolean

Returns:

true if the annotation is present, false otherwise
hasAnnotation
(DotName
name of the annotation type to look for, must not be null
name
)

Implements org.jboss.jandex.AnnotationTarget.hasAnnotation.

Returns whether an annotation instance with given name is declared on this class, any of its members, or any type within the signature of the class or its members.
public final boolean

Returns:

true if the annotation is present, false otherwise
hasDeclaredAnnotation
(DotName
name of the annotation type to look for, must not be null
name
)

Implements org.jboss.jandex.AnnotationTarget.hasDeclaredAnnotation.

Returns whether an annotation instance with given name is declared on this class.
public final boolean

Returns:

true if this class has a zero-parameter constructor, false if it does not
hasNoArgsConstructor
()

Returns whether this class declares a zero-parameter constructor.

public final List<DotName>

Returns:

immutable list of names of interfaces implemented by this class
interfaceNames
()

Returns a list of names for all interfaces this class implements.

public final DotName[]

Returns:

an array of interface names implemented by this class
interfaces
()

Deprecated
Returns an array of interface names implemented by this class.
pack-priv final Type[]
public final List<Type>

Returns:

immutable list of types declared in the implements clause of this class
interfaceTypes
()

Returns the list of types in the implements clause of this class.

public final boolean

Returns:

true if this class object represents an annotation type
isAnnotation
()

public final boolean

Returns:

true if this class object represents an enum type
isEnum
()

public final boolean

Returns:

true if this class object represents an interface type
isInterface
()

public final boolean

Returns:

true if this class object represents a Java module descriptor
isModule
()

public final boolean

Returns:

true if this class object represents a record type
isRecord
()

public final boolean

Returns:

true if this class is a synthetic class
isSynthetic
()

public final AnnotationTarget.Kind
kind()

Implements org.jboss.jandex.AnnotationTarget.kind.

Returns the kind of object this target represents.
public Set<DotName>

Returns:

immutable set of names of this class's member classes, never null
memberClasses
()

Returns a set of names of member classes declared in this class.

public final MethodInfo

Returns:

the located method or null if not found
method
(String
the name of the method to find
name
,
Type...
the type parameters of the method
parameters
)

Retrieves a method based on its signature, which includes a method name and a parameter type list.

pack-priv final MethodInternal[]
pack-priv final byte[]
public final List<MethodInfo>

Returns:

the list of methods declared in this class
methods
()

Returns a list of all methods declared in this class.

public ModuleInfo

Returns:

the module descriptor for module classes, otherwise null
module
()

Returns the module information from this class if it is a module descriptor, i.e. module-info.

public final DotName

Returns:

the binary name of the class as a DotName
name
()

Returns the binary name of the class as a DotName.

pack-priv String
public ClassInfo.NestingType

Returns:

the nesting type of this class
nestingType
()

Returns the nesting type of this class, which could either be a standard top level class, a member class (NestingType.INNER), an anonymous class, or a local class.

public final RecordComponentInfo

Returns:

the record component
recordComponent
(String
the name of the record component
name
)

Retrieves a record component by the given name.

pack-priv final RecordComponentInternal[]
pack-priv final byte[]
public final List<RecordComponentInfo>

Returns:

a list of record components
recordComponents
()

Returns a list of all record components declared by this class.

public boolean

Returns:

whether this class must have a generic signature
requiresGenericSignature
()

Implements org.jboss.jandex.GenericSignature.requiresGenericSignature.

Returns whether this class must have a generic signature.
pack-priv final void
pack-priv void
pack-priv void
pack-priv void
setFieldPositionArray(byte[] fieldPositions)

pack-priv void
pack-priv void
setFlags(short flags)

pack-priv void
setHasNoArgsConstructor(boolean hasNoArgsConstructor)

pack-priv void
setInnerClassInfo(DotName enclosingClass, String simpleName, boolean knownInnerClass)

pack-priv void
setInterfaceTypes(Type[] interfaceTypes)

pack-priv void
setMemberClasses(Set<DotName> memberClasses)

pack-priv void
pack-priv void
setMethodPositionArray(byte[] methodPositions)

pack-priv void
pack-priv void
pack-priv void
pack-priv void
setRecordComponentPositionArray(byte[] recordComponentPositions)

pack-priv void
pack-priv void
setSuperClassType(Type superClassType)

pack-priv void
setTypeParameters(Type[] typeParameters)

public String

Returns:

the simple name of a top-level, member or local class, or null if this is an anonymous class
simpleName
()

Returns the source declared name of this class if it is a top-level class, member class or a local class.

pack-priv static <
An internal member type, FieldInternal or MethodInternal
T
>
byte[]

Returns:

an array offsets in the array of internals in the order prior to sorting
sortAndGetPositions
(T[]
Array of internal types set on the ClassInfo instance
internals
,
Comparator<T>
Comparator used to sort internals and locate original positions
comparator
,
NameTable
NameTable used to intern byte arrays of member positions
names
)

Sorts the array of internals using the provided comparator and returns an array of offsets in the original order of internals.

public final Type

Returns:

the super class type definition in the extends clause
superClassType
()

Returns a super type represented by the extends clause of this class.

public final DotName

Returns:

the name of the super class of this class, or null if this class is java.lang.Object
superName
()

Returns the name of the super class declared by the extends clause of this class.

public String

Returns:

the binary name of this class
toString
()

Overrides java.lang.Object.toString.

Returns the binary name of this class.
pack-priv final Type[]
public final List<TypeVariable>

Returns:

immutable list of generic type parameters of this class
typeParameters
()

Returns the generic type parameters of this class, if any.

public final List<FieldInfo>

Returns:

a list of fields
unsortedFields
()

Returns a list of all fields declared in this class, in the declaration order.

public final List<MethodInfo>

Returns:

a list of methods
unsortedMethods
()

Returns a list of all methods declared in this class, in the declaration order.

public final List<RecordComponentInfo>

Returns:

a list of record components
unsortedRecordComponents
()

Returns a list of all record components declared in this class, in the declaration order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait