Modifier and Type | Method and Description |
---|---|
static Class<?> |
forName(String name)
|
static Class<?> |
forName(String name,
boolean initialize)
A version of
Class.forName(String, boolean, ClassLoader) that uses the ClassLoader s obtained by ClassLoaders.get() . |
static <T> Class<? extends T> |
forName(String name,
boolean initialize,
Class<T> type)
An enhanced version of
forName(String, boolean) that makes sure that the returned class extends the given type. |
static <T> Class<? extends T> |
forName(String name,
Class<T> type)
An enhanced version of
forName(String) that makes sure that the returned class extends the given type. |
public static Class<?> forName(String name, boolean initialize) throws ClassNotFoundException
Class.forName(String, boolean, ClassLoader)
that uses the ClassLoader
s obtained by ClassLoaders.get()
.
This method iterates through the ClassLoaders
returned by ClassLoaders.get()
and tries to load the desired class.
name
- the fully qualified name of the desired class.initialize
- whether the class must be initialized.ClassNotFoundException
- if the specified class could not be located by any loader returned by ClassLoaders.get()
public static Class<?> forName(String name) throws ClassNotFoundException
Class.forName(String)
that uses the ClassLoader
s obtained by ClassLoaders.get()
.
Calling this method is equivalent to:
Classes.forName(name, true)
ClassNotFoundException
forName(String, boolean)
public static <T> Class<? extends T> forName(String name, Class<T> type) throws ClassNotFoundException
forName(String)
that makes sure that the returned class extends the given type.
Calling this method is equivalent to:
Classes.forName(name, true, type)
ClassNotFoundException
public static <T> Class<? extends T> forName(String name, boolean initialize, Class<T> type) throws ClassNotFoundException
forName(String, boolean)
that makes sure that the returned class extends the given type.name
- the fully qualified name of the desired class.initialize
- whether the class must be initialized.type
- the type the returned class is expected to extend.ClassNotFoundException
- if the specified class could not be located by any loader returned by ClassLoaders.get()
.ClassCastException
- if the desired class could be loaded, but does not extend the given type.Copyright © 2012-2013. All Rights Reserved.