src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java

changeset 1166
77b2c066084c
parent 1155
3c71fcc22b99
parent 1165
1ae5988e201b
child 1167
ffd294128a48
child 1170
67512b631961
     1.1 --- a/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java	Thu Dec 22 19:00:58 2011 -0800
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,651 +0,0 @@
     1.4 -/*
     1.5 - * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 - *
     1.8 - * This code is free software; you can redistribute it and/or modify it
     1.9 - * under the terms of the GNU General Public License version 2 only, as
    1.10 - * published by the Free Software Foundation.  Oracle designates this
    1.11 - * particular file as subject to the "Classpath" exception as provided
    1.12 - * by Oracle in the LICENSE file that accompanied this code.
    1.13 - *
    1.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 - * version 2 for more details (a copy is included in the LICENSE file that
    1.18 - * accompanied this code).
    1.19 - *
    1.20 - * You should have received a copy of the GNU General Public License version
    1.21 - * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 - *
    1.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 - * or visit www.oracle.com if you need additional information or have any
    1.26 - * questions.
    1.27 - */
    1.28 -
    1.29 -package com.sun.tools.javac.main;
    1.30 -
    1.31 -import java.io.File;
    1.32 -import java.io.FileWriter;
    1.33 -import java.io.PrintWriter;
    1.34 -import java.util.EnumSet;
    1.35 -import java.util.LinkedHashMap;
    1.36 -import java.util.Map;
    1.37 -import java.util.Set;
    1.38 -import javax.lang.model.SourceVersion;
    1.39 -
    1.40 -import com.sun.tools.javac.code.Lint;
    1.41 -import com.sun.tools.javac.code.Source;
    1.42 -import com.sun.tools.javac.code.Type;
    1.43 -import com.sun.tools.javac.jvm.Target;
    1.44 -import com.sun.tools.javac.main.JavacOption.HiddenOption;
    1.45 -import com.sun.tools.javac.main.JavacOption.Option;
    1.46 -import com.sun.tools.javac.main.JavacOption.XOption;
    1.47 -import com.sun.tools.javac.processing.JavacProcessingEnvironment;
    1.48 -import com.sun.tools.javac.util.ListBuffer;
    1.49 -import com.sun.tools.javac.util.Log;
    1.50 -import com.sun.tools.javac.util.Log.PrefixKind;
    1.51 -import com.sun.tools.javac.util.Options;
    1.52 -
    1.53 -import static com.sun.tools.javac.main.OptionName.*;
    1.54 -
    1.55 -/**
    1.56 - * TODO: describe com.sun.tools.javac.main.RecognizedOptions
    1.57 - *
    1.58 - * <p><b>This is NOT part of any supported API.
    1.59 - * If you write code that depends on this, you do so at your own
    1.60 - * risk.  This code and its internal interfaces are subject to change
    1.61 - * or deletion without notice.</b></p>
    1.62 - */
    1.63 -public class RecognizedOptions {
    1.64 -
    1.65 -    private RecognizedOptions() {}
    1.66 -
    1.67 -    public interface OptionHelper {
    1.68 -
    1.69 -        void setOut(PrintWriter out);
    1.70 -
    1.71 -        void error(String key, Object... args);
    1.72 -
    1.73 -        void printVersion();
    1.74 -
    1.75 -        void printFullVersion();
    1.76 -
    1.77 -        void printHelp();
    1.78 -
    1.79 -        void printXhelp();
    1.80 -
    1.81 -        void addFile(File f);
    1.82 -
    1.83 -        void addClassName(String s);
    1.84 -
    1.85 -    }
    1.86 -
    1.87 -    public static class GrumpyHelper implements OptionHelper {
    1.88 -        private Log log;
    1.89 -
    1.90 -        public GrumpyHelper(Log log) {
    1.91 -            this.log = log;
    1.92 -        }
    1.93 -
    1.94 -        public void setOut(PrintWriter out) {
    1.95 -            throw new IllegalArgumentException();
    1.96 -        }
    1.97 -
    1.98 -        public void error(String key, Object... args) {
    1.99 -            throw new IllegalArgumentException(log.localize(PrefixKind.JAVAC, key, args));
   1.100 -        }
   1.101 -
   1.102 -        public void printVersion() {
   1.103 -            throw new IllegalArgumentException();
   1.104 -        }
   1.105 -
   1.106 -        public void printFullVersion() {
   1.107 -            throw new IllegalArgumentException();
   1.108 -        }
   1.109 -
   1.110 -        public void printHelp() {
   1.111 -            throw new IllegalArgumentException();
   1.112 -        }
   1.113 -
   1.114 -        public void printXhelp() {
   1.115 -            throw new IllegalArgumentException();
   1.116 -        }
   1.117 -
   1.118 -        public void addFile(File f) {
   1.119 -            throw new IllegalArgumentException(f.getPath());
   1.120 -        }
   1.121 -
   1.122 -        public void addClassName(String s) {
   1.123 -            throw new IllegalArgumentException(s);
   1.124 -        }
   1.125 -
   1.126 -    }
   1.127 -
   1.128 -    static Set<OptionName> javacOptions = EnumSet.of(
   1.129 -        G,
   1.130 -        G_NONE,
   1.131 -        G_CUSTOM,
   1.132 -        XLINT,
   1.133 -        XLINT_CUSTOM,
   1.134 -        NOWARN,
   1.135 -        VERBOSE,
   1.136 -        DEPRECATION,
   1.137 -        CLASSPATH,
   1.138 -        CP,
   1.139 -        SOURCEPATH,
   1.140 -        BOOTCLASSPATH,
   1.141 -        XBOOTCLASSPATH_PREPEND,
   1.142 -        XBOOTCLASSPATH_APPEND,
   1.143 -        XBOOTCLASSPATH,
   1.144 -        EXTDIRS,
   1.145 -        DJAVA_EXT_DIRS,
   1.146 -        ENDORSEDDIRS,
   1.147 -        DJAVA_ENDORSED_DIRS,
   1.148 -        PROC,
   1.149 -        PROCESSOR,
   1.150 -        PROCESSORPATH,
   1.151 -        D,
   1.152 -        S,
   1.153 -        IMPLICIT,
   1.154 -        ENCODING,
   1.155 -        SOURCE,
   1.156 -        TARGET,
   1.157 -        VERSION,
   1.158 -        FULLVERSION,
   1.159 -        DIAGS,
   1.160 -        HELP,
   1.161 -        A,
   1.162 -        X,
   1.163 -        J,
   1.164 -        MOREINFO,
   1.165 -        WERROR,
   1.166 -        // COMPLEXINFERENCE,
   1.167 -        PROMPT,
   1.168 -        DOE,
   1.169 -        PRINTSOURCE,
   1.170 -        WARNUNCHECKED,
   1.171 -        XMAXERRS,
   1.172 -        XMAXWARNS,
   1.173 -        XSTDOUT,
   1.174 -        XPKGINFO,
   1.175 -        XPRINT,
   1.176 -        XPRINTROUNDS,
   1.177 -        XPRINTPROCESSORINFO,
   1.178 -        XPREFER,
   1.179 -        O,
   1.180 -        XJCOV,
   1.181 -        XD,
   1.182 -        AT,
   1.183 -        SOURCEFILE);
   1.184 -
   1.185 -    static Set<OptionName> javacFileManagerOptions = EnumSet.of(
   1.186 -        CLASSPATH,
   1.187 -        CP,
   1.188 -        SOURCEPATH,
   1.189 -        BOOTCLASSPATH,
   1.190 -        XBOOTCLASSPATH_PREPEND,
   1.191 -        XBOOTCLASSPATH_APPEND,
   1.192 -        XBOOTCLASSPATH,
   1.193 -        EXTDIRS,
   1.194 -        DJAVA_EXT_DIRS,
   1.195 -        ENDORSEDDIRS,
   1.196 -        DJAVA_ENDORSED_DIRS,
   1.197 -        PROCESSORPATH,
   1.198 -        D,
   1.199 -        S,
   1.200 -        ENCODING,
   1.201 -        SOURCE);
   1.202 -
   1.203 -    static Set<OptionName> javacToolOptions = EnumSet.of(
   1.204 -        G,
   1.205 -        G_NONE,
   1.206 -        G_CUSTOM,
   1.207 -        XLINT,
   1.208 -        XLINT_CUSTOM,
   1.209 -        NOWARN,
   1.210 -        VERBOSE,
   1.211 -        DEPRECATION,
   1.212 -        PROC,
   1.213 -        PROCESSOR,
   1.214 -        IMPLICIT,
   1.215 -        SOURCE,
   1.216 -        TARGET,
   1.217 -        // VERSION,
   1.218 -        // FULLVERSION,
   1.219 -        // HELP,
   1.220 -        A,
   1.221 -        // X,
   1.222 -        // J,
   1.223 -        MOREINFO,
   1.224 -        WERROR,
   1.225 -        // COMPLEXINFERENCE,
   1.226 -        PROMPT,
   1.227 -        DOE,
   1.228 -        PRINTSOURCE,
   1.229 -        WARNUNCHECKED,
   1.230 -        XMAXERRS,
   1.231 -        XMAXWARNS,
   1.232 -        // XSTDOUT,
   1.233 -        XPKGINFO,
   1.234 -        XPRINT,
   1.235 -        XPRINTROUNDS,
   1.236 -        XPRINTPROCESSORINFO,
   1.237 -        XPREFER,
   1.238 -        O,
   1.239 -        XJCOV,
   1.240 -        XD);
   1.241 -
   1.242 -    static Option[] getJavaCompilerOptions(OptionHelper helper) {
   1.243 -        return getOptions(helper, javacOptions);
   1.244 -    }
   1.245 -
   1.246 -    public static Option[] getJavacFileManagerOptions(OptionHelper helper) {
   1.247 -        return getOptions(helper, javacFileManagerOptions);
   1.248 -    }
   1.249 -
   1.250 -    public static Option[] getJavacToolOptions(OptionHelper helper) {
   1.251 -        return getOptions(helper, javacToolOptions);
   1.252 -    }
   1.253 -
   1.254 -    static Option[] getOptions(OptionHelper helper, Set<OptionName> desired) {
   1.255 -        ListBuffer<Option> options = new ListBuffer<Option>();
   1.256 -        for (Option option : getAll(helper))
   1.257 -            if (desired.contains(option.getName()))
   1.258 -                options.append(option);
   1.259 -        return options.toArray(new Option[options.length()]);
   1.260 -    }
   1.261 -
   1.262 -    /**
   1.263 -     * Get all the recognized options.
   1.264 -     * @param helper an {@code OptionHelper} to help when processing options
   1.265 -     * @return an array of options
   1.266 -     */
   1.267 -    public static Option[] getAll(final OptionHelper helper) {
   1.268 -        return new Option[] {
   1.269 -        new Option(G,                                           "opt.g"),
   1.270 -        new Option(G_NONE,                                      "opt.g.none") {
   1.271 -            @Override
   1.272 -            public boolean process(Options options, String option) {
   1.273 -                options.put("-g:", "none");
   1.274 -                return false;
   1.275 -            }
   1.276 -        },
   1.277 -
   1.278 -        new Option(G_CUSTOM,                                    "opt.g.lines.vars.source",
   1.279 -                Option.ChoiceKind.ANYOF, "lines", "vars", "source"),
   1.280 -
   1.281 -        new XOption(XLINT,                                      "opt.Xlint"),
   1.282 -        new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist",
   1.283 -                Option.ChoiceKind.ANYOF, getXLintChoices()),
   1.284 -
   1.285 -        // -nowarn is retained for command-line backward compatibility
   1.286 -        new Option(NOWARN,                                      "opt.nowarn") {
   1.287 -            @Override
   1.288 -            public boolean process(Options options, String option) {
   1.289 -                options.put("-Xlint:none", option);
   1.290 -                return false;
   1.291 -            }
   1.292 -        },
   1.293 -
   1.294 -        new Option(VERBOSE,                                     "opt.verbose"),
   1.295 -
   1.296 -        // -deprecation is retained for command-line backward compatibility
   1.297 -        new Option(DEPRECATION,                                 "opt.deprecation") {
   1.298 -            @Override
   1.299 -            public boolean process(Options options, String option) {
   1.300 -                options.put("-Xlint:deprecation", option);
   1.301 -                return false;
   1.302 -            }
   1.303 -        },
   1.304 -
   1.305 -        new Option(CLASSPATH,              "opt.arg.path",      "opt.classpath"),
   1.306 -        new Option(CP,                     "opt.arg.path",      "opt.classpath") {
   1.307 -            @Override
   1.308 -            public boolean process(Options options, String option, String arg) {
   1.309 -                return super.process(options, "-classpath", arg);
   1.310 -            }
   1.311 -        },
   1.312 -        new Option(SOURCEPATH,             "opt.arg.path",      "opt.sourcepath"),
   1.313 -        new Option(BOOTCLASSPATH,          "opt.arg.path",      "opt.bootclasspath") {
   1.314 -            @Override
   1.315 -            public boolean process(Options options, String option, String arg) {
   1.316 -                options.remove("-Xbootclasspath/p:");
   1.317 -                options.remove("-Xbootclasspath/a:");
   1.318 -                return super.process(options, option, arg);
   1.319 -            }
   1.320 -        },
   1.321 -        new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
   1.322 -        new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
   1.323 -        new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
   1.324 -            @Override
   1.325 -            public boolean process(Options options, String option, String arg) {
   1.326 -                options.remove("-Xbootclasspath/p:");
   1.327 -                options.remove("-Xbootclasspath/a:");
   1.328 -                return super.process(options, "-bootclasspath", arg);
   1.329 -            }
   1.330 -        },
   1.331 -        new Option(EXTDIRS,                "opt.arg.dirs",      "opt.extdirs"),
   1.332 -        new XOption(DJAVA_EXT_DIRS,        "opt.arg.dirs",      "opt.extdirs") {
   1.333 -            @Override
   1.334 -            public boolean process(Options options, String option, String arg) {
   1.335 -                return super.process(options, "-extdirs", arg);
   1.336 -            }
   1.337 -        },
   1.338 -        new Option(ENDORSEDDIRS,            "opt.arg.dirs",     "opt.endorseddirs"),
   1.339 -        new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs",     "opt.endorseddirs") {
   1.340 -            @Override
   1.341 -            public boolean process(Options options, String option, String arg) {
   1.342 -                return super.process(options, "-endorseddirs", arg);
   1.343 -            }
   1.344 -        },
   1.345 -        new Option(PROC,                                 "opt.proc.none.only",
   1.346 -                Option.ChoiceKind.ONEOF, "none", "only"),
   1.347 -        new Option(PROCESSOR,           "opt.arg.class.list",   "opt.processor"),
   1.348 -        new Option(PROCESSORPATH,       "opt.arg.path",         "opt.processorpath"),
   1.349 -        new Option(D,                   "opt.arg.directory",    "opt.d"),
   1.350 -        new Option(S,                   "opt.arg.directory",    "opt.sourceDest"),
   1.351 -        new Option(IMPLICIT,                                    "opt.implicit",
   1.352 -                Option.ChoiceKind.ONEOF, "none", "class"),
   1.353 -        new Option(ENCODING,            "opt.arg.encoding",     "opt.encoding"),
   1.354 -        new Option(SOURCE,              "opt.arg.release",      "opt.source") {
   1.355 -            @Override
   1.356 -            public boolean process(Options options, String option, String operand) {
   1.357 -                Source source = Source.lookup(operand);
   1.358 -                if (source == null) {
   1.359 -                    helper.error("err.invalid.source", operand);
   1.360 -                    return true;
   1.361 -                }
   1.362 -                return super.process(options, option, operand);
   1.363 -            }
   1.364 -        },
   1.365 -        new Option(TARGET,              "opt.arg.release",      "opt.target") {
   1.366 -            @Override
   1.367 -            public boolean process(Options options, String option, String operand) {
   1.368 -                Target target = Target.lookup(operand);
   1.369 -                if (target == null) {
   1.370 -                    helper.error("err.invalid.target", operand);
   1.371 -                    return true;
   1.372 -                }
   1.373 -                return super.process(options, option, operand);
   1.374 -            }
   1.375 -        },
   1.376 -        new Option(VERSION,                                     "opt.version") {
   1.377 -            @Override
   1.378 -            public boolean process(Options options, String option) {
   1.379 -                helper.printVersion();
   1.380 -                return super.process(options, option);
   1.381 -            }
   1.382 -        },
   1.383 -        new HiddenOption(FULLVERSION) {
   1.384 -            @Override
   1.385 -            public boolean process(Options options, String option) {
   1.386 -                helper.printFullVersion();
   1.387 -                return super.process(options, option);
   1.388 -            }
   1.389 -        },
   1.390 -        new HiddenOption(DIAGS) {
   1.391 -            @Override
   1.392 -            public boolean process(Options options, String option) {
   1.393 -                Option xd = getOptions(helper, EnumSet.of(XD))[0];
   1.394 -                option = option.substring(option.indexOf('=') + 1);
   1.395 -                String diagsOption = option.contains("%") ?
   1.396 -                    "-XDdiagsFormat=" :
   1.397 -                    "-XDdiags=";
   1.398 -                diagsOption += option;
   1.399 -                if (xd.matches(diagsOption))
   1.400 -                    return xd.process(options, diagsOption);
   1.401 -                else
   1.402 -                    return false;
   1.403 -            }
   1.404 -        },
   1.405 -        new Option(HELP,                                        "opt.help") {
   1.406 -            @Override
   1.407 -            public boolean process(Options options, String option) {
   1.408 -                helper.printHelp();
   1.409 -                return super.process(options, option);
   1.410 -            }
   1.411 -        },
   1.412 -        new Option(A,                "opt.arg.key.equals.value","opt.A") {
   1.413 -            @Override
   1.414 -            String helpSynopsis(Log log) {
   1.415 -                hasSuffix = true;
   1.416 -                return super.helpSynopsis(log);
   1.417 -            }
   1.418 -
   1.419 -            @Override
   1.420 -            public boolean matches(String arg) {
   1.421 -                return arg.startsWith("-A");
   1.422 -            }
   1.423 -
   1.424 -            @Override
   1.425 -            public boolean hasArg() {
   1.426 -                return false;
   1.427 -            }
   1.428 -            // Mapping for processor options created in
   1.429 -            // JavacProcessingEnvironment
   1.430 -            @Override
   1.431 -            public boolean process(Options options, String option) {
   1.432 -                int argLength = option.length();
   1.433 -                if (argLength == 2) {
   1.434 -                    helper.error("err.empty.A.argument");
   1.435 -                    return true;
   1.436 -                }
   1.437 -                int sepIndex = option.indexOf('=');
   1.438 -                String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
   1.439 -                if (!JavacProcessingEnvironment.isValidOptionName(key)) {
   1.440 -                    helper.error("err.invalid.A.key", option);
   1.441 -                    return true;
   1.442 -                }
   1.443 -                return process(options, option, option);
   1.444 -            }
   1.445 -        },
   1.446 -        new Option(X,                                           "opt.X") {
   1.447 -            @Override
   1.448 -            public boolean process(Options options, String option) {
   1.449 -                helper.printXhelp();
   1.450 -                return super.process(options, option);
   1.451 -            }
   1.452 -        },
   1.453 -
   1.454 -        // This option exists only for the purpose of documenting itself.
   1.455 -        // It's actually implemented by the launcher.
   1.456 -        new Option(J,                   "opt.arg.flag",         "opt.J") {
   1.457 -            @Override
   1.458 -            String helpSynopsis(Log log) {
   1.459 -                hasSuffix = true;
   1.460 -                return super.helpSynopsis(log);
   1.461 -            }
   1.462 -            @Override
   1.463 -            public boolean process(Options options, String option) {
   1.464 -                throw new AssertionError
   1.465 -                    ("the -J flag should be caught by the launcher.");
   1.466 -            }
   1.467 -        },
   1.468 -
   1.469 -        // stop after parsing and attributing.
   1.470 -        // new HiddenOption("-attrparseonly"),
   1.471 -
   1.472 -        // new Option("-moreinfo",                                      "opt.moreinfo") {
   1.473 -        new HiddenOption(MOREINFO) {
   1.474 -            @Override
   1.475 -            public boolean process(Options options, String option) {
   1.476 -                Type.moreInfo = true;
   1.477 -                return super.process(options, option);
   1.478 -            }
   1.479 -        },
   1.480 -
   1.481 -        // treat warnings as errors
   1.482 -        new Option(WERROR,                                      "opt.Werror"),
   1.483 -
   1.484 -        // use complex inference from context in the position of a method call argument
   1.485 -        new HiddenOption(COMPLEXINFERENCE),
   1.486 -
   1.487 -        // generare source stubs
   1.488 -        // new HiddenOption("-stubs"),
   1.489 -
   1.490 -        // relax some constraints to allow compiling from stubs
   1.491 -        // new HiddenOption("-relax"),
   1.492 -
   1.493 -        // output source after translating away inner classes
   1.494 -        // new Option("-printflat",                             "opt.printflat"),
   1.495 -        // new HiddenOption("-printflat"),
   1.496 -
   1.497 -        // display scope search details
   1.498 -        // new Option("-printsearch",                           "opt.printsearch"),
   1.499 -        // new HiddenOption("-printsearch"),
   1.500 -
   1.501 -        // prompt after each error
   1.502 -        // new Option("-prompt",                                        "opt.prompt"),
   1.503 -        new HiddenOption(PROMPT),
   1.504 -
   1.505 -        // dump stack on error
   1.506 -        new HiddenOption(DOE),
   1.507 -
   1.508 -        // output source after type erasure
   1.509 -        // new Option("-s",                                     "opt.s"),
   1.510 -        new HiddenOption(PRINTSOURCE),
   1.511 -
   1.512 -        // output shrouded class files
   1.513 -        // new Option("-scramble",                              "opt.scramble"),
   1.514 -        // new Option("-scrambleall",                           "opt.scrambleall"),
   1.515 -
   1.516 -        // display warnings for generic unchecked operations
   1.517 -        new HiddenOption(WARNUNCHECKED) {
   1.518 -            @Override
   1.519 -            public boolean process(Options options, String option) {
   1.520 -                options.put("-Xlint:unchecked", option);
   1.521 -                return false;
   1.522 -            }
   1.523 -        },
   1.524 -
   1.525 -        new XOption(XMAXERRS,           "opt.arg.number",       "opt.maxerrs"),
   1.526 -        new XOption(XMAXWARNS,          "opt.arg.number",       "opt.maxwarns"),
   1.527 -        new XOption(XSTDOUT,            "opt.arg.file",         "opt.Xstdout") {
   1.528 -            @Override
   1.529 -            public boolean process(Options options, String option, String arg) {
   1.530 -                try {
   1.531 -                    helper.setOut(new PrintWriter(new FileWriter(arg), true));
   1.532 -                } catch (java.io.IOException e) {
   1.533 -                    helper.error("err.error.writing.file", arg, e);
   1.534 -                    return true;
   1.535 -                }
   1.536 -                return super.process(options, option, arg);
   1.537 -            }
   1.538 -        },
   1.539 -
   1.540 -        new XOption(XPRINT,                                     "opt.print"),
   1.541 -
   1.542 -        new XOption(XPRINTROUNDS,                               "opt.printRounds"),
   1.543 -
   1.544 -        new XOption(XPRINTPROCESSORINFO,                        "opt.printProcessorInfo"),
   1.545 -
   1.546 -        new XOption(XPREFER,                                    "opt.prefer",
   1.547 -                Option.ChoiceKind.ONEOF, "source", "newer"),
   1.548 -
   1.549 -        new XOption(XPKGINFO,                                   "opt.pkginfo",
   1.550 -                Option.ChoiceKind.ONEOF, "always", "legacy", "nonempty"),
   1.551 -
   1.552 -        /* -O is a no-op, accepted for backward compatibility. */
   1.553 -        new HiddenOption(O),
   1.554 -
   1.555 -        /* -Xjcov produces tables to support the code coverage tool jcov. */
   1.556 -        new HiddenOption(XJCOV),
   1.557 -
   1.558 -        /* This is a back door to the compiler's option table.
   1.559 -         * -XDx=y sets the option x to the value y.
   1.560 -         * -XDx sets the option x to the value x.
   1.561 -         */
   1.562 -        new HiddenOption(XD) {
   1.563 -            String s;
   1.564 -            @Override
   1.565 -            public boolean matches(String s) {
   1.566 -                this.s = s;
   1.567 -                return s.startsWith(name.optionName);
   1.568 -            }
   1.569 -            @Override
   1.570 -            public boolean process(Options options, String option) {
   1.571 -                s = s.substring(name.optionName.length());
   1.572 -                int eq = s.indexOf('=');
   1.573 -                String key = (eq < 0) ? s : s.substring(0, eq);
   1.574 -                String value = (eq < 0) ? s : s.substring(eq+1);
   1.575 -                options.put(key, value);
   1.576 -                return false;
   1.577 -            }
   1.578 -        },
   1.579 -
   1.580 -        // This option exists only for the purpose of documenting itself.
   1.581 -        // It's actually implemented by the CommandLine class.
   1.582 -        new Option(AT,                   "opt.arg.file",         "opt.AT") {
   1.583 -            @Override
   1.584 -            String helpSynopsis(Log log) {
   1.585 -                hasSuffix = true;
   1.586 -                return super.helpSynopsis(log);
   1.587 -            }
   1.588 -            @Override
   1.589 -            public boolean process(Options options, String option) {
   1.590 -                throw new AssertionError
   1.591 -                    ("the @ flag should be caught by CommandLine.");
   1.592 -            }
   1.593 -        },
   1.594 -
   1.595 -        /*
   1.596 -         * TODO: With apt, the matches method accepts anything if
   1.597 -         * -XclassAsDecls is used; code elsewhere does the lookup to
   1.598 -         * see if the class name is both legal and found.
   1.599 -         *
   1.600 -         * In apt, the process method adds the candidate class file
   1.601 -         * name to a separate list.
   1.602 -         */
   1.603 -        new HiddenOption(SOURCEFILE) {
   1.604 -            String s;
   1.605 -            @Override
   1.606 -            public boolean matches(String s) {
   1.607 -                this.s = s;
   1.608 -                return s.endsWith(".java")  // Java source file
   1.609 -                    || SourceVersion.isName(s);   // Legal type name
   1.610 -            }
   1.611 -            @Override
   1.612 -            public boolean process(Options options, String option) {
   1.613 -                if (s.endsWith(".java") ) {
   1.614 -                    File f = new File(s);
   1.615 -                    if (!f.exists()) {
   1.616 -                        helper.error("err.file.not.found", f);
   1.617 -                        return true;
   1.618 -                    }
   1.619 -                    if (!f.isFile()) {
   1.620 -                        helper.error("err.file.not.file", f);
   1.621 -                        return true;
   1.622 -                    }
   1.623 -                    helper.addFile(f);
   1.624 -                }
   1.625 -                else
   1.626 -                    helper.addClassName(s);
   1.627 -                return false;
   1.628 -            }
   1.629 -        },
   1.630 -    };
   1.631 -    }
   1.632 -
   1.633 -    public enum PkgInfo {
   1.634 -        ALWAYS, LEGACY, NONEMPTY;
   1.635 -        public static PkgInfo get(Options options) {
   1.636 -            String v = options.get(XPKGINFO);
   1.637 -            return (v == null
   1.638 -                    ? PkgInfo.LEGACY
   1.639 -                    : PkgInfo.valueOf(v.toUpperCase()));
   1.640 -        }
   1.641 -    }
   1.642 -
   1.643 -    private static Map<String,Boolean> getXLintChoices() {
   1.644 -        Map<String,Boolean> choices = new LinkedHashMap<String,Boolean>();
   1.645 -        choices.put("all", false);
   1.646 -        for (Lint.LintCategory c : Lint.LintCategory.values())
   1.647 -            choices.put(c.option, c.hidden);
   1.648 -        for (Lint.LintCategory c : Lint.LintCategory.values())
   1.649 -            choices.put("-" + c.option, c.hidden);
   1.650 -        choices.put("none", false);
   1.651 -        return choices;
   1.652 -    }
   1.653 -
   1.654 -}

mercurial