next up previous contents
Next: Related Work Up: Mobile Agents Previous: Advantages of Mobile Agents   Contents

Java for Mobile Agents

To build a Mobile Agent System an interpreted language has to be chosen. The language has to be interpreted, because moving of a running object requires access to the global variables, or better to the current execution pointer and stack. The best way to achieve this is using a virtual machine which executes the interpreter language. To provide this with a compiled language would require a lot of work and would be a very complicated task. The languages used by the others systems are, to mention the most important, Java, TCL/TK or special versions of C. in the case of the TAgents Mobile Agent System, Java was chosen as language for the following reasons:

Platform Independence
The Java language is designed as a language to write programs for different operating systems. The Java source code is compiled to a special byte code which is then interpreted by the Java Virtual Machine (JVM). There are JVMs for almost every known platforms and operating systems. To mention the most important, there are Windows (all Win32 compatible versions), Linux, SunOS (or Solaris), AIX, PalmOS, and many others. An Agent System written in Java should be able to run without modifications on every one of these platforms.
Object Oriented Design
Java is an object-oriented language which makes it very easy to extend the parts of the System, like the basic Agent and System Agent class. Also makes the object-oriented programming (OOP) it easier to maintain larger projects with many different parts. OOP is normally more readable for other developers. With an appropriate design, a Java program can be extended very easily.
Serialization
Java has a built-in serialization mechanism. Serialization is used to store the current state of a program to, for example, send this program over the network. This provides a Mobile Agent System with a standard way of sending the running Agents through the network. It can also be used for storing the current state of an Agent in memory, i.g. hard disks or RAM for backups, saving or pausing them.
Networking
The Java language provides the programmer with a very good package for doing all kind of networking. These classes are part of the java.net package which is included in the standard Java class libraries.
Security
Java provides a very good security mechanism in its version 2. With this it is possible to provide fine grained access to all parts of an program and the standard libraries.
Reflection
Java provides access to the methods and variables of an object during runtime. Therefore, the standard libraries contain the package java.lang.reflect which covers access to particular methods, as well as global variables of an object running in the JVM.
These are the main advantages of using Java for Mobile Agents. There are unfortunately also some disadvantages which are mainly a result of the platform independence of Java.

Execution Pointer
The stack of a program cannot be accessed in Java. If a program is serialized, just its global variables will be serialized and not the current execution pointer and stack.
Threads
Another disadvantage is the inability to control programs (Threads) in Java. The existing methods for stopping / resuming a Thread had been deprecated due to serious problems with the monitors that the thread was holding. There is no method to kill (destroy) a thread. The method mentioned in the class libraries has never been implemented (for the same reasons as above). The usage of memory and CPU timetypeset@protect @@footnote SF@gobble@opt Except the possibility of giving a thread a certain priority cannot be controlled. This will be addressed in further Java versions.
Especially the lack of thread control leads to a lot of problems when programming a Mobile Agent System. This is because the Agent can be foreign code from which the System has to be protected and which should be able to be destroyed by the platform whenever, for example, security is violated.

To summarize the points above, it has to be said that Java has reasonable advantages for building a Mobile Agent System and was therefor elected for the TAgents platform.


next up previous contents
Next: Related Work Up: Mobile Agents Previous: Advantages of Mobile Agents   Contents
Thomas Letsch 2001-02-21