homberghp opened a new issue, #8388:
URL: https://github.com/apache/netbeans/issues/8388

   ### 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.
   
   
![Image](https://github.com/user-attachments/assets/00957662-ea64-42bc-a63c-d4e1b59752d0)
   
   
   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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to