dynaop.util
Class Classes

java.lang.Object
  extended bydynaop.util.Classes

public class Classes
extends java.lang.Object

Class utilities.

Author:
Bob Lee (crazybob@crazybob.org)

Field Summary
static java.lang.reflect.Method EQUALS_METHOD
           
static java.lang.reflect.Method HASHCODE_METHOD
           
static java.lang.reflect.Method[] OBJECT_METHODS
           
static java.util.Set OBJECT_METHODS_SET
           
static java.lang.reflect.Method TOSTRING_METHOD
           
 
Method Summary
static java.lang.ClassLoader commonLoader(java.lang.Class[] classes)
          Finds a ClassLoader for which all of the classes are visible.
static java.lang.ClassLoader commonLoader(java.util.Collection classes)
          Finds a ClassLoader for which all of the classes are visible.
static java.lang.Class forName(java.lang.String name)
          Same as Class.forName(), except that it works for primitive types.
static java.lang.Class[] getAllInterfaces(java.lang.Class clazz)
          Gets all interfaces implemented by a given type and its super types.
static java.util.List getAllInterfacesAsList(java.lang.Class clazz)
          Gets all interfaces implemented by a given type and its super types.
static java.lang.ClassLoader getClassLoader()
          Gets the context class loader or the system class loader if the context if null.
static java.lang.ClassLoader getClassLoader(java.lang.Class clazz)
          Gets the class's loader.
static boolean implementsInterfaces(java.lang.Class clazz, java.lang.Class[] interfaces)
          Returns true if clazz implements all of the interfaces.
static java.lang.Object invoke(java.lang.Object target, java.lang.reflect.Method method, java.lang.Object[] args)
          Invokes method on target object with arguments.
static java.lang.Object newInstance(java.lang.Class clazz)
          Creates a new instance of clazz using default constructor and converting exceptions.
static java.lang.Object newInstance(java.lang.reflect.Constructor constructor, java.lang.Object[] arguments)
          Creates a new instance of clazz converting exceptions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQUALS_METHOD

public static java.lang.reflect.Method EQUALS_METHOD

HASHCODE_METHOD

public static java.lang.reflect.Method HASHCODE_METHOD

TOSTRING_METHOD

public static java.lang.reflect.Method TOSTRING_METHOD

OBJECT_METHODS

public static java.lang.reflect.Method[] OBJECT_METHODS

OBJECT_METHODS_SET

public static java.util.Set OBJECT_METHODS_SET
Method Detail

newInstance

public static java.lang.Object newInstance(java.lang.Class clazz)
Creates a new instance of clazz using default constructor and converting exceptions.


newInstance

public static java.lang.Object newInstance(java.lang.reflect.Constructor constructor,
                                           java.lang.Object[] arguments)
Creates a new instance of clazz converting exceptions.


implementsInterfaces

public static boolean implementsInterfaces(java.lang.Class clazz,
                                           java.lang.Class[] interfaces)
Returns true if clazz implements all of the interfaces.


invoke

public static java.lang.Object invoke(java.lang.Object target,
                                      java.lang.reflect.Method method,
                                      java.lang.Object[] args)
                               throws java.lang.Throwable
Invokes method on target object with arguments. If target object is a dynamic proxy, this invokes the proxy's invocation handler directly.

Throws:
java.lang.Throwable

getClassLoader

public static java.lang.ClassLoader getClassLoader(java.lang.Class clazz)
Gets the class's loader. If the class was loaded in the system loader, returns the system loader rather than null.


getClassLoader

public static java.lang.ClassLoader getClassLoader()
Gets the context class loader or the system class loader if the context if null.


commonLoader

public static java.lang.ClassLoader commonLoader(java.lang.Class[] classes)
Finds a ClassLoader for which all of the classes are visible.


commonLoader

public static java.lang.ClassLoader commonLoader(java.util.Collection classes)
Finds a ClassLoader for which all of the classes are visible.


getAllInterfacesAsList

public static java.util.List getAllInterfacesAsList(java.lang.Class clazz)
Gets all interfaces implemented by a given type and its super types.


getAllInterfaces

public static java.lang.Class[] getAllInterfaces(java.lang.Class clazz)
Gets all interfaces implemented by a given type and its super types.


forName

public static java.lang.Class forName(java.lang.String name)
                               throws java.lang.ClassNotFoundException
Same as Class.forName(), except that it works for primitive types.

Throws:
java.lang.ClassNotFoundException