JDK-8190514 : JFileChooser throws NullPointerException when "Network" is hidden in Explorer
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u152
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_7
  • CPU: x86
  • Submitted: 2017-10-25
  • Updated: 2024-03-04
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.
Other
tbdUnresolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) Client VM (build 25.152-b16, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Hide "My Network Places" from Windows Explorer view

A DESCRIPTION OF THE PROBLEM :
javax.swing.JFileChooser no-arg constructor throws NullPointerException:

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Hide "My Network Places" from Windows Explorer view
https://blogs.technet.microsoft.com/csstwplatform/2010/05/05/how-to-hide-my-network-places-from-windows-explorer-view/
2. Execute test case

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
New file chooser is created and the program is successfully terminated
ACTUAL -
The java.lang.NullPointerException is thrown

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NullPointerException
        at sun.awt.shell.Win32ShellFolder2.getFileSystemPath(Win32ShellFolder2.java:571)
        at sun.awt.shell.Win32ShellFolder2.access$400(Win32ShellFolder2.java:72)
        at sun.awt.shell.Win32ShellFolder2$10.call(Win32ShellFolder2.java:756)
        at sun.awt.shell.Win32ShellFolder2$10.call(Win32ShellFolder2.java:747)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at sun.awt.shell.Win32ShellFolderManager2$ComInvoker$3.run(Win32ShellFolderManager2.java:547)
        at java.lang.Thread.run(Thread.java:748)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.JFileChooser;

public class Test {
  public static void main(String[] args) {
    new JFileChooser();
  }
}


---------- END SOURCE ----------


Comments
Methods described in https://serverfault.com/questions/596726/hide-network-icon-in-file-explorer-on-server-2012 could remove access to Network from Explorer without removing the Shell Namespace for Network.
02-01-2024

I wonder if enabling "Hide Network Locations icon on desktop" Group Policy causes this issue too. According to the description, it “removes the Network Locations icon from the desktop. This setting affects only the desktop icon.” The policy setting can be found at User Configuration -> Administrative Templates -> Desktop -> Hide Network Locations icon on desktop. Enabling the policy adds NoNetHood=1 value under HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer.
02-01-2024

It needs deleting the registry from the system which might cause some problem. We need to find some test machine where we can perform this test and currently we do not have such machine. Postponing for machine availability to test this.
13-11-2017

does it affect 9 ?
08-11-2017

JDK 8u152 Windows 7 JFileChooser throws NPE when "My Network Places" is hidden from Windows Explorer view Tried to verified this with the provided steps, however couldn't proceed. The reproducible steps involves deleting the registry keys from the system. Not sure, if we can consider this as a valid request. Actual reproducible steps: ======================== 1. Hide "My Network Places" from Windows Explorer view https://blogs.technet.microsoft.com/csstwplatform/2010/05/05/how-to-hide-my-network-places-from-windows-explorer-view/ 2. Execute test case ========================= Writing back to the submitter to understand the context about these steps/issue?
08-11-2017

Additional information from the submitter: ======================================= - Actual steps to reproduce the issue. Explain why do you need to delete the registry keys which is not recommended under normal circumstances? Because "My Network Place" is hidden in my customer's environment. I have no authority to change customer's environment. Considers this as a Java issue, - Because sun.awt.shell.Win32ShellFolderManager2#getNetwork may return null, I think that should check null. ==============================
08-11-2017