JDK-7132194 : GtkFileDialog does not point to the correct file(s) is Recent Files are used.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2012-01-21
  • Updated: 2014-06-06
  • Resolved: 2012-02-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b27Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :


ADDITIONAL OS VERSION INFORMATION :
Linux mint 12 and openjdk

A DESCRIPTION OF THE PROBLEM :
OpenJDK Runtime Environment (IcedTea7 2.0) (7~b147-2.0-0ubuntu0.11.10.1)
OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a new java.awt.FileDialog with mode set to FileDialog.LOAD. Select files from the 'recently used' folder section. Print out the absolute path of the files selected.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Correct file and path information for each file.
ACTUAL -
The path will be the cwd + the filename.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
N/A, I wrote a patch to fix this.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.FileDialog;
import java.awt.Frame;
import java.io.File;

public class TestFileChooser{

    public static void main(String[] args){
        FileDialog choose = new FileDialog((Frame)null,"Choose File",FileDialog.LOAD);
        choose.setMultipleMode(true);
        choose.setVisible(true);
        System.out.println(choose.getDirectory());

        File[] files = choose.getFiles();
        for(File f: files){
        
            System.out.println(f.getAbsolutePath());
        
        }
        System.exit(0);
    
    }

}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
"Recent Documents" enables opening multiple files from different directories. This is a fundamental problem in the awt.FileDialog.setFiles(String directory, String[] filenames). This method should be replaced with a setFiles(File[] selected_files) with complete path information where all files are not assumed to be in the same directory.

As a work around sun_awt_X11_GtkFileDialogPeer.c should check to see if the 'current_folder' is still null, if it is still null it should return the directory as root directory and the filenames as complete path names, this would be consistent

Comments
EVALUATION Contributed patch and the review: http://mail.openjdk.java.net/pipermail/awt-dev/2012-January/002202.html
30-01-2012