|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.vub.at.objects.symbiosis.Symbiosis
The Symbiosis class is a container for auxiliary methods pertaining to making symbiotic reflective Java invocations.
Constructor Summary | |
Symbiosis()
|
Method Summary | |
static java.lang.Object |
ambientTalkToJava(ATObject atObj,
java.lang.Class targetType)
Convert an AmbientTalk object into an equivalent Java object. |
private static java.lang.Object[] |
atArgsToJavaArgs(ATObject[] args,
java.lang.Class[] types)
|
static JavaField[] |
getAllFields(java.lang.Object ofObject,
java.lang.Class fromClass)
Retrieve all public static or non-static fields from a given Java class (this includes fields defined in superclasses, but excludes shadowed superclass fields). |
static JavaMethod[] |
getAllMethods(java.lang.Class fromClass,
boolean isStatic)
Retrieve all public static or non-static methods from a given Java class (this includes methods defined in superclasses). |
static java.lang.reflect.Field |
getField(java.lang.Class fromClass,
java.lang.String fieldName,
boolean isStatic)
Retrieve a field from a Java object. |
static JavaMethod |
getMethods(java.lang.Class fromClass,
java.lang.String selector,
boolean isStatic)
Retrieve all methods of a given name from a Java object. |
static boolean |
hasField(java.lang.Class c,
java.lang.String selector,
boolean isStatic)
Query whether the given Java Class contains a (non-)static field with the given selector |
static boolean |
hasMethod(java.lang.Class c,
java.lang.String selector,
boolean isStatic)
Query whether the given Java Class contains a (non-)static method with the given selector |
private static ATObject |
invokeUniqueSymbioticConstructor(java.lang.reflect.Constructor ctor,
java.lang.Object[] jArgs)
|
private static ATObject |
invokeUniqueSymbioticMethod(java.lang.Object symbiont,
java.lang.reflect.Method javaMethod,
java.lang.Object[] jArgs)
|
static ATObject |
javaToAmbientTalk(java.lang.Object jObj)
Convert a Java object into an AmbientTalk object. |
static ATObject |
readField(java.lang.Object fromObject,
java.lang.Class ofClass,
java.lang.String fieldName)
Read a field from the given Java object reflectively. |
static ATObject |
readField(java.lang.Object fromObject,
java.lang.reflect.Field f)
Read a field from the given Java object reflectively. |
static ATObject |
symbioticInstanceCreation(java.lang.Class ofClass,
ATObject[] atArgs)
Creates a new instance of a Java class. |
static ATObject |
symbioticInvocation(ATObject wrapper,
java.lang.Object symbiont,
java.lang.Class ofClass,
java.lang.String selector,
ATObject[] atArgs)
|
static ATObject |
symbioticInvocation(ATObject wrapper,
java.lang.Object symbiont,
java.lang.String selector,
JavaMethod jMethod,
ATObject[] atArgs)
The Java method invocation algorithm is as follows: case of # of methods matching selector: 0 => XSelectorNotFound 1 => invoke the method OR XIllegalArgument, XArityMismatch, XReflectionFailure * => (case of # of methods with matching arity OR taking varargs: 0 => XSymbiosisFailure 1 => invoke the method OR XIllegalArgument, XReflectionFailure * => (case of # of methods matching 'default type' of the actual arguments: 0 => XSymbiosisFailure 1 => invoke OR XReflectionFailure * => XSymbiosisFailure)) A Java method takes a variable number of AT arguments <=> it has one formal parameter of type ATObject[] |
private static java.lang.reflect.Method |
toInterfaceMethod(java.lang.reflect.Method m)
Extremely vague and dirty feature of Java reflection: it can sometimes happen that a method is invoked on a private inner class via a publicly accessible interface method. |
static void |
writeField(java.lang.Object toObject,
java.lang.Class ofClass,
java.lang.String fieldName,
ATObject value)
Write a field in the given Java object reflectively. |
static void |
writeField(java.lang.Object toObject,
java.lang.reflect.Field f,
ATObject value)
Write a field in the given Java object reflectively. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Symbiosis()
Method Detail |
public static ATObject symbioticInvocation(ATObject wrapper, java.lang.Object symbiont, java.lang.Class ofClass, java.lang.String selector, ATObject[] atArgs) throws InterpreterException
InterpreterException
public static ATObject symbioticInvocation(ATObject wrapper, java.lang.Object symbiont, java.lang.String selector, JavaMethod jMethod, ATObject[] atArgs) throws InterpreterException
wrapper
- the ATObject wrapper for the symbiontsymbiont
- the Java object being accessed from within AmbientTalkselector
- the Java selector corresponding to the method invocationjMethod
- a JavaMethod encapsulating all applicable Java methods that correspond to the selectoratArgs
- the AT args to the symbiotic invocation
XArityMismatch
- if the wrong number of arguments were supplied
XSelectorNotFound
- if no methods correspond to the given selector (i.e. jMethod is null)
XTypeMismatch
- if one of the arguments cannot be converted into the static type expected by the Java method
XSymbiosisFailure
- if the method is overloaded and cannot be unambiguously resolved given the actual arguments
XReflectionFailure
- if the invoked method is not accessible from within AmbientTalk
XJavaException
- if the invoked Java method throws a Java exception
InterpreterException
public static ATObject symbioticInstanceCreation(java.lang.Class ofClass, ATObject[] atArgs) throws InterpreterException
ofClass
- the Java class of which to create an instanceatArgs
- the AmbientTalk arguments to the constructor, to be converted to Java arguments
XArityMismatch
- if the wrong number of arguments were supplied
XNotInstantiatable
- if no public constructors are available or if the class is abstract
XTypeMismatch
- if one of the arguments cannot be converted into the static type expected by the constructor
XSymbiosisFailure
- if the constructor is overloaded and cannot be unambiguously resolved given the actual arguments
XReflectionFailure
- if the invoked constructor is not accessible from within AmbientTalk
XJavaException
- if the invoked Java constructor throws a Java exception
InterpreterException
public static ATObject readField(java.lang.Object fromObject, java.lang.Class ofClass, java.lang.String fieldName) throws InterpreterException
InterpreterException
public static ATObject readField(java.lang.Object fromObject, java.lang.reflect.Field f) throws InterpreterException
InterpreterException
public static void writeField(java.lang.Object toObject, java.lang.Class ofClass, java.lang.String fieldName, ATObject value) throws InterpreterException
toObject
- if null, the field is assumed to be staticvalue
- the AmbientTalk value which will be converted into its Java equivalent to be written int he field
InterpreterException
public static void writeField(java.lang.Object toObject, java.lang.reflect.Field f, ATObject value) throws InterpreterException
value
- the AmbientTalk value which will be converted into its Java equivalent to be written int he field
InterpreterException
public static boolean hasMethod(java.lang.Class c, java.lang.String selector, boolean isStatic)
public static boolean hasField(java.lang.Class c, java.lang.String selector, boolean isStatic)
public static java.lang.reflect.Field getField(java.lang.Class fromClass, java.lang.String fieldName, boolean isStatic) throws XUndefinedField
XUndefinedField
- if the field does not exist or its static property does not matchpublic static JavaMethod getMethods(java.lang.Class fromClass, java.lang.String selector, boolean isStatic)
public static JavaMethod[] getAllMethods(java.lang.Class fromClass, boolean isStatic)
isStatic
- if true, all static methods of fromClass are returned, otherwise the instance methods are returnedpublic static JavaField[] getAllFields(java.lang.Object ofObject, java.lang.Class fromClass)
ofObject
- if null, all static fields of fromClass are returned, otherwise the instance fields are returnedpublic static final ATObject javaToAmbientTalk(java.lang.Object jObj) throws InterpreterException
jObj
- the Java object representing a mirror or a native type
InterpreterException
public static final java.lang.Object ambientTalkToJava(ATObject atObj, java.lang.Class targetType) throws InterpreterException
atObj
- the AmbientTalk object to convert to a Java valuetargetType
- the known static type of the Java object that should be attained
XTypeMismatch
- if the object cannot be converted into the correct Java targetType
InterpreterException
private static ATObject invokeUniqueSymbioticMethod(java.lang.Object symbiont, java.lang.reflect.Method javaMethod, java.lang.Object[] jArgs) throws InterpreterException
InterpreterException
private static ATObject invokeUniqueSymbioticConstructor(java.lang.reflect.Constructor ctor, java.lang.Object[] jArgs) throws InterpreterException
InterpreterException
private static java.lang.Object[] atArgsToJavaArgs(ATObject[] args, java.lang.Class[] types) throws InterpreterException
InterpreterException
private static java.lang.reflect.Method toInterfaceMethod(java.lang.reflect.Method m)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |