You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Peter Hull (Jira)" <ji...@apache.org> on 2021/04/01 08:36:00 UTC

[jira] [Comment Edited] (NETBEANS-4569) Format Java code throws NullPointerException

    [ https://issues.apache.org/jira/browse/NETBEANS-4569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17312994#comment-17312994 ] 

Peter Hull edited comment on NETBEANS-4569 at 4/1/21, 8:35 AM:
---------------------------------------------------------------

I have also encountered this with following source code (tried to get this as small as possible)

{{public class NewClass {}}
{{ public void t () {}}
{{ switch(0)}}{{{ default: break;}}}{{}}}
{{ }}}

I have attached my messages.log. Note https://issues.apache.org/jira/browse/NETBEANS-4570 was a duplicate of this but was closed (IMO prematurely). The suggested workround in that issue, clearing the cache, did not work for me.

Product Version: Apache NetBeans IDE 12.3
 Java: 11.0.9.1; OpenJDK 64-Bit Server VM 11.0.9.1+1
 Runtime: OpenJDK Runtime Environment 11.0.9.1+1
 System: Windows 10 version 10.0 running on amd64; Cp1252; en_GB (nb)
 User directory: C:\Users\peter\AppData\Roaming\NetBeans\12.3
 Cache directory: C:\Users\peter\AppData\Local\NetBeans\Cache\12.3

[^messages.log] 
  


was (Author: peterhull90):
I have also encountered this with following source code (tried to get this as small as possible)

{{

public class NewClass {
    public void t () {
        switch(0) { default: break;}
    }
}}}

I have attached  my messages.log. Note https://issues.apache.org/jira/browse/NETBEANS-4570 was a duplicate of this but was closed (IMO prematurely). The suggested workround in that issue, clearing the cache, did not work for me.

Product Version: Apache NetBeans IDE 12.3
Java: 11.0.9.1; OpenJDK 64-Bit Server VM 11.0.9.1+1
Runtime: OpenJDK Runtime Environment 11.0.9.1+1
System: Windows 10 version 10.0 running on amd64; Cp1252; en_GB (nb)
User directory: C:\Users\peter\AppData\Roaming\NetBeans\12.3
Cache directory: C:\Users\peter\AppData\Local\NetBeans\Cache\12.3

 [^messages.log] 
 

> Format Java code throws NullPointerException
> --------------------------------------------
>
>                 Key: NETBEANS-4569
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-4569
>             Project: NetBeans
>          Issue Type: Bug
>    Affects Versions: 12.0
>            Reporter: Boris Heithecker
>            Priority: Major
>         Attachments: messages.log
>
>
> Action Format code (Alt+Shift-F) sometimes fails due to a NullPointerException thrown.
> Affects Java code. 
> I could not determine the exact pattern to reproduce this, but it definitely depends on pieces of the source code. Commenting out parts of the affected class sometimes helps. 
> I've been working with the same sources in 11.3 and didn't notice anything like it.
> Stack trace: 
> java.lang.NullPointerExceptionjava.lang.NullPointerException at org.netbeans.modules.java.source.save.Reformatter$Pretty.scan(Reformatter.java:586) at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitCase(Reformatter.java:2919) at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitCase(Reformatter.java:396) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCase.accept(JCTree.java:1258) at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82) at org.netbeans.modules.java.source.save.Reformatter$Pretty.scan(Reformatter.java:600) at org.netbeans.modules.java.source.save.Reformatter$Pretty.handleSwitch(Reformatter.java:2870)
>  
> Maybe it can be fixed easily by checking for null. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

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