< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java

Print this page

        

*** 26,79 **** package jdk.javadoc.internal.tool; import java.io.File; import java.io.IOException; import java.io.PrintWriter; - import java.nio.file.Path; import java.text.BreakIterator; import java.text.Collator; import java.util.ArrayList; import java.util.Arrays; - import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.IllformedLocaleException; import java.util.List; import java.util.Locale; import java.util.MissingResourceException; import java.util.Objects; import java.util.ResourceBundle; import java.util.Set; import java.util.stream.Collectors; - import java.util.stream.Stream; import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; - import javax.tools.StandardLocation; 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.jvm.Target; import com.sun.tools.javac.main.Arguments; 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; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Log; - import com.sun.tools.javac.util.Log.WriterKind; - import com.sun.tools.javac.util.Options; import com.sun.tools.javac.util.StringUtils; import jdk.javadoc.doclet.Doclet; import jdk.javadoc.doclet.Doclet.Option; import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.internal.tool.Main.Result; import static javax.tools.DocumentationTool.Location.*; import static com.sun.tools.javac.main.Option.*; import static jdk.javadoc.internal.tool.Main.Result.*; --- 26,71 ---- package jdk.javadoc.internal.tool; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.text.BreakIterator; import java.text.Collator; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.IllformedLocaleException; import java.util.List; import java.util.Locale; import java.util.MissingResourceException; import java.util.Objects; import java.util.ResourceBundle; import java.util.Set; import java.util.stream.Collectors; import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; 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.jvm.Target; import com.sun.tools.javac.main.Arguments; import com.sun.tools.javac.main.CommandLine; import com.sun.tools.javac.util.ClientCodeException; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Log; import com.sun.tools.javac.util.StringUtils; import jdk.javadoc.doclet.Doclet; import jdk.javadoc.doclet.Doclet.Option; import jdk.javadoc.doclet.DocletEnvironment; + import jdk.javadoc.doclet.StandardDoclet; import jdk.javadoc.internal.tool.Main.Result; + import jdk.javadoc.internal.tool.ToolOptions.ToolOption; import static javax.tools.DocumentationTool.Location.*; import static com.sun.tools.javac.main.Option.*; import static jdk.javadoc.internal.tool.Main.Result.*;
*** 85,98 **** * <p><b>This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. * This code and its internal interfaces are subject to change or * deletion without notice.</b> */ ! public class Start extends ToolOption.Helper { - private static final Class<?> StdDoclet = - jdk.javadoc.doclet.StandardDoclet.class; /** Context for this invocation. */ private final Context context; private static final String ProgramName = "javadoc"; --- 77,88 ---- * <p><b>This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. * This code and its internal interfaces are subject to change or * deletion without notice.</b> */ ! public class Start { /** Context for this invocation. */ private final Context context; private static final String ProgramName = "javadoc";
*** 116,125 **** --- 106,117 ---- */ private boolean apiMode; private JavaFileManager fileManager; + private final ToolOptions options; + Start() { this(null, null, null, null, null, null); } Start(PrintWriter outWriter, PrintWriter errWriter) {
*** 136,196 **** : new Messager(this.context, pname, outWriter, errWriter); this.docletName = docletName; this.classLoader = classLoader; this.docletClass = null; this.locale = Locale.getDefault(); } public Start(Context context) { this.docletClass = null; this.context = Objects.requireNonNull(context); this.apiMode = true; this.docletName = null; this.classLoader = null; this.locale = Locale.getDefault(); - } - void initMessager() { - if (!apiMode) - return; - if (messager == null) { Log log = context.get(Log.logKey); if (log instanceof Messager) { messager = (Messager) log; } else { PrintWriter out = context.get(Log.errKey); messager = (out == null) ? new Messager(context, ProgramName) : new Messager(context, ProgramName, out, out); } ! } } ! /** ! * Usage ! */ @Override ! void usage() { ! usage("main.usage", OptionKind.STANDARD, "main.usage.foot"); } @Override ! void Xusage() { ! usage("main.Xusage", OptionKind.EXTENDED, "main.Xusage.foot"); } @Override ! void version() { ! messager.notice("javadoc.version", messager.programName, version("release")); } @Override ! void fullVersion() { ! messager.notice("javadoc.fullversion", messager.programName, version("full")); } ! private void usage(String headerKey, OptionKind kind, String footerKey) { messager.notice(headerKey); showToolOptions(kind); // let doclet print usage information if (docletClass != null) { --- 128,192 ---- : new Messager(this.context, pname, outWriter, errWriter); this.docletName = docletName; this.classLoader = classLoader; this.docletClass = null; this.locale = Locale.getDefault(); + + options = getToolOptions(); } public Start(Context context) { this.docletClass = null; this.context = Objects.requireNonNull(context); this.apiMode = true; this.docletName = null; this.classLoader = null; this.locale = Locale.getDefault(); Log log = context.get(Log.logKey); if (log instanceof Messager) { messager = (Messager) log; } else { PrintWriter out = context.get(Log.errKey); messager = (out == null) ? new Messager(context, ProgramName) : new Messager(context, ProgramName, out, out); } ! ! options = getToolOptions(); } ! private ToolOptions getToolOptions() { ! ToolOptions.ShowHelper helper = new ToolOptions.ShowHelper() { @Override ! public void usage() { ! showUsage("main.usage", OptionKind.STANDARD, "main.usage.foot"); } @Override ! public void Xusage() { ! showUsage("main.Xusage", OptionKind.EXTENDED, "main.Xusage.foot"); } @Override ! public void version() { ! showVersion("javadoc.version", "release"); } @Override ! public void fullVersion() { ! showVersion("javadoc.fullversion", "full"); ! } ! }; ! return new ToolOptions(context, messager, helper); ! } ! ! private void showUsage() { ! showUsage("main.usage", OptionKind.STANDARD, "main.usage.foot"); } ! private void showUsage(String headerKey, OptionKind kind, String footerKey) { messager.notice(headerKey); showToolOptions(kind); // let doclet print usage information if (docletClass != null) {
*** 205,215 **** } private static final String versionRBName = "jdk.javadoc.internal.tool.resources.version"; private static ResourceBundle versionRB; ! private static String version(String key) { if (versionRB == null) { try { versionRB = ResourceBundle.getBundle(versionRBName); } catch (MissingResourceException e) { return Log.getLocalizedString("version.not.available"); --- 201,215 ---- } private static final String versionRBName = "jdk.javadoc.internal.tool.resources.version"; private static ResourceBundle versionRB; ! private void showVersion(String labelKey, String versionKey) { ! messager.notice(labelKey, messager.programName, getVersion(versionKey)); ! } ! ! private static String getVersion(String key) { if (versionRB == null) { try { versionRB = ResourceBundle.getBundle(versionRBName); } catch (MissingResourceException e) { return Log.getLocalizedString("version.not.available");
*** 220,260 **** } catch (MissingResourceException e) { return Log.getLocalizedString("version.not.available"); } } ! void showToolOptions(OptionKind kind) { Comparator<ToolOption> comp = new Comparator<ToolOption>() { final Collator collator = Collator.getInstance(Locale.US); { collator.setStrength(Collator.PRIMARY); } @Override public int compare(ToolOption o1, ToolOption o2) { return collator.compare(o1.primaryName, o2.primaryName); } }; ! Stream.of(ToolOption.values()) .filter(opt -> opt.kind == kind) .sorted(comp) .forEach(this::showToolOption); } ! void showToolOption(ToolOption option) { List<String> names = option.getNames(); String parameters; ! if (option.hasArg || option.primaryName.endsWith(":")) { ! String sep = (option == ToolOption.J) || option.primaryName.endsWith(":") ? "" : " "; parameters = sep + option.getParameters(messager); } else { parameters = ""; } String description = option.getDescription(messager); ! showUsage(names, parameters, description); } ! void showDocletOptions(Option.Kind kind) { Comparator<Doclet.Option> comp = new Comparator<Doclet.Option>() { final Collator collator = Collator.getInstance(Locale.US); { collator.setStrength(Collator.PRIMARY); } @Override --- 220,261 ---- } catch (MissingResourceException e) { return Log.getLocalizedString("version.not.available"); } } ! private void showToolOptions(OptionKind kind) { Comparator<ToolOption> comp = new Comparator<ToolOption>() { final Collator collator = Collator.getInstance(Locale.US); { collator.setStrength(Collator.PRIMARY); } @Override public int compare(ToolOption o1, ToolOption o2) { return collator.compare(o1.primaryName, o2.primaryName); } }; ! options.getSupportedOptions().stream() .filter(opt -> opt.kind == kind) .sorted(comp) .forEach(this::showToolOption); } ! private void showToolOption(ToolOption option) { List<String> names = option.getNames(); + String primaryName = option.primaryName; String parameters; ! if (option.hasArg || primaryName.endsWith(":")) { ! String sep = primaryName.equals(ToolOptions.J) || primaryName.endsWith(":") ? "" : " "; parameters = sep + option.getParameters(messager); } else { parameters = ""; } String description = option.getDescription(messager); ! showOption(names, parameters, description); } ! private void showDocletOptions(Option.Kind kind) { Comparator<Doclet.Option> comp = new Comparator<Doclet.Option>() { final Collator collator = Collator.getInstance(Locale.US); { collator.setStrength(Collator.PRIMARY); } @Override
*** 267,288 **** .filter(opt -> opt.getKind() == kind) .sorted(comp) .forEach(this::showDocletOption); } ! void showDocletOption(Doclet.Option option) { List<String> names = option.getNames(); String parameters; ! String optname = names.get(0); ! if (option.getArgumentCount() > 0 || optname.endsWith(":")) { ! String sep = optname.endsWith(":") ? "" : " "; parameters = sep + option.getParameters(); } else { parameters = ""; } String description = option.getDescription(); ! showUsage(names, parameters, description); } // The following constants are intended to format the output to // be similar to that of the java launcher: i.e. "java -help". --- 268,289 ---- .filter(opt -> opt.getKind() == kind) .sorted(comp) .forEach(this::showDocletOption); } ! private void showDocletOption(Doclet.Option option) { List<String> names = option.getNames(); String parameters; ! String primaryName = names.get(0); ! if (option.getArgumentCount() > 0 || primaryName.endsWith(":")) { ! String sep = primaryName.endsWith(":") ? "" : " "; parameters = sep + option.getParameters(); } else { parameters = ""; } String description = option.getDescription(); ! showOption(names, parameters, description); } // The following constants are intended to format the output to // be similar to that of the java launcher: i.e. "java -help".
*** 295,305 **** /** The nominal maximum line length, when seeing if text will fit on a line. */ private static final int DEFAULT_MAX_LINE_LENGTH = 80; /** The format for a single-line help entry. */ private static final String COMPACT_FORMAT = SMALL_INDENT + "%-" + DEFAULT_SYNOPSIS_WIDTH + "s %s"; ! void showUsage(List<String> names, String parameters, String description) { String synopses = names.stream() .map(s -> s + parameters) .collect(Collectors.joining(", ")); // If option synopses and description fit on a single line of reasonable length, // display using COMPACT_FORMAT --- 296,306 ---- /** The nominal maximum line length, when seeing if text will fit on a line. */ private static final int DEFAULT_MAX_LINE_LENGTH = 80; /** The format for a single-line help entry. */ private static final String COMPACT_FORMAT = SMALL_INDENT + "%-" + DEFAULT_SYNOPSIS_WIDTH + "s %s"; ! void showOption(List<String> names, String parameters, String description) { String synopses = names.stream() .map(s -> s + parameters) .collect(Collectors.joining(", ")); // If option synopses and description fit on a single line of reasonable length, // display using COMPACT_FORMAT
*** 436,446 **** try { fileManager.close(); } catch (IOException ignore) {} } boolean haveErrorWarnings = messager.hasErrors() ! || (rejectWarnings && messager.hasWarnings()); if (!result.isOK() && !haveErrorWarnings) { // the doclet failed, but nothing reported, flag it!. error("main.unknown.error"); } if (haveErrorWarnings && result.isOK()) { --- 437,447 ---- try { fileManager.close(); } catch (IOException ignore) {} } boolean haveErrorWarnings = messager.hasErrors() ! || (this.options.rejectWarnings() && messager.hasWarnings()); if (!result.isOK() && !haveErrorWarnings) { // the doclet failed, but nothing reported, flag it!. error("main.unknown.error"); } if (haveErrorWarnings && result.isOK()) {
*** 460,470 **** private void dumpStack(Throwable t) { dumpStack(false, t); } private void dumpStack(boolean enabled, Throwable t) { ! if (t != null && (enabled || dumpOnError)) { t.printStackTrace(System.err); } } /** --- 461,471 ---- private void dumpStack(Throwable t) { dumpStack(false, t); } private void dumpStack(boolean enabled, Throwable t) { ! if (t != null && (enabled || options.dumpOnError())) { t.printStackTrace(System.err); } } /**
*** 475,489 **** throws ToolException, OptionException, com.sun.tools.javac.main.Option.InvalidValueException { long tm = System.currentTimeMillis(); List<String> javaNames = new ArrayList<>(); - compOpts = Options.instance(context); - // Make sure no obsolete source/target messages are reported try { ! com.sun.tools.javac.main.Option.XLINT_CUSTOM.process(getOptionHelper(), "-Xlint:-options"); } catch (com.sun.tools.javac.main.Option.InvalidValueException ignore) { } Arguments arguments = Arguments.instance(context); arguments.init(ProgramName); --- 476,488 ---- throws ToolException, OptionException, com.sun.tools.javac.main.Option.InvalidValueException { long tm = System.currentTimeMillis(); List<String> javaNames = new ArrayList<>(); // Make sure no obsolete source/target messages are reported try { ! options.processCompilerOption(com.sun.tools.javac.main.Option.XLINT_CUSTOM, "-Xlint:-options"); } catch (com.sun.tools.javac.main.Option.InvalidValueException ignore) { } Arguments arguments = Arguments.instance(context); arguments.init(ProgramName);
*** 509,562 **** messager.nerrors++; return CMDERR; } if (fileManager instanceof BaseFileManager) { ! ((BaseFileManager) fileManager).handleOptions(fileManagerOpts); } if (fileManager.isSupportedOption(MULTIRELEASE.primaryName) == 1) { Target target = Target.instance(context); List<String> list = List.of(target.multiReleaseValue()); fileManager.handleOption(MULTIRELEASE.primaryName, list.iterator()); } ! compOpts.notifyListeners(); ! List<String> modules = (List<String>) jdtoolOpts.computeIfAbsent(ToolOption.MODULE, ! s -> Collections.EMPTY_LIST); ! ! if (modules.isEmpty()) { ! List<String> subpkgs = (List<String>) jdtoolOpts.computeIfAbsent(ToolOption.SUBPACKAGES, ! s -> Collections.EMPTY_LIST); ! if (subpkgs.isEmpty()) { if (javaNames.isEmpty() && isEmpty(fileObjects)) { String text = messager.getText("main.No_modules_packages_or_classes_specified"); throw new ToolException(CMDERR, text); } } } JavadocTool comp = JavadocTool.make0(context); if (comp == null) return ABNORMAL; ! DocletEnvironment docEnv = comp.getEnvironment(jdtoolOpts, ! javaNames, ! fileObjects); // release resources comp = null; ! if (breakiterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) { JavacTrees trees = JavacTrees.instance(context); trees.setBreakIterator(BreakIterator.getSentenceInstance(locale)); } // pass off control to the doclet Result returnStatus = docEnv != null && doclet.run(docEnv) ? OK : ERROR; // We're done. ! if (compOpts.get("-verbose") != null) { tm = System.currentTimeMillis() - tm; messager.notice("main.done_in", Long.toString(tm)); } return returnStatus; --- 508,555 ---- messager.nerrors++; return CMDERR; } if (fileManager instanceof BaseFileManager) { ! ((BaseFileManager) fileManager).handleOptions(options.fileManagerOptions()); } if (fileManager.isSupportedOption(MULTIRELEASE.primaryName) == 1) { Target target = Target.instance(context); List<String> list = List.of(target.multiReleaseValue()); fileManager.handleOption(MULTIRELEASE.primaryName, list.iterator()); } ! options.compilerOptions().notifyListeners(); ! ! if (options.modules().isEmpty()) { ! if (options.subpackages().isEmpty()) { if (javaNames.isEmpty() && isEmpty(fileObjects)) { String text = messager.getText("main.No_modules_packages_or_classes_specified"); throw new ToolException(CMDERR, text); } } } JavadocTool comp = JavadocTool.make0(context); if (comp == null) return ABNORMAL; ! DocletEnvironment docEnv = comp.getEnvironment(options, javaNames, fileObjects); // release resources comp = null; ! if (options.breakIterator() || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) { JavacTrees trees = JavacTrees.instance(context); trees.setBreakIterator(BreakIterator.getSentenceInstance(locale)); } // pass off control to the doclet Result returnStatus = docEnv != null && doclet.run(docEnv) ? OK : ERROR; // We're done. ! if (options.verbose()) { tm = System.currentTimeMillis() - tm; messager.notice("main.done_in", Long.toString(tm)); } return returnStatus;
*** 576,587 **** int sep = arg.indexOf(':'); String targ = arg.substring(0, sep + 1); return matches(option.getNames(), targ); } ! Set<? extends Doclet.Option> docletOptions = null; ! int handleDocletOptions(int idx, List<String> args, boolean isToolOption) throws OptionException { if (docletOptions == null) { docletOptions = doclet.getSupportedOptions(); } String arg = args.get(idx); --- 569,580 ---- int sep = arg.indexOf(':'); String targ = arg.substring(0, sep + 1); return matches(option.getNames(), targ); } ! private Set<? extends Doclet.Option> docletOptions = null; ! int handleDocletOption(int idx, List<String> args, boolean isToolOption) throws OptionException { if (docletOptions == null) { docletOptions = doclet.getSupportedOptions(); } String arg = args.get(idx);
*** 599,637 **** if (matches(opt, argBase)) { if (argVal != null) { switch (opt.getArgumentCount()) { case 0: text = messager.getText("main.unnecessary_arg_provided", argBase); ! throw new OptionException(ERROR, this::usage, text); case 1: opt.process(arg, Arrays.asList(argVal)); break; default: text = messager.getText("main.only_one_argument_with_equals", argBase); ! throw new OptionException(ERROR, this::usage, text); } } else { if (args.size() - idx -1 < opt.getArgumentCount()) { text = messager.getText("main.requires_argument", arg); ! throw new OptionException(ERROR, this::usage, text); } opt.process(arg, args.subList(idx + 1, args.size())); idx += opt.getArgumentCount(); } return idx; } } // check if arg is accepted by the tool before emitting error if (!isToolOption) { text = messager.getText("main.invalid_flag", arg); ! throw new OptionException(ERROR, this::usage, text); } return idx; } ! private Doclet preprocess(JavaFileManager jfm, ! List<String> argv) throws ToolException, OptionException { // doclet specifying arguments String userDocletPath = null; String userDocletName = null; // taglet specifying arguments, since tagletpath is a doclet --- 592,630 ---- if (matches(opt, argBase)) { if (argVal != null) { switch (opt.getArgumentCount()) { case 0: text = messager.getText("main.unnecessary_arg_provided", argBase); ! throw new OptionException(ERROR, this::showUsage, text); case 1: opt.process(arg, Arrays.asList(argVal)); break; default: text = messager.getText("main.only_one_argument_with_equals", argBase); ! throw new OptionException(ERROR, this::showUsage, text); } } else { if (args.size() - idx -1 < opt.getArgumentCount()) { text = messager.getText("main.requires_argument", arg); ! throw new OptionException(ERROR, this::showUsage, text); } opt.process(arg, args.subList(idx + 1, args.size())); idx += opt.getArgumentCount(); } return idx; } } // check if arg is accepted by the tool before emitting error if (!isToolOption) { text = messager.getText("main.invalid_flag", arg); ! throw new OptionException(ERROR, this::showUsage, text); } return idx; } ! private Doclet preprocess(JavaFileManager jfm, List<String> argv) ! throws ToolException, OptionException { // doclet specifying arguments String userDocletPath = null; String userDocletName = null; // taglet specifying arguments, since tagletpath is a doclet
*** 640,656 **** List<String> userTagletNames = new ArrayList<>(); // Step 1: loop through the args, set locale early on, if found. for (int i = 0 ; i < argv.size() ; i++) { String arg = argv.get(i); ! if (arg.equals(ToolOption.DUMPONERROR.primaryName)) { ! dumpOnError = true; ! } else if (arg.equals(ToolOption.LOCALE.primaryName)) { checkOneArg(argv, i++); String lname = argv.get(i); locale = getLocale(lname); ! } else if (arg.equals(ToolOption.DOCLET.primaryName)) { checkOneArg(argv, i++); if (userDocletName != null) { if (apiMode) { throw new IllegalArgumentException("More than one doclet specified (" + userDocletName + " and " + argv.get(i) + ")."); --- 633,649 ---- List<String> userTagletNames = new ArrayList<>(); // Step 1: loop through the args, set locale early on, if found. for (int i = 0 ; i < argv.size() ; i++) { String arg = argv.get(i); ! if (arg.equals(ToolOptions.DUMP_ON_ERROR)) { ! options.setDumpOnError(true); ! } else if (arg.equals(ToolOptions.LOCALE)) { checkOneArg(argv, i++); String lname = argv.get(i); locale = getLocale(lname); ! } else if (arg.equals(ToolOptions.DOCLET)) { checkOneArg(argv, i++); if (userDocletName != null) { if (apiMode) { throw new IllegalArgumentException("More than one doclet specified (" + userDocletName + " and " + argv.get(i) + ").");
*** 667,677 **** String text = messager.getText("main.more_than_one_doclet_specified_0_and_1", docletName, argv.get(i)); throw new ToolException(CMDERR, text); } userDocletName = argv.get(i); ! } else if (arg.equals(ToolOption.DOCLETPATH.primaryName)) { checkOneArg(argv, i++); if (userDocletPath == null) { userDocletPath = argv.get(i); } else { userDocletPath += File.pathSeparator + argv.get(i); --- 660,670 ---- String text = messager.getText("main.more_than_one_doclet_specified_0_and_1", docletName, argv.get(i)); throw new ToolException(CMDERR, text); } userDocletName = argv.get(i); ! } else if (arg.equals(ToolOptions.DOCLET_PATH)) { checkOneArg(argv, i++); if (userDocletPath == null) { userDocletPath = argv.get(i); } else { userDocletPath += File.pathSeparator + argv.get(i);
*** 683,696 **** userTagletPath.add(new File(pathname)); } } } - // Step 3: doclet name specified ? if so find a ClassLoader, // and load it. ! if(docletClass == null) { if (userDocletName != null) { ClassLoader cl = classLoader; if (cl == null) { if (!fileManager.hasLocation(DOCLET_PATH)) { List<File> paths = new ArrayList<>(); --- 676,688 ---- userTagletPath.add(new File(pathname)); } } } // Step 3: doclet name specified ? if so find a ClassLoader, // and load it. ! if (docletClass == null) { if (userDocletName != null) { ClassLoader cl = classLoader; if (cl == null) { if (!fileManager.hasLocation(DOCLET_PATH)) { List<File> paths = new ArrayList<>();
*** 726,742 **** } docletClass = loadDocletClass(userDocletName, cl); } else if (docletName != null){ docletClass = loadDocletClass(docletName, getClass().getClassLoader()); } else { ! docletClass = StdDoclet; } } if (jdk.javadoc.doclet.Doclet.class.isAssignableFrom(docletClass)) { - // no need to dispatch to old, safe to init now - initMessager(); messager.setLocale(locale); try { Object o = docletClass.getConstructor().newInstance(); doclet = (Doclet) o; } catch (ReflectiveOperationException exc) { --- 718,732 ---- } docletClass = loadDocletClass(userDocletName, cl); } else if (docletName != null){ docletClass = loadDocletClass(docletName, getClass().getClassLoader()); } else { ! docletClass = StandardDoclet.class; } } if (jdk.javadoc.doclet.Doclet.class.isAssignableFrom(docletClass)) { messager.setLocale(locale); try { Object o = docletClass.getConstructor().newInstance(); doclet = (Doclet) o; } catch (ReflectiveOperationException exc) {
*** 767,802 **** private void parseArgs(List<String> args, List<String> javaNames) throws ToolException, OptionException, com.sun.tools.javac.main.Option.InvalidValueException { for (int i = 0 ; i < args.size() ; i++) { String arg = args.get(i); ! ToolOption o = ToolOption.get(arg); if (o != null) { // handle a doclet argument that may be needed however // don't increment the index, and allow the tool to consume args ! handleDocletOptions(i, args, true); if (o.hasArg) { if (arg.startsWith("--") && arg.contains("=")) { ! o.process(this, arg.substring(arg.indexOf('=') + 1)); } else { checkOneArg(args, i++); ! o.process(this, args.get(i)); } } else if (o.hasSuffix) { ! o.process(this, arg); } else { ! o.process(this); } } else if (arg.startsWith("-XD")) { // hidden javac options String s = arg.substring("-XD".length()); int eq = s.indexOf('='); String key = (eq < 0) ? s : s.substring(0, eq); String value = (eq < 0) ? s : s.substring(eq+1); ! compOpts.put(key, value); } else if (arg.startsWith("-")) { ! i = handleDocletOptions(i, args, false); } else { javaNames.add(arg); } } } --- 757,792 ---- private void parseArgs(List<String> args, List<String> javaNames) throws ToolException, OptionException, com.sun.tools.javac.main.Option.InvalidValueException { for (int i = 0 ; i < args.size() ; i++) { String arg = args.get(i); ! ToolOption o = options.getOption(arg); if (o != null) { // handle a doclet argument that may be needed however // don't increment the index, and allow the tool to consume args ! handleDocletOption(i, args, true); if (o.hasArg) { if (arg.startsWith("--") && arg.contains("=")) { ! o.process(arg.substring(arg.indexOf('=') + 1)); } else { checkOneArg(args, i++); ! o.process(args.get(i)); } } else if (o.hasSuffix) { ! o.process(arg); } else { ! o.process(); } } else if (arg.startsWith("-XD")) { // hidden javac options String s = arg.substring("-XD".length()); int eq = s.indexOf('='); String key = (eq < 0) ? s : s.substring(0, eq); String value = (eq < 0) ? s : s.substring(eq+1); ! options.compilerOptions().put(key, value); } else if (arg.startsWith("-")) { ! i = handleDocletOption(i, args, false); } else { javaNames.add(arg); } } }
*** 810,820 **** * Error and exit if one argument is not provided. */ private void checkOneArg(List<String> args, int index) throws OptionException { if ((index + 1) >= args.size() || args.get(index + 1).startsWith("-d")) { String text = messager.getText("main.requires_argument", args.get(index)); ! throw new OptionException(CMDERR, this::usage, text); } } void error(String key, Object... args) { messager.printErrorUsingKey(key, args); --- 800,810 ---- * Error and exit if one argument is not provided. */ private void checkOneArg(List<String> args, int index) throws OptionException { if ((index + 1) >= args.size() || args.get(index + 1).startsWith("-d")) { String text = messager.getText("main.requires_argument", args.get(index)); ! throw new OptionException(CMDERR, this::showUsage, text); } } void error(String key, Object... args) { messager.printErrorUsingKey(key, args);
*** 857,892 **** } } return null; } - @Override - OptionHelper getOptionHelper() { - return new GrumpyHelper(messager) { - @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); - } - - @Override - public void remove(String name) { - compOpts.remove(name); - } - @Override - public boolean handleFileManagerOption(com.sun.tools.javac.main.Option option, String value) { - fileManagerOpts.put(option, value); - return true; - } - }; - } - - @Override - String getLocalizedMessage(String msg, Object... args) { - return messager.getText(msg, args); - } } --- 847,853 ----
< prev index next >