After reading a number of messages on the SCJD board mentioning Emma, I downloaded it and started playing (invoking it mostly from an ant buildfile from within Eclipse). And it's working nicely for simple apps, but going client/server makes everything more complicated.
1) Is there a way to start the server, then go on and run the client without waiting for the server to terminate first, from within an ant buildfile? The current routine is (in Eclipse) I invoke an ant task to compile everything, then switch to a terminal window to start the server from the command line, then switch back to Eclipse and invoke another ant task to run the client. This is a pain. The ant doc says you can set "spawn=true" in the <java> task, but when I did that I got an error message saying the <java> task doesn't support the "spawn" option.
2) Is it possible to catch both the coverage stats from the RMI client and those from the RMI server in one report? I tried instrumenting both, then starting the server with coverage going to "server.emma", then running the client with coverage going to "client.emma", then stopping the server (so the data are written), then generating a report merging both ".emma" files... but when I kill the server process, it complains "java.io.FilePermission coverage.ec read". I don't know why it can't read the coverage.ec file; it's right there, world-readable, and I even shut down Eclipse before stopping the server just in case Eclipse was holding the file open.
2a) In the sockets version of the program, all is well: I can collect the server stats and the client stats in two separate files, combine them into one report, and actually learn something. But the RMI version doesn't work. Which leads to...
3) How does one cleanly shut down an RMI server, other than killing the process? [ November 29, 2004: Message edited by: Stephen Bloch ]
Really this should probably be multiple questions in multiple forums... (and feel free to go on and do this to get further information on each question) but I'll take a stab at some:
1.) Using the Ant <java> task with fork=true spawn=true is the way to go about this. Search for the error message on google or look in the Ant documentation to see how to fix this.
2.) "java.io.FilePermission coverage.ec read" looks like a permissions problem... how are you dealing with setting up permissions? (are you using -Djava.security.policy=policy-file as a command-line option? What's in your policy file?)
3.) You can add a GUI or block on reading from System.in in your server and have it shut things down however you want before calling System.exit(). What kind of stuff do you want to do to shutdown and what kind of functionality are you looking for?
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Answer to 1.) I had tried fork=true spawn=true, and got the fairly clear-cut error message
Is there more than one way to interpret that? And yes, this flatly contradicts the ant documentation.
Answer to 2.) My policy file specifies a couple of SocketPermissions on specific ports, but doesn't say anything about files. Does it need to, considering that the file in question is on the same machine that the server is running on? (I'm new to policy files....)
Answer to 3.) I wrote an RMI server program that sets a security manager, creates a registry, creates a remote object, registers it, and falls off the end of the main method. But I understand that it won't actually terminate (and save its emma data to a file) as long as somebody somewhere has a reference to the remote object. I would think the client's termination would take care of that, and just to make sure I set the reference to null in the client's finally clause, but the server still won't die unless I kill the process.
[ December 01, 2004: Message edited by: Stephen Bloch ] [ December 01, 2004: Message edited by: Stephen Bloch ]
Their achilles heel is the noogie! Give them noogies tiny ad!