JDK-6570445 : Win32ShellFolder2 throws exceptions if security manager installed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u2
  • Priority: P2
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows
  • CPU: x86
  • Submitted: 2007-06-16
  • Updated: 2011-02-16
  • Resolved: 2009-03-12
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 6 JDK 7 Other
6u4Fixed 7Resolved OpenJDK6Fixed
Related Reports
Relates :  
Description
Initially the synopsis was "JFileChooser's COM thread doesn't stop if a security manager installed", I changed it to reflect the actual issue better.

Run a simple test:
======================
import javax.swing.filechooser.FileSystemView;

public class bug6570445 {
    public static void main(String[] args) throws Exception {
        System.setSecurityManager(new SecurityManager());
	// The next line of code forces FileSystemView to request data from Win32ShellFolder2,
	// what causes an exception if a security manager installed
        FileSystemView.getFileSystemView().getRoots();
        System.out.println("Passed.");
    }
}
======================

The test throws an exception:

Exception in thread "main" java.lang.ExceptionInInitializerError
        at sun.awt.shell.Win32ShellFolder2$ComTask.execute(Win32ShellFolder2.java:1228)
        at sun.awt.shell.Win32ShellFolder2.getFileSystemPath(Win32ShellFolder2.java:559)
        at sun.awt.shell.Win32ShellFolder2.composePathForCsidl(Win32ShellFolder2.java:213)
        at sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:226)
        at sun.awt.shell.Win32ShellFolderManager2.getDesktop(Win32ShellFolderManager2.java:87)
        at sun.awt.shell.Win32ShellFolderManager2.get(Win32ShellFolderManager2.java:187)
        at sun.awt.shell.ShellFolder.get(ShellFolder.java:218)
        at javax.swing.filechooser.FileSystemView.getRoots(FileSystemView.java:363)
        at bug6570445.main(bug6570445.java:6)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission shutdownHooks)
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
        at java.security.AccessController.checkPermission(AccessController.java:546)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
        at java.lang.Runtime.addShutdownHook(Runtime.java:190)
        at sun.awt.shell.Win32ShellFolder2$ComTaskExecutor.<init>(Win32ShellFolder2.java:1169)
        at sun.awt.shell.Win32ShellFolder2$ComTaskExecutor.<clinit>(Win32ShellFolder2.java:1158)
        ... 9 more

Comments
EVALUATION In Win32ShellFolder2, the shutdown hook's code should be surrounded with a doPrivilege block.
16-06-2007