Testing with JMON - "Umbilical Java"
HolonJ is an umbilical cross development system. The JVM is the target system, which is connected to the host via a small monitor JMON running in the JVM. An umbilical development system sends code to the target on-the-fly and lets you test the code instantly in the target. Code is loaded into the JVM as complete class files.
HolonJ communicates with the monitor in the JVM. The console window of the JVM displays status information and program output. Commands to the monitor are passed via a file. Currently two commands are implemented. HolonJ can ask JMON to load a class (new) and to execute a method in a class (run), and uses the commands in the following way.
- When you load a class with F3=Load, HolonJ creates a class file and loads the new class file into JMON. If the class replaces a previous version in the JVM, the old version is no longer accessible.
- When you press F4=Run, HolonJ sends the command run with the class name, method name and the parameters, if any. The result is displayed in the JVM's console window. JMON loads the class, if it is not yet present.
HolonJ and the java interpreter running JMON. I start and test the TicTacToe program via JMON.
What happens in the example?
- line 000: Loaded the TicTacToe class.
- line 002: Selected the word tttApplication in the browser, and pressed F4=Run. It may take a while until the application appears, java must load many library classes!
- line 004: Response to my first move in the game, sound is simulated by printing the filename. The sound only works in the applet in a browser; here I am testing the game as an application.
- line 005: Selected the word isFree, entered 0 in the stack window and pressed F4=Run.
- line 006: JVM message. The method isFree was initially defined as private, therefore JMON has no access.
- line 008: I have removed the access modifier private of isFree, and reloaded the class. The new class is immediately loaded into JMON.
- line 010: Run tttApplication again, this creates a new instance of the game.
- line 012: Response to my move.
- line 014: Result of "0 isFree". The move position is counted from zero.
- line 017: Result of "1 isFree".
- Words with simple arguments (int, long) can be tested directly.
- When the arguments are objects, a test word is needed that defines a test procedure. Add the test word to the source and load it. JMON loads a new copy of the class and in one or two seconds you are ready to run the test.
- Even if you don't test all words, JMON tells you if they pass the verification test of the classloader, and also tells you what is wrong. The Java 2 SDK V1.2 looks very closely and gives useful error information. If your classes load, they probably also work. Maybe not exactly as intended, though...
JMON has been built in HolonJ. JMON contains a custom classloader and an interpreter, which reads commands from a file. Tested code runs as a thread along with the interpreter thread.