public static int | annotationValueHashCode( Gets the hash code of the argument, assuming that it is a valid value for an annotation function. |
public static String | annotationValueToString( Converts the argument objects to a string representation, assuming that it is a value value for an annotation
function. |
public static boolean | annotationValuesEqual( Checks if the arguments equal, assuming that they are valid values for an annotation function. |
public static Object | cloneArray( Invokes clone on the argument array. |
public static Object | createArray( Creates an array with the given component type and length. |
public static Object | createEmptyArray( Creates an empty array with the given component type. |
public static Class< | findClassWithNameInHierarchy( Find the class instance with the given name in a hierarchy of classes. |
public static Class< | findInterfaceWithNameInHierarchy( Find the interface instance with the given name in a hierarchy of classes. |
public static Class< | findTypeWithNameInHierarchy( Find the type instance with the given name in a hierarchy of classes. |
public static Set< | getAllInheritedTypeNames( Gets the names of all inherited types of the argument type. |
public static Set< | getAllInheritedTypes( Gets all inherited types of the argument type. |
public static Map< | getAllInheritedTypesWithDistance( Gets all inherited types of the argument type and maps them to their inheritance distance from the argument. |
public static Set< | getAllInterfaces( Gets all interfaces of the argument type. |
public static < | getAnnotation( Gets the annotation from the given array that has the same type as the specified type. |
public static Class< | getArrayClassWithComponent( Gets a class instance that has the component type as the argument. |
public static ByteArrayRegion | getClassBytesUsingClassLoader( Tries to get the bytes for the given parameter class using its classloader. |
public static String | getClassName( Gets the name of the argument Class, if non- null . |
public static < | getConstructorAssert( Gets the constructor with the specified parameter types from a class, throws an AssertionError if fails. |
public static < | getDeclaredConstructorAssert( Gets the declared constructor with the specified parameter types from a class, throws an AssertionError
if fails. |
public static Field | getDeclaredFieldAssert( Gets the declared field with the specified name from a class, throws an AssertionError if fails. |
public static Method | getDeclaredMethodAssert( Gets the declared method with the specified parameter types and name from a class, throws an
AssertionError if fails. |
public static MethodHandle | getDefaultMethodHandle( Gets a MethodHandle to the default method implementation of an interface method. |
public static String | getEnclosingCanonicalNameOf( Gets the enclosing element canonical name of a given type. |
public static Field | getFieldAssert( Gets the field with the specified name from a class, throws an AssertionError if fails. |
public static Object | getFieldValue( Gets the value of a field. |
public static Set< | getInterfaces( Gets the set of interfaces the argument class implements. |
public static Method | getMethodAssert( Gets the method with the specified parameter types and name from a class, throws an AssertionError if
fails. |
public static Object | Gets the Module for the given type. |
public static String | getPackageNameOf( Gets the package name of the given type based on its name. |
public static Object | getPrimitiveClassDefaultValue( Gets the default value for a primitive class. |
public static ByteArrayRegion | getResourceBytes( Gets the bytes of a resource from a ClassLoader given the name of the resource. |
public static boolean | hasDirectSuperClassOrInterface( Checks if the given type has directly extends or implements the given type. |
public static boolean | hasParentClassLoader( Checks if the subject classloader has a given parent classloader in its parent hierarchy. |
public static < | invokeConstructor( Invokes the specified constructor with the given array of arguments. |
public static Object | invokeDefaultMethodOn( Invokes the default implementation of an interface method. |
public static Object | invokeMethod( Invokes the specified method with the given array of arguments. |
public static boolean | Checks if the argument object is an array. |
public static boolean | isBoxedPrimitive( Checks if the argument class is a boxed primitive. |
public static boolean | isEnumOrEnumAnonymous( Checks if the argument type represents either an enum class, or an anonymous enum inner class. |
public static boolean | isSamePrimitive( Checks if the argument classes represent the same classes in regards with primitive types. |
public static Class< | lookupAccessClass( Determines if a class can be accessed from the lookup context defined bythis Lookup object. |
public static < | newInstance( Creates a new instance of the argument class by invoking the no-arg constructor. |
public static Class< | Looks up the primitive class instance for the specified name. |
public static Class< | primitivize( Primitivises the argument class. |
public static void | reduceAssignableTypes( Reduces the argument type set to only contain types which do not have assignable duplicates. |
public static void | removeNonInterfaces( Removes the elements from the argument iterable which are not interface types. |
public static < | requireInterface( Validation method for ensuring that the argument is an interface type. |
public static void | setFieldValue( Sets the value of the field, handling null values for primitive types. |
public static Class< | unprimitivize( Unprimitivises the argument class. |
public static Object | wrapIntoSingletonArray( Wraps a single value into an array with a single element. |
This function calls ArrayUtils.arrayHashCode(
Although the null
is not a valid annotation value, this function will return 0 for it.
This function calls ArrayUtils.arrayToString(
Although the null
is not a valid annotation value, this function will return "null"
for
it.
This function calls ArrayUtils.arraysEqual(
Although the null
is not a valid annotation value, this function will return false
if
only one of the arguments are null
, and true
if both of them are.
true
if the arguments are considered to be equal.
This method will always invoke .clone()
on the array. If the array is a primitive array, it will be
casted down and invoekd accordingly.
If the argument is null
, null
is returned.
This method creates a shallow clone, elements are not cloned.
Same as:
Array.newInstance(component, length);
null
.Same as:
Array.newInstance(component, 0);
null
.This method will try to find the class instance that has the same name as the argument. The method will look at the specified class argument, and check the super classes if they have the same name.
Note: Unlike findTypeWithNameInHierarchy(
null
if not found.null
.This method will try to find the interface instance that has the same name as the argument. The method will look at the specified class argument, and check the super classes and super interfaces if they have the same name.
Note: Unlike findTypeWithNameInHierarchy(
null
if not found.null
.This method will try to find the type instance that has the same name as the argument. The method will look at the specified class argument, and check the super classes and super interfaces if they have the same name.
Note: Unlike findInterfaceWithNameInHierarchy(
null
if not found.null
.This method will put the names of all superclasses and all interfaces into the result set, and return that. The result set will also contain the argument type name as well.
If the argument is null
, null
is returned.
The returned set has a deterministic iteration order, meaning that invoking this method between different invocations of the Java Virtual Machine will produce the same set with the same iteration order.
This method will put all superclasses and all interfaces into the result set, and return that. The result set will also contain the argument type as well.
If the argument is null
, null
is returned.
The returned set has a deterministic iteration order, meaning that invoking this method between different invocations of the Java Virtual Machine will produce the same set with the same iteration order.
This method collects all classes and interfaces that the argument extends and implements. Each type is mapped to the inheritance distance of the type in relation to the argument.
The inheritance distance is defined as the number of 'hops' it takes to reach the inheritance declaration from the starting type.
E.g. for the type Integer:
Integer : 0 Number : 1 (viaThe inheritance distances are minimized, meaning that if a type is present via multiple types (i.e. an interface is implemented by multiple supertypes), then the lesser of them will be taken.Integer
) Comparable<Integer> : 1 (viaInteger
) Serializable : 2 (viaNumber
) Object : 2 (viaNumber
)
null
if the argument is null
.This method will collect all interfaces that the argument type extends. If the argument is already an interface, it will be part of the result set.
If the argument is null
, null
is returned.
The returned set has a deterministic iteration order, meaning that invoking this method between different invocations of the Java Virtual Machine will produce the same set with the same iteration order.
null
if the argument is null
.
If any of the arguments are null
, this method returns null
.
null
.This method is the same as:
createEmptyArray(component).getClass();The implementation of this method may be optimized on JDK12+, where the
Class.arrayType()
function
is available.null
.This method gets the bytes for the corresponding class file from the defining classloader.
It is not ensured that the returned bytes are actually represent the given class parameter. This method should be used with care and for testing purposes only.
null
if not found.null
.null
if the argument is null
.
This function will use Class.getConstructor(
null
.
This function will use Class.getDeclaredConstructor(
null
.
This function will use Class.getDeclaredField(
null
.
This function will use Class.getDeclaredMethod(
null
.This method was tested to handle different Java runtime versions appropriately.
null
.This method returns the canonical name of the enclosing Java element that declares the given type. For inner types, this returns the canonical name of the enclosing type. For top level type, this returns the name of the package it is declared in.
This function will use Class.getField(
null
.
The field will be set to accessible by calling Field.setAccessible(
null
for static fields.This method will collect all the interfaces that a type implements. The returned set will be reduced, meaning that if an interface I is present, none of the interfaces that I extends will be in the resulting set. E.g. if a class implements List, it will not contain the interfaces for Collection, or Iterable.
If the argument is already an interface, the returned set will contain only the argument.
The returned set has a deterministic iteration order, meaning that invoking this method between different invocations of the Java Virtual Machine will produce the same set with the same iteration order.
null
.
This function will use Class.getMethod(
null
.Module
for the given type.
If the current code runs on Java 8 or below, this method returns null
. Otherwise it returns
Class.getModule()
.
Note: This method returns Object to keep compatibility with Java 8.
null
if not applicable. null
is also
returned if the argument is null
.
The name of the type will be retrieved, and the part before the last '.'
dot character will be
returned. An empty string is returned if no dot character was found, representing the default package.
If the argument type is an inner class, the package name is returned nonetheless.
null
is returned if the argument is null
.
The argument may be a direct primitive class (such as int.class
), or a boxed type (such as
Integer).
null
if not found. (In which case null
would be the
default value, as the argument is a reference type.)
This function will open the resource stream from the classloader usin
ClassLoader.getResourceAsStream(
null
if the resource was not found, or an I/O error occurred.null
.This method will compare the given super type with the super class and interfaces of the examined type.
true
if either the super class or one of the implemented interfaces are the specified super
type.null
.
The subject classloader will be checked if it equals to the expected parent classloader. The same will be
recursively checked for the parent classloader of the subject
.
If the parent
is null
, this method will return true
.
true
if the parent classloader was found in the parent hierarchy of the subject.
The constructor will be set to accessible by calling Constructor.setAccessible(
This method was tested to handle different Java runtime versions appropriately.
null
.
The method will be set to accessible by calling Method.setAccessible(
null
for static methods.It is determined by checking if its class is an array.
true
if the argument is non-null
and an array.The class Void is considered to be a boxed primitive.
true
if the argument is a boxed primitive.
For enum objects which are inner classes as well, Class.isEnum() will return false
. E.g.:
public enum MyEnum { FIRST_ENUM, SECOND_ENUM { }; } // MyEnum.FIRST_ENUM.getClass() will return MyEnum.class // MyEnum.SECOND_ENUM.getClass() will return a type that is a subclass of MyEnum, butThis method will check if the given type is either an enum, or an anonymous inner enum.
This method returns false
if the argument is null
.
true
if the argument type is an enum or anonymous inner enum class.
The function converts the argument classes to their primitive counterparts if any, and checks if they equal. The
primitive counterpart is determined using primitivize(
If both arguments are null
, true
is returned.
true
if the classes are the same in regards with the primitive types.
The method calls Lookup.accessClass(targetClass)
when run on Java 9+, while simply returns the
targetClass
when running on Java 8 or below.
null
.The no-arg constructor will be looked up, set to accessible, and invoked.
Same as:
invokeConstructor(clazz.getDeclaredConstructor());
null
if not found.null
.If the argument class is a boxed type of a primitive class, then the primitive class will be returned for it. In any other cases, the argument class will be returned.
Note that Void will be converted to void.class
.
This method will remove any types in the argument collection for which there is a subclass or subinterface present.
E.g. If the type Collection and List is in it, then Collection will be removed, as it is already present in List, as that extends it.
Only the types will be removed which have at least one subclass of it present. E.g. If the argument contains Number, Float, and Double, only Number will be removed.
If the argument is null
, this method does nothing.
null
.null
values for primitive types.
The field will be set to accessible by calling Field.setAccessible(
If the field has a primitive type, and the value is null
, the default value will be set for the
field.
In any other cases, the Field.set(
null
for static fields.null
.If the argument class is a primitive class, then the boxed type will be returned for it. In any other cases, the argument class will be returned.
Note that void.class
will be converted to Void.
null
.