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

javadoc throws NullPointerException

XMLWordPrintable

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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.14393]

      A DESCRIPTION OF THE PROBLEM :
      javadoc throws NullPointerException when processing libraries that make use of class shadowing.

      As mentioned at https://issues.apache.org/jira/browse/MJAVADOC-478 this issue is also reproducible under JDK9.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run attached testcase

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Following class shadowing rules, the first class in the classpath should shadow any classes that follow with the same name. As such:

      one/com/MyClass should show up in the Javadoc output.
      two/com/MyClass should be omitted from the Javadoc output.
      ACTUAL -
      javadoc: error - java.lang.NullPointerException

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      When running under jdk9:

      Standard Doclet version 9-ea
      Building tree for all the packages and classes...
      javadoc: error - An internal exception has occurred.
              (java.lang.NullPointerException)
      Please file a bug against the javadoc tool via the Java bug reporting page
      (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)
      for duplicates. Include error messages and the following diagnostic in your report. Thank you.
      java.lang.NullPointerException
              at jdk.compiler/com.sun.tools.javac.comp.Enter.getClassEnv(Enter.java:159)
              at jdk.compiler/com.sun.tools.javac.api.JavacTrees.getAttrContext(JavacTrees.java:885)
              at jdk.compiler/com.sun.tools.javac.api.JavacTrees.attributeDocReference(JavacTrees.java:422)
              at jdk.compiler/com.sun.tools.javac.api.JavacTrees.getElement(JavacTrees.java:407)
              at jdk.compiler/com.sun.tools.doclint.Checker.visitReference(Checker.java:849)
              at jdk.compiler/com.sun.tools.doclint.Checker.visitReference(Checker.java:102)
              at jdk.compiler/com.sun.tools.javac.tree.DCTree$DCReference.accept(DCTree.java:631)
              at jdk.compiler/com.sun.source.util.DocTreePathScanner.scan(DocTreePathScanner.java:71)
              at jdk.compiler/com.sun.source.util.DocTreeScanner.visitLink(DocTreeScanner.java:296)
              at jdk.compiler/com.sun.tools.doclint.Checker.visitLink(Checker.java:763)
              at jdk.compiler/com.sun.tools.doclint.Checker.visitLink(Checker.java:102)
              at jdk.compiler/com.sun.tools.javac.tree.DCTree$DCLink.accept(DCTree.java:500)
              at jdk.compiler/com.sun.source.util.DocTreePathScanner.scan(DocTreePathScanner.java:71)
              at jdk.compiler/com.sun.source.util.DocTreeScanner.scanAndReduce(DocTreeScanner.java:83)
              at jdk.compiler/com.sun.source.util.DocTreeScanner.scan(DocTreeScanner.java:98)
              at jdk.compiler/com.sun.source.util.DocTreeScanner.scanAndReduce(DocTreeScanner.java:106)
              at jdk.compiler/com.sun.source.util.DocTreeScanner.visitDocComment(DocTreeScanner.java:184)
              at jdk.compiler/com.sun.tools.doclint.Checker.visitDocComment(Checker.java:231)
              at jdk.compiler/com.sun.tools.doclint.Checker.visitDocComment(Checker.java:102)
              at jdk.compiler/com.sun.tools.javac.tree.DCTree$DCDocComment.accept(DCTree.java:132)
              at jdk.compiler/com.sun.source.util.DocTreePathScanner.scan(DocTreePathScanner.java:50)
              at jdk.compiler/com.sun.tools.doclint.Checker.scan(Checker.java:193)
              at jdk.compiler/com.sun.tools.doclint.DocLint.scan(DocLint.java:348)
              at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.WorkArounds.runDocLint(WorkArounds.java:108)
              at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getDocCommentTree0(Utils.java:3028)
              at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getDocCommentTree(Utils.java:3056)
              at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils$WeakSoftHashMap.computeIfAbsent(Utils.java:3238)
              at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.getCommentHelper(Utils.java:2871)
              at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.hasBlockTag(Utils.java:2953)
              at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.hasBlockTag(Utils.java:2949)
              at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.Utils.isHidden(Utils.java:1553)
              at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.ClassTree.buildTree(ClassTree.java:177)
              at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.ClassTree.<init>(ClassTree.java:120)
              at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:200)
              at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.run(AbstractDoclet.java:115)
              at jdk.javadoc/jdk.javadoc.doclets.StandardDoclet.run(StandardDoclet.java:71)
              at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:604)
              at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:424)
              at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:341)
              at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
              at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      one/com/MyClass.java:
      ------------------------------------------
      package com;

      /**
       * This class *should* show up in the Javadoc.
       */
      public interface MyClass {
      }
      ------------------------------------------

      two/com/MyClass.java:
      ------------------------------------------
      package com;

      /**
       * This class should *not* show up in the Javadoc.
       *
       * The following link tag causes a NullPointerException: {@link Requirements}.
       */
      public interface MyClass {
      }
      ------------------------------------------

      argfile:
      ------------------------------------------
      'one/com/MyClass.java'
      'two/com/MyClass.java'
      ------------------------------------------

      options:
      ------------------------------------------
      -d
      'apidocs'
      ------------------------------------------

      javadoc.bat:
      ------------------------------------------
      javadoc.exe @options @argfile
      ------------------------------------------
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Remove either file from the argfile (prevent class shadowing from occurring).

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

              Created:
              Updated:
              Resolved: