Package org.jboss.jandex
Class JandexReflection
java.lang.Object
org.jboss.jandex.JandexReflection
Utilities that allow moving from the Jandex world to the runtime world using reflection.
To maintain stratification, these methods are intentionally not present
on the respective Jandex classes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
An implementation ofGenericArrayType
that is compatible with the JDK's implementation (as in, theequals()
andhashCode()
methods work as expected).private static class
An implementation ofParameterizedType
that is compatible with the JDK's implementation (as in, theequals()
andhashCode()
methods work as expected).private static class
An implementation ofTypeVariable
that is NOT compatible with the JDK's implementation (as in, theequals()
andhashCode()
methods do not work as expected).private static class
A delegating implementation ofTypeVariable
that is NOT compatible with the JDK's implementation (as in, theequals()
andhashCode()
methods do not work as expected).private static class
private static class
An implementation ofWildcardType
that is compatible with the JDK's implementation (as in, theequals()
andhashCode()
methods work as expected). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Class
<?> static Class
<?> Loads a class corresponding to givenClassInfo
from the thread context classloader.static Class
<?> loadRawType
(Type type) Loads a class corresponding to the raw type of givenType
from the thread context classloader.static Type
private static Type
loadType
(Type type, JandexReflection.TypeVariables typeVariables)
-
Constructor Details
-
JandexReflection
public JandexReflection()
-
-
Method Details
-
loadType
Loads a ReflectionType
corresponding to the given JandexType
. Classes are loaded from the thread context classloader. If there is no TCCL, the classloader that loadedJandexReflection
is used. Returnsnull
whentype
isnull
.The result is equal to the corresponding
Type
obtained from Reflection and has the same hash code, as long as it doesn't contain any type variables. -
loadType
-
loadRawType
Loads a class corresponding to the raw type of givenType
from the thread context classloader. If there is no TCCL, the classloader that loadedJandexReflection
is used. Returnsnull
whentype
isnull
.Specifically:
- for the
void
pseudo-type, returnsvoid.class
; - for primitive types, returns the corresponding class object (e.g.
int.class
); - for class types, returns the corresponding class object (e.g.
String.class
); - for array types, returns the corresponding class object (e.g.
String[][].class
); - for parameterized types, returns the class object of the generic class
(e.g.
List.class
forList<String>
); - for wildcard types, returns the class object of the upper bound type
(e.g.
Number.class
for? extends Number
), orObject.class
if the wildcard type has no upper bound (e.g.? super Integer
); - for type variables, returns the class object of the first bound
(e.g.
Number.class
forT extends Number & Comparable<T>
), orObject.class
if the type variable has no bounds (e.g. justT
); - for type variables references, follows the reference to obtain the type
variable and then returns the class object of the first bound (e.g.
Number.class
forT extends Number & Comparable<T>
), orObject.class
if the type variable has no bounds (e.g. justT
); - for unresolved type variables, returns
Object.class
.
- for the
-
loadClass
Loads a class corresponding to givenClassInfo
from the thread context classloader. If there is no TCCL, the classloader that loadedJandexReflection
is used. Returnsnull
whenclazz
isnull
. -
load
-