Program: 3756
Project: 3756
Buggy source:
/** 
 * The implementation that the other methods delegate to. This provides the caller with all available options for customizing the <tt>JFileChooser</tt> instance. If a <tt>FileDialog</tt> is displayed instead of a <tt>JFileChooser</tt> (on OS X, for example), most or all of these options have no effect.
 * @param parent the <tt>Component</tt> that should be the dialog's parent
 * @param titleKey the key for the locale-specific string to use for thefile dialog title
 * @param approveKey the key for the locale-specific string to use for theapprove button text
 * @param directory the directory to open the dialog to
 * @param mode the "mode" to open the <tt>JFileChooser</tt> in from the<tt>JFileChooser</tt> class, such as <tt>JFileChooser.DIRECTORIES_ONLY</tt>
 * @param option the option to look for in the return code, such as<tt>JFileChooser.APPROVE_OPTION</tt>
 * @param allowMultiSelect true if the chooser allows multiple files to bechosen
 * @param filter the <tt>FileFilter</tt> instance for customizing thefiles that are displayed -- if this is null, no filter is used
 * @return the selected <tt>File</tt> instance, or <tt>null</tt> if afile was not selected correctly
 */
public static List<File> getInput(Component parent,String titleKey,String approveKey,File directory,int mode,int option,boolean allowMultiSelect,final FileFilter filter){
  if (!OSUtils.isMacOSX()) {
    if (OSUtils.isWindows() && mode == JFileChooser.DIRECTORIES_ONLY && !allowMultiSelect) {
      try {
        WindowsFolderChooser folder=new WindowsFolderChooser(parent,titleKey,false,true,directory.getAbsolutePath());
        String path=folder.showWidget();
        if (path != null && path.length() > 0) {
          File file=new File(path);
          setLastInputDirectory(file);
          return Collections.singletonList(file);
        }
 else {
          return null;
        }
      }
 catch (      UnsatisfiedLinkError ule) {
        return getFileChooser(parent,titleKey,approveKey,directory,mode,option,allowMultiSelect,filter);
      }
    }
 else {
      return getFileChooser(parent,titleKey,approveKey,directory,mode,option,allowMultiSelect,filter);
    }
  }
 else {
    boolean canChooseFiles=(mode == JFileChooser.FILES_ONLY || mode == JFileChooser.FILES_AND_DIRECTORIES);
    boolean canChooseDirectories=(mode == JFileChooser.DIRECTORIES_ONLY || mode == JFileChooser.FILES_AND_DIRECTORIES);
    List<File> selectedFiles=MacOSXUtils.openNativeFileDialog(I18n.tr(titleKey),directory,canChooseFiles,canChooseDirectories,allowMultiSelect,filter);
    if (selectedFiles == null) {
      return null;
    }
 else {
      if (selectedFiles.size() > 0) {
        if (selectedFiles.get(0).isFile()) {
          setLastInputDirectory(selectedFiles.get(0));
        }
 else {
          if (selectedFiles.get(0).getParent() != null)           setLastInputDirectory(new File(selectedFiles.get(0).getParent()));
 else           setLastInputDirectory(selectedFiles.get(0));
        }
      }
      return selectedFiles;
    }
  }
}

Fixed version (ground truth):
/** 
 * The implementation that the other methods delegate to. This provides the caller with all available options for customizing the <tt>JFileChooser</tt> instance. If a <tt>FileDialog</tt> is displayed instead of a <tt>JFileChooser</tt> (on OS X, for example), most or all of these options have no effect.
 * @param parent the <tt>Component</tt> that should be the dialog's parent
 * @param titleKey the key for the locale-specific string to use for thefile dialog title
 * @param approveKey the key for the locale-specific string to use for theapprove button text
 * @param directory the directory to open the dialog to
 * @param mode the "mode" to open the <tt>JFileChooser</tt> in from the<tt>JFileChooser</tt> class, such as <tt>JFileChooser.DIRECTORIES_ONLY</tt>
 * @param option the option to look for in the return code, such as<tt>JFileChooser.APPROVE_OPTION</tt>
 * @param allowMultiSelect true if the chooser allows multiple files to bechosen
 * @param filter the <tt>FileFilter</tt> instance for customizing thefiles that are displayed -- if this is null, no filter is used
 * @return the selected <tt>File</tt> instance, or <tt>null</tt> if afile was not selected correctly
 */
public static List<File> getInput(Component parent,String titleKey,String approveKey,File directory,int mode,int option,boolean allowMultiSelect,final FileFilter filter){
  if (!OSUtils.isMacOSX()) {
    if (OSUtils.isWindows() && mode == JFileChooser.DIRECTORIES_ONLY && !allowMultiSelect) {
      try {
        String oldPath=directory == null ? null : directory.getAbsolutePath();
        WindowsFolderChooser folder=new WindowsFolderChooser(parent,titleKey,false,true,oldPath);
        String path=folder.showWidget();
        if (path != null && path.length() > 0) {
          File file=new File(path);
          setLastInputDirectory(file);
          return Collections.singletonList(file);
        }
 else {
          return null;
        }
      }
 catch (      UnsatisfiedLinkError ule) {
        return getFileChooser(parent,titleKey,approveKey,directory,mode,option,allowMultiSelect,filter);
      }
    }
 else {
      return getFileChooser(parent,titleKey,approveKey,directory,mode,option,allowMultiSelect,filter);
    }
  }
 else {
    boolean canChooseFiles=(mode == JFileChooser.FILES_ONLY || mode == JFileChooser.FILES_AND_DIRECTORIES);
    boolean canChooseDirectories=(mode == JFileChooser.DIRECTORIES_ONLY || mode == JFileChooser.FILES_AND_DIRECTORIES);
    List<File> selectedFiles=MacOSXUtils.openNativeFileDialog(I18n.tr(titleKey),directory,canChooseFiles,canChooseDirectories,allowMultiSelect,filter);
    if (selectedFiles == null) {
      return null;
    }
 else {
      if (selectedFiles.size() > 0) {
        if (selectedFiles.get(0).isFile()) {
          setLastInputDirectory(selectedFiles.get(0));
        }
 else {
          if (selectedFiles.get(0).getParent() != null)           setLastInputDirectory(new File(selectedFiles.get(0).getParent()));
 else           setLastInputDirectory(selectedFiles.get(0));
        }
      }
      return selectedFiles;
    }
  }
}