JDK-8213583 : Error while opening the JFileChooser when desktop contains shortcuts pointing to deleted files
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8u191,11.0.1,12
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-11-09
  • Updated: 2019-03-28
  • Resolved: 2018-11-29
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 11 JDK 12 JDK 8 Other
11.0.3Fixed 12 b23Fixed 8u202Fixed openjdk8u212Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
If a Windows Desktop shortcut is bad (the file to which it points is gone), regardless of the default directory set in 
JFilechooser, an error is thrown saying that the shortcut is bad even though JFilechooser was not instructed 
to look at the Desktop.
Comments
Fix Request Equivalent backport to jdk8u, already in Oracle 8u202 BPR, Oracle 8u211 and 8u212.
22-02-2019

Fix Request This is needed in 11u as well (I see it is in 11.0.3-oracle). The patch applies cleanly to 11u and builds fine on Linux. I have not tested on Windows, because patch is trivial.
19-02-2019

Additional details and logs from submitter added into JDK-8214050
27-11-2018

Problem description: On Windows when a SecurityManager is defined and JFileChooser is opened for the folder which contains a broken shortcut the system popup message is displayed. The current implementation of ShellFolder for Windows calls IShellLinkW::Resolve without any flags. So the appearance of the dialog with system message for the broken shortcut is quite expected, see https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-ishelllinkw-resolve Fix: It is necessary to use SLR_NO_UI flag to suppress any system dialogs during IShellLinkW::Resolve invocation.
26-11-2018

The issue was triggered by JDK-8194546. It is reproducible on JDK 12, 11 and 8u191/8u192.
26-11-2018

Test case to reproduce the problem (taken from JDK-8214178): ---------- BEGIN SOURCE ---------- import java.io.*; import javax.swing.JFileChooser; ///////////////////////////////////// // // NOTE: // There must be a broken shortcut in the Windows desktop before running this program. // public class BrokenLinkBug { public static void main(String[] args) throws Exception { // Creates a temporary security policy final File tempPolicyFile = File.createTempFile("broken-links-bug-", ".policy"); tempPolicyFile.deleteOnExit(); try (final PrintStream policyStream = new PrintStream(new FileOutputStream(tempPolicyFile))) { policyStream.println("grant { permission java.security.AllPermission; };"); } System.setProperty("java.security.policy", tempPolicyFile.getAbsolutePath()); // Trigger the problem System.setSecurityManager(new SecurityManager()); JFileChooser chooser = new JFileChooser(); chooser.showDialog(null, "Open"); // not really needed } } ---------- END SOURCE ---------- Steps to reproduce: 1. Create a file and a shortcut to it on Windows desktop. 2. Remove the file 3. Run the test Expected: No popup messages are displayed Actual: A system popup message appears: "The item <somefile> that this shortcut refers to has been changed or moved, so this shortcut will no longer work properly. Do you want to delete this shortcut?"
23-11-2018