langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java
author vromero
Mon, 22 Feb 2016 16:17:25 -0800
changeset 36153 ed5063b304be
parent 31506 4e07f827a794
child 36155 1555ce1fcb4f
permissions -rw-r--r--
8149600: javac, remove unused options, step 2 Reviewed-by: jjg, mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
     1
/*
36153
ed5063b304be 8149600: javac, remove unused options, step 2
vromero
parents: 31506
diff changeset
     2
 * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
     4
 *
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    10
 *
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    15
 * accompanied this code).
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    16
 *
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    20
 *
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    23
 * questions.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    24
 */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    25
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    26
package com.sun.tools.javac.main;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    27
14960
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    28
import java.io.File;
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    29
import java.io.FileWriter;
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    30
import java.io.PrintWriter;
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    31
import java.util.Collections;
14960
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    32
import java.util.EnumSet;
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    33
import java.util.LinkedHashMap;
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    34
import java.util.Map;
31506
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
    35
import java.util.ServiceLoader;
14960
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    36
import java.util.Set;
31506
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
    37
import java.util.TreeSet;
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
    38
import java.util.stream.Collectors;
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
    39
import java.util.stream.StreamSupport;
14960
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    40
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    41
import javax.lang.model.SourceVersion;
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    42
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    43
import com.sun.tools.doclint.DocLint;
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    44
import com.sun.tools.javac.code.Lint;
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
    45
import com.sun.tools.javac.code.Lint.LintCategory;
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    46
import com.sun.tools.javac.code.Source;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    47
import com.sun.tools.javac.code.Type;
15724
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
    48
import com.sun.tools.javac.jvm.Profile;
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    49
import com.sun.tools.javac.jvm.Target;
31506
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
    50
import com.sun.tools.javac.platform.PlatformProvider;
14960
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    51
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    52
import com.sun.tools.javac.util.Log;
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    53
import com.sun.tools.javac.util.Log.PrefixKind;
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    54
import com.sun.tools.javac.util.Log.WriterKind;
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    55
import com.sun.tools.javac.util.Options;
22153
f9f06fcca59d 8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents: 19670
diff changeset
    56
import com.sun.tools.javac.util.StringUtils;
31506
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
    57
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    58
import static com.sun.tools.javac.main.Option.ChoiceKind.*;
14960
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
    59
import static com.sun.tools.javac.main.Option.OptionGroup.*;
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    60
import static com.sun.tools.javac.main.Option.OptionKind.*;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    61
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    62
/**
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    63
 * Options for javac. The specific Option to handle a command-line option
26264
a09fedde76be 8044859: javac duplicates option processing when using Compiler API
jjg
parents: 25874
diff changeset
    64
 * is identified by searching the members of this enum in order, looking for
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    65
 * the first {@link #matches match}. The action for an Option is performed
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    66
 * by calling {@link #process process}, and by providing a suitable
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    67
 * {@link OptionHelper} to provide access the compiler state.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    68
 *
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    69
 * <p><b>This is NOT part of any supported API.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    70
 * If you write code that depends on this, you do so at your own
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    71
 * risk.  This code and its internal interfaces are subject to change
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    72
 * or deletion without notice.</b></p>
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    73
 */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    74
public enum Option {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    75
    G("-g", "opt.g", STANDARD, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    76
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    77
    G_NONE("-g:none", "opt.g.none", STANDARD, BASIC) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    78
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    79
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    80
            helper.put("-g:", "none");
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    81
            return false;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    82
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    83
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    84
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    85
    G_CUSTOM("-g:",  "opt.g.lines.vars.source",
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    86
            STANDARD, BASIC, ANYOF, "lines", "vars", "source"),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    87
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    88
    XLINT("-Xlint", "opt.Xlint", EXTENDED, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
    89
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
    90
    XLINT_CUSTOM("-Xlint:", EXTENDED, BASIC, ANYOF, getXLintChoices()) {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
    91
        private static final String LINT_KEY_FORMAT = "         %-19s %s";
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 24298
diff changeset
    92
        @Override
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
    93
        void help(Log log, OptionKind kind) {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
    94
            if (this.kind != kind)
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
    95
                return;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
    96
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
    97
            log.printRawLines(WriterKind.NOTICE,
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
    98
                              String.format(HELP_LINE_FORMAT,
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
    99
                                            log.localize(PrefixKind.JAVAC, "opt.Xlint.subopts"),
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   100
                                            log.localize(PrefixKind.JAVAC, "opt.Xlint.suboptlist")));
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   101
            log.printRawLines(WriterKind.NOTICE,
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   102
                              String.format(LINT_KEY_FORMAT,
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   103
                                            "all",
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   104
                                            log.localize(PrefixKind.JAVAC, "opt.Xlint.all")));
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   105
            for (LintCategory lc : LintCategory.values()) {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   106
                if (lc.hidden) continue;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   107
                log.printRawLines(WriterKind.NOTICE,
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   108
                                  String.format(LINT_KEY_FORMAT,
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   109
                                                lc.option,
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   110
                                                log.localize(PrefixKind.JAVAC,
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   111
                                                             "opt.Xlint.desc." + lc.option)));
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   112
            }
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   113
            log.printRawLines(WriterKind.NOTICE,
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   114
                              String.format(LINT_KEY_FORMAT,
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   115
                                            "none",
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   116
                                            log.localize(PrefixKind.JAVAC, "opt.Xlint.none")));
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   117
        }
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   118
    },
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   119
14960
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   120
    XDOCLINT("-Xdoclint", "opt.Xdoclint", EXTENDED, BASIC),
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   121
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   122
    XDOCLINT_CUSTOM("-Xdoclint:", "opt.Xdoclint.subopts", "opt.Xdoclint.custom", EXTENDED, BASIC) {
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   123
        @Override
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   124
        public boolean matches(String option) {
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   125
            return DocLint.isValidOption(
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   126
                    option.replace(XDOCLINT_CUSTOM.text, DocLint.XMSGS_CUSTOM_PREFIX));
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   127
        }
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   128
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   129
        @Override
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   130
        public boolean process(OptionHelper helper, String option) {
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   131
            String prev = helper.get(XDOCLINT_CUSTOM);
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   132
            String next = (prev == null) ? option : (prev + " " + option);
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   133
            helper.put(XDOCLINT_CUSTOM.text, next);
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   134
            return false;
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   135
        }
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   136
    },
ea7606a9683e 8004833: Integrate doclint support into javac
jjg
parents: 14801
diff changeset
   137
29427
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   138
    XDOCLINT_PACKAGE("-Xdoclint/package:", "opt.Xdoclint.package.args", "opt.Xdoclint.package.desc", EXTENDED, BASIC) {
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   139
        @Override
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   140
        public boolean matches(String option) {
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   141
            return DocLint.isValidOption(
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   142
                    option.replace(XDOCLINT_PACKAGE.text, DocLint.XCHECK_PACKAGE));
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   143
        }
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   144
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   145
        @Override
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   146
        public boolean process(OptionHelper helper, String option) {
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   147
            String prev = helper.get(XDOCLINT_PACKAGE);
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   148
            String next = (prev == null) ? option : (prev + " " + option);
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   149
            helper.put(XDOCLINT_PACKAGE.text, next);
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   150
            return false;
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   151
        }
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   152
    },
44f4e6905b67 8071851: Provide filtering of doclint checking based on packages
jlahoda
parents: 26264
diff changeset
   153
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   154
    // -nowarn is retained for command-line backward compatibility
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   155
    NOWARN("-nowarn", "opt.nowarn", STANDARD, BASIC) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   156
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   157
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   158
            helper.put("-Xlint:none", option);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   159
            return false;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   160
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   161
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   162
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   163
    VERBOSE("-verbose", "opt.verbose", STANDARD, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   164
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   165
    // -deprecation is retained for command-line backward compatibility
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   166
    DEPRECATION("-deprecation", "opt.deprecation", STANDARD, BASIC) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   167
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   168
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   169
            helper.put("-Xlint:deprecation", option);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   170
            return false;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   171
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   172
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   173
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   174
    CLASSPATH("-classpath", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   175
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   176
    CP("-cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   177
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   178
        public boolean process(OptionHelper helper, String option, String arg) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   179
            return super.process(helper, "-classpath", arg);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   180
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   181
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   182
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   183
    SOURCEPATH("-sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   184
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   185
    BOOTCLASSPATH("-bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   186
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   187
        public boolean process(OptionHelper helper, String option, String arg) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   188
            helper.remove("-Xbootclasspath/p:");
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   189
            helper.remove("-Xbootclasspath/a:");
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   190
            return super.process(helper, option, arg);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   191
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   192
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   193
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   194
    XBOOTCLASSPATH_PREPEND("-Xbootclasspath/p:", "opt.arg.path", "opt.Xbootclasspath.p", EXTENDED, FILEMANAGER),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   195
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   196
    XBOOTCLASSPATH_APPEND("-Xbootclasspath/a:", "opt.arg.path", "opt.Xbootclasspath.a", EXTENDED, FILEMANAGER),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   197
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   198
    XBOOTCLASSPATH("-Xbootclasspath:", "opt.arg.path", "opt.bootclasspath", EXTENDED, FILEMANAGER) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   199
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   200
        public boolean process(OptionHelper helper, String option, String arg) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   201
            helper.remove("-Xbootclasspath/p:");
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   202
            helper.remove("-Xbootclasspath/a:");
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   203
            return super.process(helper, "-bootclasspath", arg);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   204
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   205
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   206
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   207
    EXTDIRS("-extdirs", "opt.arg.dirs", "opt.extdirs", STANDARD, FILEMANAGER),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   208
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   209
    DJAVA_EXT_DIRS("-Djava.ext.dirs=", "opt.arg.dirs", "opt.extdirs", EXTENDED, FILEMANAGER) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   210
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   211
        public boolean process(OptionHelper helper, String option, String arg) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   212
            return super.process(helper, "-extdirs", arg);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   213
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   214
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   215
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   216
    ENDORSEDDIRS("-endorseddirs", "opt.arg.dirs", "opt.endorseddirs", STANDARD, FILEMANAGER),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   217
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   218
    DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs=", "opt.arg.dirs", "opt.endorseddirs", EXTENDED, FILEMANAGER) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   219
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   220
        public boolean process(OptionHelper helper, String option, String arg) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   221
            return super.process(helper, "-endorseddirs", arg);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   222
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   223
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   224
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   225
    PROC("-proc:", "opt.proc.none.only", STANDARD, BASIC,  ONEOF, "none", "only"),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   226
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   227
    PROCESSOR("-processor", "opt.arg.class.list", "opt.processor", STANDARD, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   228
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   229
    PROCESSORPATH("-processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   230
15031
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents: 14960
diff changeset
   231
    PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC),
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents: 14960
diff changeset
   232
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   233
    D("-d", "opt.arg.directory", "opt.d", STANDARD, FILEMANAGER),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   234
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   235
    S("-s", "opt.arg.directory", "opt.sourceDest", STANDARD, FILEMANAGER),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   236
12213
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 11317
diff changeset
   237
    H("-h", "opt.arg.directory", "opt.headerDest", STANDARD, FILEMANAGER),
516b112d6c68 7150368: javac should include basic ability to generate native headers
jjg
parents: 11317
diff changeset
   238
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   239
    IMPLICIT("-implicit:", "opt.implicit", STANDARD, BASIC, ONEOF, "none", "class"),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   240
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   241
    ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   242
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   243
        public boolean process(OptionHelper helper, String option, String operand) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   244
            return super.process(helper, option, operand);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   245
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   246
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   247
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   248
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   249
    SOURCE("-source", "opt.arg.release", "opt.source", STANDARD, BASIC) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   250
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   251
        public boolean process(OptionHelper helper, String option, String operand) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   252
            Source source = Source.lookup(operand);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   253
            if (source == null) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   254
                helper.error("err.invalid.source", operand);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   255
                return true;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   256
            }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   257
            return super.process(helper, option, operand);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   258
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   259
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   260
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   261
    TARGET("-target", "opt.arg.release", "opt.target", STANDARD, BASIC) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   262
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   263
        public boolean process(OptionHelper helper, String option, String operand) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   264
            Target target = Target.lookup(operand);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   265
            if (target == null) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   266
                helper.error("err.invalid.target", operand);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   267
                return true;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   268
            }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   269
            return super.process(helper, option, operand);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   270
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   271
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   272
31506
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   273
    RELEASE("-release", "opt.arg.release", "opt.release", STANDARD, BASIC) {
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   274
        @Override
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   275
        void help(Log log, OptionKind kind) {
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   276
            if (this.kind != kind)
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   277
                return;
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   278
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   279
            Iterable<PlatformProvider> providers =
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   280
                    ServiceLoader.load(PlatformProvider.class, Arguments.class.getClassLoader());
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   281
            Set<String> platforms = StreamSupport.stream(providers.spliterator(), false)
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   282
                                                 .flatMap(provider -> StreamSupport.stream(provider.getSupportedPlatformNames()
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   283
                                                                                                   .spliterator(),
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   284
                                                                                           false))
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   285
                                                 .collect(Collectors.toCollection(TreeSet :: new));
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   286
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   287
            StringBuilder targets = new StringBuilder();
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   288
            String delim = "";
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   289
            for (String platform : platforms) {
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   290
                targets.append(delim);
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   291
                targets.append(platform);
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   292
                delim = ", ";
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   293
            }
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   294
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   295
            log.printRawLines(WriterKind.NOTICE,
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   296
                    String.format(HELP_LINE_FORMAT,
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   297
                        super.helpSynopsis(log),
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   298
                        log.localize(PrefixKind.JAVAC, descrKey, targets.toString())));
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   299
        }
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   300
    },
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents: 29427
diff changeset
   301
15724
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
   302
    PROFILE("-profile", "opt.arg.profile", "opt.profile", STANDARD, BASIC) {
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
   303
        @Override
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
   304
        public boolean process(OptionHelper helper, String option, String operand) {
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
   305
            Profile profile = Profile.lookup(operand);
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
   306
            if (profile == null) {
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
   307
                helper.error("err.invalid.profile", operand);
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
   308
                return true;
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
   309
            }
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
   310
            return super.process(helper, option, operand);
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
   311
        }
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
   312
    },
3063fb01c8a1 8004182: Add support for profiles in javac
jjg
parents: 15043
diff changeset
   313
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   314
    VERSION("-version", "opt.version", STANDARD, INFO) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   315
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   316
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   317
            Log log = helper.getLog();
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   318
            String ownName = helper.getOwnName();
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   319
            log.printLines(PrefixKind.JAVAC, "version", ownName,  JavaCompiler.version());
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   320
            return super.process(helper, option);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   321
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   322
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   323
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   324
    FULLVERSION("-fullversion", null, HIDDEN, INFO) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   325
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   326
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   327
            Log log = helper.getLog();
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   328
            String ownName = helper.getOwnName();
11317
72a4280ef5b2 7121681: compiler message file broken for javac -fullversion
jjg
parents: 11316
diff changeset
   329
            log.printLines(PrefixKind.JAVAC, "fullVersion", ownName,  JavaCompiler.fullVersion());
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   330
            return super.process(helper, option);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   331
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   332
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   333
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   334
    DIAGS("-XDdiags=", null, HIDDEN, INFO) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   335
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   336
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   337
            option = option.substring(option.indexOf('=') + 1);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   338
            String diagsOption = option.contains("%") ?
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   339
                "-XDdiagsFormat=" :
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   340
                "-XDdiags=";
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   341
            diagsOption += option;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   342
            if (XD.matches(diagsOption))
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   343
                return XD.process(helper, diagsOption);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   344
            else
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   345
                return false;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   346
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   347
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   348
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   349
    HELP("-help", "opt.help", STANDARD, INFO) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   350
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   351
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   352
            Log log = helper.getLog();
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   353
            String ownName = helper.getOwnName();
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   354
            log.printLines(PrefixKind.JAVAC, "msg.usage.header", ownName);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   355
            for (Option o: getJavaCompilerOptions()) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   356
                o.help(log, OptionKind.STANDARD);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   357
            }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   358
            log.printNewline();
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   359
            return super.process(helper, option);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   360
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   361
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   362
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   363
    A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, true) {
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   364
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   365
        public boolean matches(String arg) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   366
            return arg.startsWith("-A");
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   367
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   368
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   369
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   370
        public boolean hasArg() {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   371
            return false;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   372
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   373
        // Mapping for processor options created in
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   374
        // JavacProcessingEnvironment
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   375
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   376
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   377
            int argLength = option.length();
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   378
            if (argLength == 2) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   379
                helper.error("err.empty.A.argument");
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   380
                return true;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   381
            }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   382
            int sepIndex = option.indexOf('=');
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   383
            String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   384
            if (!JavacProcessingEnvironment.isValidOptionName(key)) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   385
                helper.error("err.invalid.A.key", option);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   386
                return true;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   387
            }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   388
            return process(helper, option, option);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   389
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   390
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   391
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   392
    X("-X", "opt.X", STANDARD, INFO) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   393
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   394
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   395
            Log log = helper.getLog();
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   396
            for (Option o: getJavaCompilerOptions()) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   397
                o.help(log, OptionKind.EXTENDED);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   398
            }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   399
            log.printNewline();
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   400
            log.printLines(PrefixKind.JAVAC, "msg.usage.nonstandard.footer");
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   401
            return super.process(helper, option);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   402
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   403
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   404
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   405
    // This option exists only for the purpose of documenting itself.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   406
    // It's actually implemented by the launcher.
15043
4aae62f3b9a8 8006037: extra space in javac -help for -J and @ options
jjg
parents: 15031
diff changeset
   407
    J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, true) {
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   408
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   409
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   410
            throw new AssertionError
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   411
                ("the -J flag should be caught by the launcher.");
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   412
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   413
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   414
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   415
    MOREINFO("-moreinfo", null, HIDDEN, BASIC) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   416
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   417
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   418
            Type.moreInfo = true;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   419
            return super.process(helper, option);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   420
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   421
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   422
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   423
    // treat warnings as errors
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   424
    WERROR("-Werror", "opt.Werror", STANDARD, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   425
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   426
    // prompt after each error
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   427
    // new Option("-prompt",                                        "opt.prompt"),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   428
    PROMPT("-prompt", null, HIDDEN, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   429
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   430
    // dump stack on error
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   431
    DOE("-doe", null, HIDDEN, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   432
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   433
    // output source after type erasure
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   434
    PRINTSOURCE("-printsource", null, HIDDEN, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   435
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   436
    // display warnings for generic unchecked operations
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   437
    WARNUNCHECKED("-warnunchecked", null, HIDDEN, BASIC) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   438
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   439
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   440
            helper.put("-Xlint:unchecked", option);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   441
            return false;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   442
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   443
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   444
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   445
    XMAXERRS("-Xmaxerrs", "opt.arg.number", "opt.maxerrs", EXTENDED, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   446
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   447
    XMAXWARNS("-Xmaxwarns", "opt.arg.number", "opt.maxwarns", EXTENDED, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   448
11316
4dcad625e72e 7111022: javac no long prints last round of processing
jjg
parents: 11315
diff changeset
   449
    XSTDOUT("-Xstdout", "opt.arg.file", "opt.Xstdout", EXTENDED, INFO) {
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   450
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   451
        public boolean process(OptionHelper helper, String option, String arg) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   452
            try {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   453
                Log log = helper.getLog();
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   454
                log.setWriters(new PrintWriter(new FileWriter(arg), true));
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   455
            } catch (java.io.IOException e) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   456
                helper.error("err.error.writing.file", arg, e);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   457
                return true;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   458
            }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   459
            return super.process(helper, option, arg);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   460
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   461
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   462
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   463
    XPRINT("-Xprint", "opt.print", EXTENDED, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   464
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   465
    XPRINTROUNDS("-XprintRounds", "opt.printRounds", EXTENDED, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   466
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   467
    XPRINTPROCESSORINFO("-XprintProcessorInfo", "opt.printProcessorInfo", EXTENDED, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   468
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   469
    XPREFER("-Xprefer:", "opt.prefer", EXTENDED, BASIC, ONEOF, "source", "newer"),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   470
24298
cc4f0f71a505 8028196: Javac allows timestamps inside rt.jar to affect compilation when using -sourcepath.
alundblad
parents: 23792
diff changeset
   471
    XXUSERPATHSFIRST("-XXuserPathsFirst", "opt.userpathsfirst", HIDDEN, BASIC),
cc4f0f71a505 8028196: Javac allows timestamps inside rt.jar to affect compilation when using -sourcepath.
alundblad
parents: 23792
diff changeset
   472
19670
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   473
    // see enum PkgInfo
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   474
    XPKGINFO("-Xpkginfo:", "opt.pkginfo", EXTENDED, BASIC, ONEOF, "always", "legacy", "nonempty"),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   475
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   476
    /* -O is a no-op, accepted for backward compatibility. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   477
    O("-O", null, HIDDEN, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   478
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   479
    /* -Xjcov produces tables to support the code coverage tool jcov. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   480
    XJCOV("-Xjcov", null, HIDDEN, BASIC),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   481
14548
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 12213
diff changeset
   482
    PLUGIN("-Xplugin:", "opt.arg.plugin", "opt.plugin", EXTENDED, BASIC) {
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 12213
diff changeset
   483
        @Override
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 12213
diff changeset
   484
        public boolean process(OptionHelper helper, String option) {
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 12213
diff changeset
   485
            String p = option.substring(option.indexOf(':') + 1);
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 12213
diff changeset
   486
            String prev = helper.get(PLUGIN);
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 12213
diff changeset
   487
            helper.put(PLUGIN.text, (prev == null) ? p : prev + '\0' + p.trim());
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 12213
diff changeset
   488
            return false;
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 12213
diff changeset
   489
        }
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 12213
diff changeset
   490
    },
aa687b312c97 8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents: 12213
diff changeset
   491
17582
4079713129dd 8012003: Method diagnostics resolution need to be simplified in some cases
mcimadamore
parents: 15724
diff changeset
   492
    XDIAGS("-Xdiags:", "opt.diags", EXTENDED, BASIC, ONEOF, "compact", "verbose"),
4079713129dd 8012003: Method diagnostics resolution need to be simplified in some cases
mcimadamore
parents: 15724
diff changeset
   493
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   494
    /* This is a back door to the compiler's option table.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   495
     * -XDx=y sets the option x to the value y.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   496
     * -XDx sets the option x to the value x.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   497
     */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   498
    XD("-XD", null, HIDDEN, BASIC) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   499
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   500
        public boolean matches(String s) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   501
            return s.startsWith(text);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   502
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   503
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   504
        public boolean process(OptionHelper helper, String option) {
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   505
            option = option.substring(text.length());
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   506
            int eq = option.indexOf('=');
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   507
            String key = (eq < 0) ? option : option.substring(0, eq);
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   508
            String value = (eq < 0) ? option : option.substring(eq+1);
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   509
            helper.put(key, value);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   510
            return false;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   511
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   512
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   513
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   514
    // This option exists only for the purpose of documenting itself.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   515
    // It's actually implemented by the CommandLine class.
15043
4aae62f3b9a8 8006037: extra space in javac -help for -J and @ options
jjg
parents: 15031
diff changeset
   516
    AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, true) {
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   517
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   518
        public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   519
            throw new AssertionError("the @ flag should be caught by CommandLine.");
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   520
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   521
    },
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   522
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   523
    /*
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   524
     * TODO: With apt, the matches method accepts anything if
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   525
     * -XclassAsDecls is used; code elsewhere does the lookup to
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   526
     * see if the class name is both legal and found.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   527
     *
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   528
     * In apt, the process method adds the candidate class file
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   529
     * name to a separate list.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   530
     */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   531
    SOURCEFILE("sourcefile", null, HIDDEN, INFO) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   532
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   533
        public boolean matches(String s) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   534
            return s.endsWith(".java")  // Java source file
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   535
                || SourceVersion.isName(s);   // Legal type name
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   536
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   537
        @Override
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   538
        public boolean process(OptionHelper helper, String option) {
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   539
            if (option.endsWith(".java") ) {
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   540
                File f = new File(option);
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   541
                if (!f.exists()) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   542
                    helper.error("err.file.not.found", f);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   543
                    return true;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   544
                }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   545
                if (!f.isFile()) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   546
                    helper.error("err.file.not.file", f);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   547
                    return true;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   548
                }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   549
                helper.addFile(f);
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   550
            } else {
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   551
                helper.addClassName(option);
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   552
            }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   553
            return false;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   554
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   555
    };
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   556
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   557
    /** The kind of an Option. This is used by the -help and -X options. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   558
    public enum OptionKind {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   559
        /** A standard option, documented by -help. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   560
        STANDARD,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   561
        /** An extended option, documented by -X. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   562
        EXTENDED,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   563
        /** A hidden option, not documented. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   564
        HIDDEN,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   565
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   566
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   567
    /** The group for an Option. This determines the situations in which the
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   568
     *  option is applicable. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   569
    enum OptionGroup {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   570
        /** A basic option, available for use on the command line or via the
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   571
         *  Compiler API. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   572
        BASIC,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   573
        /** An option for javac's standard JavaFileManager. Other file managers
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   574
         *  may or may not support these options. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   575
        FILEMANAGER,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   576
        /** A command-line option that requests information, such as -help. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   577
        INFO,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   578
        /** A command-line "option" representing a file or class name. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   579
        OPERAND
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   580
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   581
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   582
    /** The kind of choice for "choice" options. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   583
    enum ChoiceKind {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   584
        /** The expected value is exactly one of the set of choices. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   585
        ONEOF,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   586
        /** The expected value is one of more of the set of choices. */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   587
        ANYOF
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   588
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   589
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   590
    public final String text;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   591
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   592
    final OptionKind kind;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   593
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   594
    final OptionGroup group;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   595
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   596
    /** Documentation key for arguments.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   597
     */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   598
    final String argsNameKey;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   599
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   600
    /** Documentation key for description.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   601
     */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   602
    final String descrKey;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   603
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   604
    /** Suffix option (-foo=bar or -foo:bar)
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   605
     */
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   606
    final boolean hasSuffix;
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   607
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   608
    /** The kind of choices for this option, if any.
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   609
     */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   610
    final ChoiceKind choiceKind;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   611
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   612
    /** The choices for this option, if any, and whether or not the choices
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   613
     *  are hidden
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   614
     */
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   615
    final Map<String,Boolean> choices;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   616
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   617
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   618
    Option(String text, String descrKey,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   619
            OptionKind kind, OptionGroup group) {
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   620
        this(text, null, descrKey, kind, group, null, null, false);
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   621
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   622
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   623
    Option(String text, String argsNameKey, String descrKey,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   624
            OptionKind kind, OptionGroup group) {
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   625
        this(text, argsNameKey, descrKey, kind, group, null, null, false);
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   626
    }
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   627
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   628
    Option(String text, String argsNameKey, String descrKey,
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   629
            OptionKind kind, OptionGroup group, boolean doHasSuffix) {
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   630
        this(text, argsNameKey, descrKey, kind, group, null, null, doHasSuffix);
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   631
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   632
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   633
    Option(String text, OptionKind kind, OptionGroup group,
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   634
            ChoiceKind choiceKind, Map<String,Boolean> choices) {
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   635
        this(text, null, null, kind, group, choiceKind, choices, false);
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   636
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   637
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   638
    Option(String text, String descrKey,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   639
            OptionKind kind, OptionGroup group,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   640
            ChoiceKind choiceKind, String... choices) {
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   641
        this(text, null, descrKey, kind, group, choiceKind,
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   642
                createChoices(choices), false);
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   643
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   644
    // where
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   645
        private static Map<String,Boolean> createChoices(String... choices) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22153
diff changeset
   646
            Map<String,Boolean> map = new LinkedHashMap<>();
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   647
            for (String c: choices)
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   648
                map.put(c, false);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   649
            return map;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   650
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   651
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   652
    private Option(String text, String argsNameKey, String descrKey,
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   653
            OptionKind kind, OptionGroup group,
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   654
            ChoiceKind choiceKind, Map<String,Boolean> choices,
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   655
            boolean doHasSuffix) {
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   656
        this.text = text;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   657
        this.argsNameKey = argsNameKey;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   658
        this.descrKey = descrKey;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   659
        this.kind = kind;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   660
        this.group = group;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   661
        this.choiceKind = choiceKind;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   662
        this.choices = choices;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   663
        char lastChar = text.charAt(text.length()-1);
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14548
diff changeset
   664
        this.hasSuffix = doHasSuffix || lastChar == ':' || lastChar == '=';
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   665
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   666
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   667
    public String getText() {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   668
        return text;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   669
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   670
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   671
    public OptionKind getKind() {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   672
        return kind;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   673
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   674
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   675
    public boolean hasArg() {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   676
        return argsNameKey != null && !hasSuffix;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   677
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   678
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   679
    public boolean matches(String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   680
        if (!hasSuffix)
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   681
            return option.equals(text);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   682
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   683
        if (!option.startsWith(text))
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   684
            return false;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   685
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   686
        if (choices != null) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   687
            String arg = option.substring(text.length());
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   688
            if (choiceKind == ChoiceKind.ONEOF)
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   689
                return choices.keySet().contains(arg);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   690
            else {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   691
                for (String a: arg.split(",+")) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   692
                    if (!choices.keySet().contains(a))
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   693
                        return false;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   694
                }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   695
            }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   696
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   697
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   698
        return true;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   699
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   700
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   701
    public boolean process(OptionHelper helper, String option, String arg) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   702
        if (choices != null) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   703
            if (choiceKind == ChoiceKind.ONEOF) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   704
                // some clients like to see just one of option+choice set
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   705
                for (String s: choices.keySet())
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   706
                    helper.remove(option + s);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   707
                String opt = option + arg;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   708
                helper.put(opt, opt);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   709
                // some clients like to see option (without trailing ":")
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   710
                // set to arg
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   711
                String nm = option.substring(0, option.length() - 1);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   712
                helper.put(nm, arg);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   713
            } else {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   714
                // set option+word for each word in arg
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   715
                for (String a: arg.split(",+")) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   716
                    String opt = option + a;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   717
                    helper.put(opt, opt);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   718
                }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   719
            }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   720
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   721
        helper.put(option, arg);
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 24298
diff changeset
   722
        if (group == OptionGroup.FILEMANAGER)
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 24298
diff changeset
   723
            helper.handleFileManagerOption(this, arg);
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   724
        return false;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   725
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   726
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   727
    public boolean process(OptionHelper helper, String option) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   728
        if (hasSuffix)
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   729
            return process(helper, text, option.substring(text.length()));
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   730
        else
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   731
            return process(helper, option, option);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   732
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   733
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   734
    private static final String HELP_LINE_FORMAT = "  %-26s %s";
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   735
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   736
    void help(Log log, OptionKind kind) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   737
        if (this.kind != kind)
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   738
            return;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   739
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   740
        log.printRawLines(WriterKind.NOTICE,
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents: 22163
diff changeset
   741
                String.format(HELP_LINE_FORMAT,
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   742
                    helpSynopsis(log),
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   743
                    log.localize(PrefixKind.JAVAC, descrKey)));
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   744
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   745
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   746
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   747
    private String helpSynopsis(Log log) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   748
        StringBuilder sb = new StringBuilder();
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   749
        sb.append(text);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   750
        if (argsNameKey == null) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   751
            if (choices != null) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   752
                String sep = "{";
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   753
                for (Map.Entry<String,Boolean> e: choices.entrySet()) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   754
                    if (!e.getValue()) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   755
                        sb.append(sep);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   756
                        sb.append(e.getKey());
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   757
                        sep = ",";
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   758
                    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   759
                }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   760
                sb.append("}");
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   761
            }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   762
        } else {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   763
            if (!hasSuffix)
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   764
                sb.append(" ");
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   765
            sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   766
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   767
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   768
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   769
        return sb.toString();
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   770
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   771
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   772
    // For -XpkgInfo:value
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   773
    public enum PkgInfo {
19670
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   774
        /**
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   775
         * Always generate package-info.class for every package-info.java file.
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   776
         * The file may be empty if there annotations with a RetentionPolicy
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   777
         * of CLASS or RUNTIME.  This option may be useful in conjunction with
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   778
         * build systems (such as Ant) that expect javac to generate at least
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   779
         * one .class file for every .java file.
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   780
         */
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   781
        ALWAYS,
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   782
        /**
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   783
         * Generate a package-info.class file if package-info.java contains
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   784
         * annotations. The file may be empty if all the annotations have
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   785
         * a RetentionPolicy of SOURCE.
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   786
         * This value is just for backwards compatibility with earlier behavior.
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   787
         * Either of the other two values are to be preferred to using this one.
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   788
         */
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   789
        LEGACY,
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   790
        /**
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   791
         * Generate a package-info.class file if and only if there are annotations
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   792
         * in package-info.java to be written into it.
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   793
         */
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   794
        NONEMPTY;
197392292aad 8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents: 17582
diff changeset
   795
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   796
        public static PkgInfo get(Options options) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   797
            String v = options.get(XPKGINFO);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   798
            return (v == null
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   799
                    ? PkgInfo.LEGACY
22153
f9f06fcca59d 8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents: 19670
diff changeset
   800
                    : PkgInfo.valueOf(StringUtils.toUpperCase(v)));
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   801
        }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   802
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   803
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   804
    private static Map<String,Boolean> getXLintChoices() {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22153
diff changeset
   805
        Map<String,Boolean> choices = new LinkedHashMap<>();
11315
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   806
        choices.put("all", false);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   807
        for (Lint.LintCategory c : Lint.LintCategory.values())
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   808
            choices.put(c.option, c.hidden);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   809
        for (Lint.LintCategory c : Lint.LintCategory.values())
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   810
            choices.put("-" + c.option, c.hidden);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   811
        choices.put("none", false);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   812
        return choices;
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   813
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   814
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   815
    static Set<Option> getJavaCompilerOptions() {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   816
        return EnumSet.allOf(Option.class);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   817
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   818
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   819
    public static Set<Option> getJavacFileManagerOptions() {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   820
        return getOptions(EnumSet.of(FILEMANAGER));
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   821
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   822
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   823
    public static Set<Option> getJavacToolOptions() {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   824
        return getOptions(EnumSet.of(BASIC));
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   825
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   826
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   827
    static Set<Option> getOptions(Set<OptionGroup> desired) {
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   828
        Set<Option> options = EnumSet.noneOf(Option.class);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   829
        for (Option option : Option.values())
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   830
            if (desired.contains(option.group))
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   831
                options.add(option);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   832
        return Collections.unmodifiableSet(options);
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   833
    }
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   834
ee0b12cdcb8e 7121164: renamed files not committed
jjg
parents:
diff changeset
   835
}