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

File.setWritable() / File.canWrite() not behaving as expected

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • CPU:
      generic
    • OS:
      windows
    • Verification:
      Verified

      Description

      SYNOPSIS
      --------
      File.setWritable() / File.canWrite() not behaving as expected

      OPERATING SYSTEM
      ----------------
      Windows

      FULL JDK VERSION
      ----------------
      Java 6, from 1.6.0_23 onwards
      Not reproducible on Java 7

      PROBLEM DESCRIPTION from LICENSEE
      ---------------------------------
      If setWritable(false) returns true, canWrite() should return false.

      From 1.6.0_23, canWrite() is returning true under these circumstances, which is not correct. The problem seems to be caused by an incomplete backport of the changes for CR 6728842 from Java 7 (see suggested fix).

      TESTCASE
      --------
      import java.io.File;

      public class Test {
          public static void main(String[] args){
              File f = new File("wibblefish");
              f.deleteOnExit();
              if (f.mkdirs())
                  if (f.setWritable(false,false)) {
                      if (f.canWrite()) {
                          System.out.println("Test failed");
                      } else {
                          System.out.println("Test passed (setWritable() succeeded)");
                      }
                  } else {
                      System.out.println("Test Passed (setWritable() failed)");
                  }
          }
      }

      REPRODUCTION INSTRUCTIONS
      -------------------------
      Compile and execute the above given testcase.

      Expected output:
      Test passed (setWritable() succeeded)
      OR
      Test Passed (setWritable() failed)

      Observed output:
      Test failed

      SUGGESTED FIX from LICENSEE
      ---------------------------
      See Suggested Fix section of CR.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                coffeys Sean Coffey
                Reporter:
                dkorbel David Korbel (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: