Tatsurou Sekiguchi' Web Site [English] [“ú–{Œê]

Programming Reference

A migration is described in an extended Java language. A program in the extended language is translated into a program in the standard Java language by JavaGO compiler (jgoc). Then, a generated Java program can be compiled by any standard Java compiler. The extension introduces only three keywords go, undock and migratory. The migration in JavaGO is completely controlled by these three keywords.

The go statement

A migration is initiated by executing a go statement. A go statement takes a string as an input and may throw an exception.

void go( java.lang.String destination ) throws java.lang.Exception,
    javago.NotifyGone;

The destination is designated by a URL. There are two kinds of destination URLs.

jgp://host:port/namespace It specifies a name and a port number of a migration server, and a name space in the migration server. If a migration succeeds, the current thread terminates in the departure host, and then it is resumed in the destination host. When no name space is specified, the runtime system automatically assigns a random name space with the thread.
file:///dir/file It specifies a file into which the execution state of the current thread is stored. The execution continues when state saving succeeds.

When a migration takes place, exception javago.NotifyGone is thrown. Since this exception is used to implement the JavaGO migration mechanism, it must not be blocked. Exception javago.NotifyGone is a subclass of Throwable. When a migration fails, an exception is thrown that notifies the reason of the failure. Error handling of a go statement can be written as follows.

try {
    ...
    go ("jgp://flute:12002/test_place");
    ...
} catch (Exception err) {
    ...
}

A go statement must not be put in a constructor nor an initializer. In addition, a go statement must not be put in a non-migratory method provided that it is not enclosed within an undock statement. A go statement must not be put in the initialization part, the conditional part and the iteration part of a for statement.

The undock statement

A part of a thread that is moved on migration can be controlled by using an undock statement.

undock {
    ...
}

The migrated part is the inside area of an undock statement. When a go statement is within overlapped scopes of several undock statements, the migrated part is the innermost one. An undock statement blocks exception javago.NotifyGone, and throws exception java.lang.Exception. An undock statement must not be put in a constructor nor an initializer.

The migratory method modifier

A migration can take place in a method that is declared as migratory.

public migratory void foo();

The method declared as migratory is called a migratory method. A migratory method can be called in a migratory method, but it must not be called in a non-migratory method unless it is not enclosed within an undock statement. A migratory method must no be called in the initialization part, the conditional part and the iteration part of a for statement.

Thread Restoration from a File

To restore a thread from a file, use the following library function.

public static void javago.StackFrame.Restore( String Path )
    throws Exception;

The parameter is a path of the file. If some problems occur, an exception that notifies the reason of the failure is thrown.

Points to Notice in Programming

  • The JavaGO Compiler may add new variables and labels whose prefixes are "M_" into a method.
  • New inner classes may be defined.
  • New methods whose names begin with "UD" may be defined.
  • The class of every local variable whose value may be transmitted to a remote computer must be declared as public and must implement java.io.Serializable.
Copyright (C) Tatsurou Sekiguchi. All rights reserved.