Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-5440

NPE on code formatting

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 12.2
    • None
    • None
    • Netbeans 12.2

      macosx 11.2.3

      OpenJDK 11

    Description

      When performing code formatting on a particular java class, NB throws the following NPE:

      {{
      java.lang.NullPointerException
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.scan(Reformatter.java:587)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitCase(Reformatter.java:2938)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitCase(Reformatter.java:397)
      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:601)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.handleSwitch(Reformatter.java:2889)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitSwitch(Reformatter.java:2790)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitSwitch(Reformatter.java:397)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSwitch.accept(JCTree.java:1229)
      at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.scan(Reformatter.java:601)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitBlock(Reformatter.java:1986)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitBlock(Reformatter.java:397)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1032)
      at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.scan(Reformatter.java:601)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.wrapStatement(Reformatter.java:4579)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.wrapStatement(Reformatter.java:4531)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitIf(Reformatter.java:2585)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitIf(Reformatter.java:397)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1433)
      at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.scan(Reformatter.java:601)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitBlock(Reformatter.java:1986)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitBlock(Reformatter.java:397)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1032)
      at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.scan(Reformatter.java:601)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitMethod(Reformatter.java:1559)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitMethod(Reformatter.java:397)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
      at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.scan(Reformatter.java:601)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitClass(Reformatter.java:1052)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitClass(Reformatter.java:397)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
      at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.scan(Reformatter.java:601)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitCompilationUnit(Reformatter.java:648)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.visitCompilationUnit(Reformatter.java:397)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
      at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
      at org.netbeans.modules.java.source.save.Reformatter$Pretty.reformat(Reformatter.java:514)
      at org.netbeans.modules.java.source.save.Reformatter.reformatImpl(Reformatter.java:228)
      at org.netbeans.modules.java.source.save.Reformatter.reformat(Reformatter.java:101)
      at org.netbeans.modules.editor.indent.TaskHandler$MimeItem.runTask(TaskHandler.java:550)
      at org.netbeans.modules.editor.indent.TaskHandler.runTasks(TaskHandler.java:309)
      at org.netbeans.modules.editor.indent.IndentImpl.reformat(IndentImpl.java:349)
      at org.netbeans.modules.editor.indent.api.Reformat.reformat(Reformat.java:129)
      at org.netbeans.editor.ActionFactory$FormatAction$1$1.run(ActionFactory.java:1854)
      at org.netbeans.editor.GuardedDocument.runAtomicAsUser(GuardedDocument.java:333)
      at org.netbeans.editor.ActionFactory$FormatAction$1.run(ActionFactory.java:1833)
      at org.netbeans.modules.progress.ui.RunOffEDTImpl$1.run(RunOffEDTImpl.java:146)
      at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
      at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
      at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
      [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
      }}

      Attachments

        Activity

          People

            Unassigned Unassigned
            joergd Jörg Delker
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: