|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--com.svincent.util.BaseObject
|
+--com.svincent.util.ReflectUtil
Minimizes the tedium of Java reflection.
Java reflection is an exciting technology which enables a whole new style of programming. It's particularly exciting when coupled with dynamically generated code, for langauge interpreters, etc.
Unfortunately, every time you do reflection, you're swamped with exceptions. SecurityExceptions, MethodNotFound exceptions, etc etc. It's enough to drive one batty. It's good to know various things happened, but most of the time, you just want to fail gracefully on all of them.
ReflectUtil is designed to minimize some of the horrors of reflectively accessing java objects, by repackaging some exceptions.
XXX current issue: ReflectException should be subclassed, so that various exceptions can be managed, if desired.
| Method Summary | |
static void |
callMain(java.lang.Class c,
java.lang.String[] args)
Calls the main() method on the given class. |
static java.lang.Object |
construct(java.lang.Class c,
java.lang.Object[] args)
|
static java.lang.Object |
construct(java.lang.String className,
java.lang.Object[] args)
|
static java.lang.reflect.Method |
getMethod(java.lang.Class clazz,
java.lang.String name,
java.lang.Class[] parmTypes)
Return a method of 'c' with the given name and parameters. |
static java.lang.String |
getMethodSignature(java.lang.reflect.Method method)
Return a human-readable method signature for the given method. |
static java.lang.String |
getMethodSignature(java.lang.String name,
java.lang.Class[] parmTypes)
Return a human-readable method signature for the method with the given name and parameters. |
static java.lang.Object |
invoke(java.lang.Object self,
java.lang.reflect.Method method,
java.lang.Object[] parms)
Invokes the given method, wrapping exceptions up in ReflectExceptions for ease of consumption. |
| Methods inherited from class com.svincent.util.BaseObject |
dump,
dump,
dumpToString,
tag |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Method Detail |
public static void callMain(java.lang.Class c,
java.lang.String[] args)
throws ReflectException
public static java.lang.Object construct(java.lang.String className,
java.lang.Object[] args)
throws ReflectException
public static java.lang.Object construct(java.lang.Class c,
java.lang.Object[] args)
throws ReflectException
public static java.lang.reflect.Method getMethod(java.lang.Class clazz,
java.lang.String name,
java.lang.Class[] parmTypes)
throws ReflectException
public static java.lang.Object invoke(java.lang.Object self,
java.lang.reflect.Method method,
java.lang.Object[] parms)
throws ReflectException
public static java.lang.String getMethodSignature(java.lang.String name,
java.lang.Class[] parmTypes)
public static java.lang.String getMethodSignature(java.lang.reflect.Method method)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
This is documentation for Moksa Prolog, which can be found at http://www.svincent.com/moksa/
Copyright © 1999 Shawn P. Vincent.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.