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

JCK1.3a, api/javax_swing/JFileChooser/descriptions.html#getset[FileChooser2011]

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta2
    • CPU:
      x86
    • OS:
      windows_95
    • Verification:
      Verified

      Description



      Name: iaR10016 Date: 05/28/2001


      JDK : JDK1.4.0 beta-b65
      JCK : JCK1.3a
      Platform[s] : Windows NT, Windows 2000, Windows ME, Windows 98, Windows 95
      switch/Mode : -client -Xmixed
      JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
      Failing Test : api/javax_swing/JFileChooser/descriptions.html#getset [TestCaseID FileChooser2011]

      JavaTM 2 Platform Std. Ed. v1.4.0 Specification reads:

      ...
      Object.equals(Object obj)

      public boolean equals(Object obj)
        Indicates whether some other object is "equal to" this one.
        The equals method implements an equivalence relation:
        It is reflexive: for any reference value x, x.equals(x) should return true.
        It is symmetric: for any reference values x and y, x.equals(y) should return true if and only if
        y.equals(x) returns true.
        It is transitive: for any reference values x, y, and z, if x.equals(y) returns true and y.equals(z)
        returns true, then x.equals(z) should return true.
        It is consistent: for any reference values x and y, multiple invocations of x.equals(y)
        consistently return true or consistently return false, provided no information used in equals
        comparisons on the object is modified.
        For any non-null reference value x, x.equals(null) should return false.

      ...
      File.compareTo(File pathname)

      public int compareTo(File pathname)
        Compares two abstract pathnames lexicographically. The ordering defined by this method depends
        upon the underlying system. On UNIX systems, alphabetic case is significant in comparing pathnames;
        on Win32 systems it is not.
        Parameters:
           pathname - The abstract pathname to be compared to this abstract pathname
        Returns:
           Zero if the argument is equal to this abstract pathname, a value less than zero if this abstract
           pathname is lexicographically less than the argument, or a value greater than zero if this abstract
           pathname is lexicographically greater than the argument
      ...

      The following test example demonstrates the bug:

      -------------- test.java --------------------------
      import javax.swing.*;
      import java.io.File;

      public class test {
          public static void main(String argv[]) {
              try {
                  File f1 = new File(argv[0]);
                  File f2 = new File(f1,"test");
                  if (!f2.exists()) f2.mkdirs();
                  JFileChooser c = new JFileChooser(f2);
                  c.changeToParentDirectory();
                  f2 = c.getCurrentDirectory();
                  System.out.println("f1: " + f1);
                  System.out.println("f2: " + f2);
                  System.out.println("f1.compareTo(f2): " + f1.compareTo(f2));
                  System.out.println("f2.compareTo(f1): " + f2.compareTo(f1));
                  System.out.println("f1.equals(f2) : " + f1.equals(f2) );
                  System.out.println("f2.equals(f1) : " + f2.equals(f1) );
                  System.out.println("f1.getClass() : " + f1.getClass());
                  System.out.println("f2.getClass() : " + f2.getClass());
              } catch(Exception e) { System.out.println("Unexpected exception "+e+" was thrown"); }
          }
       }
      ---------------------------------------------------

      Sample output (Windows OS):

      ...
      $ java test C:/results
      f1: C:/results
      f2: C:/results
      f1.compareTo(f2): 0
      f2.compareTo(f1): 1
      f1.equals(f2) : true
      f2.equals(f1) : false
      f1.getClass() : class java.io.File
      f2.getClass() : class sun.awt.Shell.Win32ShellFolder
      $
      ...

      This example demonstrates that JFileChooser.getCurrentDirectory() method
      returns sun.awt.Shell.Win32ShellFolder class (which is a subclass of java.io.File)
      variable.
      Variables f1 and f2 point to the same directory ("C:/results"), and the method
      f1.compareTo(f2) and f1.equals(f2) correctly returns 0 and true respectively.

      Code Source for the sun.awt.Shell package is not shipped with JDK1.4.0.
      But I suppose that this class overrides File.equals() and File.compareTo()
      methods incorrectly.

      Here is the sample output for this example in RedHat Linux 6.2:

      ...
      $ /net/linux-15/export/home/jdk1.4.0/linux/bin/java test /net/linux-15/export/home/ira
      f1: /net/linux-15/export/home/ira
      f2: /net/linux-15/export/home/ira
      f1.compareTo(f2): 0
      f2.compareTo(f1): 0
      f1.equals(f2) : true
      f2.equals(f1) : true
      f1.getClass() : class java.io.File
      f2.getClass() : class java.io.File
      $
      ...

      Test source location:
      =====================
      /net/jdk/export/disk8/local.java/jck1.3a/JCK-runtime-13a/tests/api/javax_swing/JFileChooser/getsetTests.java

      jtr file location:
      ==================
      /net/jtgb4u4c.eng/export/sail16/results/merlin/b65/jck13a/win32/win95_client_linux-19/workDir/api/javax_swing/JFileChooser/descriptions_getset.jtr

      How to reproduce:
      ====================
      Run the following script under Windows 95
      (probably, you need to change WORKDIR, JCK and JAVA_HOME paths):
      --------Script START---------------------
      #!/bin/sh
      JAVA_HOME="C:/jdk1.4.0"
      JCK="H:/jck1.3a/JCK-runtime-13a"
      export CLASSPATH="$JCK/classes:$JCK/javatest.jar"
      WORKDIR="file:C:/results"
      executeClass="javasoft.sqe.tests.api.javax.swing.JFileChooser.getsetTests"
      executeArgs="-TestCaseID JFileChooser2011 -TestURL file:$JCK/tests/api/javax_swing/JFileChooser/descriptions.html#getset -TestWorkDirURL $WORKDIR"
      $JAVA_HOME/bin/java ${executeClass} ${executeArgs}
      ---------Script END----------------------

      Test output:
      =============
      JFileChooser2011: Failed. Set incorrect directory:H:\jck1.3a\JCK-runtime-13a\tests\api\javax_swing\JFileChooser\testdirH:\jck1.3a\JCK-runtime-13a\tests\api\javax_swing\JFileChooser\testdir
      ====== JFileChooser2011 ====== public void changeToParentDirectory()
      STATUS:Failed.tests: 1; failed: 1; first test case failure: JFileChooser2011

      Specific Machine Info:
      =====================
      Hostname: linux-18
      OS: Windows 95

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            leifs Leif Samuelsson (Inactive)
            Reporter:
            irasunw Ira Ira (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: