Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4668635

Warn when element of classpath or sourcepath doesn't exist (special-case tilde)

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 1.4.0
    • tools

      When an element of the classpath points to a directory that does not exist,
      a message does not appear until looking for a path on that classpath.
      It would be helpful if a warning was output for that initial error,
      to more easily detect the problem.

      Given -classpath a:b, at first look, the warning might be something like:

        warning - path "b" does not exist

      (If it's possible for whitespace to be interpreted as a path,
      quotes around the path name, as shown, would help.)

      In the case that prompted this feature request, when a jar file is
      under a home directory, non-leading tildes (that represent the
      home directory) are not expanded (nor should they be) in -classpath
      or -sourcepath arguments. Currently, a "Package xxx not found in import"
      error is thrown when trying to load a package from that path.
      In the following example, the above message would
      help narrow the problem, but not completely resolve it
      for the user:

        warning - path "~/java/classes/jh.jar" does not exist

      Because the user is unaware that the shell interprets the
      first tilde but not following ones, he is still left wondering
      where the trick lies, as "ls ~/java/classes/jh.jar"
      indicates the file exists. Perhaps the message can
      be worded more carefully to make this distinction to the
      user, such as:

        warning - path "~/java/classes/jh.jar" does not exist (~ does not expand)

      Or perhaps for Unix, check for leading "~/" and warn to replace
      it with the expanded path?

      Due to the tricky nature of the problem, this bug was quite
      time-consuming to narrow down and fix -- it would seem to warrant
      an extra care in the warning message.


      Example:

      The jar files exist:

      % ls ~/java/classes/xerces.jar ~/java/classes/jh.jar
      /nethome/qwang/java/classes/jh.jar
      /nethome/qwang/java/classes/xerces.jar

      However, when using a tilde in the second element (/java/classes/jh.jar),
      packages inside that jar file cannot be found:

      % javadoc -d ~/java/src/doc3 -classpath ~/java/classes/xerces.jar:~/java/classes/jh.jar -sourcepath ~/java/src pipe
          Loading source files for package pipe...
          Constructing Javadoc information... /nethome/qwang/java/src/pipe/form/PipeMenu.java:14: Package javax.help not found in import.
                              import javax.help.*;
                              ^

      However, it works when "/nethome/qwang" is used instead of tilde.
      (Putting quotes around the classpath argument does not work)

      ..............

      NOTE: The above example is abbreviated from the original bug reported
      in length at the Javadoc forum, "Package not found in import" at:
      http://forum.java.sun.com/thread.jsp?forum=41&thread=241106

      This is a follow-on to bug 4668475:
      "Package not found" error when tilde (~) is used as second path in -classpath

            bpatel Bhavesh Patel (Inactive)
            dkramersunw Douglas Kramer (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: