From e4eef278925a971dd09fdd4c1ad63637219f9ed4 Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Thu, 14 Apr 2016 14:30:48 -0700 Subject: [PATCH] 8152818: Javadoc must support module options supported by javac Reviewed-by: jjg, martin --- .../jdk/javadoc/internal/tool/Start.java | 21 +++++- .../jdk/javadoc/internal/tool/ToolOption.java | 65 ++++++++++++++----- .../tool/resources/javadoc.properties | 20 +++++- 3 files changed, 87 insertions(+), 19 deletions(-) diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java index 0de7455a4a5..824ffc81348 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java @@ -52,6 +52,8 @@ import com.sun.tools.javac.api.JavacTrees; import com.sun.tools.javac.file.BaseFileManager; import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.main.CommandLine; +import com.sun.tools.javac.main.OptionHelper; +import com.sun.tools.javac.main.OptionHelper.GrumpyHelper; import com.sun.tools.javac.platform.PlatformDescription; import com.sun.tools.javac.platform.PlatformUtils; import com.sun.tools.javac.util.ClientCodeException; @@ -342,7 +344,7 @@ public class Start extends ToolOption.Helper { compOpts = Options.instance(context); // Make sure no obsolete source/target messages are reported - compOpts.put("-Xlint:-options", "-Xlint:-options"); + com.sun.tools.javac.main.Option.XLINT.process(getOptionHelper(), "-Xlint:-options"); doclet.init(locale, messager); parseArgs(argList, javaNames); @@ -550,6 +552,8 @@ public class Start extends ToolOption.Helper { if (o.hasArg) { oneArg(args, i++); o.process(this, args.get(i)); + } else if (o.hasSuffix) { + o.process(this, arg); } else { setOption(arg); o.process(this); @@ -690,4 +694,19 @@ public class Start extends ToolOption.Helper { } return null; } + + @Override + OptionHelper getOptionHelper() { + return new GrumpyHelper(null) { + @Override + public String get(com.sun.tools.javac.main.Option option) { + return compOpts.get(option); + } + + @Override + public void put(String name, String value) { + compOpts.put(name, value); + } + }; + } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java index 7f8d2f0e828..9eaa29213d6 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java @@ -32,6 +32,7 @@ import java.util.Map; import java.util.StringTokenizer; import com.sun.tools.javac.main.Option; +import com.sun.tools.javac.main.OptionHelper; import com.sun.tools.javac.util.Options; /** @@ -118,14 +119,14 @@ public enum ToolOption { ADDMODS("-addmods", true) { @Override public void process(Helper helper, String arg) { - helper.setCompilerOpt(opt, arg); + Option.ADDMODS.process(helper.getOptionHelper(), opt, arg); } }, LIMITMODS("-limitmods", true) { @Override public void process(Helper helper, String arg) { - helper.setCompilerOpt(opt, arg); + Option.LIMITMODS.process(helper.getOptionHelper(), opt, arg); } }, @@ -133,35 +134,63 @@ public enum ToolOption { @Override public void process(Helper helper, String arg) { helper.encoding = arg; - helper.setCompilerOpt(opt, arg); + helper.setFileManagerOpt(Option.ENCODING, arg); } }, RELEASE("-release", true) { @Override public void process(Helper helper, String arg) { - helper.setCompilerOpt(opt, arg); + Option.RELEASE.process(helper.getOptionHelper(), opt, arg); } }, SOURCE("-source", true) { @Override public void process(Helper helper, String arg) { - helper.setCompilerOpt(opt, arg); + Option.SOURCE.process(helper.getOptionHelper(), opt, arg); } }, XMAXERRS("-Xmaxerrs", true) { @Override public void process(Helper helper, String arg) { - helper.setCompilerOpt(opt, arg); + Option.XMAXERRS.process(helper.getOptionHelper(), opt, arg); } }, XMAXWARNS("-Xmaxwarns", true) { @Override public void process(Helper helper, String arg) { - helper.setCompilerOpt(opt, arg); + Option.XMAXWARNS.process(helper.getOptionHelper(), opt, arg); + } + }, + + XADDREADS("-XaddReads:", false) { + @Override + public void process(Helper helper, String arg) { + Option.XADDREADS.process(helper.getOptionHelper(), arg); + } + }, + + XADDEXPORTS("-XaddExports:", false) { + @Override + public void process(Helper helper, String arg) { + Option.XADDEXPORTS.process(helper.getOptionHelper(), arg); + } + }, + + XMODULE("-Xmodule:", false) { + @Override + public void process(Helper helper, String arg) { + Option.XMODULE.process(helper.getOptionHelper(), arg); + } + }, + + XPATCH("-Xpatch:", false) { + @Override + public void process(Helper helper, String arg) { + Option.XMODULE.process(helper.getOptionHelper(), arg); } }, @@ -299,6 +328,7 @@ public enum ToolOption { public final String opt; public final boolean hasArg; + public final boolean hasSuffix; // ex: foo:bar or -foo=bar ToolOption(String opt) { this(opt, false); @@ -307,6 +337,8 @@ public enum ToolOption { ToolOption(String opt, boolean hasArg) { this.opt = opt; this.hasArg = hasArg; + char lastChar = opt.charAt(opt.length() - 1); + this.hasSuffix = lastChar == ':' || lastChar == '='; } void process(Helper helper, String arg) { } @@ -314,9 +346,16 @@ public enum ToolOption { void process(Helper helper) { } static ToolOption get(String name) { - for (ToolOption o: values()) { - if (name.equals(o.opt)) + String oname = name; + if (name.contains(":")) { + oname = name.substring(0, name.indexOf(':') + 1); + } else if (name.contains("=")) { + oname = name.substring(0, name.indexOf('=') + 1); + } + for (ToolOption o : values()) { + if (oname.equals(o.opt)) { return o; + } } return null; } @@ -366,6 +405,7 @@ public enum ToolOption { abstract void Xusage(); abstract void usageError(String msg, Object... args); + abstract OptionHelper getOptionHelper(); void addToList(List list, String str){ StringTokenizer st = new StringTokenizer(str, ":"); @@ -388,13 +428,6 @@ public enum ToolOption { } } - void setCompilerOpt(String opt, String arg) { - if (compOpts.get(opt) != null) { - usageError("main.option.already.seen", opt); - } - compOpts.put(opt, arg); - } - void setFileManagerOpt(Option opt, String arg) { fileManagerOpts.put(opt, arg); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties index 1bebe48ddae..f9cab63f716 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties @@ -37,6 +37,13 @@ main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\ \ -help Display command line options and exit\n\ \ -doclet Generate output via alternate doclet\n\ \ -docletpath Specify where to find doclet class files\n\ +\ -modulesourcepath Specify where to find input source files for multiple modules\n\ +\ -upgrademodulepath Override location of upgradeable modules\n\ +\ -modulepath Specify where to find application modules\n\ +\ -mp Specify where to find application modules\n\ +\ -addmods (,)* Root modules to resolve in addition to the initial modules,\n\ +\ or all modules on the module path if is ALL-MODULE-PATH.\n\ +\ -limitmods (,)* Limit the universe of observable modules\n\ \ -sourcepath Specify where to find source files\n\ \ -classpath Specify where to find user class files\n\ \ -cp Specify where to find user class files\n\ @@ -56,14 +63,23 @@ main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\ main.Xusage=\ \ -Xmaxerrs Set the maximum number of errors to print\n\ -\ -Xmaxwarns Set the maximum number of warnings to print\n +\ -Xmaxwarns Set the maximum number of warnings to print\n\ +\ -XaddExports:/=(,)*\n\ +\ Specify a package to be considered as exported from its \n\ +\ defining module to additional modules, or to all unnamed \n\ +\ modules if is ALL-UNNAMED.\n\ +\ -XaddReads:=(,)*\n\ +\ Specify additional modules to be considered as required by a\n\ +\ given module. may be ALL-UNNAMED to require\n\ +\ the unnamed module.\n\ +\ -Xmodule: Specify a module to which the classes being compiled belong.\n\ +\ -Xpatch: Specify location of module class files to patch\n main.Xusage.foot=\ These options are non-standard and subject to change without notice. main.doclet.usage.header=Provided by the {0} doclet: -main.option.already.seen=The {0} option may be specified no more than once. main.requires_argument=option {0} requires an argument. main.invalid_flag=invalid flag: {0} main.No_packages_or_classes_specified=No packages or classes specified.