Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8067735

Compile failed, NPE when using functions in stream().map()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8u5
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_05"
      Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      error occured when i try compile this code

      private ResponseListener commentsListener = new ResponseListener() {

              @Override
              public void receive(NModel nmodel) {
                  NList<NModel> ticketsList = nmodel.getAsList(NSchema.LIST);
                  DefaultListModel<String> dlm = new DefaultListModel<>(ticketsList.stream().map(item -> commentToString(item)).collect(Collectors.toArray()));
                  getTicketsList().setModel(dlm);
              }

              @Override
              public void handleError(Response rspns) {
                  System.out.println(rspns.getErrorMessage());
              }
          };
          
          private String commentToString(NModel comment) {
              StringBuilder builder = new StringBuilder();
              builder.append("author ");
              builder.append(comment.getAsString(CommentSchema.FIELD_AUTHOR));
              builder.append(" ");
              builder.append(comment.getAsString(CommentSchema.FIELD_DATE));
              builder.append(" ");
              builder.append(comment.getAsString(CommentSchema.FIELD_TEXT));
              return builder.toString();
          }


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      An exception has occurred in the compiler (1.8.0). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.NullPointerException
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitIdent(Flow.java:2327)
      at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2005)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.tree.TreeScanner.visitSelect(TreeScanner.java:264)
      at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1891)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExpr(Flow.java:1596)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitApply(Flow.java:2204)
      at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1459)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.tree.TreeScanner.visitSelect(TreeScanner.java:264)
      at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1891)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExpr(Flow.java:1596)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitApply(Flow.java:2204)
      at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1459)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.tree.TreeScanner.visitSelect(TreeScanner.java:264)
      at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1891)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExpr(Flow.java:1596)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitApply(Flow.java:2204)
      at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1459)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExpr(Flow.java:1596)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExprs(Flow.java:1608)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitNewClass(Flow.java:2210)
      at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1510)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExpr(Flow.java:1596)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitVarDef(Flow.java:1806)
      at com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitVarDef(Flow.java:2521)
      at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:846)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitBlock(Flow.java:1815)
      at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:903)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitMethodDef(Flow.java:1753)
      at com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitMethodDef(Flow.java:2507)
      at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:772)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitClassDef(Flow.java:1705)
      at com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitClassDef(Flow.java:2486)
      at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:687)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitNewClass(Flow.java:2211)
      at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1510)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scanExpr(Flow.java:1596)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitVarDef(Flow.java:1806)
      at com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitVarDef(Flow.java:2521)
      at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:846)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.visitClassDef(Flow.java:1698)
      at com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitClassDef(Flow.java:2486)
      at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:687)
      at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:389)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.scan(Flow.java:1367)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.analyzeTree(Flow.java:2370)
      at com.sun.tools.javac.comp.Flow$AbstractAssignAnalyzer.analyzeTree(Flow.java:2353)
      at com.sun.tools.javac.comp.Flow.analyzeTree(Flow.java:210)
      at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1325)
      at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1299)
      at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:904)
      at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:863)
      at com.sun.tools.javac.main.Main.compile(Main.java:523)
      at com.sun.tools.javac.main.Main.compile(Main.java:381)
      at com.sun.tools.javac.main.Main.compile(Main.java:370)
      at com.sun.tools.javac.main.Main.compile(Main.java:361)
      at com.sun.tools.javac.Main.compile(Main.java:56)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:483)
      at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:56)
      at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1153)
      at org.netbeans.nbbuild.CustomJavac.compile(CustomJavac.java:124)
      at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:930)
      at org.netbeans.nbbuild.CustomJavac.execute(CustomJavac.java:105)
      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
      at sun.reflect.GeneratedMethodAccessor3554.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:483)
      at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
      at org.apache.tools.ant.Task.perform(Task.java:348)
      at org.apache.tools.ant.Target.execute(Target.java:435)
      at org.apache.tools.ant.Target.performTasks(Target.java:456)
      at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
      at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
      at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
      at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:286)
      at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:555)
      at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
      C:\Program Files\NetBeans 8.0\harness\common.xml:217: Compile failed; see the compiler error output for details.
      BUILD FAILED (total time: 8 seconds)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      private ResponseListener commentsListener = new ResponseListener() {

              @Override
              public void receive(NModel nmodel) {
                  NList<NModel> ticketsList = nmodel.getAsList(NSchema.LIST);
                  DefaultListModel<String> dlm = new DefaultListModel<>(ticketsList.stream().map(item -> commentToString(item)).collect(Collectors.toArray()));
                  getTicketsList().setModel(dlm);
              }

              @Override
              public void handleError(Response rspns) {
                  System.out.println(rspns.getErrorMessage());
              }
          };
          
          private String commentToString(NModel comment) {
              StringBuilder builder = new StringBuilder();
              builder.append("author ");
              builder.append(comment.getAsString(CommentSchema.FIELD_AUTHOR));
              builder.append(" ");
              builder.append(comment.getAsString(CommentSchema.FIELD_DATE));
              builder.append(" ");
              builder.append(comment.getAsString(CommentSchema.FIELD_TEXT));
              return builder.toString();
          }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: