Name: boT120536 Date: 02/13/2001
java version "1.2.2"
Solaris VM (build Solaris_JDK_1.2.2_05, native threads, sunwjit)
Here's another take on the javac dependency problem.
I want to use javac for parallel make.
I could live without global dependencies *if* javac
weren't so naive about the way it writes output files.
Say we have classes A & B, both of which use C.
Run javac on A & B simultaneously.
A gets to C first, compiles and starts writing C.class
B discovers C.class exists, so loads it, but gets
premature EOF because A hasn't finished writing.
I can think of several ways to solve the problem:
1: write output to a uniqe temp-file name, when complete use
atomic rename system call to give it the proper name.
Virtue: simple
Vice: multiple javacs might compile the same class, wasting CPU
2: use file locks
Virtue: avoids wasting CPU as for #1
Vice: not portable to all UNIXes or filesystem types.
this is probably a minor concern though, since those
that don't have file locks are few & far between
3: if a reading javac hits premature EOF, and file modtime
is "recent", retry the read "N" times. (must define
"recent" and "N" somehow)
Virtue: simple, avoids wasting CPU, doesn't use locks.
Vice: could run into trouble with clock-skew & races.
(Review ID: 116744)
======================================================================