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

System.setProperty("user.dir","xxx") has no effect on File.getAbsolutePath

XMLWordPrintable

    • x86_64
    • os_x

      ADDITIONAL SYSTEM INFORMATION :
      openjdk 11-ea 2018-09-25
      OpenJDK Runtime Environment 18.9 (build 11-ea+10)
      OpenJDK 64-Bit Server VM 18.9 (build 11-ea+10, mixed mode)

      Mac OS X 10.12.1

      A DESCRIPTION OF THE PROBLEM :
              System.out.println(new java.io.File("a").getAbsolutePath());
              System.setProperty("user.dir", "/User/zhb");
              System.out.println(new java.io.File("a").getAbsolutePath());

      On Java 10 or lower, the output is:

      /the/current/working/dir/a
      /User/zhb/a

      On Java 11 ea, the output is:

      /the/current/working/dir/a
      /the/current/working/dir/a

      REGRESSION : Last worked in version 11

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      class MyTest {
          public static void main(String []args){
              System.out.println(new java.io.File("a").getAbsolutePath());
              System.setProperty("user.dir", "/User/zhb");
              System.out.println(new java.io.File("a").getAbsolutePath());
          }
      }


      Compile and run on Java 10 and Java 11 repectively.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Keep the previous behaviour
      ACTUAL -
      Different behavior as Java 1-

      CUSTOMER SUBMITTED WORKAROUND :
      No found yet.

      FREQUENCY : always


            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: