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

Compiler throws null pointer exception on code with redundant parenthesis.

    Details

    • Subcomponent:
    • Introduced In Version:
      9
    • CPU:
      generic
    • OS:
      generic

      Description

      A DESCRIPTION OF THE PROBLEM :
      The compiler throws a null pointer exception rather than compiling the given example program.

      REGRESSION : Last worked in version 8u212

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
       %javac src/test/java/bug/CompileBugTest.java -cp ~/.m2/repository/org/projectlombok/lombok/1.18.8/lombok-1.18.8.jar:/Users/khartmann/.m2/repository/junit/junit/4.12/junit-4.12.jar

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Compilation of the given file.
      ACTUAL -
      An exception has occurred in the compiler (12.0.1). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.NullPointerException
      at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitApply(Flow.java:1304)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:394)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitExec(TreeScanner.java:218)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1519)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:394)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitBlock(Flow.java:1060)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:394)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitMethodDef(Flow.java:1027)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:872)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:394)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitClassDef(Flow.java:990)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:780)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:394)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1396)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.analyzeTree(Flow.java:1386)
      at jdk.compiler/com.sun.tools.javac.comp.Flow.analyzeTree(Flow.java:217)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1401)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1375)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
      at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
      at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)

      ---------- BEGIN SOURCE ----------
      package bug;

      import static org.junit.Assert.assertTrue;

      import java.util.ArrayList;
      import java.util.List;
      import java.util.Set;
      import java.util.UUID;
      import lombok.Builder;
      import lombok.NonNull;
      import lombok.Value;
      import lombok.val;

      public class CompileBugTest {
        public void testListToken() {
          BugTokenService tokenService = new BugTokenService();
          val responseList = tokenService.listToken(UUID.randomUUID());
          List<BugResponse> expected = new ArrayList<>();
          assertTrue((responseList.stream().allMatch(expected::contains)));
          // assertTrue(responseList.stream().allMatch(expected::contains));
        }
      }

      @Value
      @Builder
      class BugResponse {
        @NonNull private final String accessToken;
        @NonNull private final Set<String> scope;
        @NonNull private final Long exp;
        private String description;
      }

      class BugTokenService {
        public BugTokenService() {}

        public List<BugResponse> listToken(@NonNull UUID userId) {
          return new ArrayList<>();
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use the commented version of the assertion (ie. remove the redundant set of parenthesis).

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              fmatte Fairoz Matte
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: