Incremental java compile AKA javac print compile dependencies

Jonathan Gibbons jonathan.gibbons at oracle.com
Tue May 25 18:01:36 PDT 2010


On 05/25/2010 05:11 PM, Joshua Maurice wrote:
>
>
> What is relevant is that to get decent levels of incremental, aka 
> skipping unnecessary rebuilds, the build system needs to know for each 
> java X, the full list of class files and java files which will be 
> directly used by javac when compiling X. Whenever any of those direct 
> compile dependencies have an "interface" / "signature" change, X needs 
> to be recompiled.

Stop right there.   There's likely a wrong assumption here, hidden in 
the word "directly".

If you start from scratch, with no classes precompiled, when you compile 
X, javac will pull in from the sourcepath the transitive closure of X 
and all its dependencies.  Thus if X refers to Y, and if the 
implementation of Y refers to Z, then javac will compile X and Y and Z, 
even though there no direct reference in any way from X to Z.   This is 
why your proposed technique of tracking -verbose output will not work.

There is a difference between the set of files needed to compile X, and 
the set of files on which X has a direct dependency (meaning that if 
they change, X needs to be recompiled.)  To determine the set of files 
(or even better, the classes) on which X depends, you must either look 
at the classfile (which has the constant problem) or at the AST sometime 
after Attr.

-- Jon




More information about the compiler-dev mailing list