JDK-8194893 : javac -verbose prints wrong paths for output files
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-01-10
  • Updated: 2018-05-03
  • Resolved: 2018-01-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11 b01Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Regression: javac -verbose prints wrong paths for output files (JDK9 and higher). This breaks tools that parse the output of Javac.

To reproduce:
Use a Java source in a package, e.g. bar.java in barpackage
javac -d <output dir> -verbose <path to java source>

Output:
On Linux I see:
[wrote DirectoryFileObject[/work:barpackage/bar.class]]
Notice the ':' instead of '/'
Using JDK8:
[wrote RegularFileObject[/work/barpackage/bar.class]]

On Windows:
[wrote DirectoryFileObject[\work:barpackage/bar.class]]
Notice the ':' instead of '\' and the '/' instead of '\'
Using JDK8:
[wrote RegularFileObject[\work\barpackage\bar.class]]

Comments
$ hg diff src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java diff -r 13f6856e8489 src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Tue Jan 09 16:24:24 2018 +0100 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Wed Jan 10 13:03:51 2018 -0800 @@ -1678,7 +1678,7 @@ try { writeClassFile(out, c); if (verbose) - log.printVerbose("wrote.file", outFile); + log.printVerbose("wrote.file", outFile.getName()); out.close(); out = null; } finally {
10-01-2018

It is risky/unspecified to rely out the output of -verbose. If you want to know when files are written, you would do better to use the JavaCompiler API, with a verbose file manager, or else use a TaskListener to be invoked when files are written.
10-01-2018

javac is (incorrectly) using the FileObject.toString() method, instead of FileObject.getName() The JDK8 behavior is incorrect as well, as the output should not include the implementing class.
10-01-2018