public final class Classes extends Object
Modifier and Type | Method and Description |
---|---|
static <T> Class<T> |
forName(String fqcn)
Attempts to load the specified class name from the current thread's
context class loader , then the
current ClassLoader (Classes.class.getClassLoader() ), then the system/application
ClassLoader (ClassLoader.getSystemClassLoader() , in that order. |
static <T> Constructor<T> |
getConstructor(Class<T> clazz,
Class... argTypes) |
static InputStream |
getResourceAsStream(String name)
Returns the specified resource by checking the current thread's
context class loader , then the
current ClassLoader (Classes.class.getClassLoader() ), then the system/application
ClassLoader (ClassLoader.getSystemClassLoader() , in that order, using
getResourceAsStream(name) . |
static <T> T |
instantiate(Constructor<T> ctor,
Object... args) |
static <T> T |
invokeStatic(String fqcn,
String methodName,
Class[] argTypes,
Object... args) |
static boolean |
isAvailable(String fullyQualifiedClassName) |
static <T> T |
newInstance(Class<T> clazz) |
static <T> T |
newInstance(Class<T> clazz,
Object... args) |
static <T> T |
newInstance(String fqcn) |
static <T> T |
newInstance(String fqcn,
Class[] ctorArgTypes,
Object... args) |
static <T> T |
newInstance(String fqcn,
Object... args) |
public static <T> Class<T> forName(String fqcn) throws UnknownClassException
context class loader
, then the
current ClassLoader (Classes.class.getClassLoader()
), then the system/application
ClassLoader (ClassLoader.getSystemClassLoader()
, in that order. If any of them cannot locate
the specified class, an UnknownClassException
is thrown (our RuntimeException equivalent of
the JRE's ClassNotFoundException
.fqcn
- the fully qualified class name to loadUnknownClassException
- if the class cannot be found.public static InputStream getResourceAsStream(String name)
context class loader
, then the
current ClassLoader (Classes.class.getClassLoader()
), then the system/application
ClassLoader (ClassLoader.getSystemClassLoader()
, in that order, using
getResourceAsStream(name)
.name
- the name of the resource to acquire from the classloader(s).null
if the resource cannot be found from any
of the three mentioned ClassLoaders.public static boolean isAvailable(String fullyQualifiedClassName)
public static <T> T newInstance(String fqcn)
public static <T> T newInstance(Class<T> clazz)
public static <T> Constructor<T> getConstructor(Class<T> clazz, Class... argTypes)
public static <T> T instantiate(Constructor<T> ctor, Object... args)
Copyright © 2014–2020 jsonwebtoken.io. All rights reserved.