|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.common.reflect.Reflection
@Beta public final class Reflection
Static utilities relating to Java reflection.
Method Summary | ||
---|---|---|
static String |
getPackageName(Class<?> cls)
Returns the package name of cls according to the Java Language Specification (section
6.7). |
|
static String |
getPackageName(String classFullName)
Returns the package name of classFullName according to the Java Language Specification
(section 6.7). |
|
static void |
initialize(Class<?>... classes)
Ensures that the given classes are initialized, as described in JLS Section 12.4.2. |
|
static
|
newProxy(Class<T> interfaceType,
InvocationHandler handler)
Returns a proxy instance that implements interfaceType by
dispatching method invocations to handler . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static String getPackageName(Class<?> cls)
cls
according to the Java Language Specification (section
6.7). Unlike Class.getPackage()
, this method only parses the class name, without
attempting to define the Package
and hence load files.
public static String getPackageName(String classFullName)
classFullName
according to the Java Language Specification
(section 6.7). Unlike Class.getPackage()
, this method only parses the class name, without
attempting to define the Package
and hence load files.
public static void initialize(Class<?>... classes)
WARNING: Normally it's a smell if a class needs to be explicitly initialized, because static state hurts system maintainability and testability. In cases when you have no choice while inter-operating with a legacy framework, this method helps to keep the code less ugly.
ExceptionInInitializerError
- if an exception is thrown during
initialization of a classpublic static <T> T newProxy(Class<T> interfaceType, InvocationHandler handler)
interfaceType
by
dispatching method invocations to handler
. The class loader of
interfaceType
will be used to define the proxy class. To implement
multiple interfaces or specify a class loader, use
Proxy.newProxyInstance(java.lang.ClassLoader, java.lang.Class>[], java.lang.reflect.InvocationHandler)
.
IllegalArgumentException
- if interfaceType
does not specify
the type of a Java interface
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |