JavaParty Object Model

Remote classes

Remote classes and their instances are the "first class" objects in JavaParty. JavaParty provides a runtime environment distributed over several machines that approximately behaves like a single Java virtual machine with respect to remote objects:

  • Remote objects as arguments and results of method invocations are passed by reference.
  • Instance variables of remote objects are accessible from anywhere in the distributed environment.
  • Remote classes along with their static variables and static methods are represented as unique entities in the environment.

Local classes

Existing regular Java classes can be reused in distributed JavaParty programs or can be written and compiled with the JavaParty compiler. Local classes are all classes that are not marked with the remote modifier.

Local objects are always private to the remote object they are created in. If they are passed to methods of other remote objects or stored into instance variables of other remote objects, they are always copied.

Local classes and objects behave in the distributed environment according to the following rules:

  • Instances of local classes are bound to the virtual machine they are created in and can not be referenced from other nodes of the environment.
  • Local objects can be passed as arguments to remote method invocations and can be returned as result. Like in RMI, local objects are always passed by copy, no matter whether the target remote object resides on the same virtual machine or not.
  • A local class is loaded and initialized separately in each virtual machine that participates in the JavaParty environment.
  • Accesses to static methods and static variables of local classes always affect the class loaded on the current virtual machine.

Note: Good practice for JavaParty program is not to use non-final static fields of local classes, since you would loose location transparency.

Method invocations on remote objects

Invoking a method of a remote object not necessarily results in a remote method invocation. A method invocation is considered to be local, if it is syntactically evident that a method of the same remote object is invoked. In that case local method invocation semantics apply and all parameters of object type are passed by reference no matter whether they are remote or not. The following sections explain what is considered to be a remote invocation in JavaParty and what is not.

Local invocations

The method invocation occurs within a non-static method of a remote object and no explicit reference, the this, or the super reference is used. In that case it is syntactically clear that a method of a the same remote object is invoked.

The following invocations of method bar() are considered to be non-remote method invocations, and local semantics apply: Any additional arguments would be passed by reference, even if they are local objects:

remote class R {
    void bar() { ... }

    void foo() {
        bar();       // local access;  // local access

Remote invocations

In contrast, the following invocation of method bar() is considered to be remote, and any additional local object parameters would be copied, even if at runtime a method of the same object will be invoked:

remote class R {
    void bar() { ... }

    void foo() {
        R r = this;;  // remote access

The difference to the previous example is that from the syntax of the invocation it is not evident that a method of the same object will be invoked. Because an explicit reference to an arbitrary object r is used, this access is considered to be a remote access and remote semantics apply.

From the above follows that an invocation of a static method of a remote class is always considered to be a remote invocation, unless it is from within a static method of the same class.

In the following example a static method s_bar() is invoked from within a non-static method of the same class. In all three invocations of s_bar() remote semantics apply, because the object that currently executes the method foo() and the object representing the remote class R could be allocated on different nodes.

remote class R {
    static void s_bar() { ... }

    void foo() {
        R r = this;

        s_bar();   // remote access
        R.s_bar()  // remote access
        r.s_bar()  // remote access

You can try the example source:trunk/jp/src/examples/ to verify these descriptions of the JavaParty behavior.

Last modified 11 years ago Last modified on Mar 23, 2006 12:42:17 AM