ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank E. Weiss" <fra...@well.com>
Subject Re: newbie question: javac not checking build dependencies?
Date Thu, 03 Jan 2002 22:48:36 GMT
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?

SEARCHING FOR TYPES
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:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message