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

(spec) !new File(f.toURI()).equals(f)

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      mantis
    • CPU:
      sparc
    • OS:
      solaris_2.6
    • Verification:
      Verified

      Description



      Name: nkR10003 Date: 04/24/2002



      The JavaDoc comments for File.toURI() method says:
      /**
       * ...
       *
       * For a given abstract pathname f, it is guaranteed that
       *
       * new File( f.toURI()).equals( f)
       *
       * so long as the original abstract pathname, the URI, and the new abstract
       * pathname are all created in (possibly different invocations of) the same
       * Java virtual machine.
       * ...
       *
       */

      This statement does not work.

      Example below demonstrates this problem:
      ------------------example--------------------
      import java.io.File;
      import java.net.URI;

      public class test {
          public static void main(String[] args) {
              File f = new File("test.txt");
              if (!new File(f.toURI()).equals(f)) {
                  System.out.println("Test failed: new File(f.toURI()) does not equal to f");
                  System.exit(-1);
              }
              
              System.out.println("Test passed");
              return;
          }
      }
      ----------------output:----------------------
      %java -version

      java version "1.4.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b09)
      Java HotSpot(TM) Client VM (build 1.4.1-beta-b09, mixed mode)

      %java test

      Test failed: new File(f.toURI()) does not equal to f
      ---------------------------------------------
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            iris Iris Clark
            Reporter:
            knasunw Kna Kna (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: