Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6570445

Win32ShellFolder2 throws exceptions if security manager installed

    Details

    • Subcomponent:
    • Introduced In Build:
      b01
    • Introduced In Version:
      6u2
    • CPU:
      x86
    • OS:
      windows

      Backports

        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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  rupashka Pavel Porvatov (Inactive)
                  Reporter:
                  loneid Leonid Popov (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: