Process class patch.

The interface for the Sun Java Process class, as of Java 1.4, has an
unfortunate shortcoming. The user is unable to access the process
identification (PID) of the executed process or provide the timeout
argument to the Object.wait method used by the waitFor method. Process
is an abstract class that is implemented in a host OS dependent manner
which relies on JNI methods that make the necessary host process
management system calls. For Unix systems the implementation is in the
UNIXProcess class.

The PID is held in the private "pid" variable of the UNIXProcess.java
code. The ability to provide the timeout argument is a trivial
modification of the waitFor method. The accompanying Process.patch and
UNIXProcess.patch files provide the Java source code that will
correctly patch the respective files as distributed by Sun.

THIS PATCH HAS NO AFFECT ON EXISTING FUNCTIONALITY.


Installation:

It is possible to apply the patch without any source code files. The
class files in the JFC runtime jar may be updated with the class files
provided in this kit. Solaris, Linux and Darwin (Max OS-X) OS
subdirectories each contain a "patched" subdirectory where the
appropriate class files are located. These class files are based on the
patched source files for Java 1.4 on the corresponding OS. The patched
source files are also provided. If you decide to use the patched class
files, copy them into a java/lang subdirectory and skip to the JFC
runtime jar section below.


Java SDK source:

The Java SDK distributions typically provide the Java classes source
code in the src.zip file where the distribution was installed. Extract
the java/lang/Process.java and java/lang/UNIXProcess.java files into
your working directory.

unzip $JAVA_SDK_DIR/src.zip \
	java/lang/Process.java java/lang/UNIXProcess.java

This will create a java/lang subdirectory with the *.java files that
you can patch.

For those without the original Java SDK source files, copies that may
be suitable for Java 1.4 installations are provided with this kit.
Solaris, Linux and Darwin (Max OS-X) OS subdirectories each contain an
"original" subdirectory where the appropriate source files are located.
The Process.java file defines the abstract interface and should be
common for every OS. The UNIXProcess.java file, because of OS
dependencies, may vary from OS to OS. N.B.: These files are from the
Sun Java 1.4 distribution for the corresponding OS; if you have a
different Java version or OS these files may or may not be appropriate.
Copy the appropriate *.java files into a java/lang subdirectory where
the patches will be applied.

To patch to the original Java SDK source, insert the entire contents of
the *.patch file (or just the code sections) at the end of the
corresponding *.java file just before its closing '}' character.
Compile the patched files with javac. After successful compilation
remove, or move, the *.java files.

At this point you should have a java/lang subdirectory containing
patched class files:

Process.class
UNIXProcess$1.class
UNIXProcess$2.class
UNIXProcess$3.class
UNIXProcess.class

Note: For Linux there is an additional UNIXProcess$Gate.class file.


JFC runtime jar:

Locate your JFC runtime jar file. This is expected to be the rt.jar
file in your Java installation directory under the jre/lib subdirectory.
For OS-X it should be the classes.jar file in the
/System/Library/Frameworks/JavaVM.framework/Classes directory. If you
are uncertain, use the jar utility to search *.jar files for the class
files, listed above, in the java/lang directory; for example,
"jar tf $JAVA_DIR/jre/lib/rt.jar | grep 'java/lang/.*Process.*'"
should list the appropriate class files in a typical rt.jar file.

To update your JFC jar file you may need root privileges, depending on
the permissions on the jar file in your Java installation. First, of
course, make a copy of your original jar file. Then use the patched
class files to update the originals in the jar file. From the directory
that contains the java/lang subdirectory with the patched class files:

jar uf $JAVA_DIR/jre/lib/rt.jar java

For Java on Darwin substitute "$JAVA_DIR/jre/lib/rt.jar" with
"/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar".

The patch installation is now complete.


The author can be contacted with questions, comments or corrections at:

Bradford Castalia
Senior Systems Analyst                              Castalia@Arizona.edu
Planetary Image Research Laboratory
Department of Planetary Sciences                 1629 E. University Blvd.
University of Arizona                        Tucson, Arizona  85721-0092


The *.java files in this kit are Copyright 2000 Sun Microsystems, Inc.,
from source distributions available from the http://java.sun.com site.

The *.patch files in this kit are free software:

Copyright (C) 2003  Arizona Board of Regents on behalf of the Planetary
Image Research Laboratory, Lunar and Planetary Laboratory at the
University of Arizona.

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
