uk.ac.cam.cl.ijam
Class Runtime

java.lang.Object
  extended by uk.ac.cam.cl.ijam.Runtime

public class Runtime
extends java.lang.Object

This is the main class of the program. The program can parse basic module files, compile them into module definitions. It can then instantiate these module definitions into module instances, and execute module instances.

The contents of the module definitions, i.e. the classes, can contain any Java code --- we simply changed the default classloader, so that the classes are now looked up in the following order:

  1. the Java's core library (java._, javax._);
  2. the module's normal members;
  3. the imported module instances (recursively).

Therefore, instead of searching for a class in the reverse depth-first search (as in the Java Module System), we are searching for it first in the core library, then with the (non-reverse) depth-first search. We believe this gives a more intuitive and more useful semantics, as we explain in our paper.

The same procedure is taken when looking up a module definition in the repository structure, i.e. we look in the repository itself first, only then in its parent (recursively).

Third, and most importantly, we allow the developer of a superpackage to specify whether he/she wants to share a particular import or not, and (if yes) with whom. A superpackage can also specify whether it prefers to replicate when being imported. See the documentation of the ImportDependency class for more details.

Since this is a toy implementation made only to show the benefits of the modified class lookup function and the ability to specify import dependencies more expressively, many aspects of it are simplified. For example, each module definition has a corresponding directory, which represents its contents.

The user can enter compatibility mode, which will give the Lightweight Java Module System's (LJAM's) semantics instead.

See Also:
main(String[]), ModuleDefinition, ImportDependency

Field Summary
private static Repository BOOTSTRAP_R
           
(package private) static boolean COMPATIBILITY_MODE
           
 
Constructor Summary
Runtime()
           
 
Method Summary
private static void executeMain(java.lang.String arg)
          Execute the specified class.
private static java.util.List<java.io.File> findModuleFiles()
          As the name suggests, this method finds the module files.
static void main(java.lang.String[] args)
          This is the entry point of the iJAM's Runtime.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPATIBILITY_MODE

static boolean COMPATIBILITY_MODE

BOOTSTRAP_R

private static final Repository BOOTSTRAP_R
Constructor Detail

Runtime

public Runtime()
Method Detail

main

public static void main(java.lang.String[] args)

This is the entry point of the iJAM's Runtime. It will execute the specified main classes (prefixed with their module definitions). The module files are assumed to be in the executing directory; and the contents of each corresponding module definition (class files) in the same-named, sub-directories.

Try executing with the following command:
java Runtime A::Main B::Main C::Main D::Main

Parameters:
args - An optional first argument -cm specifies that the system should use LJAM's semantics. The following arguments are the classes (with module prefixes) to execute, e.g. "B::Main".

findModuleFiles

private static java.util.List<java.io.File> findModuleFiles()
As the name suggests, this method finds the module files. The method assumes that the contents of each module definition, i.e. the classes, are located in a directory within the current directory. Each directory must also contain the module file, which this method looks for.

Returns:
A list of module files found.

executeMain

private static void executeMain(java.lang.String arg)
Execute the specified class. The specified class has to include the name of the module definition as well, e.g. "B::Main", where B is the name of the module definition, and Main is the name of the class.

Parameters:
arg - The specified main class to execute.