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