|
JMMF API pre-release v0.4 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.lang.reflect.AccessibleObject
|
+--fr.umlv.jmmf.reflect.MultiMethod
an implementation of the multi-method. This class support the 1.2 security model. The current implementation of the multi-method mecanism desactivate default Java language access control checks.
class Test {
interface A {}
class B implemnts A {}
class C implements A
{ int value; }
static public String toString(B b)
{ return b.toString(); }
static public String toString(C c)
{ return String.valueOf(c.value); }
public static void main(String[] args)
throw Throwable
{
MultiMethod mm=new MultiMethod("toString",Test.class);
A a=new B();
System.out.println(mm.invoke(null,new Object[]{a}));
a=new C();
System.out.println(mm.invoke(null,new Object[]{a}));
Method method=mm.asMethod();
System.out.println(method);
System.out.println(method.invoke(null,new Object[]{a}));
}
}
| Fields inherited from interface java.lang.reflect.Member |
DECLARED,
PUBLIC |
| Method Summary | |
java.lang.reflect.Method |
asMethod()
return a Java Method object that corresponding to the current multi-method. this method is dynamically generated. |
java.lang.reflect.Method |
asMethod(java.lang.ClassLoader loader)
return a Java Method object that corresponding to the current multi-method. this method is dynamically generated. |
static MultiMethod |
create(java.lang.Class clazz,
java.lang.String name,
int argLength)
construct a multi-method by taking all method named name with argLength parameter(s) in class clazz. |
static MultiMethod |
create(java.lang.Class clazz,
java.lang.String name,
int argLength,
boolean onlyPublic)
construct a multi-method by taking all method named name with argLength parameter(s) in class clazz. |
boolean |
equals(java.lang.Object o)
Compares this MultiMethod against the specified
object.
|
java.lang.Class |
getDeclaringClass()
return class that contains all methods of the current multi-method. |
java.lang.Class[] |
getExceptionTypes()
return the exception types of the current method. |
int |
getModifiers()
returns the Java language modifiers for the multi-method represented by this MultiMethod object,
as an integer. |
java.lang.String |
getName()
return the name of the current multi-method. |
java.lang.Class[] |
getParameterTypes()
return the parameter types of the current method. a parameter type is the lowest common subtype of all parameter types of the methods that composed the multi-method. |
java.lang.Class |
getReturnType()
return the return type of the current method. a return type is the lowest common subtype of all return types of the methods that composed the multi-method. |
int |
hashCode()
Returns a hashcode for this MultiMethod.
|
java.lang.Object |
invoke(java.lang.Object target,
java.lang.Object[] args)
call the best method of the multi-method according to the type of all items if args array on a specified target object. |
java.lang.Object |
invoke(java.lang.Object target,
java.lang.Object[] args,
java.lang.Class[] types)
call the best method of the multi-method according to the type of all items if args array on a specified target object. |
java.lang.String |
toString()
return a string representation of the multi-method. |
| Methods inherited from class java.lang.reflect.AccessibleObject |
isAccessible,
setAccessible,
setAccessible |
| Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
| Method Detail |
public boolean equals(java.lang.Object o)
MultiMethod against the specified
object.
Returns true if the objects are the same. Two
MultiMethods are the same if they were declared by the
same class and have the same name and formal
parameter types and return type.public int hashCode()
MultiMethod.
The hashcode is computed
as the exclusive-or of the hashcodes for the underlying
method's declaring class name and the method's name.public java.lang.String toString()
public java.lang.Object invoke(java.lang.Object target,
java.lang.Object[] args)
throws java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
NoMatchingMethodException,
MultipleMatchingMethodsException
target - object on which the best method is called.args - arguments of the multi-method, the types on this
arguments is used to called the best method.java.lang.reflect.Method.invoke,
invoke(Object, Object[])
public java.lang.Object invoke(java.lang.Object target,
java.lang.Object[] args,
java.lang.Class[] types)
throws java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
NoMatchingMethodException,
MultipleMatchingMethodsException
target - object on which the best method is called.args - arguments of the multi-method,types - the best method of the multi-method is
called according to this types.java.lang.reflect.Method.invokepublic int getModifiers()
MultiMethod object,
as an integer. The Modifier class should
be used to decode the modifiers.Modifierpublic java.lang.String getName()
public java.lang.Class getDeclaringClass()
public java.lang.Class[] getParameterTypes()
java.lang.reflect.Method.getParameterTypespublic java.lang.Class[] getExceptionTypes()
java.lang.reflect.Method.getExceptionTypespublic java.lang.Class getReturnType()
java.lang.reflect.Method.getReturnTypepublic java.lang.reflect.Method asMethod()
public java.lang.reflect.Method asMethod(java.lang.ClassLoader loader)
loader - classloader used to load the class that contains
the method.
public static MultiMethod create(java.lang.Class clazz,
java.lang.String name,
int argLength)
clazz - class which owns the named methods.name - name of the methods.argLenth - number of parameters.
public static MultiMethod create(java.lang.Class clazz,
java.lang.String name,
int argLength,
boolean onlyPublic)
clazz - class which owns the named methods.name - name of the methods.argLenth - number of parameters.
|
JMMF API pre-release v0.4 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||