Re: How to set up a fast correct java build?
On Fri, 8 Jan 2010, Andreas Leitgeb wrote:
Joshua Maurice <joshuamaurice@gmail.com> wrote:
It appears the "sanest" approach is to obtain or write my own Java
parser. I don't need to do any syntax or semantic checking at all. I
just need an exhaustive list of all used package qualified class
names. Still sounds like a large project though. /sigh
This topic appears here every once in a while.
Java just doesn't lend itself to structured C/C++-style dependencies,
because of the 1:n relation-ship of source files to generated .class
files.
In C/C++ you have a couple of source-files (ideally one .c and a flock
of .h's) that determine the contents of a particular object file. And
you know exactly which object files you need for an executable.
In Java, however, one source file can result in any number of .class
files for all the inner, nested, anonymous, synthetic, or further
(non-public) toplevel classes. (I know, it's a partially redundant list.)
So the very concept of "which source-files are relevant for this .class"
is futile, when one doesn't know the set of .class files in advance.
This is an outrageous calumny! The conclusion from the last Grand
Incremental Build Debate was that you *could* do it, but only if you had a
lot more metadata. We came to the same conclusion as Mr Maurice - you'd
have to write a java parser to extract the requisite information.
Although i think the only raw data you couldn't get from class files is
the origins of compile-time constants. This would be a pretty easy thing
to add to the class file format, as an attribute at the top level of the
file, indicating the origins of any entries in the constant pool derived
from compile-time constants in other classes. Sun might be amenable to an
RFE to add it.
Anyway, once you have that information, there is some complicated work in
computing dependencies, but it's entirely possible. It's just that
nobody's done it, or done it and kept it current. Except possibly Eclipse ...
The only generally *safe* Java build is the complete rebuild.
Certainly, the only *generally available* safe build is a clean one.
tom
--
There are lousy reviews, and then there's empirical shitness. -- pikelet