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

NPE at Win32ShellFolderManager2.createShellFolder

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      other

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_131"
      Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
      Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [version 10.0.15063]

      A DESCRIPTION OF THE PROBLEM :
      This is an upstream bug for:
      https://josm.openstreetmap.de/ticket/14795

      As per quality outreach please add label "josm-found" to this bug report.

      On Windows 10, a JFileChooser can fails to be initialized with the following stacktrace:

      java.lang.NullPointerException
      at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Unknown Source)
      at sun.awt.shell.Win32ShellFolderManager2.getRecent(Unknown Source)
      at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
      at sun.awt.shell.ShellFolder.get(Unknown Source)
      at sun.swing.WindowsPlacesBar.<init>(Unknown Source)
      at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(Unknown Source)
      at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(Unknown Source)
      at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
      at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(Unknown Source)
      at javax.swing.JComponent.setUI(Unknown Source)
      at javax.swing.JFileChooser.updateUI(Unknown Source)
      at javax.swing.JFileChooser.setup(Unknown Source)
      at javax.swing.JFileChooser.<init>(Unknown Source)
      at javax.swing.JFileChooser.<init>(Unknown Source)

      Looking at the source code it seems the most plausible explanation is that an exception occurs in Win32ShellFolderManager2.getDesktop but is silently ignored. Thus getDesktop() returns null:

          static Win32ShellFolder2 getDesktop() {
              if (desktop == null) {
                  try {
                      desktop = new Win32ShellFolder2(DESKTOP);
                  } catch (SecurityException e) {
                      // Ignore error
                  } catch (IOException e) {
                      // Ignore error
                  } catch (InterruptedException e) {
                      // Ignore error
                  }
              }
              return desktop;
          }

      And the NPE occurs because of parent (desktop) is null:

          static Win32ShellFolder2 createShellFolder(Win32ShellFolder2 parent, File file)
                  throws FileNotFoundException, InterruptedException {
              long pIDL;
              try {
                  pIDL = parent.parseDisplayName(file.getCanonicalPath());
              } catch (IOException ex) {
                  pIDL = 0;
              }
              if (pIDL == 0) {
                  // Shouldn't happen but watch for it anyway
                  throw new FileNotFoundException("File " + file.getAbsolutePath() + " not found");
              }

              try {
                  return createShellFolderFromRelativePIDL(parent, pIDL);
              } finally {
                  Win32ShellFolder2.releasePIDL(pIDL);
              }
          }


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.NullPointerException
      at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Unknown Source)
      at sun.awt.shell.Win32ShellFolderManager2.getRecent(Unknown Source)
      at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
      at sun.awt.shell.ShellFolder.get(Unknown Source)
      at sun.swing.WindowsPlacesBar.<init>(Unknown Source)
      at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(Unknown Source)
      at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(Unknown Source)
      at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
      at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(Unknown Source)
      at javax.swing.JComponent.setUI(Unknown Source)
      at javax.swing.JFileChooser.updateUI(Unknown Source)
      at javax.swing.JFileChooser.setup(Unknown Source)
      at javax.swing.JFileChooser.<init>(Unknown Source)
      at javax.swing.JFileChooser.<init>(Unknown Source)

      REPRODUCIBILITY :
      This bug can be reproduced rarely.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pardesha Pardeep Sharma
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: