netbeans
netbeans copied to clipboard
Exceptions if .hint file name has non identifier characters
Apache NetBeans version
Apache NetBeans 15
What happened
I think it's non-identifier characters in the file name, could be wrong
Added a file <userdir>/config/rules/JOptionPane-2.hint
. Tried to edit it from inspect dialog, exceptions
java.lang.NullPointerException
at org.netbeans.modules.java.hints.spiimpl.options.HintsPanel.editScriptButtonActionPerformed(HintsPanel.java:760)
at org.netbeans.modules.java.hints.spiimpl.options.HintsPanel.access$1100(HintsPanel.java:108)
at org.netbeans.modules.java.hints.spiimpl.options.HintsPanel$11.actionPerformed(HintsPanel.java:593)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
and
java.lang.NullPointerException
at org.netbeans.modules.java.hints.spiimpl.options.HintsPanel.openInEditorActionPerformed(HintsPanel.java:836)
at org.netbeans.modules.java.hints.spiimpl.options.HintsPanel.access$800(HintsPanel.java:108)
at org.netbeans.modules.java.hints.spiimpl.options.HintsPanel$8.actionPerformed(HintsPanel.java:502)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
I foolishly thought there was a problem with the contents of the file, chasing my tail. I finally became suspect of the name, changing the name to JOptionPane_2.hint fixed the problem.
How to reproduce
No response
Did this work correctly in an earlier version?
No / Don't know
Operating System
Linux harmony 5.19.0-76051900-generic #202207312230~1660780566~22.04~9d60db1
JDK
openjdk version "11.0.2" 2019-01-15
Apache NetBeans packaging
Own source build
Anything else
No response
Are you willing to submit a pull request?
No
Code of Conduct
Yes
@mbien, you might be familiar with this area. :-)
It think the system uses the file name (minus ending) as hint name by default if it wasn't configured anywhere else (see hint option).
I imagine this is likely what it causing this. Going to take a look.
oops. Turns out -
has a special meaning. Not sure what exactly but it removes everything after it from the name. Might have to dig into the old repo to find a commit.
https://github.com/apache/netbeans/blob/4ae01ea70f4530443343beee3292e880a74099bd/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/options/HintsPanel.java#L1313-L1322
history: https://github.com/emilianbold/netbeans-releases/commit/ef035cb5ce9fcf9266fac7851ba42357cd7e08f6 https://github.com/emilianbold/netbeans-releases/commit/5b1a0fe8623495d50eceadf6e946c1287e51d11b
Wow, that's curious. That 2nd change by emi is particularly interesting. Is the code above used only for hints put into the 'rules/' directory by a user? Maybe the problem comes from the scanning of rules directory and the creation of the id
as in selectedHint.id
.
Seems like if anything found in rules, JOP.hint
, is given an id JOP.hint-
, then at lease this code would work. Then again what might not work. It would be nice to know what the hell the "-" is all about.
A dialog that can't open file would at least avoid confusing fools like me.