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

Behavioural change in javac since JDK 9 when using src linked by symlinks

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 17.0.8
    • tools

      Logging this issue for record purposes.

      The javac behaviour change seen exists since JDK 9. One such summary of the change is available here: https://mail.openjdk.org/pipermail/compiler-dev/2016-November/010544.html

      Specifying the output directory via the javac "-d" directive should resolve the issue reported.

       mkdir symLinkTest
       cd symLinkTest
       mkdir readOnlyDir
       echo "public class Hello {}" > readOnlyDir/Hello.java
       ln -s readOnlyDir/Hello.java
       chmod 555 readOnlyDir
        
        
        /jdk1.8.0_381/bin/javac Hello.java
           --> Hello.class created in symLinkTest directory


        With JDK 9 or later:

        $ /jdk-11.0.16/bin/javac Hello.java
        Hello.java:1: error: error while writing Hello: /tmp/symLinkTest/readOnlyDir/Hello.class
        public class Hello {}
               ^
        1 error

      following works:
      $ /jdk-11.0.16/bin/javac -d . Hello.java

            rwallace Ryan Wallace (Inactive)
            shadowbug Shadow Bug
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: