JDK-4102600 : javac -d dir flag and -depend flag do not work together: rebuilds all each time.
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1998-01-08
  • Updated: 2000-01-28
  • Resolved: 2000-01-28
Related Reports
Duplicate :  
Relates :  
Description

Name: tb29552			Date: 01/08/98


Create three .java files:

A.java:

  class A{
    B b;
  }

B.java:

  class B{
    C c;
  }

C.java:

  class C{
  }

and place them all in the same directory.
Then compile using:
  javac -d targetdir -depend A.java

All three classfiles are (correctly) compiled
into targetdir.

Then recompile (without making any changes)
using:
  javac -d targetdir -depend A.java

All three classfiles are (incorrectly) recompiled.
No new compilation should be necessary as 
all the classfiles are up to date.  If class files 
exist in the same directory as the java files
unecessary recompilation does not take place.

The problem does not occur if you do not use
the -d targetdir argument (ie. build the class
files into the same place as the java files).  This
has been tested and shown to be because
regardless of whether the -d argument has been
used the compiler is checking in the same 
directory as the java files for the class files when
deciding if the class file is out of date (and so
needs to be recompiled).

Although it correctly places the class files in a
different directory it does not check in that
directory when looking for existing class files.

If you are compiling into a different directory with 
the -d argument it never finds the class files and 
so always considers them to be out of date and 
rebuilds everything each time.

This is proving to be a very costly problem on
large projects where recompilation that should
take a minute at most is taking up to an hour.

The problem is reproducable on NT4.0 and
Unix using javac supplied with jdk1.1.x and
jdk1.2Beta2.

This could also be a possible solution for Bug
======================================================================

Comments
WORK AROUND Name: tb29552 Date: 01/08/98 Do not use the -d argument with javac. ======================================================================
11-06-2004

EVALUATION Reproduced in 1.1.7 and 1.2beta4. The submitter expects thatthe argument to -d will be added to the classpath, but that isn't happening. It would be reasonable for it to do so in this case. The larger concern is that -depend is just not usable for large projects, and ends up recursing through all class files reachable from Object, not just A, B and C in the example. Putting the argument to -d on the classpath would not help with that; -depend will never be a substitute for a proper dependency utility such as make. david.stoutamire@Eng 1998-07-02 The proximate cause of the problem is user error -- the target directory specified by -d is not in the classpath, thus the up-to-date classfiles will not be found. This case reveals flaws in the usuability of the compiler, however. See 4304048. william.maddox@Eng 2000-01-28
28-01-2000