Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netbeans not being able to open any project #8040

Closed
talos12121 opened this issue Dec 12, 2024 · 10 comments · Fixed by #8110
Closed

Netbeans not being able to open any project #8040

talos12121 opened this issue Dec 12, 2024 · 10 comments · Fixed by #8110
Labels

Comments

@talos12121
Copy link

Apache NetBeans version

Apache NetBeans 23

What happened

I have been using the program for quite some time now and now all of a sudden I cant open any project. Every time I press open project it returns with an unexpected exception. The message is the following, Cannot invoke "String.matches(String)"because the return value of "java.io.File.to.String()"is null. If I press show details it also shows that a java.lang.NullPointerException has occured. I have tried uninstalling netbeans and reinstalling it several times and still the same thing. I did the same thing with the jdk but I still get the same error
messages.log

Language / Project Type / NetBeans Component

NetBeans Platform Application

How to reproduce

basically just by pressing open project or pressing ctrl+shift+o it should show the unexpected exception message I mentioned above

Did this work correctly in an earlier version?

No / Don't know

Operating System

windows 11 version 10.0

JDK

jdk-23_windows-x64_bin

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

Basically the problem occurs every time I try to open a project in netbeans

Are you willing to submit a pull request?

Yes

@talos12121 talos12121 added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Dec 12, 2024
@mbien
Copy link
Member

mbien commented Dec 13, 2024

  Product Version         = Apache NetBeans IDE 23
  Operating System        = Windows 11 version 10.0 running on amd64
  Java; VM; Vendor        = 23.0.1; Java HotSpot(TM) 64-Bit Server VM 23.0.1+11-39; Oracle Corporation
  Runtime                 = Java(TM) SE Runtime Environment 23.0.1+11-39

...

java.lang.NullPointerException: Cannot invoke "String.matches(String)" because the return value of "java.io.File.toString()" is null
	at org.netbeans.modules.project.ui.ProjectChooserAccessory$ProjectFileView.getIcon(ProjectChooserAccessory.java:578)
	at java.desktop/javax.swing.JFileChooser.getIcon(JFileChooser.java:1607)
	at org.netbeans.swing.dirchooser.DirectoryChooserUI$DirectoryComboBoxRenderer.getListCellRendererComponent(DirectoryChooserUI.java:1843)
	at java.desktop/javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize(BasicComboBoxUI.java:1446)
	at com.formdev.flatlaf.ui.FlatComboBoxUI.getDisplaySize(FlatComboBoxUI.java:712)

Interesting. I don't see how File#toString could return null, the way File is constructed it would fail much earlier if the path would resolve to null.

https://github.com/openjdk/jdk/blob/367c3041272d43b0474b433c555f22a3e15579f6/src/java.base/share/classes/java/io/File.java#L2004-L2006

https://github.com/openjdk/jdk/blob/367c3041272d43b0474b433c555f22a3e15579f6/src/java.base/share/classes/java/io/File.java#L520-L522

the code around ProjectChooserAccessory did also not change in a while.

@mbien
Copy link
Member

mbien commented Dec 13, 2024

btw as workaround you should be able to drag and drop projects directly into the editor or navigate to them using the favorites window to use right click open.

Resetting your config might also fix this issue for you. But this won't help finding out what the cause for this was.

The project folder which the dialog is opening by default is remembered as property in projectui.properties which should be in
C:/Users/varda/AppData/Roaming/NetBeans/23/config/Preferences/org/netbeans/modules/ in your case. Or if you use project groups in the groups sub folders.

@talos12121
Copy link
Author

I found a solution for that. I uninstalled java, the jdk and also netbeans. After that, I updated windows, reinstalled java then a previous version of jdk (in my case jdk 19) which I was using on my second pc and lastly I installed netbeans 17 which I was also using on my second pc. I think I probably had to uninstall java completely and then install them with that specific order. I will also try to install the latest version of jdk and netbeans. Thanks for the help

@neilcsmith-net
Copy link
Member

Make sure to delete the NB23 userdir and cachedir before attempting to upgrade again.

@mbien could it be not properly protected in case of deserialization?

@mbien
Copy link
Member

mbien commented Dec 13, 2024

@neilcsmith-net serialization could explain why a field is null in java.io.File yeah.

@mbien
Copy link
Member

mbien commented Jan 2, 2025

duplicate of #7067

@mbien mbien removed the needs:triage Requires attention from one of the committers label Jan 2, 2025
@mbien
Copy link
Member

mbien commented Jan 2, 2025

I have the suspicion that this too is windows "ShellFolder" related. Both stack traces of both issues contain ComboBoxUI frames which grab items from combo box models. And the only combo box model with files in it is the upper JComboBox.

its initialized with windows shell items:

if(useShellFolder) {
directories.addAll(Arrays.asList(getShellFolderRoots()));
} else {
directories.addAll(Arrays.asList(fileChooser.getFileSystemView().getRoots()));
}
// Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path,
// for example /foo/bar/ becomes /foo/bar
File canonical;
try {
canonical = directory.getCanonicalFile();
} catch (IOException e) {
// Maybe drive is not ready. Can't abort here.
canonical = directory;
}
// create File instances of each directory leading up to the top
File sf = useShellFolder? getShellFolderForFile(canonical) : canonical;

ShellFolders do have their own writeReplace but no read counterpart.
https://github.com/openjdk/jdk/blob/a77ed30fcc3360cd16a11b1899f52f7e871df1df/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java#L379-L416

so next time if someone can reproduce this we could check the hypothesis by starting with
-J-Dnb.FileChooser.useShellFolder=false

@neilcsmith-net
Copy link
Member

@mbien I'm not sure if it would help address this issue, as I'm not sure whether it would change what's returned, but it does look like we might be able to get rid of all the reflection usage in that class now? eg. https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/filechooser/FileSystemView.java#L653

@mbien
Copy link
Member

mbien commented Jan 2, 2025

yeah, some of the methods can be called directly now.

as sidenote, the API still doesn't return anything useful on linux (I have several drives mounted on default mount locations):

    System.out.println(fc.getFileSystemView().getDefaultDirectory());
    System.out.println(fc.getFileSystemView().getHomeDirectory());
    System.out.println(List.of(fc.getFileSystemView().getRoots()));
    System.out.println(List.of(fc.getFileSystemView().getChooserComboBoxFiles()));
    System.out.println(List.of(fc.getFileSystemView().getChooserShortcutPanelFiles()));
    System.out.println(List.of(fc.getFileSystemView().getChooserShortcutPanelFiles()));
/home/mbien
/home/mbien
[/]
[/]
[/home/mbien]
[/home/mbien]

@mbien
Copy link
Member

mbien commented Jan 3, 2025

I'm not sure if it would help address this issue,

@neilcsmith-net me neither. But the code uses non public API here:

File sf = useShellFolder? getShellFolderForFile(canonical) : canonical;

this check is missing when sun.awt.shell.ShellFolder.getShellFolder called directly for example (instead of using the package private method):
https://github.com/openjdk/jdk/blob/84e6432bb73e35b32f12cdc0e1a172b7c973e618/src/java.desktop/share/classes/javax/swing/filechooser/FileSystemView.java#L719-L721

I assume that the regular file chooser works fine on windows for those who face this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants