JavaParty Syntax

Extended JavaParty Syntax

The JavaParty language extends the Java language with only one new modifier called remote. By prepending a class declaration with the remote modifier, the class is declared to be a remote class.

public remote class R {
    /** instance variable of remote class */
    public int x;

    /** instance method of remote class */
    public void foo() { ... }

    /** static variable of remote class */
    public static int y;

    /** static method of remote class */
    public static void bar() { ... }

The instances of a remote class are the "first class" members of a distributed JavaParty environment. They are able to interact with each other, even if they reside on different machines coupled to a JavaParty environment. Accessing Remote Objects and Classes

Syntactically, there is no further difference between remote classes and non-remote classes. Instances of remote classes are created with the new keyword, and the static and non-static members can be accessed like in regular Java.

// create an instance of remote class R
R r = new R()

// access an instance variable of the created remote object
r.x = 42;

// call its method foo()

// access a static member of the remote class R
R.y = 13;

// call a static method of the remote class;

Runtime Type System

The instanceof operator is used in Java to test an object to be an instance of a certain class at runtime. This mechanism works in JavaParty, too. Remote objects can be assigned to any variable that is declared to be of type java.lang.Object. The contents of that variable can thereafter be tested to be of a certain remote class like any other Java class.

Object obj = new R();

// Test whether obj is an instance of remote class R.
if (obj instanceof R) { ... }
Last modified 16 years ago Last modified on Mar 23, 2006 12:42:05 AM