Package org.jboss.jandex
Class JandexReflection
- java.lang.Object
-
- org.jboss.jandex.JandexReflection
-
public class JandexReflection extends java.lang.ObjectUtilities 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 Classes Modifier and Type Class Description private static classJandexReflection.GenericArrayTypeImplAn implementation ofGenericArrayTypethat is compatible with the JDK's implementation (as in, theequals()andhashCode()methods work as expected).private static classJandexReflection.ParameterizedTypeImplAn implementation ofParameterizedTypethat is compatible with the JDK's implementation (as in, theequals()andhashCode()methods work as expected).private static classJandexReflection.TypeVariableImpl<D extends java.lang.reflect.GenericDeclaration>An implementation ofTypeVariablethat is NOT compatible with the JDK's implementation (as in, theequals()andhashCode()methods do not work as expected).private static classJandexReflection.TypeVariableReferenceImpl<D extends java.lang.reflect.GenericDeclaration>A delegating implementation ofTypeVariablethat is NOT compatible with the JDK's implementation (as in, theequals()andhashCode()methods do not work as expected).private static classJandexReflection.TypeVariablesprivate static classJandexReflection.WildcardTypeImplAn implementation ofWildcardTypethat is compatible with the JDK's implementation (as in, theequals()andhashCode()methods work as expected).
-
Constructor Summary
Constructors Constructor Description JandexReflection()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.Class<?>load(DotName name)static java.lang.Class<?>loadClass(ClassInfo clazz)Loads a class corresponding to givenClassInfofrom the thread context classloader.static java.lang.Class<?>loadRawType(Type type)Loads a class corresponding to the raw type of givenTypefrom the thread context classloader.static java.lang.reflect.TypeloadType(Type type)Loads a ReflectionTypecorresponding to the given JandexType.private static java.lang.reflect.TypeloadType(Type type, JandexReflection.TypeVariables typeVariables)
-
-
-
Method Detail
-
loadType
public static java.lang.reflect.Type loadType(Type type)
Loads a ReflectionTypecorresponding to the given JandexType. Classes are loaded from the thread context classloader. If there is no TCCL, the classloader that loadedJandexReflectionis used. Returnsnullwhentypeisnull.The result is equal to the corresponding
Typeobtained from Reflection and has the same hash code, as long as it doesn't contain any type variables.- Parameters:
type- a JandexType- Returns:
- the corresponding Reflection
Type
-
loadType
private static java.lang.reflect.Type loadType(Type type, JandexReflection.TypeVariables typeVariables)
-
loadRawType
public static java.lang.Class<?> loadRawType(Type type)
Loads a class corresponding to the raw type of givenTypefrom the thread context classloader. If there is no TCCL, the classloader that loadedJandexReflectionis used. Returnsnullwhentypeisnull.Specifically:
- for the
voidpseudo-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.classforList<String>); - for wildcard types, returns the class object of the upper bound type
(e.g.
Number.classfor? extends Number), orObject.classif 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.classforT extends Number & Comparable<T>), orObject.classif 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.classforT extends Number & Comparable<T>), orObject.classif the type variable has no bounds (e.g. justT); - for unresolved type variables, returns
Object.class.
- Parameters:
type- a JandexType- Returns:
- the corresponding
Class
- for the
-
loadClass
public static java.lang.Class<?> loadClass(ClassInfo clazz)
Loads a class corresponding to givenClassInfofrom the thread context classloader. If there is no TCCL, the classloader that loadedJandexReflectionis used. Returnsnullwhenclazzisnull.- Parameters:
clazz- a JandexClassInfo- Returns:
- the corresponding
Class
-
load
private static java.lang.Class<?> load(DotName name)
-
-