Apache NetBeans version
Apache NetBeans latest daily build
What happened
While opening a NetBeans project (netbeans/java/refactoring.java) netbeans shows an error in in the bottom status line.
This happens only after a fresh netbeans installation is used on a first project scan.

The stacktrace shows
java.lang.NullPointerException: Cannot invoke "javax.lang.model.element.Element.getKind()" because "e" is null
at org.netbeans.modules.profiler.nbimpl.providers.JavaProfilerSourceImpl$10$1.visitMethod(JavaProfilerSourceImpl.java:639)
at org.netbeans.modules.profiler.nbimpl.providers.JavaProfilerSourceImpl$10$1.visitMethod(JavaProfilerSourceImpl.java:635)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:993)
The resolution in this case is simple, check the Element e for nulity before dereferencing.
The relevant code is:
if (e.getKind() == ElementKind.METHOD) {
ExecutableElement ee = (ExecutableElement)e;
if (ee.getSimpleName().contentEquals("suite") && // NOI18N
(ee.getReturnType().toString().equals(JUNIT_TEST) ||
ee.getReturnType().toString().equals(JUNIT_SUITE))) {
rslt[0] |= true;
}
}
The solution is simple modify first line to
if (e !=null && e.getKind() == ElementKind.METHOD) {
which has no adverse effect on the logic.
Language / Project Type / NetBeans Component
java/ netbeans/ Java Profiler profiler(NetBeans Bindings)
How to reproduce
run ant tryme on a freshly built netbeans and open a netbeans module for instance java/refactoring.java.
If you ran tryme before, remove ~/.netbeans
Did this work correctly in an earlier version?
No / Don't know
Operating System
Ubunutu 24.04
JDK
17
Apache NetBeans packaging
Own source build
Anything else
You may have to clean caches from an earlier run.
Are you willing to submit a pull request?
Yes
Apache NetBeans version
Apache NetBeans latest daily build
What happened
While opening a NetBeans project (netbeans/java/refactoring.java) netbeans shows an error in in the bottom status line.
This happens only after a fresh netbeans installation is used on a first project scan.
The stacktrace shows
The resolution in this case is simple, check the
Element efor nulity before dereferencing.The relevant code is:
The solution is simple modify first line to
which has no adverse effect on the logic.
Language / Project Type / NetBeans Component
java/ netbeans/ Java Profiler profiler(NetBeans Bindings)
How to reproduce
run
ant trymeon a freshly built netbeans and open a netbeans module for instance java/refactoring.java.If you ran tryme before, remove ~/.netbeans
Did this work correctly in an earlier version?
No / Don't know
Operating System
Ubunutu 24.04
JDK
17
Apache NetBeans packaging
Own source build
Anything else
You may have to clean caches from an earlier run.
Are you willing to submit a pull request?
Yes