ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Misha Dmitriev <>
Subject Re: newbie question: javac not checking build dependencies?
Date Fri, 04 Jan 2002 00:37:31 GMT wrote:

> P.S. Interestingly enough, by now Sun could have added a new attribute to
> .class format that could be used to simulate symbolic links for all static
> finals that got optimized into literals. Then we could have had a perfect
> depends tool...

You are reading our thoughts :-)) In fact, this very solution is being
considered at Sun, and chances are that it will be introduced in the next
version of JDK/javac (1.5) along with javamake as a standard tool. BTW, if you
want javamake to become a standard tool, you can send me an e-mail (see a note
about that on its home page).

Regarding the question of why javac is not a sufficiently good dependency
checker. The problem with compile-time constants (static finals) is one thing.
But the main thing, which you can deduce from the cited docummentation, is
that javac simply won't check any source/class files that are
 - not given to it explicitly, and
 - not required by those given explicitly.
Nevertheless, such classes may be a part of your project. So if you want to
use javac as a reliable dependency checker, you really have to feed all of
your project sources to it every time. This, however, will result in total
recompilation -> wasted time. Javamake and other dependency checking tools
allow you to avoid total recompilation essentially by preserving dependencies
between classes and analysing them to determine what to recompile. To analyse
dependencies preserved in a suitable format, is much faster than to recompile



> Please respond to "Ant Users List" <>
> To:     Ant Users List <>
> cc:
> Subject:        Re: newbie question: javac not checking build dependencies?
> I have a question. Why use *.java or the depends task instead of using
> javac?
> The following excerpt from the Java2 SDK 1.3.1 explains what javac does.
> Isn't
> this the correct way to do dependency checking for Java?
> When compiling a source file, the compiler often needs information about a
> type
> it does not yet recognize. The compiler needs type information for every
> class
> or interface used, extended, or implemented in the source file. This
> includes
> classes and interfaces not explicitly mentioned in the source file but
> which
> provide information through inheritance.
> For example, when you subclass java.applet.Applet, you are also using
> Applet's
> ancestor classes: java.awt.Panel, java.awt.Container, java.awt.Component,
> and
> java.awt.Object.
> When the compiler needs type information, it looks for a source file or
> class
> file which defines the type. The compiler searches first in the bootstrap
> and
> extension classes, then in the user class path. The user class path is
> defined
> by setting the CLASSPATH environment variable or by using the -classpath
> command line option. (For details, see Setting the Class Path). If you use
> the
> -sourcepath option, the compiler searches the indicated path for source
> files;
> otherwise the compiler searches the user class path both for class files
> and
> source files. You can specify different bootstrap or extension classes
> with the
> -bootclasspath and -extdirs options; see Cross-Compilation Options below.
> A successful type search may produce a class file, a source file, or both.
> Here
> is how javac handles each situation:
> Search produces a class file but no source file: javac uses the class
> file.
> Search produces a source file but no class file: javac compiles the source
> file
> and uses the resulting class file.
> Search produces both a source file and a class file: javac determines
> whether
> the class file is out of date. If the class file is out of date, javac
> recompiles the source file and uses the updated class file. Otherwise,
> javac
> just uses the class file.
> By default, javac considers a class file out of date only if it is older
> than
> the source file. (The -Xdepend option specifies a slower but more reliable
> procedure.)
> Note that javac can silently compile source files not mentioned on the
> command
> line. Use the -verbose option to trace automatic compilation.
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message