Details
-
Bug
-
Resolution: Fixed
-
P3
-
9
-
b39
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8194700 | 11 | Jonathan Gibbons | P3 | Resolved | Fixed | b01 |
JDK-8194798 | 10.0.1 | Jonathan Gibbons | P3 | Resolved | Fixed | b01 |
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
/** ???? */
^
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
- backported by
-
JDK-8194700 javadoc -encoding doesn't work when using the old doclet API
-
- Resolved
-
-
JDK-8194798 javadoc -encoding doesn't work when using the old doclet API
-
- Resolved
-