Check out the new USENIX Web site. next up previous
Next: Using JAVA reflection Up: Accessors Previous: Accessors

Querying objects

Informally, an accessor A is characterized by a set of tuples: A=((M1, P1), ..., (Mk, Pk)), where every Mi is a method and Pi=(Pi,1, ...,Pi,l(i)) its corresponding argument list. Whenever a method Mi is applied to an object, this subsumes that it is invoked with its arguments Pi.

An accessor can be seen as a function, which applied to a message object returns another object: A(o: obj): obj. When such an accessor A is evaluated for a message object m, M1 is invoked on m and every method Mi+1 (0 < i < k) is recursively invoked on the result of Mi. Finally, the result of Mk is returned.[*]

In JAVA, an accessor object implements the interface Accessor given in Figure 4, and is evaluated by calling the get() method with the message object as argument. This method can throw exceptions raised when evaluating the method chain, which enables the reaction to exceptions. Returning null in case of exceptions would contradict the use of null as matching criterion.

public interface Accessor {

  public Object get(Object m) throws Exception;

Figure 4: Accessor Interface

Patrick Eugster