|
ref_send API 2.17 defensive programming in Java |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.joe_e.reflect.Reflection
public final class Reflection
The reflection interface.
This API provides reflective access to all the public constructors, public fields and public methods of public Joe-E classes and interfaces. The API provides no more permission than is provided by static Joe-E program code. If you can do something with the reflection API, you could also have done it using static Joe-E code. The only difference is expressivity.
Method Summary | ||
---|---|---|
static void |
clearStackTrace(java.lang.Throwable e)
Clears the stack trace on an exception. |
|
static
|
construct(java.lang.reflect.Constructor<T> ctor,
java.lang.Object... args)
Invokes a reflected constructor. |
|
static
|
constructor(java.lang.Class<T> type,
java.lang.Class<?>... args)
Gets a public constructor. |
|
static PowerlessArray<java.lang.reflect.Constructor<?>> |
constructors(java.lang.Class<?> type)
Gets all declared public constructors. |
|
static java.lang.reflect.Field |
field(java.lang.Class<?> type,
java.lang.String name)
Gets a public field. |
|
static PowerlessArray<java.lang.reflect.Field> |
fields(java.lang.Class<?> type)
Gets all public fields. |
|
static java.lang.Object |
get(java.lang.reflect.Field field,
java.lang.Object self)
Gets the value of a field. |
|
static java.lang.String |
getName(java.lang.Class<?> c)
Get the name of the entity represented by a Class object,
in the same format as returned by Class.getName() . |
|
static java.lang.Object |
invoke(java.lang.reflect.Method method,
java.lang.Object self,
java.lang.Object... args)
Invokes a reflected method. |
|
static java.lang.reflect.Method |
method(java.lang.Class<?> type,
java.lang.String name,
java.lang.Class<?>... args)
Gets a public method. |
|
static PowerlessArray<java.lang.reflect.Method> |
methods(java.lang.Class<?> type)
Gets all public methods. |
|
static void |
set(java.lang.reflect.Field field,
java.lang.Object self,
java.lang.Object value)
Sets the value of a field. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.reflect.Field field(java.lang.Class<?> type, java.lang.String name) throws java.lang.NoSuchFieldException
This method wraps Class.getField(java.lang.String)
.
type
- class to searchname
- field name
java.lang.NoSuchFieldException
- no matching field foundpublic static PowerlessArray<java.lang.reflect.Field> fields(java.lang.Class<?> type)
This method wraps Class.getFields()
.
type
- object type
public static <T> java.lang.reflect.Constructor<T> constructor(java.lang.Class<T> type, java.lang.Class<?>... args) throws java.lang.NoSuchMethodException
This method wraps Class.getConstructor(java.lang.Class>...)
.
type
- class to searchargs
- each parameter type
java.lang.NoSuchMethodException
- no matching constructor foundpublic static PowerlessArray<java.lang.reflect.Constructor<?>> constructors(java.lang.Class<?> type)
This method wraps Class.getConstructors()
.
type
- class to search
public static java.lang.reflect.Method method(java.lang.Class<?> type, java.lang.String name, java.lang.Class<?>... args) throws java.lang.NoSuchMethodException
This method wraps Class.getMethod(java.lang.String, java.lang.Class>...)
.
type
- class to searchname
- method nameargs
- each parameter type
java.lang.NoSuchMethodException
- no matching method foundpublic static PowerlessArray<java.lang.reflect.Method> methods(java.lang.Class<?> type)
This method wraps Class.getMethods()
.
type
- object type
public static java.lang.String getName(java.lang.Class<?> c)
Class
object,
in the same format as returned by Class.getName()
. This wrapper
exists to avoid exposing the number of proxy interfaces that have been
generated.
c
- the class to get the name of
c
java.lang.IllegalArgumentException
- if c
is a proxy classpublic static void clearStackTrace(java.lang.Throwable e)
e
- exception to modifypublic static java.lang.Object get(java.lang.reflect.Field field, java.lang.Object self) throws java.lang.IllegalAccessException
field
- field to accessself
- target object
java.lang.IllegalAccessException
- field
is inaccessiblepublic static void set(java.lang.reflect.Field field, java.lang.Object self, java.lang.Object value) throws java.lang.IllegalAccessException
field
- field to accessself
- target objectvalue
- new value
java.lang.IllegalAccessException
- field
is inaccessiblepublic static <T> T construct(java.lang.reflect.Constructor<T> ctor, java.lang.Object... args) throws java.lang.Exception
ctor
- constructor to invokeargs
- each argument
java.lang.IllegalAccessException
- ctor
is inaccessible
java.lang.ClassCastException
- ctor.newInstance()
throws an
IllegalArgumentException
, usually due to mismatched types
java.lang.Exception
- an exception thrown by the invoked constructorpublic static java.lang.Object invoke(java.lang.reflect.Method method, java.lang.Object self, java.lang.Object... args) throws java.lang.Exception
method
- method to invokeself
- target objectargs
- each argument
java.lang.IllegalAccessException
- method
is inaccessible
java.lang.ClassCastException
- method.invoke()
throws an
IllegalArgumentException
, usually due to mismatched types
java.lang.Exception
- an exception thrown by the invoked method
|
ref_send API 2.17 defensive programming in Java |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1998-2009 Waterken Inc. under the terms of the MIT X license.