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

javadoc -encoding doesn't work when using the old doclet API

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 10
    • Component/s: tools
    • Labels:

      Backports

        Description

        In JDK 9, the javadoc flag -encoding fails to override the default encoding when using the old doclet API.

        The following patch fixes the bug:

        ```
        diff --git a/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java b/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java
        --- a/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java
        +++ b/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java
        @@ -157,10 +157,11 @@
             ENCODING("-encoding", true) {
                 @Override
                 public void process(Helper helper, String arg) {
                     helper.encoding = arg;
                     helper.setCompilerOpt(opt, arg);
        + helper.setFileManagerOpt(Option.ENCODING, arg);
                 }
             },
         
             RELEASE("--release", true) {
                 @Override
        ```

        Repro:

        === Doclet.java
        import com.sun.javadoc.*;
        public class Doclet extends com.sun.javadoc.Doclet {
          public static LanguageVersion languageVersion() {
            return LanguageVersion.JAVA_1_5;
          }
        }
        === Test.java
        /** 🥑 */
        class Test {}
        ===

        $ javac -cp $JAVA_HOME/lib/tools.jar Doclet.java

        with 1.8.0_152-ea:

        $ javadoc -J-Dfile.encoding=ascii -doclet Doclet -docletpath . -encoding UTF-8 Test.java
        ... OK

        with 9+181:

        $ javadoc -J-Dfile.encoding=ascii -doclet Doclet -docletpath . -encoding UTF-8 Test.java
        javadoc: warning - The old Doclet and Taglet APIs in the packages
        com.sun.javadoc, com.sun.tools.doclets and their implementations
        are planned to be removed in a future JDK release. These
        components have been superseded by the new APIs in jdk.javadoc.doclet.
        Users are strongly recommended to migrate to the new APIs.
        Loading source file Test.java...
        Test.java:1: error: unmappable character (0xF0) for encoding US-ASCII
        /** ???? */
            ^

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jjg Jonathan Gibbons
                  Reporter:
                  cushon Liam Miller-Cushon
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: