langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
author jjg
Mon, 07 Mar 2011 13:45:06 -0800
changeset 8637 be1b564b50aa
parent 7681 1f0819a3341f
child 9087 e9e44877cd18
permissions -rw-r--r--
6980021: javac should document @file command line option Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
7681
1f0819a3341f 6962318: Update copyright year
ohair
parents: 6575
diff changeset
     2
 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3661
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3661
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3661
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3661
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3661
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.javac.main;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
    28
import com.sun.tools.javac.code.Lint;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.javac.code.Source;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.tools.javac.code.Type;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.tools.javac.jvm.Target;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import com.sun.tools.javac.main.JavacOption.HiddenOption;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import com.sun.tools.javac.main.JavacOption.Option;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import com.sun.tools.javac.main.JavacOption.XOption;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
import com.sun.tools.javac.util.ListBuffer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
import com.sun.tools.javac.util.Options;
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
import java.io.File;
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
import java.io.FileWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
import java.io.PrintWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
import java.util.EnumSet;
3661
104c425e96aa 6873845: refine access to symbol file
jjg
parents: 2212
diff changeset
    42
import java.util.LinkedHashMap;
104c425e96aa 6873845: refine access to symbol file
jjg
parents: 2212
diff changeset
    43
import java.util.Map;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
import java.util.Set;
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
import javax.lang.model.SourceVersion;
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
import static com.sun.tools.javac.main.OptionName.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * TODO: describe com.sun.tools.javac.main.RecognizedOptions
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    52
 * <p><b>This is NOT part of any supported API.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * If you write code that depends on this, you do so at your own
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * risk.  This code and its internal interfaces are subject to change
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 * or deletion without notice.</b></p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
public class RecognizedOptions {
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    private RecognizedOptions() {}
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    public interface OptionHelper {
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
        void setOut(PrintWriter out);
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
        void error(String key, Object... args);
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        void printVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        void printFullVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        void printHelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        void printXhelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        void addFile(File f);
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        void addClassName(String s);
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    public static class GrumpyHelper implements OptionHelper {
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        public void setOut(PrintWriter out) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        public void error(String key, Object... args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
            throw new IllegalArgumentException(Main.getLocalizedString(key, args));
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        public void printVersion() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        public void printFullVersion() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        public void printHelp() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        public void printXhelp() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        public void addFile(File f) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
            throw new IllegalArgumentException(f.getPath());
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        public void addClassName(String s) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
            throw new IllegalArgumentException(s);
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    static Set<OptionName> javacOptions = EnumSet.of(
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        G,
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
        G_NONE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        G_CUSTOM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        XLINT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        XLINT_CUSTOM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        NOWARN,
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        VERBOSE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        DEPRECATION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        CLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        CP,
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        SOURCEPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        BOOTCLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        XBOOTCLASSPATH_PREPEND,
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        XBOOTCLASSPATH_APPEND,
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        XBOOTCLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        EXTDIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        DJAVA_EXT_DIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        ENDORSEDDIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        DJAVA_ENDORSED_DIRS,
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   137
        PROC,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        PROCESSOR,
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        PROCESSORPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
        D,
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        S,
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
        IMPLICIT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        ENCODING,
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        SOURCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        TARGET,
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        VERSION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        FULLVERSION,
2085
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   148
        DIAGS,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        HELP,
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        A,
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        X,
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        J,
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        MOREINFO,
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        WERROR,
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        // COMPLEXINFERENCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        PROMPT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        DOE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        PRINTSOURCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        WARNUNCHECKED,
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        XMAXERRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        XMAXWARNS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        XSTDOUT,
6575
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   163
        XPKGINFO,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        XPRINT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
        XPRINTROUNDS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
        XPRINTPROCESSORINFO,
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        XPREFER,
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        O,
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
        XJCOV,
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
        XD,
8637
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   171
        AT,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        SOURCEFILE);
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
    static Set<OptionName> javacFileManagerOptions = EnumSet.of(
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        CLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
        CP,
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
        SOURCEPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        BOOTCLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        XBOOTCLASSPATH_PREPEND,
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        XBOOTCLASSPATH_APPEND,
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        XBOOTCLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        EXTDIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
        DJAVA_EXT_DIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
        ENDORSEDDIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        DJAVA_ENDORSED_DIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        PROCESSORPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        D,
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        S,
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        ENCODING,
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        SOURCE);
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    static Set<OptionName> javacToolOptions = EnumSet.of(
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        G,
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        G_NONE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
        G_CUSTOM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
        XLINT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
        XLINT_CUSTOM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        NOWARN,
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        VERBOSE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        DEPRECATION,
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   201
        PROC,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        PROCESSOR,
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        IMPLICIT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        SOURCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        TARGET,
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        // VERSION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        // FULLVERSION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
        // HELP,
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        A,
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
        // X,
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        // J,
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        MOREINFO,
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        WERROR,
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        // COMPLEXINFERENCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
        PROMPT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
        DOE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
        PRINTSOURCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        WARNUNCHECKED,
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        XMAXERRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
        XMAXWARNS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
        // XSTDOUT,
6575
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   222
        XPKGINFO,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        XPRINT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        XPRINTROUNDS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        XPRINTPROCESSORINFO,
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
        XPREFER,
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
        O,
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        XJCOV,
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
        XD);
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    static Option[] getJavaCompilerOptions(OptionHelper helper) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        return getOptions(helper, javacOptions);
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    public static Option[] getJavacFileManagerOptions(OptionHelper helper) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        return getOptions(helper, javacFileManagerOptions);
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
    public static Option[] getJavacToolOptions(OptionHelper helper) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
        return getOptions(helper, javacToolOptions);
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
    static Option[] getOptions(OptionHelper helper, Set<OptionName> desired) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        ListBuffer<Option> options = new ListBuffer<Option>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
        for (Option option : getAll(helper))
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
            if (desired.contains(option.getName()))
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
                options.append(option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
        return options.toArray(new Option[options.length()]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
    /**
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   252
     * Get all the recognized options.
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   253
     * @param helper an {@code OptionHelper} to help when processing options
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   254
     * @return an array of options
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    public static Option[] getAll(final OptionHelper helper) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   257
        return new Option[] {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
        new Option(G,                                           "opt.g"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
        new Option(G_NONE,                                      "opt.g.none") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   260
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
                options.put("-g:", "none");
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   267
        new Option(G_CUSTOM,                                    "opt.g.lines.vars.source",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   268
                Option.ChoiceKind.ANYOF, "lines", "vars", "source"),
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   269
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   270
        new XOption(XLINT,                                      "opt.Xlint"),
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   271
        new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   272
                Option.ChoiceKind.ANYOF, getXLintChoices()),
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   273
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   274
        // -nowarn is retained for command-line backward compatibility
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   275
        new Option(NOWARN,                                      "opt.nowarn") {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   276
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
            public boolean process(Options options, String option) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   278
                options.put("-Xlint:none", option);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
        new Option(VERBOSE,                                     "opt.verbose"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
        // -deprecation is retained for command-line backward compatibility
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
        new Option(DEPRECATION,                                 "opt.deprecation") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   287
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   288
            public boolean process(Options options, String option) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   289
                options.put("-Xlint:deprecation", option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   290
                return false;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   291
            }
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   292
        },
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        new Option(CLASSPATH,              "opt.arg.path",      "opt.classpath"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
        new Option(CP,                     "opt.arg.path",      "opt.classpath") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   296
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
                return super.process(options, "-classpath", arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
        new Option(SOURCEPATH,             "opt.arg.path",      "opt.sourcepath"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
        new Option(BOOTCLASSPATH,          "opt.arg.path",      "opt.bootclasspath") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   303
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
                options.remove("-Xbootclasspath/p:");
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
                options.remove("-Xbootclasspath/a:");
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
                return super.process(options, option, arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
        new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
        new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   313
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
                options.remove("-Xbootclasspath/p:");
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
                options.remove("-Xbootclasspath/a:");
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
                return super.process(options, "-bootclasspath", arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
        new Option(EXTDIRS,                "opt.arg.dirs",      "opt.extdirs"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
        new XOption(DJAVA_EXT_DIRS,        "opt.arg.dirs",      "opt.extdirs") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   322
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
                return super.process(options, "-extdirs", arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
        new Option(ENDORSEDDIRS,            "opt.arg.dirs",     "opt.endorseddirs"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
        new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs",     "opt.endorseddirs") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   329
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
                return super.process(options, "-endorseddirs", arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
        },
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   334
        new Option(PROC,                                 "opt.proc.none.only",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   335
                Option.ChoiceKind.ONEOF, "none", "only"),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
        new Option(PROCESSOR,           "opt.arg.class.list",   "opt.processor"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
        new Option(PROCESSORPATH,       "opt.arg.path",         "opt.processorpath"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
        new Option(D,                   "opt.arg.directory",    "opt.d"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
        new Option(S,                   "opt.arg.directory",    "opt.sourceDest"),
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   340
        new Option(IMPLICIT,                                    "opt.implicit",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   341
                Option.ChoiceKind.ONEOF, "none", "class"),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
        new Option(ENCODING,            "opt.arg.encoding",     "opt.encoding"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
        new Option(SOURCE,              "opt.arg.release",      "opt.source") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   344
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
            public boolean process(Options options, String option, String operand) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
                Source source = Source.lookup(operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
                if (source == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
                    helper.error("err.invalid.source", operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
                return super.process(options, option, operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
        new Option(TARGET,              "opt.arg.release",      "opt.target") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   355
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
            public boolean process(Options options, String option, String operand) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
                Target target = Target.lookup(operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
                if (target == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
                    helper.error("err.invalid.target", operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
                return super.process(options, option, operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
        new Option(VERSION,                                     "opt.version") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   366
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
                helper.printVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
        new HiddenOption(FULLVERSION) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   373
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
                helper.printFullVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
        },
2085
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   379
        new HiddenOption(DIAGS) {
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   380
            @Override
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   381
            public boolean process(Options options, String option) {
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   382
                Option xd = getOptions(helper, EnumSet.of(XD))[0];
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   383
                option = option.substring(option.indexOf('=') + 1);
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   384
                String diagsOption = option.contains("%") ?
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   385
                    "-XDdiagsFormat=" :
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   386
                    "-XDdiags=";
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   387
                diagsOption += option;
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   388
                if (xd.matches(diagsOption))
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   389
                    return xd.process(options, diagsOption);
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   390
                else
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   391
                    return false;
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   392
            }
4792e12a8ca2 6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents: 1996
diff changeset
   393
        },
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
        new Option(HELP,                                        "opt.help") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   395
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
                helper.printHelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
        new Option(A,                "opt.arg.key.equals.value","opt.A") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   402
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   403
            String helpSynopsis() {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   404
                hasSuffix = true;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   405
                return super.helpSynopsis();
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   406
            }
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   407
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   408
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   409
            public boolean matches(String arg) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   410
                return arg.startsWith("-A");
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   411
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   413
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   414
            public boolean hasArg() {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   415
                return false;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   416
            }
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   417
            // Mapping for processor options created in
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   418
            // JavacProcessingEnvironment
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   419
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   420
            public boolean process(Options options, String option) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   421
                int argLength = option.length();
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   422
                if (argLength == 2) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   423
                    helper.error("err.empty.A.argument");
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   424
                    return true;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
                }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   426
                int sepIndex = option.indexOf('=');
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   427
                String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   428
                if (!JavacProcessingEnvironment.isValidOptionName(key)) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   429
                    helper.error("err.invalid.A.key", option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   430
                    return true;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
                }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   432
                return process(options, option, option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   433
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
        new Option(X,                                           "opt.X") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   436
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
                helper.printXhelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
        // This option exists only for the purpose of documenting itself.
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
        // It's actually implemented by the launcher.
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
        new Option(J,                   "opt.arg.flag",         "opt.J") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   446
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
            String helpSynopsis() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
                hasSuffix = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
                return super.helpSynopsis();
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
            }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   451
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
                throw new AssertionError
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
                    ("the -J flag should be caught by the launcher.");
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
        // stop after parsing and attributing.
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
        // new HiddenOption("-attrparseonly"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
        // new Option("-moreinfo",                                      "opt.moreinfo") {
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
        new HiddenOption(MOREINFO) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   463
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   464
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
                Type.moreInfo = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
06bc494ca11e Initial load
duke
parents:
diff changeset
   470
        // treat warnings as errors
1996
c855318a4b03 6595666: fix -Werror
jjg
parents: 1206
diff changeset
   471
        new Option(WERROR,                                      "opt.Werror"),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   472
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
        // use complex inference from context in the position of a method call argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   474
        new HiddenOption(COMPLEXINFERENCE),
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
06bc494ca11e Initial load
duke
parents:
diff changeset
   476
        // generare source stubs
06bc494ca11e Initial load
duke
parents:
diff changeset
   477
        // new HiddenOption("-stubs"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
        // relax some constraints to allow compiling from stubs
06bc494ca11e Initial load
duke
parents:
diff changeset
   480
        // new HiddenOption("-relax"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
        // output source after translating away inner classes
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
        // new Option("-printflat",                             "opt.printflat"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
        // new HiddenOption("-printflat"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
        // display scope search details
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
        // new Option("-printsearch",                           "opt.printsearch"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
        // new HiddenOption("-printsearch"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
        // prompt after each error
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
        // new Option("-prompt",                                        "opt.prompt"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   492
        new HiddenOption(PROMPT),
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
        // dump stack on error
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
        new HiddenOption(DOE),
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
        // output source after type erasure
06bc494ca11e Initial load
duke
parents:
diff changeset
   498
        // new Option("-s",                                     "opt.s"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   499
        new HiddenOption(PRINTSOURCE),
06bc494ca11e Initial load
duke
parents:
diff changeset
   500
06bc494ca11e Initial load
duke
parents:
diff changeset
   501
        // output shrouded class files
06bc494ca11e Initial load
duke
parents:
diff changeset
   502
        // new Option("-scramble",                              "opt.scramble"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
        // new Option("-scrambleall",                           "opt.scrambleall"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   504
06bc494ca11e Initial load
duke
parents:
diff changeset
   505
        // display warnings for generic unchecked operations
06bc494ca11e Initial load
duke
parents:
diff changeset
   506
        new HiddenOption(WARNUNCHECKED) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   507
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   508
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   509
                options.put("-Xlint:unchecked", option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   510
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   511
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   512
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   513
06bc494ca11e Initial load
duke
parents:
diff changeset
   514
        new XOption(XMAXERRS,           "opt.arg.number",       "opt.maxerrs"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   515
        new XOption(XMAXWARNS,          "opt.arg.number",       "opt.maxwarns"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   516
        new XOption(XSTDOUT,            "opt.arg.file",         "opt.Xstdout") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   517
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   518
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   519
                try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   520
                    helper.setOut(new PrintWriter(new FileWriter(arg), true));
06bc494ca11e Initial load
duke
parents:
diff changeset
   521
                } catch (java.io.IOException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   522
                    helper.error("err.error.writing.file", arg, e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   523
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   524
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   525
                return super.process(options, option, arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   526
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   527
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   528
06bc494ca11e Initial load
duke
parents:
diff changeset
   529
        new XOption(XPRINT,                                     "opt.print"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   530
06bc494ca11e Initial load
duke
parents:
diff changeset
   531
        new XOption(XPRINTROUNDS,                               "opt.printRounds"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   532
06bc494ca11e Initial load
duke
parents:
diff changeset
   533
        new XOption(XPRINTPROCESSORINFO,                        "opt.printProcessorInfo"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   534
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   535
        new XOption(XPREFER,                                    "opt.prefer",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   536
                Option.ChoiceKind.ONEOF, "source", "newer"),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   537
6575
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   538
        new XOption(XPKGINFO,                                   "opt.pkginfo",
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   539
                Option.ChoiceKind.ONEOF, "always", "legacy", "nonempty"),
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   540
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   541
        /* -O is a no-op, accepted for backward compatibility. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   542
        new HiddenOption(O),
06bc494ca11e Initial load
duke
parents:
diff changeset
   543
06bc494ca11e Initial load
duke
parents:
diff changeset
   544
        /* -Xjcov produces tables to support the code coverage tool jcov. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   545
        new HiddenOption(XJCOV),
06bc494ca11e Initial load
duke
parents:
diff changeset
   546
06bc494ca11e Initial load
duke
parents:
diff changeset
   547
        /* This is a back door to the compiler's option table.
06bc494ca11e Initial load
duke
parents:
diff changeset
   548
         * -XDx=y sets the option x to the value y.
06bc494ca11e Initial load
duke
parents:
diff changeset
   549
         * -XDx sets the option x to the value x.
06bc494ca11e Initial load
duke
parents:
diff changeset
   550
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   551
        new HiddenOption(XD) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   552
            String s;
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   553
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   554
            public boolean matches(String s) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   555
                this.s = s;
06bc494ca11e Initial load
duke
parents:
diff changeset
   556
                return s.startsWith(name.optionName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   557
            }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   558
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   559
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   560
                s = s.substring(name.optionName.length());
06bc494ca11e Initial load
duke
parents:
diff changeset
   561
                int eq = s.indexOf('=');
06bc494ca11e Initial load
duke
parents:
diff changeset
   562
                String key = (eq < 0) ? s : s.substring(0, eq);
06bc494ca11e Initial load
duke
parents:
diff changeset
   563
                String value = (eq < 0) ? s : s.substring(eq+1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   564
                options.put(key, value);
06bc494ca11e Initial load
duke
parents:
diff changeset
   565
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   566
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   567
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   568
8637
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   569
        // This option exists only for the purpose of documenting itself.
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   570
        // It's actually implemented by the CommandLine class.
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   571
        new Option(AT,                   "opt.arg.file",         "opt.AT") {
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   572
            @Override
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   573
            String helpSynopsis() {
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   574
                hasSuffix = true;
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   575
                return super.helpSynopsis();
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   576
            }
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   577
            @Override
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   578
            public boolean process(Options options, String option) {
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   579
                throw new AssertionError
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   580
                    ("the @ flag should be caught by CommandLine.");
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   581
            }
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   582
        },
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   583
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   584
        /*
06bc494ca11e Initial load
duke
parents:
diff changeset
   585
         * TODO: With apt, the matches method accepts anything if
06bc494ca11e Initial load
duke
parents:
diff changeset
   586
         * -XclassAsDecls is used; code elsewhere does the lookup to
06bc494ca11e Initial load
duke
parents:
diff changeset
   587
         * see if the class name is both legal and found.
06bc494ca11e Initial load
duke
parents:
diff changeset
   588
         *
8637
be1b564b50aa 6980021: javac should document @file command line option
jjg
parents: 7681
diff changeset
   589
         * In apt, the process method adds the candidate class file
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   590
         * name to a separate list.
06bc494ca11e Initial load
duke
parents:
diff changeset
   591
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   592
        new HiddenOption(SOURCEFILE) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   593
            String s;
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   594
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   595
            public boolean matches(String s) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   596
                this.s = s;
06bc494ca11e Initial load
duke
parents:
diff changeset
   597
                return s.endsWith(".java")  // Java source file
06bc494ca11e Initial load
duke
parents:
diff changeset
   598
                    || SourceVersion.isName(s);   // Legal type name
06bc494ca11e Initial load
duke
parents:
diff changeset
   599
            }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   600
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   601
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   602
                if (s.endsWith(".java") ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   603
                    File f = new File(s);
06bc494ca11e Initial load
duke
parents:
diff changeset
   604
                    if (!f.exists()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   605
                        helper.error("err.file.not.found", f);
06bc494ca11e Initial load
duke
parents:
diff changeset
   606
                        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   607
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   608
                    if (!f.isFile()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   609
                        helper.error("err.file.not.file", f);
06bc494ca11e Initial load
duke
parents:
diff changeset
   610
                        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   611
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   612
                    helper.addFile(f);
06bc494ca11e Initial load
duke
parents:
diff changeset
   613
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   614
                else
06bc494ca11e Initial load
duke
parents:
diff changeset
   615
                    helper.addClassName(s);
06bc494ca11e Initial load
duke
parents:
diff changeset
   616
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   617
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   618
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   619
    };
06bc494ca11e Initial load
duke
parents:
diff changeset
   620
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   621
6575
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   622
    public enum PkgInfo {
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   623
        ALWAYS, LEGACY, NONEMPTY;
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   624
        public static PkgInfo get(Options options) {
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   625
            String v = options.get(XPKGINFO);
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   626
            return (v == null
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   627
                    ? PkgInfo.LEGACY
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   628
                    : PkgInfo.valueOf(v.toUpperCase()));
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   629
        }
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   630
    }
ae1798028008 6960424: new option -Xpkginfo for better control of when package-info.class is generated
jjg
parents: 5847
diff changeset
   631
3661
104c425e96aa 6873845: refine access to symbol file
jjg
parents: 2212
diff changeset
   632
    private static Map<String,Boolean> getXLintChoices() {
104c425e96aa 6873845: refine access to symbol file
jjg
parents: 2212
diff changeset
   633
        Map<String,Boolean> choices = new LinkedHashMap<String,Boolean>();
104c425e96aa 6873845: refine access to symbol file
jjg
parents: 2212
diff changeset
   634
        choices.put("all", false);
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   635
        for (Lint.LintCategory c : Lint.LintCategory.values())
3661
104c425e96aa 6873845: refine access to symbol file
jjg
parents: 2212
diff changeset
   636
            choices.put(c.option, c.hidden);
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   637
        for (Lint.LintCategory c : Lint.LintCategory.values())
3661
104c425e96aa 6873845: refine access to symbol file
jjg
parents: 2212
diff changeset
   638
            choices.put("-" + c.option, c.hidden);
104c425e96aa 6873845: refine access to symbol file
jjg
parents: 2212
diff changeset
   639
        choices.put("none", false);
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   640
        return choices;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   641
    }
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   642
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   643
}