Having demonstrated the need for the extension of the Java method signature, in order to support
both input and output parameters, we are left with the task of devising a suitable mechanism.
In a non-reflective language, the solution would be likely to involve both a set of keywords (e.g. in and out) and
a pre-processing phase during which these would be interpreted and removed--before the java compiler be invoked.
Java however offers a more elegant alternative using, once again, the reflective capabilities of
the language.
Let us define the following scheme:
the valid parameter passing modes are __in and __out
for each function parameter, its mode must be appended to the function name
modes must be specified in the same order as their corresponding parameter
all input parameters must precede the first output parameter in the definition sequence
An example of such a method prototype is given in Table 4.1.
Table 4.1:
Example of an extended method prototype
All method prototypes resulting from this scheme will be valid with respect to the Java language. No pre-processing
stage is therefore required. The method name can be obtained by reflection, and parsed in order to reconcile
the parameters with their respective passing mode. This is the role of the ModeQueueBuilder class (c.f. Figure B.2).