United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6570445 Win32ShellFolder2 throws exceptions if security manager installed
JDK-6570445 : Win32ShellFolder2 throws exceptions if security manager installed

Details
Type:
Bug
Submit Date:
2007-06-16
Status:
Closed
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2009-03-12
Component:
client-libs
OS:
windows
Sub-Component:
javax.swing
CPU:
x86
Priority:
P2
Resolution:
Cannot Reproduce
Affected Versions:
6u2
Fixed Versions:
7

Related Reports
Backport:
Backport:
Relates:

Sub Tasks

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.
                                     
2007-06-16



Hardware and Software, Engineered to Work Together