edu.rice.cs.plt.reflect
Class ReflectUtil

java.lang.Object
  extended by edu.rice.cs.plt.reflect.ReflectUtil

public final class ReflectUtil
extends Object


Field Summary
static ClassLoader BOOT_CLASS_LOADER
          A ClassLoader for the bootstrap classes -- those provided by the bootstrap class path in Sun JVMs.
static Iterable<File> SYSTEM_CLASS_PATH
          The value of system property "java.class.path", parsed as a list of files.
 
Method Summary
static Class<?> arrayBaseClass(Class<?> c)
          Gets the base component type of an array of arbitrary dimensions.
static int arrayDimensions(Class<?> c)
          Return the number of array dimensions represented by the given class.
static
<T> Class<T>
box(Class<T> c)
          If c is a primitive type, return its boxed counterpart; otherwise, return c.
static
<T> T
cast(Class<? extends T> c, Object o)
          An implementation of Class.cast(java.lang.Object), which is unavailable prior to Java 5.0.
static
<T,R> Lambda<T,R>
constructorAsLambda(Class<? extends R> c, Class<? super T> argT)
          Wrap a constructor in a lambda.
static
<T1,T2,R> Lambda2<T1,T2,R>
constructorAsLambda2(Class<? extends R> c, Class<? super T1> arg1T, Class<? super T2> arg2T)
          Wrap a constructor in a lambda.
static
<T1,T2,T3,R>
Lambda3<T1,T2,T3,R>
constructorAsLambda3(Class<? extends R> c, Class<? super T1> arg1T, Class<? super T2> arg2T, Class<? super T3> arg3T)
          Wrap a constructor in a lambda.
static
<T1,T2,T3,T4,R>
Lambda4<T1,T2,T3,T4,R>
constructorAsLambda4(Class<? extends R> c, Class<? super T1> arg1T, Class<? super T2> arg2T, Class<? super T3> arg3T, Class<? super T4> arg4T)
          Wrap a constructor in a lambda.
static
<R> Thunk<R>
constructorAsThunk(Class<? extends R> c)
          Wrap a constructor in a thunk.
static
<T> Box<T>
fieldAsBox(Object object, String fieldName, Class<T> fieldType)
          Wrap a field of the given object in a box.
static
<T> Class<? extends T>
getClass(T obj)
          Produce a correctly-typed class corresponding to obj.
static Object getStaticField(ClassLoader loader, String className, String fieldName)
           
static Object getStaticField(String className, String fieldName)
           
static Object invokeStaticMethod(ClassLoader loader, String className, String methodName, Class<?>[] signature, Object... args)
           
static Object invokeStaticMethod(ClassLoader loader, String className, String methodName, Object... args)
           
static Object invokeStaticMethod(String className, String methodName, Class<?>[] signature, Object... args)
           
static Object invokeStaticMethod(String className, String methodName, Object... args)
           
static boolean isAnonymousClass(Class<?> c)
          An implementation of Class.isAnonymousClass(), which is unavailable prior to Java 5.0
static Object loadLibraryAdapter(ClassLoader baseLoader, Iterable<? extends File> libraryPath, String adapterName, Class<?>[] constructorSig, Object... constructorArgs)
          Create an adapter object which provides an interface to a library that is not available statically on the class path (or, more generally, to the baseLoader).
static Object loadLibraryAdapter(ClassLoader baseLoader, Iterable<? extends File> libraryPath, String adapterName, Object... constructorArgs)
          Create an adapter object which provides an interface to a library that is not available statically on the class path (or, more generally, to the baseLoader).
static Object loadLibraryAdapter(Iterable<? extends File> libraryPath, String adapterName, Class<?>[] constructorSig, Object... constructorArgs)
          Create an adapter object which provides an interface to a library that is not available statically on the class path (or, more generally, to the baseLoader).
static Object loadLibraryAdapter(Iterable<? extends File> libraryPath, String adapterName, Object... constructorArgs)
          Create an adapter object which provides an interface to a library that is not available statically on the class path (or, more generally, to the baseLoader).
static Object loadObject(ClassLoader loader, String className, Class<?>[] constructorSig, Object... constructorArgs)
          Create an instance of the given class.
static Object loadObject(ClassLoader loader, String className, Object... constructorArgs)
          Create an instance of the given class.
static Object loadObject(String className, Class<?>[] constructorSig, Object... constructorArgs)
          Create an instance of the given class.
static Object loadObject(String className, Object... constructorArgs)
          Create an instance of the given class.
static ComposedClassLoader mergeLoaders(ClassLoader first, ClassLoader second)
          Combine two class loaders by first matching classes in first, then delegating to second.
static ComposedClassLoader mergeLoaders(ClassLoader first, ClassLoader second, boolean blackList, String... firstPrefixes)
          Combine two class loaders by matching a subset of those in first, followed by a search in second.
static ComposedClassLoader mergeLoaders(ClassLoader first, ClassLoader second, String... firstIncludes)
          Combine two class loaders by matching specific classes (or class prefixes) from first, and delegating all other searches to second.
static
<O,R> Lambda<O,R>
methodAsLambda(Class<? super O> c, String methodName, Class<? extends R> retT)
          Wrap a method in a lambda, with the receiver object as the first argument.
static
<T,R> Lambda<T,R>
methodAsLambda(Object object, String methodName, Class<? super T> argT, Class<? extends R> retT)
          Wrap a method of the given object in a lambda.
static
<O,T,R> Lambda2<O,T,R>
methodAsLambda2(Class<? super O> c, String methodName, Class<? super T> argT, Class<? extends R> retT)
          Wrap a method in a lambda, with the receiver object as the first argument.
static
<T1,T2,R> Lambda2<T1,T2,R>
methodAsLambda2(Object object, String methodName, Class<? super T1> arg1T, Class<? super T2> arg2T, Class<? extends R> retT)
          Wrap a method of the given object in a lambda.
static
<O,T1,T2,R>
Lambda3<O,T1,T2,R>
methodAsLambda3(Class<? super O> c, String methodName, Class<? super T1> arg1T, Class<? super T2> arg2T, Class<? extends R> retT)
          Wrap a method in a lambda, with the receiver object as the first argument.
static
<T1,T2,T3,R>
Lambda3<T1,T2,T3,R>
methodAsLambda3(Object object, String methodName, Class<? super T1> arg1T, Class<? super T2> arg2T, Class<? super T3> arg3T, Class<? extends R> retT)
          Wrap a method of the given object in a lambda.
static
<O,T1,T2,T3,R>
Lambda4<O,T1,T2,T3,R>
methodAsLambda4(Class<? super O> c, String methodName, Class<? super T1> arg1T, Class<? super T2> arg2T, Class<? super T3> arg3T, Class<? extends R> retT)
          Wrap a method in a lambda, with the receiver object as the first argument.
static
<R> Thunk<R>
methodAsThunk(Object object, String methodName, Class<? extends R> retT)
          Wrap a method of the given object in a thunk.
static String simpleName(Class<?> c)
          Produce the simple name of the given class, as specified by Class.getSimpleName(), with an improved scheme for anonymous classes.
static
<T> Box<T>
staticFieldAsBox(Class<?> c, String fieldName, Class<T> fieldType)
          Wrap a static field in a box.
static
<O,T,R> Lambda<T,R>
staticMethodAsLambda(Class<? super O> c, String methodName, Class<? super T> argT, Class<? extends R> retT)
          Wrap a static method in a lambda.
static
<O,T1,T2,R>
Lambda2<T1,T2,R>
staticMethodAsLambda2(Class<? super O> c, String methodName, Class<? super T1> arg1T, Class<? super T2> arg2T, Class<? extends R> retT)
          Wrap a static method in a lambda.
static
<O,T1,T2,T3,R>
Lambda3<T1,T2,T3,R>
staticMethodAsLambda3(Class<? super O> c, String methodName, Class<? super T1> arg1T, Class<? super T2> arg2T, Class<? super T3> arg3T, Class<? extends R> retT)
          Wrap a static method in a lambda.
static
<O,R> Thunk<R>
staticMethodAsThunk(Class<? super O> c, String methodName, Class<? extends R> retT)
          Wrap a static method in a thunk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOOT_CLASS_LOADER

public static final ClassLoader BOOT_CLASS_LOADER
A ClassLoader for the bootstrap classes -- those provided by the bootstrap class path in Sun JVMs. Note that this is not the actual loader used for bootstrap classes, but rather an immediate child; for any available class c ("java.lang.Number" or "javax.swing.JFrame", for example), BOOT_CLASS_LOADER.loadClass(c).getClassLoader() has value null. When constructing a class loader, there is no need to use this object as a parent -- simply use null as the parent parameter.


SYSTEM_CLASS_PATH

public static final Iterable<File> SYSTEM_CLASS_PATH
The value of system property "java.class.path", parsed as a list of files. Consistent with most other uses of JVM properties in Java libraries, does not reflect subsequent changes to the property.

Method Detail

simpleName

public static String simpleName(Class<?> c)
Produce the simple name of the given class, as specified by Class.getSimpleName(), with an improved scheme for anonymous classes. The simple name of a class is generally the unqualified name used to declare it. Arrays evaluate to the simple name of their element type, followed by a pair of brackets. Anonymous classes, rather than evaluating to an empty string, produce something like "anonymous Foo" (where Foo is the supertype). Assumes non-anonymous classes follow a naming convention in which the simple name is the suffix of the full class name following all '.' and '$' characters, and immediately following a (possibly empty) sequence of digits.


isAnonymousClass

public static boolean isAnonymousClass(Class<?> c)
An implementation of Class.isAnonymousClass(), which is unavailable prior to Java 5.0


arrayBaseClass

public static Class<?> arrayBaseClass(Class<?> c)
Gets the base component type of an array of arbitrary dimensions. For example, for each of String, String[], and String[][], this is String.


arrayDimensions

public static int arrayDimensions(Class<?> c)
Return the number of array dimensions represented by the given class. For String[][], this is 2. For String, this is 0.


cast

public static <T> T cast(Class<? extends T> c,
                         Object o)
              throws ClassCastException

An implementation of Class.cast(java.lang.Object), which is unavailable prior to Java 5.0. Unlike the Java API method, this version allows a boxed value to be cast to its unboxed equivalent — for example, ReflectUtil.cast(int.class, 23) will succeed (see SDN bug 6456930).

The method is only capable of checking that o is an instance of the class c — not that o is an instance of type T (for example, casting with a Class<List<Integer>> would only check that o is a List<?>, but the return type would by List<Integer>). Such discrepancies are rare in practice, because class literals (Foo.class) will only produce classes for which T is unparameterized or raw.

Following Class.cast(), a boxed type cannot be cast to its unboxed equivalent, despite the fact that such a cast would be safe. (From a practical point of view, we would prefer to avoid incurring the overhead of box(java.lang.Class) on every cast.)

Throws:
ClassCastException - If the object cannot be cast to the given type.

getClass

public static <T> Class<? extends T> getClass(T obj)
Produce a correctly-typed class corresponding to obj. obj.getClass(), in contrast, returns a Class<?>.


box

public static <T> Class<T> box(Class<T> c)
If c is a primitive type, return its boxed counterpart; otherwise, return c.


loadObject

public static Object loadObject(String className,
                                Object... constructorArgs)
                         throws ReflectException

Create an instance of the given class. This is a convenience method that uses the class loader of ReflectUtil to load className, and that infers the constructor signature from the given arguments.

Note that the inference process for the constructor signature is potentially error-prone, because it uses the concrete runtime types of the objects, which may be more specific than what is needed. It is impossible, for example, to use this method to invoke a constructor whose parameters include interface, abstract class, or primitive types. In such cases, loadObject(String, Class[], Object[]) should be used instead.

A typical use of this method is to instantiate an object that belongs to or directly refers to a library that is not guaranteed to be statically available at runtime. Since no direct reference can by made to that object's class or any of the library's classes in the main body of code (otherwise, a NoClassDefFoundError may occur), reflection must be used to load the object.

Throws:
ReflectException - As specified by loadObject(ClassLoader, String, Class[], Object[])
See Also:
loadObject(String, Class[], Object[]), loadObject(ClassLoader, String, Class[], Object[])

loadObject

public static Object loadObject(String className,
                                Class<?>[] constructorSig,
                                Object... constructorArgs)
                         throws ReflectException

Create an instance of the given class. This is a convenience method that uses the class loader of ReflectUtil to load className.

A typical use of this method is to instantiate an object that belongs to or directly refers to a library that is not guaranteed to be statically available at runtime. Since no direct reference can by made to that object's class or any of the library's classes in the main body of code (otherwise, a NoClassDefFoundError may occur), reflection must be used to load the object.

Throws:
ReflectException - As specified by loadObject(ClassLoader, String, Class[], Object[])
See Also:
loadObject(String, Object[]), loadObject(ClassLoader, String, Class[], Object[])

loadObject

public static Object loadObject(ClassLoader loader,
                                String className,
                                Object... constructorArgs)
                         throws ReflectException

Create an instance of the given class. This is a convenience method that infers the constructor signature from the given arguments.

Note that the inference process for the constructor signature is potentially error-prone, because it uses the concrete runtime types of the objects, which may be more specific than what is needed. It is impossible, for example, to use this method to invoke a constructor whose parameters include interface, abstract class, or primitive types. In such cases, loadObject(ClassLoader, String, Class[], Object[]) should be used instead.

A typical use of this method is to instantiate an object that belongs to or directly refers to a library that is not guaranteed to be statically available at runtime. Since no direct reference can by made to that object's class or any of the library's classes in the main body of code (otherwise, a NoClassDefFoundError may occur), reflection must be used to load the object.

Throws:
ReflectException - As specified by loadObject(ClassLoader, String, Class[], Object[])
See Also:
loadObject(String, Object[]), loadObject(ClassLoader, String, Class[], Object[])

loadObject

public static Object loadObject(ClassLoader loader,
                                String className,
                                Class<?>[] constructorSig,
                                Object... constructorArgs)
                         throws ReflectException

Create an instance of the given class. This method invokes Class.forName(String, boolean, ClassLoader) (with initialize set to true), Class.getConstructor(Class[]), and Constructor.newInstance(java.lang.Object...).

A typical use of this method is to instantiate an object that belongs to or directly refers to a library that is not guaranteed to be statically available at runtime. Since no direct reference can by made to that object's class or any of the library's classes in the main body of code (otherwise, a NoClassDefFoundError may occur), reflection must be used to load the object.

Parameters:
loader - A class loader used to load the specified class
className - The name of the class to be instantiated
constructorSig - The types of the desired constructor's parameters; these must exactly match the the constructor's declared signature (may not be null)
constructorArgs - The arguments to pass to the constructor (null is also acceptable where there are no parameters)
Throws:
ReflectException - This operation may trigger any of the following, which is wrapped as a ReflectException:

getStaticField

public static Object getStaticField(String className,
                                    String fieldName)
                             throws ReflectException
Throws:
ReflectException

getStaticField

public static Object getStaticField(ClassLoader loader,
                                    String className,
                                    String fieldName)
                             throws ReflectException
Throws:
ReflectException

invokeStaticMethod

public static Object invokeStaticMethod(String className,
                                        String methodName,
                                        Object... args)
                                 throws ReflectException
Throws:
ReflectException

invokeStaticMethod

public static Object invokeStaticMethod(ClassLoader loader,
                                        String className,
                                        String methodName,
                                        Object... args)
                                 throws ReflectException
Throws:
ReflectException

invokeStaticMethod

public static Object invokeStaticMethod(String className,
                                        String methodName,
                                        Class<?>[] signature,
                                        Object... args)
                                 throws ReflectException
Throws:
ReflectException

invokeStaticMethod

public static Object invokeStaticMethod(ClassLoader loader,
                                        String className,
                                        String methodName,
                                        Class<?>[] signature,
                                        Object... args)
                                 throws ReflectException
Throws:
ReflectException

loadLibraryAdapter

public static Object loadLibraryAdapter(Iterable<? extends File> libraryPath,
                                        String adapterName,
                                        Object... constructorArgs)
                                 throws ReflectException

Create an adapter object which provides an interface to a library that is not available statically on the class path (or, more generally, to the baseLoader). This assumes the relevant code may be organized into three groups: the base classes, which are available to the baseLoader and make no direct references to the library or adapter classes; the library classes, which are located in the path represented by libraryPath, and make no direct references to the adapter class; and the adapter class (including its inner classes), which is available to the baseLoader, and which can directly refer to both the library and base classes.

This is a convenience method that uses the class loader of ReflectUtil as baseLoader, and that infers the constructor signature from the given arguments. Note that the inference process for the constructor signature is potentially error-prone, because it uses the concrete runtime types of the objects, which may be more specific than what is needed. It is impossible, for example, to use this method to invoke a constructor whose parameters include interface, abstract class, or primitive types. In such cases, loadLibraryAdapter(Iterable, String, Class[], Object[]) should be used instead.

Throws:
ReflectException - As specified by loadObject(ClassLoader, String, Class[], Object[])

loadLibraryAdapter

public static Object loadLibraryAdapter(Iterable<? extends File> libraryPath,
                                        String adapterName,
                                        Class<?>[] constructorSig,
                                        Object... constructorArgs)
                                 throws ReflectException

Create an adapter object which provides an interface to a library that is not available statically on the class path (or, more generally, to the baseLoader). This assumes the relevant code may be organized into three groups: the base classes, which are available to the baseLoader and make no direct references to the library or adapter classes; the library classes, which are located in the path represented by libraryPath, and make no direct references to the adapter class; and the adapter class (including its inner classes), which is available to the baseLoader, and which can directly refer to both the library and base classes.

This is a convenience method that uses the class loader of ReflectUtil to load className.

Throws:
ReflectException - As specified by loadObject(ClassLoader, String, Class[], Object[])

loadLibraryAdapter

public static Object loadLibraryAdapter(ClassLoader baseLoader,
                                        Iterable<? extends File> libraryPath,
                                        String adapterName,
                                        Object... constructorArgs)
                                 throws ReflectException

Create an adapter object which provides an interface to a library that is not available statically on the class path (or, more generally, to the baseLoader). This assumes the relevant code may be organized into three groups: the base classes, which are available to the baseLoader and make no direct references to the library or adapter classes; the library classes, which are located in the path represented by libraryPath, and make no direct references to the adapter class; and the adapter class (including its inner classes), which is available to the baseLoader, and which can directly refer to both the library and base classes.

This is a convenience method that infers the constructor signature from the given arguments. Note that the inference process for the constructor signature is potentially error-prone, because it uses the concrete runtime types of the objects, which may be more specific than what is needed. It is impossible, for example, to use this method to invoke a constructor whose parameters include interface, abstract class, or primitive types. In such cases, loadLibraryAdapter(ClassLoader, Iterable, String, Class[], Object[]) should be used instead.

Throws:
ReflectException - As specified by loadObject(ClassLoader, String, Class[], Object[])

loadLibraryAdapter

public static Object loadLibraryAdapter(ClassLoader baseLoader,
                                        Iterable<? extends File> libraryPath,
                                        String adapterName,
                                        Class<?>[] constructorSig,
                                        Object... constructorArgs)
                                 throws ReflectException

Create an adapter object which provides an interface to a library that is not available statically on the class path (or, more generally, to the baseLoader). This assumes the relevant code may be organized into three groups: the base classes, which are available to the baseLoader and make no direct references to the library or adapter classes; the library classes, which are located in the path represented by libraryPath, and make no direct references to the adapter class; and the adapter class (including its inner classes), which is available to the baseLoader, and which can directly refer to both the library and base classes.

This method constructs an appropriate class loader and then invokes loadObject(ClassLoader, String, Class[], Object[]).

Throws:
ReflectException - As specified by loadObject(ClassLoader, String, Class[], Object[])

mergeLoaders

public static ComposedClassLoader mergeLoaders(ClassLoader first,
                                               ClassLoader second)
Combine two class loaders by first matching classes in first, then delegating to second.


mergeLoaders

public static ComposedClassLoader mergeLoaders(ClassLoader first,
                                               ClassLoader second,
                                               String... firstIncludes)
Combine two class loaders by matching specific classes (or class prefixes) from first, and delegating all other searches to second. Bootstrap classes will not be filtered from first.


mergeLoaders

public static ComposedClassLoader mergeLoaders(ClassLoader first,
                                               ClassLoader second,
                                               boolean blackList,
                                               String... firstPrefixes)
Combine two class loaders by matching a subset of those in first, followed by a search in second. The nature of the subset is defined by parameters blackList and firstPrefixes. Bootstrap classes will not be filtered from first.

Parameters:
blackList - Whether classes matching firstPrefixes should be shadowed in first; otherwise, all classes except those that match will be shadowed.
firstPrefixes - Class or package prefix to match in determining which classes or first are shadowed

staticFieldAsBox

public static <T> Box<T> staticFieldAsBox(Class<?> c,
                                          String fieldName,
                                          Class<T> fieldType)
Wrap a static field in a box. The field will be accessed via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the box's value() and set() methods. If the field is known statically, and performance is important, consider defining a custom box instead.


fieldAsBox

public static <T> Box<T> fieldAsBox(Object object,
                                    String fieldName,
                                    Class<T> fieldType)
Wrap a field of the given object in a box. The field will be accessed via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the box's value() and set() methods. If the field is known statically, and performance is important, consider defining a custom box instead.


staticMethodAsThunk

public static <O,R> Thunk<R> staticMethodAsThunk(Class<? super O> c,
                                                 String methodName,
                                                 Class<? extends R> retT)
Wrap a static method in a thunk. The method will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the thunk's value() method. If the method is known statically, and performance is important, consider defining a custom thunk instead.


methodAsThunk

public static <R> Thunk<R> methodAsThunk(Object object,
                                         String methodName,
                                         Class<? extends R> retT)
Wrap a method of the given object in a thunk. The method will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the thunk's value() method. If the method is known statically, and performance is important, consider defining a custom thunk instead.


methodAsLambda

public static <O,R> Lambda<O,R> methodAsLambda(Class<? super O> c,
                                               String methodName,
                                               Class<? extends R> retT)
Wrap a method in a lambda, with the receiver object as the first argument. The method will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the method is known statically, and performance is important, consider defining a custom lambda instead.


staticMethodAsLambda

public static <O,T,R> Lambda<T,R> staticMethodAsLambda(Class<? super O> c,
                                                       String methodName,
                                                       Class<? super T> argT,
                                                       Class<? extends R> retT)
Wrap a static method in a lambda. The method will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the method is known statically, and performance is important, consider defining a custom lambda instead.


methodAsLambda

public static <T,R> Lambda<T,R> methodAsLambda(Object object,
                                               String methodName,
                                               Class<? super T> argT,
                                               Class<? extends R> retT)
Wrap a method of the given object in a lambda. The method will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the method is known statically, and performance is important, consider defining a custom lambda instead.


methodAsLambda2

public static <O,T,R> Lambda2<O,T,R> methodAsLambda2(Class<? super O> c,
                                                     String methodName,
                                                     Class<? super T> argT,
                                                     Class<? extends R> retT)
Wrap a method in a lambda, with the receiver object as the first argument. The method will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the method is known statically, and performance is important, consider defining a custom lambda instead.


staticMethodAsLambda2

public static <O,T1,T2,R> Lambda2<T1,T2,R> staticMethodAsLambda2(Class<? super O> c,
                                                                 String methodName,
                                                                 Class<? super T1> arg1T,
                                                                 Class<? super T2> arg2T,
                                                                 Class<? extends R> retT)
Wrap a static method in a lambda. The method will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the method is known statically, and performance is important, consider defining a custom lambda instead.


methodAsLambda2

public static <T1,T2,R> Lambda2<T1,T2,R> methodAsLambda2(Object object,
                                                         String methodName,
                                                         Class<? super T1> arg1T,
                                                         Class<? super T2> arg2T,
                                                         Class<? extends R> retT)
Wrap a method of the given object in a lambda. The method will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the method is known statically, and performance is important, consider defining a custom lambda instead.


methodAsLambda3

public static <O,T1,T2,R> Lambda3<O,T1,T2,R> methodAsLambda3(Class<? super O> c,
                                                             String methodName,
                                                             Class<? super T1> arg1T,
                                                             Class<? super T2> arg2T,
                                                             Class<? extends R> retT)
Wrap a method in a lambda, with the receiver object as the first argument. The method will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the method is known statically, and performance is important, consider defining a custom lambda instead.


staticMethodAsLambda3

public static <O,T1,T2,T3,R> Lambda3<T1,T2,T3,R> staticMethodAsLambda3(Class<? super O> c,
                                                                       String methodName,
                                                                       Class<? super T1> arg1T,
                                                                       Class<? super T2> arg2T,
                                                                       Class<? super T3> arg3T,
                                                                       Class<? extends R> retT)
Wrap a static method in a lambda. The method will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the method is known statically, and performance is important, consider defining a custom lambda instead.


methodAsLambda3

public static <T1,T2,T3,R> Lambda3<T1,T2,T3,R> methodAsLambda3(Object object,
                                                               String methodName,
                                                               Class<? super T1> arg1T,
                                                               Class<? super T2> arg2T,
                                                               Class<? super T3> arg3T,
                                                               Class<? extends R> retT)
Wrap a method of the given object in a lambda. The method will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the method is known statically, and performance is important, consider defining a custom lambda instead.


methodAsLambda4

public static <O,T1,T2,T3,R> Lambda4<O,T1,T2,T3,R> methodAsLambda4(Class<? super O> c,
                                                                   String methodName,
                                                                   Class<? super T1> arg1T,
                                                                   Class<? super T2> arg2T,
                                                                   Class<? super T3> arg3T,
                                                                   Class<? extends R> retT)
Wrap a method in a lambda, with the receiver object as the first argument. The method will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the method is known statically, and performance is important, consider defining a custom lambda instead.


constructorAsThunk

public static <R> Thunk<R> constructorAsThunk(Class<? extends R> c)
Wrap a constructor in a thunk. The constructor will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the thunk's value() method. If the constructor is known statically, and performance is important, consider defining a custom thunk instead.


constructorAsLambda

public static <T,R> Lambda<T,R> constructorAsLambda(Class<? extends R> c,
                                                    Class<? super T> argT)
Wrap a constructor in a lambda. The constructor will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the constructor is known statically, and performance is important, consider defining a custom lambda instead.


constructorAsLambda2

public static <T1,T2,R> Lambda2<T1,T2,R> constructorAsLambda2(Class<? extends R> c,
                                                              Class<? super T1> arg1T,
                                                              Class<? super T2> arg2T)
Wrap a constructor in a lambda. The constructor will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the constructor is known statically, and performance is important, consider defining a custom lambda instead.


constructorAsLambda3

public static <T1,T2,T3,R> Lambda3<T1,T2,T3,R> constructorAsLambda3(Class<? extends R> c,
                                                                    Class<? super T1> arg1T,
                                                                    Class<? super T2> arg2T,
                                                                    Class<? super T3> arg3T)
Wrap a constructor in a lambda. The constructor will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the constructor is known statically, and performance is important, consider defining a custom lambda instead.


constructorAsLambda4

public static <T1,T2,T3,T4,R> Lambda4<T1,T2,T3,T4,R> constructorAsLambda4(Class<? extends R> c,
                                                                          Class<? super T1> arg1T,
                                                                          Class<? super T2> arg2T,
                                                                          Class<? super T3> arg3T,
                                                                          Class<? super T4> arg4T)
Wrap a constructor in a lambda. The constructor will be invoked via reflection, and any resulting errors will be thrown as ReflectExceptions nested in WrappedExceptions by the lambda's value() method. If the constructor is known statically, and performance is important, consider defining a custom lambda instead.