langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
author xdono
Wed, 02 Jul 2008 12:56:02 -0700
changeset 735 372aa565a221
parent 168 25697c18650b
child 1206 3a05355982a9
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
735
372aa565a221 6719955: Update copyright year
xdono
parents: 168
diff changeset
     2
 * Copyright 2006-2008 Sun Microsystems, Inc.  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
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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;
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
    41
import java.util.Arrays;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
    42
import java.util.Collection;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
import java.util.EnumSet;
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
    44
import java.util.LinkedHashSet;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
import java.util.Set;
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
import java.util.StringTokenizer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
import javax.lang.model.SourceVersion;
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
import static com.sun.tools.javac.main.OptionName.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * TODO: describe com.sun.tools.javac.main.RecognizedOptions
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * <p><b>This is NOT part of any API supported by Sun Microsystems.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 * If you write code that depends on this, you do so at your own
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * risk.  This code and its internal interfaces are subject to change
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * or deletion without notice.</b></p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
public class RecognizedOptions {
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    private RecognizedOptions() {}
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    public interface OptionHelper {
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
        void setOut(PrintWriter out);
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        void error(String key, Object... args);
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        void printVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        void printFullVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        void printHelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        void printXhelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        void addFile(File f);
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
        void addClassName(String s);
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    public static class GrumpyHelper implements OptionHelper {
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        public void setOut(PrintWriter out) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
        public void error(String key, Object... args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
            throw new IllegalArgumentException(Main.getLocalizedString(key, args));
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
        public void printVersion() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        public void printFullVersion() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        public void printHelp() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
        public void printXhelp() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        public void addFile(File f) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
            throw new IllegalArgumentException(f.getPath());
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        public void addClassName(String s) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
            throw new IllegalArgumentException(s);
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    static Set<OptionName> javacOptions = EnumSet.of(
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        G,
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        G_NONE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        G_CUSTOM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        XLINT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        XLINT_CUSTOM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        NOWARN,
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        VERBOSE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        DEPRECATION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        CLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        CP,
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        SOURCEPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        BOOTCLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        XBOOTCLASSPATH_PREPEND,
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        XBOOTCLASSPATH_APPEND,
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        XBOOTCLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        EXTDIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        DJAVA_EXT_DIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
        ENDORSEDDIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        DJAVA_ENDORSED_DIRS,
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   139
        PROC,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
        PROCESSOR,
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        PROCESSORPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
        D,
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        S,
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        IMPLICIT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        ENCODING,
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        SOURCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        TARGET,
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        VERSION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        FULLVERSION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        HELP,
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        A,
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        X,
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        J,
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        MOREINFO,
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        WERROR,
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        // COMPLEXINFERENCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        PROMPT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        DOE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        PRINTSOURCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        WARNUNCHECKED,
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        XMAXERRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        XMAXWARNS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        XSTDOUT,
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,
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
        SOURCEFILE);
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    static Set<OptionName> javacFileManagerOptions = EnumSet.of(
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        CLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        CP,
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
        SOURCEPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
        BOOTCLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        XBOOTCLASSPATH_PREPEND,
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        XBOOTCLASSPATH_APPEND,
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        XBOOTCLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        EXTDIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        DJAVA_EXT_DIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
        ENDORSEDDIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
        DJAVA_ENDORSED_DIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        PROCESSORPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        D,
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        S,
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        ENCODING,
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        SOURCE);
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
    static Set<OptionName> javacToolOptions = EnumSet.of(
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        G,
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        G_NONE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        G_CUSTOM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
        XLINT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
        XLINT_CUSTOM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
        NOWARN,
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        VERBOSE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        DEPRECATION,
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   200
        PROC,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
        PROCESSOR,
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        IMPLICIT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        SOURCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        TARGET,
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        // VERSION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        // FULLVERSION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        // HELP,
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
        A,
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        // X,
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
        // J,
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        MOREINFO,
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        WERROR,
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        // COMPLEXINFERENCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        PROMPT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
        DOE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
        PRINTSOURCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
        WARNUNCHECKED,
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        XMAXERRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        XMAXWARNS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
        // XSTDOUT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
        XPRINT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
        XPRINTROUNDS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        XPRINTPROCESSORINFO,
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        XPREFER,
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        O,
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
        XJCOV,
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
        XD);
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    static Option[] getJavaCompilerOptions(OptionHelper helper) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        return getOptions(helper, javacOptions);
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    public static Option[] getJavacFileManagerOptions(OptionHelper helper) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
        return getOptions(helper, javacFileManagerOptions);
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
    public static Option[] getJavacToolOptions(OptionHelper helper) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        return getOptions(helper, javacToolOptions);
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
    static Option[] getOptions(OptionHelper helper, Set<OptionName> desired) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
        ListBuffer<Option> options = new ListBuffer<Option>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
        for (Option option : getAll(helper))
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
            if (desired.contains(option.getName()))
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
                options.append(option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
        return options.toArray(new Option[options.length()]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
    /**
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   250
     * Get all the recognized options.
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   251
     * @param helper an {@code OptionHelper} to help when processing options
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   252
     * @return an array of options
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
    public static Option[] getAll(final OptionHelper helper) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   255
        return new Option[] {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
        new Option(G,                                           "opt.g"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        new Option(G_NONE,                                      "opt.g.none") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   258
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
                options.put("-g:", "none");
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   265
        new Option(G_CUSTOM,                                    "opt.g.lines.vars.source",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   266
                Option.ChoiceKind.ANYOF, "lines", "vars", "source"),
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   267
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   268
        new XOption(XLINT,                                      "opt.Xlint"),
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   269
        new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   270
                Option.ChoiceKind.ANYOF, getXLintChoices()),
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   271
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   272
        // -nowarn is retained for command-line backward compatibility
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   273
        new Option(NOWARN,                                      "opt.nowarn") {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   274
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
            public boolean process(Options options, String option) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   276
                options.put("-Xlint:none", option);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        new Option(VERBOSE,                                     "opt.verbose"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
        // -deprecation is retained for command-line backward compatibility
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
        new Option(DEPRECATION,                                 "opt.deprecation") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   285
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   286
            public boolean process(Options options, String option) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   287
                options.put("-Xlint:deprecation", option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   288
                return false;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   289
            }
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   290
        },
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
        new Option(CLASSPATH,              "opt.arg.path",      "opt.classpath"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
        new Option(CP,                     "opt.arg.path",      "opt.classpath") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   294
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
                return super.process(options, "-classpath", arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
        new Option(SOURCEPATH,             "opt.arg.path",      "opt.sourcepath"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
        new Option(BOOTCLASSPATH,          "opt.arg.path",      "opt.bootclasspath") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   301
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
                options.remove("-Xbootclasspath/p:");
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
                options.remove("-Xbootclasspath/a:");
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
                return super.process(options, option, arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
        new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
        new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
        new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   311
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
                options.remove("-Xbootclasspath/p:");
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
                options.remove("-Xbootclasspath/a:");
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
                return super.process(options, "-bootclasspath", arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
        new Option(EXTDIRS,                "opt.arg.dirs",      "opt.extdirs"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
        new XOption(DJAVA_EXT_DIRS,        "opt.arg.dirs",      "opt.extdirs") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   320
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
                return super.process(options, "-extdirs", arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
        new Option(ENDORSEDDIRS,            "opt.arg.dirs",     "opt.endorseddirs"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
        new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs",     "opt.endorseddirs") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   327
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
                return super.process(options, "-endorseddirs", arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
        },
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   332
        new Option(PROC,                                 "opt.proc.none.only",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   333
                Option.ChoiceKind.ONEOF, "none", "only"),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
        new Option(PROCESSOR,           "opt.arg.class.list",   "opt.processor"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
        new Option(PROCESSORPATH,       "opt.arg.path",         "opt.processorpath"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
        new Option(D,                   "opt.arg.directory",    "opt.d"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
        new Option(S,                   "opt.arg.directory",    "opt.sourceDest"),
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   338
        new Option(IMPLICIT,                                    "opt.implicit",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   339
                Option.ChoiceKind.ONEOF, "none", "class"),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
        new Option(ENCODING,            "opt.arg.encoding",     "opt.encoding"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
        new Option(SOURCE,              "opt.arg.release",      "opt.source") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   342
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
            public boolean process(Options options, String option, String operand) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
                Source source = Source.lookup(operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
                if (source == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
                    helper.error("err.invalid.source", operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
                return super.process(options, option, operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
        new Option(TARGET,              "opt.arg.release",      "opt.target") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   353
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
            public boolean process(Options options, String option, String operand) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
                Target target = Target.lookup(operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
                if (target == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
                    helper.error("err.invalid.target", operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
                return super.process(options, option, operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
        new Option(VERSION,                                     "opt.version") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   364
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
                helper.printVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
        new HiddenOption(FULLVERSION) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   371
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
                helper.printFullVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
        new Option(HELP,                                        "opt.help") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   378
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
                helper.printHelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
        new Option(A,                "opt.arg.key.equals.value","opt.A") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   385
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   386
            String helpSynopsis() {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   387
                hasSuffix = true;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   388
                return super.helpSynopsis();
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   389
            }
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   390
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   391
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   392
            public boolean matches(String arg) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   393
                return arg.startsWith("-A");
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   394
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   396
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   397
            public boolean hasArg() {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   398
                return false;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   399
            }
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   400
            // Mapping for processor options created in
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   401
            // JavacProcessingEnvironment
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
            public boolean process(Options options, String option) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   404
                int argLength = option.length();
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   405
                if (argLength == 2) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   406
                    helper.error("err.empty.A.argument");
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   407
                    return true;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
                }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   409
                int sepIndex = option.indexOf('=');
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   410
                String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   411
                if (!JavacProcessingEnvironment.isValidOptionName(key)) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   412
                    helper.error("err.invalid.A.key", option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   413
                    return true;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
                }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   415
                return process(options, option, option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   416
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
        new Option(X,                                           "opt.X") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   419
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
                helper.printXhelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
        // This option exists only for the purpose of documenting itself.
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
        // It's actually implemented by the launcher.
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
        new Option(J,                   "opt.arg.flag",         "opt.J") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   429
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
            String helpSynopsis() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
                hasSuffix = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
                return super.helpSynopsis();
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
            }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   434
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
                throw new AssertionError
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
                    ("the -J flag should be caught by the launcher.");
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
        // stop after parsing and attributing.
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
        // new HiddenOption("-attrparseonly"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
        // new Option("-moreinfo",                                      "opt.moreinfo") {
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
        new HiddenOption(MOREINFO) {
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
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
                Type.moreInfo = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
        // treat warnings as errors
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
        new HiddenOption(WERROR),
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
        // use complex inference from context in the position of a method call argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
        new HiddenOption(COMPLEXINFERENCE),
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
        // generare source stubs
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
        // new HiddenOption("-stubs"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
        // relax some constraints to allow compiling from stubs
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
        // new HiddenOption("-relax"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   464
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
        // output source after translating away inner classes
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
        // new Option("-printflat",                             "opt.printflat"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
        // new HiddenOption("-printflat"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
        // display scope search details
06bc494ca11e Initial load
duke
parents:
diff changeset
   470
        // new Option("-printsearch",                           "opt.printsearch"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   471
        // new HiddenOption("-printsearch"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   472
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
        // prompt after each error
06bc494ca11e Initial load
duke
parents:
diff changeset
   474
        // new Option("-prompt",                                        "opt.prompt"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
        new HiddenOption(PROMPT),
06bc494ca11e Initial load
duke
parents:
diff changeset
   476
06bc494ca11e Initial load
duke
parents:
diff changeset
   477
        // dump stack on error
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
        new HiddenOption(DOE),
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
06bc494ca11e Initial load
duke
parents:
diff changeset
   480
        // output source after type erasure
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
        // new Option("-s",                                     "opt.s"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
        new HiddenOption(PRINTSOURCE),
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
        // output shrouded class files
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
        // new Option("-scramble",                              "opt.scramble"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
        // new Option("-scrambleall",                           "opt.scrambleall"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
        // display warnings for generic unchecked operations
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
        new HiddenOption(WARNUNCHECKED) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   490
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   492
                options.put("-Xlint:unchecked", option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
        new XOption(XMAXERRS,           "opt.arg.number",       "opt.maxerrs"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   498
        new XOption(XMAXWARNS,          "opt.arg.number",       "opt.maxwarns"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   499
        new XOption(XSTDOUT,            "opt.arg.file",         "opt.Xstdout") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   500
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   501
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   502
                try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
                    helper.setOut(new PrintWriter(new FileWriter(arg), true));
06bc494ca11e Initial load
duke
parents:
diff changeset
   504
                } catch (java.io.IOException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   505
                    helper.error("err.error.writing.file", arg, e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   506
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   507
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   508
                return super.process(options, option, arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   509
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   510
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   511
06bc494ca11e Initial load
duke
parents:
diff changeset
   512
        new XOption(XPRINT,                                     "opt.print"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   513
06bc494ca11e Initial load
duke
parents:
diff changeset
   514
        new XOption(XPRINTROUNDS,                               "opt.printRounds"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   515
06bc494ca11e Initial load
duke
parents:
diff changeset
   516
        new XOption(XPRINTPROCESSORINFO,                        "opt.printProcessorInfo"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   517
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   518
        new XOption(XPREFER,                                    "opt.prefer",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   519
                Option.ChoiceKind.ONEOF, "source", "newer"),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   520
06bc494ca11e Initial load
duke
parents:
diff changeset
   521
        /* -O is a no-op, accepted for backward compatibility. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   522
        new HiddenOption(O),
06bc494ca11e Initial load
duke
parents:
diff changeset
   523
06bc494ca11e Initial load
duke
parents:
diff changeset
   524
        /* -Xjcov produces tables to support the code coverage tool jcov. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   525
        new HiddenOption(XJCOV),
06bc494ca11e Initial load
duke
parents:
diff changeset
   526
06bc494ca11e Initial load
duke
parents:
diff changeset
   527
        /* This is a back door to the compiler's option table.
06bc494ca11e Initial load
duke
parents:
diff changeset
   528
         * -XDx=y sets the option x to the value y.
06bc494ca11e Initial load
duke
parents:
diff changeset
   529
         * -XDx sets the option x to the value x.
06bc494ca11e Initial load
duke
parents:
diff changeset
   530
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   531
        new HiddenOption(XD) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   532
            String s;
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   533
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   534
            public boolean matches(String s) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   535
                this.s = s;
06bc494ca11e Initial load
duke
parents:
diff changeset
   536
                return s.startsWith(name.optionName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   537
            }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   538
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   539
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   540
                s = s.substring(name.optionName.length());
06bc494ca11e Initial load
duke
parents:
diff changeset
   541
                int eq = s.indexOf('=');
06bc494ca11e Initial load
duke
parents:
diff changeset
   542
                String key = (eq < 0) ? s : s.substring(0, eq);
06bc494ca11e Initial load
duke
parents:
diff changeset
   543
                String value = (eq < 0) ? s : s.substring(eq+1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   544
                options.put(key, value);
06bc494ca11e Initial load
duke
parents:
diff changeset
   545
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   546
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   547
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   548
06bc494ca11e Initial load
duke
parents:
diff changeset
   549
        /*
06bc494ca11e Initial load
duke
parents:
diff changeset
   550
         * TODO: With apt, the matches method accepts anything if
06bc494ca11e Initial load
duke
parents:
diff changeset
   551
         * -XclassAsDecls is used; code elsewhere does the lookup to
06bc494ca11e Initial load
duke
parents:
diff changeset
   552
         * see if the class name is both legal and found.
06bc494ca11e Initial load
duke
parents:
diff changeset
   553
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   554
         * In apt, the process method adds the candiate class file
06bc494ca11e Initial load
duke
parents:
diff changeset
   555
         * name to a separate list.
06bc494ca11e Initial load
duke
parents:
diff changeset
   556
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   557
        new HiddenOption(SOURCEFILE) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   558
            String s;
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   559
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   560
            public boolean matches(String s) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   561
                this.s = s;
06bc494ca11e Initial load
duke
parents:
diff changeset
   562
                return s.endsWith(".java")  // Java source file
06bc494ca11e Initial load
duke
parents:
diff changeset
   563
                    || SourceVersion.isName(s);   // Legal type name
06bc494ca11e Initial load
duke
parents:
diff changeset
   564
            }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   565
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   566
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   567
                if (s.endsWith(".java") ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   568
                    File f = new File(s);
06bc494ca11e Initial load
duke
parents:
diff changeset
   569
                    if (!f.exists()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   570
                        helper.error("err.file.not.found", f);
06bc494ca11e Initial load
duke
parents:
diff changeset
   571
                        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   572
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   573
                    if (!f.isFile()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   574
                        helper.error("err.file.not.file", f);
06bc494ca11e Initial load
duke
parents:
diff changeset
   575
                        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   576
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   577
                    helper.addFile(f);
06bc494ca11e Initial load
duke
parents:
diff changeset
   578
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   579
                else
06bc494ca11e Initial load
duke
parents:
diff changeset
   580
                    helper.addClassName(s);
06bc494ca11e Initial load
duke
parents:
diff changeset
   581
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   582
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   583
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   584
    };
06bc494ca11e Initial load
duke
parents:
diff changeset
   585
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   586
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   587
    private static Collection<String> getXLintChoices() {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   588
        Collection<String> choices = new LinkedHashSet<String>();
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   589
        choices.add("all");
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   590
        for (Lint.LintCategory c : Lint.LintCategory.values())
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   591
            choices.add(c.option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   592
        for (Lint.LintCategory c : Lint.LintCategory.values())
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   593
            choices.add("-" + c.option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   594
        choices.add("none");
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   595
        return choices;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   596
    }
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   597
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   598
}