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

javadoc crashes when a doc-files directory contains a '#' file

XMLWordPrintable

        A DESCRIPTION OF THE PROBLEM :
        Running javadoc using the files included below resulted in a crash. A 'doc-files' subdirectory
        had a file in it whose name contained the character '#' and was there because the editor I was
        using creates such files temporarily for checkpointing. This file was not referenced in the Java source
        code file, but javadoc had a problem with it anyway.

        I suspect that the root cause is that the javadoc code is not URL-encoding the '#' character when it
        appears in a file name



        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        I. create directories named docs and pkg
        2. insert the file Test.java into package. The contents of this file is
        package pkg;
        /**
         * Javadoc test case.
         */
        public class Test {
            public int i = 10;
            public Test() {}
        }

        3. In the directory pkg, create a subdirectory named doc-files.

        4. create a file with any content in doc-files name #file.html#

        5. In the initial directory, run the command
            javadoc -d docs pkg/*.java


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        No crash
        ACTUAL -
        Loading source file pkg/Test.java...
        Constructing Javadoc information...
        Standard Doclet version 11.0.7
        Building tree for all the packages and classes...
        Generating docs/pkg/Test.html...
        Generating docs/pkg/package-summary.html...
        Copying file ./pkg/doc-files/#file.html# to directory docs/pkg/doc-files...
        javadoc: error - An internal exception has occurred.
        (java.lang.IllegalArgumentException: Invalid relative name: doc-files/#file.html#)
        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.IllegalArgumentException: Invalid relative name: doc-files/#file.html#
        at jdk.compiler/com.sun.tools.javac.file.JavacFileManager.getFileForOutput(JavacFileManager.java:830)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.StandardDocFileFactory$StandardDocFile.getFileObjectForOutput(StandardDocFileFactory.java:378)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.StandardDocFileFactory$StandardDocFile.openOutputStream(StandardDocFileFactory.java:187)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.util.DocFile.copyFile(DocFile.java:150)
        at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.DocFilesHandlerImpl.copyDirectory(DocFilesHandlerImpl.java:149)
        at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.DocFilesHandlerImpl.copyDocFiles(DocFilesHandlerImpl.java:123)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.PackageSummaryBuilder.buildPackageDoc(PackageSummaryBuilder.java:129)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.PackageSummaryBuilder.build(PackageSummaryBuilder.java:110)
        at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.HtmlDoclet.generatePackageFiles(HtmlDoclet.java:311)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:210)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.run(AbstractDoclet.java:114)
        at jdk.javadoc/jdk.javadoc.doclet.StandardDoclet.run(StandardDoclet.java:72)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:588)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:432)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:345)
        at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
        at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)
        1 error


        ---------- BEGIN SOURCE ----------
        In pkg/Test.java:

        package pkg;
        /**
         * Javadoc test case.
         */
        public class Test {
            public int i = 10;
            public Test() {}
        }


        In pkg/doc-files/#file.html#

        [insert any text into this file]
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Save files when using emacs before running javadoc

        The bug occurred because the editor emacs creates 'checkpoint' files with file names that contain the
        character '#'. Saving eliminates these files,

        FREQUENCY : rarely


              jjg Jonathan Gibbons
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: