Program: 90958
Project: 90958
Buggy source:
public static File chooseFile(boolean useJFileChooser,final Component parent,final String selectedFile,final FileFilter fileFilter,final String dialogTitle,final DialogType dialogType,final SelectionMode selectionMode){
  final boolean isSaveDialog=(dialogType == DialogType.SAVE);
  final boolean isDirectoriesOnly=(selectionMode == SelectionMode.DIRECTORIES_ONLY);
  if (isSaveDialog && isDirectoriesOnly)   useJFileChooser=true;
  String title=dialogTitle;
  if (title == null)   title=(isSaveDialog ? "String_Node_Str" : "String_Node_Str") + (fileFilter == null ? "String_Node_Str" : "String_Node_Str" + fileFilter.getDescription());
  File file=null;
  if (useJFileChooser) {
    final JFileChooser fileChooser=new JFileChooser();
    fileChooser.setDialogTitle(title);
    if (selectedFile != null)     fileChooser.setSelectedFile(new File(selectedFile));
    fileChooser.setFileSelectionMode(isDirectoriesOnly ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_ONLY);
    fileChooser.setFileFilter(fileFilter);
    final int returnVal=isSaveDialog ? fileChooser.showSaveDialog(parent) : fileChooser.showOpenDialog(parent);
    if (returnVal == JFileChooser.APPROVE_OPTION)     file=fileChooser.getSelectedFile();
  }
 else {
    final int fdMode=isSaveDialog ? FileDialog.SAVE : FileDialog.LOAD;
    final FileDialog fd;
    if (parent != null || parent instanceof Frame)     fd=new FileDialog((Frame)parent,title,fdMode);
 else     if (parent != null || parent instanceof Dialog)     fd=new FileDialog((Dialog)parent,title,fdMode);
 else     fd=new FileDialog((Frame)null,title,fdMode);
    if (selectedFile != null) {
      fd.setDirectory(new File(selectedFile).getParent());
      fd.setFile(new File(selectedFile).getName());
    }
    System.setProperty("String_Node_Str",isDirectoriesOnly ? "String_Node_Str" : "String_Node_Str");
    final AtomicBoolean workedWithFilenameFilter=new AtomicBoolean(false);
    if (fileFilter != null) {
      final FilenameFilter filenameFilter=new FilenameFilter(){
        private boolean firstTime=true;
        @Override public boolean accept(        final File dir,        final String name){
          if (firstTime) {
            workedWithFilenameFilter.set(true);
            firstTime=false;
          }
          return fileFilter.accept(new File(dir,name));
        }
      }
;
      fd.setFilenameFilter(filenameFilter);
      fd.setVisible(true);
    }
    if (fileFilter == null || (isMac() && !workedWithFilenameFilter.get())) {
      fd.setFilenameFilter(null);
      fd.setVisible(true);
    }
    final String filename=fd.getFile();
    if (filename != null) {
      file=new File(fd.getDirectory() + filename);
    }
  }
  return file;
}

Fixed version (ground truth):
public static File chooseFile(boolean useJFileChooser,final Component parent,final String selectedFile,final FileFilter fileFilter,final String dialogTitle,final DialogType dialogType,final SelectionMode selectionMode){
  final boolean isSaveDialog=(dialogType == DialogType.SAVE);
  final boolean isDirectoriesOnly=(selectionMode == SelectionMode.DIRECTORIES_ONLY);
  if (isSaveDialog && isDirectoriesOnly)   useJFileChooser=true;
  String title=dialogTitle;
  if (title == null)   title=(isSaveDialog ? "String_Node_Str" : "String_Node_Str") + (fileFilter == null ? "String_Node_Str" : "String_Node_Str" + fileFilter.getDescription());
  File file=null;
  if (useJFileChooser) {
    final JFileChooser fileChooser=new JFileChooser();
    fileChooser.setDialogTitle(title);
    if (selectedFile != null)     fileChooser.setSelectedFile(new File(selectedFile));
    fileChooser.setFileSelectionMode(isDirectoriesOnly ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_ONLY);
    fileChooser.setFileFilter(fileFilter);
    final int returnVal=isSaveDialog ? fileChooser.showSaveDialog(parent) : fileChooser.showOpenDialog(parent);
    if (returnVal == JFileChooser.APPROVE_OPTION)     file=fileChooser.getSelectedFile();
  }
 else {
    final int fdMode=isSaveDialog ? FileDialog.SAVE : FileDialog.LOAD;
    final FileDialog fd;
    if (parent != null && parent instanceof Frame)     fd=new FileDialog((Frame)parent,title,fdMode);
 else     if (parent != null && parent instanceof Dialog)     fd=new FileDialog((Dialog)parent,title,fdMode);
 else     fd=new FileDialog((Frame)null,title,fdMode);
    if (selectedFile != null) {
      fd.setDirectory(new File(selectedFile).getParent());
      fd.setFile(new File(selectedFile).getName());
    }
    System.setProperty("String_Node_Str",isDirectoriesOnly ? "String_Node_Str" : "String_Node_Str");
    final AtomicBoolean workedWithFilenameFilter=new AtomicBoolean(false);
    if (fileFilter != null) {
      final FilenameFilter filenameFilter=new FilenameFilter(){
        private boolean firstTime=true;
        @Override public boolean accept(        final File dir,        final String name){
          if (firstTime) {
            workedWithFilenameFilter.set(true);
            firstTime=false;
          }
          return fileFilter.accept(new File(dir,name));
        }
      }
;
      fd.setFilenameFilter(filenameFilter);
      fd.setVisible(true);
    }
    if (fileFilter == null || (isMac() && !workedWithFilenameFilter.get())) {
      fd.setFilenameFilter(null);
      fd.setVisible(true);
    }
    final String filename=fd.getFile();
    if (filename != null) {
      file=new File(fd.getDirectory() + filename);
    }
  }
  return file;
}