Running javac with symlinks

Jonathan Gibbons jonathan.gibbons at oracle.com
Sat Nov 26 03:37:27 UTC 2016


Bruno,

Since it is not really specified how javac operates in the context of 
symlinks, I think you can say that the new behavior is neither a feature 
nor a bug, but maybe just a side-effect of the internal change from 
using java.io.File to java.nio.file.Path.

That being said, the behavior was inconsistent for following symlinks as 
needed for directories, but not for the final file itself. And as you 
noted when you forwarded the question to jdk9-dev, the man page does 
specify "the same directory as the source file".

> Also, both man pages from openjdk8 and an early access Java SE9 [2] have the same text regarding the default behavior:
>
> "If the -d option is not specified, then javac puts each class file in the same directory as the source file from which it was generated."
So, I think that makes the change come down on the side of a feature, 
and not a bug.

In general, I would recommend specifying an output directory for 
compiled class files with -d, and not rely on behavior of putting the 
class file in the same directory as the source, which IMO is more 
suitable for simple HelloWorld-type programs.

-- Jon


On 11/25/16 10:47 AM, Bruno Alexandre Rosa wrote:
>
> Hi, everyone,
>
> I came across a minor unusual situation trying to compile and run the 
> java version of a benchmark suite [1]: in jdk9, when the source files 
> are actually symlinks, the bytecode files are generated in the same 
> directories as the *targets* of the links as opposed to the behavior 
> in jdk8, whereas in the bytecode files are generated in the same path 
> as the link themselves.
>
> So, my question is: is this new behavior a feature or a bug?
>
> Regards,
>
> Bruno Rosa
>
> [1] - https://benchmarksgame.alioth.debian.org/
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20161125/fb4c40d4/attachment.html>


More information about the compiler-dev mailing list