author | jjg |
Thu, 04 Jan 2018 10:14:50 -0800 | |
changeset 48433 | 04d8d293e458 |
parent 48236 | 31febb3f66f7 |
child 48543 | 7067fe4e054e |
permissions | -rw-r--r-- |
11315 | 1 |
/* |
48433 | 2 |
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. |
11315 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.tools.javac.main; |
|
27 |
||
14960 | 28 |
import java.io.FileWriter; |
29 |
import java.io.PrintWriter; |
|
48433 | 30 |
import java.lang.module.ModuleDescriptor; |
36157
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
31 |
import java.nio.file.Files; |
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
32 |
import java.nio.file.Path; |
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
33 |
import java.nio.file.Paths; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
34 |
import java.text.Collator; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
35 |
import java.util.Arrays; |
11315 | 36 |
import java.util.Collections; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
37 |
import java.util.Comparator; |
14960 | 38 |
import java.util.EnumSet; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
39 |
import java.util.Iterator; |
41637 | 40 |
import java.util.LinkedHashSet; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
41 |
import java.util.Locale; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
42 |
import java.util.ServiceLoader; |
14960 | 43 |
import java.util.Set; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
44 |
import java.util.TreeSet; |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
45 |
import java.util.regex.Pattern; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
46 |
import java.util.stream.Collectors; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
47 |
import java.util.stream.StreamSupport; |
14960 | 48 |
|
49 |
import javax.lang.model.SourceVersion; |
|
50 |
||
48433 | 51 |
import jdk.internal.misc.VM; |
52 |
||
14960 | 53 |
import com.sun.tools.doclint.DocLint; |
11315 | 54 |
import com.sun.tools.javac.code.Lint; |
23114 | 55 |
import com.sun.tools.javac.code.Lint.LintCategory; |
11315 | 56 |
import com.sun.tools.javac.code.Source; |
57 |
import com.sun.tools.javac.code.Type; |
|
15724 | 58 |
import com.sun.tools.javac.jvm.Profile; |
11315 | 59 |
import com.sun.tools.javac.jvm.Target; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
60 |
import com.sun.tools.javac.platform.PlatformProvider; |
14960 | 61 |
import com.sun.tools.javac.processing.JavacProcessingEnvironment; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
62 |
import com.sun.tools.javac.util.Assert; |
14960 | 63 |
import com.sun.tools.javac.util.Log; |
64 |
import com.sun.tools.javac.util.Log.PrefixKind; |
|
65 |
import com.sun.tools.javac.util.Log.WriterKind; |
|
11315 | 66 |
import com.sun.tools.javac.util.Options; |
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
19670
diff
changeset
|
67 |
import com.sun.tools.javac.util.StringUtils; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
68 |
|
11315 | 69 |
import static com.sun.tools.javac.main.Option.ChoiceKind.*; |
14960 | 70 |
import static com.sun.tools.javac.main.Option.OptionGroup.*; |
11315 | 71 |
import static com.sun.tools.javac.main.Option.OptionKind.*; |
72 |
||
73 |
/** |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
74 |
* Options for javac. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
75 |
* The specific Option to handle a command-line option can be found by calling |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
76 |
* {@link #lookup}, which search some or all of the members of this enum in order, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
77 |
* looking for the first {@link #matches match}. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
78 |
* The action for an Option is performed {@link #handleOption}, which determines |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
79 |
* whether an argument is needed and where to find it; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
80 |
* {@code handleOption} then calls {@link #process process} providing a suitable |
11315 | 81 |
* {@link OptionHelper} to provide access the compiler state. |
82 |
* |
|
83 |
* <p><b>This is NOT part of any supported API. |
|
84 |
* If you write code that depends on this, you do so at your own |
|
85 |
* risk. This code and its internal interfaces are subject to change |
|
86 |
* or deletion without notice.</b></p> |
|
87 |
*/ |
|
88 |
public enum Option { |
|
89 |
G("-g", "opt.g", STANDARD, BASIC), |
|
90 |
||
91 |
G_NONE("-g:none", "opt.g.none", STANDARD, BASIC) { |
|
92 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
93 |
public void process(OptionHelper helper, String option) { |
11315 | 94 |
helper.put("-g:", "none"); |
95 |
} |
|
96 |
}, |
|
97 |
||
98 |
G_CUSTOM("-g:", "opt.g.lines.vars.source", |
|
99 |
STANDARD, BASIC, ANYOF, "lines", "vars", "source"), |
|
100 |
||
101 |
XLINT("-Xlint", "opt.Xlint", EXTENDED, BASIC), |
|
102 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
103 |
XLINT_CUSTOM("-Xlint:", "opt.arg.Xlint", "opt.Xlint.custom", EXTENDED, BASIC, ANYOF, getXLintChoices()) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
104 |
private final String LINT_KEY_FORMAT = LARGE_INDENT + " %-" + |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
105 |
(DEFAULT_SYNOPSIS_WIDTH + SMALL_INDENT.length() - LARGE_INDENT.length() - 2) + "s %s"; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
24298
diff
changeset
|
106 |
@Override |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
107 |
protected void help(Log log) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
108 |
super.help(log); |
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
109 |
log.printRawLines(WriterKind.STDOUT, |
23114 | 110 |
String.format(LINT_KEY_FORMAT, |
111 |
"all", |
|
112 |
log.localize(PrefixKind.JAVAC, "opt.Xlint.all"))); |
|
113 |
for (LintCategory lc : LintCategory.values()) { |
|
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
114 |
log.printRawLines(WriterKind.STDOUT, |
23114 | 115 |
String.format(LINT_KEY_FORMAT, |
116 |
lc.option, |
|
117 |
log.localize(PrefixKind.JAVAC, |
|
118 |
"opt.Xlint.desc." + lc.option))); |
|
119 |
} |
|
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
120 |
log.printRawLines(WriterKind.STDOUT, |
23114 | 121 |
String.format(LINT_KEY_FORMAT, |
122 |
"none", |
|
123 |
log.localize(PrefixKind.JAVAC, "opt.Xlint.none"))); |
|
124 |
} |
|
125 |
}, |
|
11315 | 126 |
|
14960 | 127 |
XDOCLINT("-Xdoclint", "opt.Xdoclint", EXTENDED, BASIC), |
128 |
||
129 |
XDOCLINT_CUSTOM("-Xdoclint:", "opt.Xdoclint.subopts", "opt.Xdoclint.custom", EXTENDED, BASIC) { |
|
130 |
@Override |
|
131 |
public boolean matches(String option) { |
|
132 |
return DocLint.isValidOption( |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
133 |
option.replace(XDOCLINT_CUSTOM.primaryName, DocLint.XMSGS_CUSTOM_PREFIX)); |
14960 | 134 |
} |
135 |
||
136 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
137 |
public void process(OptionHelper helper, String option) { |
14960 | 138 |
String prev = helper.get(XDOCLINT_CUSTOM); |
139 |
String next = (prev == null) ? option : (prev + " " + option); |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
140 |
helper.put(XDOCLINT_CUSTOM.primaryName, next); |
14960 | 141 |
} |
142 |
}, |
|
143 |
||
29427
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
144 |
XDOCLINT_PACKAGE("-Xdoclint/package:", "opt.Xdoclint.package.args", "opt.Xdoclint.package.desc", EXTENDED, BASIC) { |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
145 |
@Override |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
146 |
public boolean matches(String option) { |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
147 |
return DocLint.isValidOption( |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
148 |
option.replace(XDOCLINT_PACKAGE.primaryName, DocLint.XCHECK_PACKAGE)); |
29427
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
149 |
} |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
150 |
|
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
151 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
152 |
public void process(OptionHelper helper, String option) { |
29427
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
153 |
String prev = helper.get(XDOCLINT_PACKAGE); |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
154 |
String next = (prev == null) ? option : (prev + " " + option); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
155 |
helper.put(XDOCLINT_PACKAGE.primaryName, next); |
29427
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
156 |
} |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
157 |
}, |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
158 |
|
43145
35ee451a5fd3
8172474: javac should enable doclint checking for HTML 5
jjg
parents:
42823
diff
changeset
|
159 |
DOCLINT_FORMAT("--doclint-format", "opt.doclint.format", EXTENDED, BASIC, ONEOF, "html4", "html5"), |
35ee451a5fd3
8172474: javac should enable doclint checking for HTML 5
jjg
parents:
42823
diff
changeset
|
160 |
|
11315 | 161 |
// -nowarn is retained for command-line backward compatibility |
162 |
NOWARN("-nowarn", "opt.nowarn", STANDARD, BASIC) { |
|
163 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
164 |
public void process(OptionHelper helper, String option) { |
11315 | 165 |
helper.put("-Xlint:none", option); |
166 |
} |
|
167 |
}, |
|
168 |
||
169 |
VERBOSE("-verbose", "opt.verbose", STANDARD, BASIC), |
|
170 |
||
171 |
// -deprecation is retained for command-line backward compatibility |
|
172 |
DEPRECATION("-deprecation", "opt.deprecation", STANDARD, BASIC) { |
|
173 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
174 |
public void process(OptionHelper helper, String option) { |
11315 | 175 |
helper.put("-Xlint:deprecation", option); |
176 |
} |
|
177 |
}, |
|
178 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
179 |
CLASS_PATH("--class-path -classpath -cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
180 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
181 |
SOURCE_PATH("--source-path -sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
182 |
|
40762
f8883aa0053c
8160851: Remove old launcher module-related options
mchung
parents:
40308
diff
changeset
|
183 |
MODULE_SOURCE_PATH("--module-source-path", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER), |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
184 |
|
40762
f8883aa0053c
8160851: Remove old launcher module-related options
mchung
parents:
40308
diff
changeset
|
185 |
MODULE_PATH("--module-path -p", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER), |
11315 | 186 |
|
40762
f8883aa0053c
8160851: Remove old launcher module-related options
mchung
parents:
40308
diff
changeset
|
187 |
UPGRADE_MODULE_PATH("--upgrade-module-path", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER), |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
188 |
|
40762
f8883aa0053c
8160851: Remove old launcher module-related options
mchung
parents:
40308
diff
changeset
|
189 |
SYSTEM("--system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER), |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
190 |
|
40762
f8883aa0053c
8160851: Remove old launcher module-related options
mchung
parents:
40308
diff
changeset
|
191 |
PATCH_MODULE("--patch-module", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER) { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
192 |
// The deferred filemanager diagnostics mechanism assumes a single value per option, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
193 |
// but --patch-module can be used multiple times, once per module. Therefore we compose |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
194 |
// a value for the option containing the last value specified for each module, and separate |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
195 |
// the the module=path pairs by an invalid path character, NULL. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
196 |
// The standard file manager code knows to split apart the NULL-separated components. |
11315 | 197 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
198 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
41992
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
199 |
if (arg.isEmpty()) { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
200 |
throw helper.newInvalidValueException("err.no.value.for.option", option); |
41992
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
201 |
} else if (getPattern().matcher(arg).matches()) { |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
202 |
String prev = helper.get(PATCH_MODULE); |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
203 |
if (prev == null) { |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
204 |
super.process(helper, option, arg); |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
205 |
} else { |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
206 |
String argModulePackage = arg.substring(0, arg.indexOf('=')); |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
207 |
boolean isRepeated = Arrays.stream(prev.split("\0")) |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
208 |
.map(s -> s.substring(0, s.indexOf('='))) |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
209 |
.collect(Collectors.toSet()) |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
210 |
.contains(argModulePackage); |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
211 |
if (isRepeated) { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
212 |
throw helper.newInvalidValueException("err.repeated.value.for.patch.module", argModulePackage); |
41992
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
213 |
} else { |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
214 |
super.process(helper, option, prev + '\0' + arg); |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
215 |
} |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
216 |
} |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
217 |
} else { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
218 |
throw helper.newInvalidValueException("err.bad.value.for.option", option, arg); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
219 |
} |
41992
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
220 |
} |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
221 |
|
41992
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
222 |
@Override |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
223 |
public Pattern getPattern() { |
720257f5307d
8169447: javac should detect/reject repeated use of --patch-module on command line
jjg
parents:
41938
diff
changeset
|
224 |
return Pattern.compile("([^/]+)=(,*[^,].*)"); |
11315 | 225 |
} |
226 |
}, |
|
227 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
228 |
BOOT_CLASS_PATH("--boot-class-path -bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) { |
11315 | 229 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
230 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
11315 | 231 |
helper.remove("-Xbootclasspath/p:"); |
232 |
helper.remove("-Xbootclasspath/a:"); |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
233 |
super.process(helper, option, arg); |
11315 | 234 |
} |
235 |
}, |
|
236 |
||
237 |
XBOOTCLASSPATH_PREPEND("-Xbootclasspath/p:", "opt.arg.path", "opt.Xbootclasspath.p", EXTENDED, FILEMANAGER), |
|
238 |
||
239 |
XBOOTCLASSPATH_APPEND("-Xbootclasspath/a:", "opt.arg.path", "opt.Xbootclasspath.a", EXTENDED, FILEMANAGER), |
|
240 |
||
241 |
XBOOTCLASSPATH("-Xbootclasspath:", "opt.arg.path", "opt.bootclasspath", EXTENDED, FILEMANAGER) { |
|
242 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
243 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
11315 | 244 |
helper.remove("-Xbootclasspath/p:"); |
245 |
helper.remove("-Xbootclasspath/a:"); |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
246 |
super.process(helper, "-bootclasspath", arg); |
11315 | 247 |
} |
248 |
}, |
|
249 |
||
250 |
EXTDIRS("-extdirs", "opt.arg.dirs", "opt.extdirs", STANDARD, FILEMANAGER), |
|
251 |
||
252 |
DJAVA_EXT_DIRS("-Djava.ext.dirs=", "opt.arg.dirs", "opt.extdirs", EXTENDED, FILEMANAGER) { |
|
253 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
254 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
255 |
EXTDIRS.process(helper, "-extdirs", arg); |
11315 | 256 |
} |
257 |
}, |
|
258 |
||
259 |
ENDORSEDDIRS("-endorseddirs", "opt.arg.dirs", "opt.endorseddirs", STANDARD, FILEMANAGER), |
|
260 |
||
261 |
DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs=", "opt.arg.dirs", "opt.endorseddirs", EXTENDED, FILEMANAGER) { |
|
262 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
263 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
264 |
ENDORSEDDIRS.process(helper, "-endorseddirs", arg); |
11315 | 265 |
} |
266 |
}, |
|
267 |
||
268 |
PROC("-proc:", "opt.proc.none.only", STANDARD, BASIC, ONEOF, "none", "only"), |
|
269 |
||
270 |
PROCESSOR("-processor", "opt.arg.class.list", "opt.processor", STANDARD, BASIC), |
|
271 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
272 |
PROCESSOR_PATH("--processor-path -processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER), |
11315 | 273 |
|
40762
f8883aa0053c
8160851: Remove old launcher module-related options
mchung
parents:
40308
diff
changeset
|
274 |
PROCESSOR_MODULE_PATH("--processor-module-path", "opt.arg.path", "opt.processormodulepath", STANDARD, FILEMANAGER), |
36526 | 275 |
|
15031
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14960
diff
changeset
|
276 |
PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC), |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14960
diff
changeset
|
277 |
|
11315 | 278 |
D("-d", "opt.arg.directory", "opt.d", STANDARD, FILEMANAGER), |
279 |
||
280 |
S("-s", "opt.arg.directory", "opt.sourceDest", STANDARD, FILEMANAGER), |
|
281 |
||
12213
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
11317
diff
changeset
|
282 |
H("-h", "opt.arg.directory", "opt.headerDest", STANDARD, FILEMANAGER), |
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
11317
diff
changeset
|
283 |
|
11315 | 284 |
IMPLICIT("-implicit:", "opt.implicit", STANDARD, BASIC, ONEOF, "none", "class"), |
285 |
||
36155
1555ce1fcb4f
8149772: cleanup handling of -encoding in JavacFileManager
jjg
parents:
36153
diff
changeset
|
286 |
ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER), |
11315 | 287 |
|
288 |
SOURCE("-source", "opt.arg.release", "opt.source", STANDARD, BASIC) { |
|
289 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
290 |
public void process(OptionHelper helper, String option, String operand) throws InvalidValueException { |
11315 | 291 |
Source source = Source.lookup(operand); |
292 |
if (source == null) { |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
293 |
throw helper.newInvalidValueException("err.invalid.source", operand); |
11315 | 294 |
} |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
295 |
super.process(helper, option, operand); |
11315 | 296 |
} |
297 |
}, |
|
298 |
||
299 |
TARGET("-target", "opt.arg.release", "opt.target", STANDARD, BASIC) { |
|
300 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
301 |
public void process(OptionHelper helper, String option, String operand) throws InvalidValueException { |
11315 | 302 |
Target target = Target.lookup(operand); |
303 |
if (target == null) { |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
304 |
throw helper.newInvalidValueException("err.invalid.target", operand); |
11315 | 305 |
} |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
306 |
super.process(helper, option, operand); |
11315 | 307 |
} |
308 |
}, |
|
309 |
||
40762
f8883aa0053c
8160851: Remove old launcher module-related options
mchung
parents:
40308
diff
changeset
|
310 |
RELEASE("--release", "opt.arg.release", "opt.release", STANDARD, BASIC) { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
311 |
@Override |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
312 |
protected void help(Log log) { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
313 |
Iterable<PlatformProvider> providers = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
314 |
ServiceLoader.load(PlatformProvider.class, Arguments.class.getClassLoader()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
315 |
Set<String> platforms = StreamSupport.stream(providers.spliterator(), false) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
316 |
.flatMap(provider -> StreamSupport.stream(provider.getSupportedPlatformNames() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
317 |
.spliterator(), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
318 |
false)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
319 |
.collect(Collectors.toCollection(TreeSet :: new)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
320 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
321 |
StringBuilder targets = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
322 |
String delim = ""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
323 |
for (String platform : platforms) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
324 |
targets.append(delim); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
325 |
targets.append(platform); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
326 |
delim = ", "; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
327 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
328 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
329 |
super.help(log, log.localize(PrefixKind.JAVAC, descrKey, targets.toString())); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
330 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
331 |
}, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
332 |
|
15724 | 333 |
PROFILE("-profile", "opt.arg.profile", "opt.profile", STANDARD, BASIC) { |
334 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
335 |
public void process(OptionHelper helper, String option, String operand) throws InvalidValueException { |
15724 | 336 |
Profile profile = Profile.lookup(operand); |
337 |
if (profile == null) { |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
338 |
throw helper.newInvalidValueException("err.invalid.profile", operand); |
15724 | 339 |
} |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
340 |
super.process(helper, option, operand); |
15724 | 341 |
} |
342 |
}, |
|
343 |
||
42821
e5eee1c92be0
8170553: javac info options should match launcher options
jjg
parents:
42408
diff
changeset
|
344 |
VERSION("--version -version", "opt.version", STANDARD, INFO) { |
11315 | 345 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
346 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
11315 | 347 |
Log log = helper.getLog(); |
348 |
String ownName = helper.getOwnName(); |
|
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
349 |
log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "version", ownName, JavaCompiler.version()); |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
350 |
super.process(helper, option); |
11315 | 351 |
} |
352 |
}, |
|
353 |
||
42821
e5eee1c92be0
8170553: javac info options should match launcher options
jjg
parents:
42408
diff
changeset
|
354 |
FULLVERSION("--full-version -fullversion", null, HIDDEN, INFO) { |
11315 | 355 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
356 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
11315 | 357 |
Log log = helper.getLog(); |
358 |
String ownName = helper.getOwnName(); |
|
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
359 |
log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "fullVersion", ownName, JavaCompiler.fullVersion()); |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
360 |
super.process(helper, option); |
11315 | 361 |
} |
362 |
}, |
|
363 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
364 |
// Note: -h is already taken for "native header output directory". |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
365 |
HELP("--help -help", "opt.help", STANDARD, INFO) { |
11315 | 366 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
367 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
11315 | 368 |
Log log = helper.getLog(); |
369 |
String ownName = helper.getOwnName(); |
|
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
370 |
log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "msg.usage.header", ownName); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
371 |
showHelp(log, OptionKind.STANDARD); |
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
372 |
log.printNewline(WriterKind.STDOUT); |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
373 |
super.process(helper, option); |
11315 | 374 |
} |
375 |
}, |
|
376 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
377 |
A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, ArgKind.ADJACENT) { |
11315 | 378 |
@Override |
379 |
public boolean matches(String arg) { |
|
380 |
return arg.startsWith("-A"); |
|
381 |
} |
|
382 |
||
383 |
@Override |
|
384 |
public boolean hasArg() { |
|
385 |
return false; |
|
386 |
} |
|
387 |
// Mapping for processor options created in |
|
388 |
// JavacProcessingEnvironment |
|
389 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
390 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
11315 | 391 |
int argLength = option.length(); |
392 |
if (argLength == 2) { |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
393 |
throw helper.newInvalidValueException("err.empty.A.argument"); |
11315 | 394 |
} |
395 |
int sepIndex = option.indexOf('='); |
|
396 |
String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) ); |
|
397 |
if (!JavacProcessingEnvironment.isValidOptionName(key)) { |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
398 |
throw helper.newInvalidValueException("err.invalid.A.key", option); |
11315 | 399 |
} |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
400 |
helper.put(option, option); |
11315 | 401 |
} |
402 |
}, |
|
403 |
||
44291
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
404 |
DEFAULT_MODULE_FOR_CREATED_FILES("--default-module-for-created-files", |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
405 |
"opt.arg.default.module.for.created.files", |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
406 |
"opt.default.module.for.created.files", EXTENDED, BASIC) { |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
407 |
@Override |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
408 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
409 |
String prev = helper.get(DEFAULT_MODULE_FOR_CREATED_FILES); |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
410 |
if (prev != null) { |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
411 |
throw helper.newInvalidValueException("err.option.too.many", |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
412 |
DEFAULT_MODULE_FOR_CREATED_FILES.primaryName); |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
413 |
} else if (arg.isEmpty()) { |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
414 |
throw helper.newInvalidValueException("err.no.value.for.option", option); |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
415 |
} else if (getPattern().matcher(arg).matches()) { |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
416 |
helper.put(DEFAULT_MODULE_FOR_CREATED_FILES.primaryName, arg); |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
417 |
} else { |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
418 |
throw helper.newInvalidValueException("err.bad.value.for.option", option, arg); |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
419 |
} |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
420 |
} |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
421 |
|
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
422 |
@Override |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
423 |
public Pattern getPattern() { |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
424 |
return Pattern.compile("[^,].*"); |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
425 |
} |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
426 |
}, |
e1b620ac6c98
8175119: Need to specify module of types created by Filer.createSourceFile/Filer.createClassFile?
jlahoda
parents:
43772
diff
changeset
|
427 |
|
42821
e5eee1c92be0
8170553: javac info options should match launcher options
jjg
parents:
42408
diff
changeset
|
428 |
X("--help-extra -X", "opt.X", STANDARD, INFO) { |
11315 | 429 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
430 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
11315 | 431 |
Log log = helper.getLog(); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
432 |
showHelp(log, OptionKind.EXTENDED); |
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
433 |
log.printNewline(WriterKind.STDOUT); |
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
434 |
log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "msg.usage.nonstandard.footer"); |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
435 |
super.process(helper, option); |
11315 | 436 |
} |
437 |
}, |
|
438 |
||
439 |
// This option exists only for the purpose of documenting itself. |
|
440 |
// It's actually implemented by the launcher. |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
441 |
J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, ArgKind.ADJACENT) { |
11315 | 442 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
443 |
public void process(OptionHelper helper, String option) { |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40835
diff
changeset
|
444 |
throw new AssertionError("the -J flag should be caught by the launcher."); |
11315 | 445 |
} |
446 |
}, |
|
447 |
||
448 |
MOREINFO("-moreinfo", null, HIDDEN, BASIC) { |
|
449 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
450 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
11315 | 451 |
Type.moreInfo = true; |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
452 |
super.process(helper, option); |
11315 | 453 |
} |
454 |
}, |
|
455 |
||
456 |
// treat warnings as errors |
|
457 |
WERROR("-Werror", "opt.Werror", STANDARD, BASIC), |
|
458 |
||
459 |
// prompt after each error |
|
460 |
// new Option("-prompt", "opt.prompt"), |
|
461 |
PROMPT("-prompt", null, HIDDEN, BASIC), |
|
462 |
||
463 |
// dump stack on error |
|
464 |
DOE("-doe", null, HIDDEN, BASIC), |
|
465 |
||
466 |
// output source after type erasure |
|
467 |
PRINTSOURCE("-printsource", null, HIDDEN, BASIC), |
|
468 |
||
469 |
// display warnings for generic unchecked operations |
|
470 |
WARNUNCHECKED("-warnunchecked", null, HIDDEN, BASIC) { |
|
471 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
472 |
public void process(OptionHelper helper, String option) { |
11315 | 473 |
helper.put("-Xlint:unchecked", option); |
474 |
} |
|
475 |
}, |
|
476 |
||
477 |
XMAXERRS("-Xmaxerrs", "opt.arg.number", "opt.maxerrs", EXTENDED, BASIC), |
|
478 |
||
479 |
XMAXWARNS("-Xmaxwarns", "opt.arg.number", "opt.maxwarns", EXTENDED, BASIC), |
|
480 |
||
11316
4dcad625e72e
7111022: javac no long prints last round of processing
jjg
parents:
11315
diff
changeset
|
481 |
XSTDOUT("-Xstdout", "opt.arg.file", "opt.Xstdout", EXTENDED, INFO) { |
11315 | 482 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
483 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
11315 | 484 |
try { |
485 |
Log log = helper.getLog(); |
|
486 |
log.setWriters(new PrintWriter(new FileWriter(arg), true)); |
|
487 |
} catch (java.io.IOException e) { |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
488 |
throw helper.newInvalidValueException("err.error.writing.file", arg, e); |
11315 | 489 |
} |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
490 |
super.process(helper, option, arg); |
11315 | 491 |
} |
492 |
}, |
|
493 |
||
494 |
XPRINT("-Xprint", "opt.print", EXTENDED, BASIC), |
|
495 |
||
496 |
XPRINTROUNDS("-XprintRounds", "opt.printRounds", EXTENDED, BASIC), |
|
497 |
||
498 |
XPRINTPROCESSORINFO("-XprintProcessorInfo", "opt.printProcessorInfo", EXTENDED, BASIC), |
|
499 |
||
500 |
XPREFER("-Xprefer:", "opt.prefer", EXTENDED, BASIC, ONEOF, "source", "newer"), |
|
501 |
||
24298
cc4f0f71a505
8028196: Javac allows timestamps inside rt.jar to affect compilation when using -sourcepath.
alundblad
parents:
23792
diff
changeset
|
502 |
XXUSERPATHSFIRST("-XXuserPathsFirst", "opt.userpathsfirst", HIDDEN, BASIC), |
cc4f0f71a505
8028196: Javac allows timestamps inside rt.jar to affect compilation when using -sourcepath.
alundblad
parents:
23792
diff
changeset
|
503 |
|
19670
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
504 |
// see enum PkgInfo |
11315 | 505 |
XPKGINFO("-Xpkginfo:", "opt.pkginfo", EXTENDED, BASIC, ONEOF, "always", "legacy", "nonempty"), |
506 |
||
507 |
/* -O is a no-op, accepted for backward compatibility. */ |
|
508 |
O("-O", null, HIDDEN, BASIC), |
|
509 |
||
510 |
/* -Xjcov produces tables to support the code coverage tool jcov. */ |
|
511 |
XJCOV("-Xjcov", null, HIDDEN, BASIC), |
|
512 |
||
14548
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
12213
diff
changeset
|
513 |
PLUGIN("-Xplugin:", "opt.arg.plugin", "opt.plugin", EXTENDED, BASIC) { |
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
12213
diff
changeset
|
514 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
515 |
public void process(OptionHelper helper, String option) { |
36526 | 516 |
String p = option.substring(option.indexOf(':') + 1).trim(); |
14548
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
12213
diff
changeset
|
517 |
String prev = helper.get(PLUGIN); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
518 |
helper.put(PLUGIN.primaryName, (prev == null) ? p : prev + '\0' + p); |
14548
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
12213
diff
changeset
|
519 |
} |
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
12213
diff
changeset
|
520 |
}, |
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
12213
diff
changeset
|
521 |
|
17582
4079713129dd
8012003: Method diagnostics resolution need to be simplified in some cases
mcimadamore
parents:
15724
diff
changeset
|
522 |
XDIAGS("-Xdiags:", "opt.diags", EXTENDED, BASIC, ONEOF, "compact", "verbose"), |
4079713129dd
8012003: Method diagnostics resolution need to be simplified in some cases
mcimadamore
parents:
15724
diff
changeset
|
523 |
|
40835
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
524 |
DEBUG("--debug:", null, HIDDEN, BASIC) { |
39599 | 525 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
526 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
527 |
HiddenGroup.DEBUG.process(helper, option); |
39599 | 528 |
} |
529 |
}, |
|
530 |
||
40835
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
531 |
SHOULDSTOP("--should-stop:", null, HIDDEN, BASIC) { |
39601 | 532 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
533 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
534 |
HiddenGroup.SHOULDSTOP.process(helper, option); |
39601 | 535 |
} |
536 |
}, |
|
537 |
||
40835
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
538 |
DIAGS("--diags:", null, HIDDEN, BASIC) { |
39812 | 539 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
540 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
541 |
HiddenGroup.DIAGS.process(helper, option); |
39812 | 542 |
} |
543 |
}, |
|
544 |
||
545 |
/* This is a back door to the compiler's option table. |
|
546 |
* -XDx=y sets the option x to the value y. |
|
547 |
* -XDx sets the option x to the value x. |
|
548 |
*/ |
|
549 |
XD("-XD", null, HIDDEN, BASIC) { |
|
550 |
@Override |
|
551 |
public boolean matches(String s) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
552 |
return s.startsWith(primaryName); |
39812 | 553 |
} |
554 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
555 |
public void process(OptionHelper helper, String option) { |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
556 |
process(helper, option, option.substring(primaryName.length())); |
39812 | 557 |
} |
558 |
||
559 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
560 |
public void process(OptionHelper helper, String option, String arg) { |
39812 | 561 |
int eq = arg.indexOf('='); |
562 |
String key = (eq < 0) ? arg : arg.substring(0, eq); |
|
563 |
String value = (eq < 0) ? arg : arg.substring(eq+1); |
|
564 |
helper.put(key, value); |
|
565 |
} |
|
566 |
}, |
|
567 |
||
40762
f8883aa0053c
8160851: Remove old launcher module-related options
mchung
parents:
40308
diff
changeset
|
568 |
ADD_EXPORTS("--add-exports", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) { |
36526 | 569 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
570 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
571 |
if (arg.isEmpty()) { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
572 |
throw helper.newInvalidValueException("err.no.value.for.option", option); |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
573 |
} else if (getPattern().matcher(arg).matches()) { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
574 |
String prev = helper.get(ADD_EXPORTS); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
575 |
helper.put(ADD_EXPORTS.primaryName, (prev == null) ? arg : prev + '\0' + arg); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
576 |
} else { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
577 |
throw helper.newInvalidValueException("err.bad.value.for.option", option, arg); |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
578 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
579 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
580 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
581 |
@Override |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
582 |
public Pattern getPattern() { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
583 |
return Pattern.compile("([^/]+)/([^=]+)=(,*[^,].*)"); |
36526 | 584 |
} |
585 |
}, |
|
586 |
||
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41992
diff
changeset
|
587 |
ADD_OPENS("--add-opens", null, null, HIDDEN, BASIC), |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41992
diff
changeset
|
588 |
|
40762
f8883aa0053c
8160851: Remove old launcher module-related options
mchung
parents:
40308
diff
changeset
|
589 |
ADD_READS("--add-reads", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) { |
36526 | 590 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
591 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
592 |
if (arg.isEmpty()) { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
593 |
throw helper.newInvalidValueException("err.no.value.for.option", option); |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
594 |
} else if (getPattern().matcher(arg).matches()) { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
595 |
String prev = helper.get(ADD_READS); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
596 |
helper.put(ADD_READS.primaryName, (prev == null) ? arg : prev + '\0' + arg); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
597 |
} else { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
598 |
throw helper.newInvalidValueException("err.bad.value.for.option", option, arg); |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
599 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
600 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
601 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
602 |
@Override |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
603 |
public Pattern getPattern() { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
604 |
return Pattern.compile("([^=]+)=(,*[^,].*)"); |
36526 | 605 |
} |
606 |
}, |
|
607 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
608 |
MODULE("--module -m", "opt.arg.m", "opt.m", STANDARD, BASIC), |
36526 | 609 |
|
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
610 |
ADD_MODULES("--add-modules", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC) { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
611 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
612 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
613 |
if (arg.isEmpty()) { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
614 |
throw helper.newInvalidValueException("err.no.value.for.option", option); |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
615 |
} else if (getPattern().matcher(arg).matches()) { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
616 |
String prev = helper.get(ADD_MODULES); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
617 |
// since the individual values are simple names, we can simply join the |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
618 |
// values of multiple --add-modules options with ',' |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
619 |
helper.put(ADD_MODULES.primaryName, (prev == null) ? arg : prev + ',' + arg); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
620 |
} else { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
621 |
throw helper.newInvalidValueException("err.bad.value.for.option", option, arg); |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
622 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
623 |
} |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
624 |
|
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
625 |
@Override |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
626 |
public Pattern getPattern() { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
627 |
return Pattern.compile(",*[^,].*"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
628 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
629 |
}, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
630 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
631 |
LIMIT_MODULES("--limit-modules", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC) { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
632 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
633 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
634 |
if (arg.isEmpty()) { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
635 |
throw helper.newInvalidValueException("err.no.value.for.option", option); |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
636 |
} else if (getPattern().matcher(arg).matches()) { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
637 |
helper.put(LIMIT_MODULES.primaryName, arg); // last one wins |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
638 |
} else { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
639 |
throw helper.newInvalidValueException("err.bad.value.for.option", option, arg); |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
640 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
641 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
642 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
643 |
@Override |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
644 |
public Pattern getPattern() { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
645 |
return Pattern.compile(",*[^,].*"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
646 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
647 |
}, |
36526 | 648 |
|
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
649 |
MODULE_VERSION("--module-version", "opt.arg.module.version", "opt.module.version", STANDARD, BASIC) { |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
650 |
@Override |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
651 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
652 |
if (arg.isEmpty()) { |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
653 |
throw helper.newInvalidValueException("err.no.value.for.option", option); |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
654 |
} else { |
48433 | 655 |
// use official parser if available |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
656 |
try { |
48433 | 657 |
ModuleDescriptor.Version.parse(arg); |
658 |
} catch (IllegalArgumentException e) { |
|
659 |
throw helper.newInvalidValueException("err.bad.value.for.option", option, arg); |
|
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
660 |
} |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
661 |
} |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
662 |
super.process(helper, option, arg); |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
663 |
} |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
664 |
}, |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
665 |
|
11315 | 666 |
// This option exists only for the purpose of documenting itself. |
667 |
// It's actually implemented by the CommandLine class. |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
668 |
AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, ArgKind.ADJACENT) { |
11315 | 669 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
670 |
public void process(OptionHelper helper, String option) { |
11315 | 671 |
throw new AssertionError("the @ flag should be caught by CommandLine."); |
672 |
} |
|
673 |
}, |
|
674 |
||
36526 | 675 |
// Standalone positional argument: source file or type name. |
11315 | 676 |
SOURCEFILE("sourcefile", null, HIDDEN, INFO) { |
677 |
@Override |
|
678 |
public boolean matches(String s) { |
|
36526 | 679 |
if (s.endsWith(".java")) // Java source file |
680 |
return true; |
|
681 |
int sep = s.indexOf('/'); |
|
682 |
if (sep != -1) { |
|
683 |
return SourceVersion.isName(s.substring(0, sep)) |
|
684 |
&& SourceVersion.isName(s.substring(sep + 1)); |
|
685 |
} else { |
|
686 |
return SourceVersion.isName(s); // Legal type name |
|
687 |
} |
|
11315 | 688 |
} |
689 |
@Override |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
690 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
14801
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
691 |
if (option.endsWith(".java") ) { |
36157
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
692 |
Path p = Paths.get(option); |
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
693 |
if (!Files.exists(p)) { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
694 |
throw helper.newInvalidValueException("err.file.not.found", p); |
11315 | 695 |
} |
36157
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
696 |
if (!Files.isRegularFile(p)) { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
697 |
throw helper.newInvalidValueException("err.file.not.file", p); |
11315 | 698 |
} |
36157
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
699 |
helper.addFile(p); |
14801
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
700 |
} else { |
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
701 |
helper.addClassName(option); |
11315 | 702 |
} |
703 |
} |
|
37394
c36230ee15d9
8149757: Implement Multi-Release JAR aware JavacFileManager for javac
jjg
parents:
36526
diff
changeset
|
704 |
}, |
c36230ee15d9
8149757: Implement Multi-Release JAR aware JavacFileManager for javac
jjg
parents:
36526
diff
changeset
|
705 |
|
40762
f8883aa0053c
8160851: Remove old launcher module-related options
mchung
parents:
40308
diff
changeset
|
706 |
MULTIRELEASE("--multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER), |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
707 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
708 |
INHERIT_RUNTIME_ENVIRONMENT("--inherit-runtime-environment", "opt.inherit_runtime_environment", |
43372
4b28b3f27a64
8173312: Hide support for --inherit-runtime-environment
jjg
parents:
43145
diff
changeset
|
709 |
HIDDEN, BASIC) { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
710 |
@Override |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
711 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
48433 | 712 |
String[] runtimeArgs = VM.getRuntimeArguments(); |
713 |
for (String arg : runtimeArgs) { |
|
714 |
// Handle any supported runtime options; ignore all others. |
|
715 |
// The runtime arguments always use the single token form, e.g. "--name=value". |
|
716 |
for (Option o : getSupportedRuntimeOptions()) { |
|
717 |
if (o.matches(arg)) { |
|
718 |
switch (o) { |
|
719 |
case ADD_MODULES: |
|
720 |
int eq = arg.indexOf('='); |
|
721 |
Assert.check(eq > 0, () -> ("invalid runtime option:" + arg)); |
|
722 |
// --add-modules=ALL-DEFAULT is not supported at compile-time |
|
723 |
// so remove it from list, and only process the rest |
|
724 |
// if the set is non-empty. |
|
725 |
// Note that --add-modules=ALL-DEFAULT is automatically added |
|
726 |
// by the standard javac launcher. |
|
727 |
String mods = Arrays.stream(arg.substring(eq + 1).split(",")) |
|
728 |
.filter(s -> !s.isEmpty() && !s.equals("ALL-DEFAULT")) |
|
729 |
.collect(Collectors.joining(",")); |
|
730 |
if (!mods.isEmpty()) { |
|
731 |
String updatedArg = arg.substring(0, eq + 1) + mods; |
|
732 |
o.handleOption(helper, updatedArg, Collections.emptyIterator()); |
|
733 |
} |
|
734 |
break; |
|
735 |
default: |
|
736 |
o.handleOption(helper, arg, Collections.emptyIterator()); |
|
737 |
break; |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
738 |
} |
48433 | 739 |
break; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
740 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
741 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
742 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
743 |
} |
11315 | 744 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
745 |
private Option[] getSupportedRuntimeOptions() { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
746 |
Option[] supportedRuntimeOptions = { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
747 |
ADD_EXPORTS, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
748 |
ADD_MODULES, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
749 |
LIMIT_MODULES, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
750 |
MODULE_PATH, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
751 |
UPGRADE_MODULE_PATH, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
752 |
PATCH_MODULE |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
753 |
}; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
754 |
return supportedRuntimeOptions; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
755 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
756 |
}; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
757 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
758 |
/** |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
759 |
* This exception is thrown when an invalid value is given for an option. |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
760 |
* The detail string gives a detailed, localized message, suitable for use |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
761 |
* in error messages reported to the user. |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
762 |
*/ |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
763 |
public static class InvalidValueException extends Exception { |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
764 |
private static final long serialVersionUID = -1; |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
765 |
|
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
766 |
public InvalidValueException(String msg) { |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
767 |
super(msg); |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
768 |
} |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
769 |
|
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
770 |
public InvalidValueException(String msg, Throwable cause) { |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
771 |
super(msg, cause); |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
772 |
} |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
773 |
} |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
774 |
|
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
775 |
/** |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
776 |
* The kind of argument, if any, accepted by this option. The kind is augmented |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
777 |
* by characters in the name of the option. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
778 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
779 |
public enum ArgKind { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
780 |
/** This option does not take any argument. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
781 |
NONE, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
782 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
783 |
// Not currently supported |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
784 |
// /** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
785 |
// * This option takes an optional argument, which may be provided directly after an '=' |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
786 |
// * separator, or in the following argument position if that word does not itself appear |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
787 |
// * to be the name of an option. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
788 |
// */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
789 |
// OPTIONAL, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
790 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
791 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
792 |
* This option takes an argument. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
793 |
* If the name of option ends with ':' or '=', the argument must be provided directly |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
794 |
* after that separator. |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40835
diff
changeset
|
795 |
* Otherwise, it may appear after an '=' or in the following argument position. |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
796 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
797 |
REQUIRED, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
798 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
799 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
800 |
* This option takes an argument immediately after the option name, with no separator |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
801 |
* character. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
802 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
803 |
ADJACENT |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
804 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
805 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
806 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
807 |
* The kind of an Option. This is used by the -help and -X options. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
808 |
*/ |
11315 | 809 |
public enum OptionKind { |
810 |
/** A standard option, documented by -help. */ |
|
811 |
STANDARD, |
|
812 |
/** An extended option, documented by -X. */ |
|
813 |
EXTENDED, |
|
814 |
/** A hidden option, not documented. */ |
|
815 |
HIDDEN, |
|
816 |
} |
|
817 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
818 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
819 |
* The group for an Option. This determines the situations in which the |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
820 |
* option is applicable. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
821 |
*/ |
11315 | 822 |
enum OptionGroup { |
823 |
/** A basic option, available for use on the command line or via the |
|
824 |
* Compiler API. */ |
|
825 |
BASIC, |
|
826 |
/** An option for javac's standard JavaFileManager. Other file managers |
|
827 |
* may or may not support these options. */ |
|
828 |
FILEMANAGER, |
|
829 |
/** A command-line option that requests information, such as -help. */ |
|
830 |
INFO, |
|
831 |
/** A command-line "option" representing a file or class name. */ |
|
832 |
OPERAND |
|
833 |
} |
|
834 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
835 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
836 |
* The kind of choice for "choice" options. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
837 |
*/ |
11315 | 838 |
enum ChoiceKind { |
839 |
/** The expected value is exactly one of the set of choices. */ |
|
840 |
ONEOF, |
|
841 |
/** The expected value is one of more of the set of choices. */ |
|
842 |
ANYOF |
|
843 |
} |
|
844 |
||
39812 | 845 |
enum HiddenGroup { |
40835
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
846 |
DIAGS("diags"), |
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
847 |
DEBUG("debug"), |
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
848 |
SHOULDSTOP("should-stop"); |
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
849 |
|
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
850 |
static final Set<String> skipSet = new java.util.HashSet<>( |
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
851 |
Arrays.asList("--diags:", "--debug:", "--should-stop:")); |
39812 | 852 |
|
853 |
final String text; |
|
854 |
||
855 |
HiddenGroup(String text) { |
|
856 |
this.text = text; |
|
857 |
} |
|
858 |
||
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
859 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
39812 | 860 |
String p = option.substring(option.indexOf(':') + 1).trim(); |
861 |
String[] subOptions = p.split(";"); |
|
862 |
for (String subOption : subOptions) { |
|
863 |
subOption = text + "." + subOption.trim(); |
|
864 |
XD.process(helper, subOption, subOption); |
|
865 |
} |
|
866 |
} |
|
40835
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
867 |
|
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
868 |
static boolean skip(String name) { |
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
869 |
return skipSet.contains(name); |
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
870 |
} |
39812 | 871 |
} |
872 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
873 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
874 |
* The "primary name" for this option. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
875 |
* This is the name that is used to put values in the {@link Options} table. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
876 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
877 |
public final String primaryName; |
11315 | 878 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
879 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
880 |
* The set of names (primary name and aliases) for this option. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
881 |
* Note that some names may end in a separator, to indicate that an argument must immediately |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
882 |
* follow the separator (and cannot appear in the following argument position. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
883 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
884 |
public final String[] names; |
11315 | 885 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
886 |
/** Documentation key for arguments. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
887 |
protected final String argsNameKey; |
11315 | 888 |
|
889 |
/** Documentation key for description. |
|
890 |
*/ |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
891 |
protected final String descrKey; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
892 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
893 |
/** The kind of this option. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
894 |
private final OptionKind kind; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
895 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
896 |
/** The group for this option. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
897 |
private final OptionGroup group; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
898 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
899 |
/** The kind of argument for this option. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
900 |
private final ArgKind argKind; |
11315 | 901 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
902 |
/** The kind of choices for this option, if any. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
903 |
private final ChoiceKind choiceKind; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
904 |
|
41637 | 905 |
/** The choices for this option, if any. */ |
906 |
private final Set<String> choices; |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
907 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
908 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
909 |
* Looks up the first option matching the given argument in the full set of options. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
910 |
* @param arg the argument to be matches |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
911 |
* @return the first option that matches, or null if none. |
11315 | 912 |
*/ |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
913 |
public static Option lookup(String arg) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
914 |
return lookup(arg, EnumSet.allOf(Option.class)); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
915 |
} |
11315 | 916 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
917 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
918 |
* Looks up the first option matching the given argument within a set of options. |
41637 | 919 |
* @param arg the argument to be matched |
920 |
* @param options the set of possible options |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
921 |
* @return the first option that matches, or null if none. |
11315 | 922 |
*/ |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
923 |
public static Option lookup(String arg, Set<Option> options) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
924 |
for (Option option: options) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
925 |
if (option.matches(arg)) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
926 |
return option; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
927 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
928 |
return null; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
929 |
} |
11315 | 930 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
931 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
932 |
* Writes the "command line help" for given kind of option to the log. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
933 |
* @param log the log |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
934 |
* @param kind the kind of options to select |
11315 | 935 |
*/ |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
936 |
private static void showHelp(Log log, OptionKind kind) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
937 |
Comparator<Option> comp = new Comparator<Option>() { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
938 |
final Collator collator = Collator.getInstance(Locale.US); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
939 |
{ collator.setStrength(Collator.PRIMARY); } |
11315 | 940 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
941 |
@Override |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
942 |
public int compare(Option o1, Option o2) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
943 |
return collator.compare(o1.primaryName, o2.primaryName); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
944 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
945 |
}; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
946 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
947 |
getJavaCompilerOptions() |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
948 |
.stream() |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
949 |
.filter(o -> o.kind == kind) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
950 |
.sorted(comp) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
951 |
.forEach(o -> { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
952 |
o.help(log); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
953 |
}); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
954 |
} |
11315 | 955 |
|
956 |
Option(String text, String descrKey, |
|
957 |
OptionKind kind, OptionGroup group) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
958 |
this(text, null, descrKey, kind, group, null, null, ArgKind.NONE); |
39812 | 959 |
} |
960 |
||
11315 | 961 |
Option(String text, String argsNameKey, String descrKey, |
962 |
OptionKind kind, OptionGroup group) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
963 |
this(text, argsNameKey, descrKey, kind, group, null, null, ArgKind.REQUIRED); |
14801
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
964 |
} |
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
965 |
|
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
966 |
Option(String text, String argsNameKey, String descrKey, |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
967 |
OptionKind kind, OptionGroup group, ArgKind ak) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
968 |
this(text, argsNameKey, descrKey, kind, group, null, null, ak); |
11315 | 969 |
} |
970 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
971 |
Option(String text, String argsNameKey, String descrKey, OptionKind kind, OptionGroup group, |
41637 | 972 |
ChoiceKind choiceKind, Set<String> choices) { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
973 |
this(text, argsNameKey, descrKey, kind, group, choiceKind, choices, ArgKind.REQUIRED); |
11315 | 974 |
} |
975 |
||
976 |
Option(String text, String descrKey, |
|
977 |
OptionKind kind, OptionGroup group, |
|
978 |
ChoiceKind choiceKind, String... choices) { |
|
14801
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
979 |
this(text, null, descrKey, kind, group, choiceKind, |
41637 | 980 |
new LinkedHashSet<>(Arrays.asList(choices)), ArgKind.REQUIRED); |
11315 | 981 |
} |
982 |
||
983 |
private Option(String text, String argsNameKey, String descrKey, |
|
984 |
OptionKind kind, OptionGroup group, |
|
41637 | 985 |
ChoiceKind choiceKind, Set<String> choices, |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
986 |
ArgKind argKind) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
987 |
this.names = text.trim().split("\\s+"); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
988 |
Assert.check(names.length >= 1); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
989 |
this.primaryName = names[0]; |
11315 | 990 |
this.argsNameKey = argsNameKey; |
991 |
this.descrKey = descrKey; |
|
992 |
this.kind = kind; |
|
993 |
this.group = group; |
|
994 |
this.choiceKind = choiceKind; |
|
995 |
this.choices = choices; |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
996 |
this.argKind = argKind; |
11315 | 997 |
} |
998 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
999 |
public String getPrimaryName() { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1000 |
return primaryName; |
11315 | 1001 |
} |
1002 |
||
1003 |
public OptionKind getKind() { |
|
1004 |
return kind; |
|
1005 |
} |
|
1006 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1007 |
public ArgKind getArgKind() { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1008 |
return argKind; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1009 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1010 |
|
11315 | 1011 |
public boolean hasArg() { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1012 |
return (argKind != ArgKind.NONE); |
11315 | 1013 |
} |
1014 |
||
48236
31febb3f66f7
8189782: com.sun.tools.javac.api.JavacTool.isSupportedOption misreports number of arguments consumed
jlahoda
parents:
47216
diff
changeset
|
1015 |
public boolean hasSeparateArg() { |
31febb3f66f7
8189782: com.sun.tools.javac.api.JavacTool.isSupportedOption misreports number of arguments consumed
jlahoda
parents:
47216
diff
changeset
|
1016 |
return getArgKind() == ArgKind.REQUIRED && |
31febb3f66f7
8189782: com.sun.tools.javac.api.JavacTool.isSupportedOption misreports number of arguments consumed
jlahoda
parents:
47216
diff
changeset
|
1017 |
!primaryName.endsWith(":") && !primaryName.endsWith("="); |
31febb3f66f7
8189782: com.sun.tools.javac.api.JavacTool.isSupportedOption misreports number of arguments consumed
jlahoda
parents:
47216
diff
changeset
|
1018 |
} |
31febb3f66f7
8189782: com.sun.tools.javac.api.JavacTool.isSupportedOption misreports number of arguments consumed
jlahoda
parents:
47216
diff
changeset
|
1019 |
|
11315 | 1020 |
public boolean matches(String option) { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1021 |
for (String name: names) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1022 |
if (matches(option, name)) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1023 |
return true; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1024 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1025 |
return false; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1026 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1027 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1028 |
private boolean matches(String option, String name) { |
40835
6ab9ed1abc46
8162546: change hidden options -Xdebug to --debug, -XshouldStop to --should-stop, and -diags to --diags
vromero
parents:
40762
diff
changeset
|
1029 |
if (name.startsWith("--") && !HiddenGroup.skip(name)) { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1030 |
return option.equals(name) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1031 |
|| hasArg() && option.startsWith(name + "="); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1032 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1033 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1034 |
boolean hasSuffix = (argKind == ArgKind.ADJACENT) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1035 |
|| name.endsWith(":") || name.endsWith("="); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1036 |
|
11315 | 1037 |
if (!hasSuffix) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1038 |
return option.equals(name); |
11315 | 1039 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1040 |
if (!option.startsWith(name)) |
11315 | 1041 |
return false; |
1042 |
||
1043 |
if (choices != null) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1044 |
String arg = option.substring(name.length()); |
11315 | 1045 |
if (choiceKind == ChoiceKind.ONEOF) |
41637 | 1046 |
return choices.contains(arg); |
11315 | 1047 |
else { |
1048 |
for (String a: arg.split(",+")) { |
|
41637 | 1049 |
if (!choices.contains(a)) |
11315 | 1050 |
return false; |
1051 |
} |
|
1052 |
} |
|
1053 |
} |
|
1054 |
||
1055 |
return true; |
|
1056 |
} |
|
1057 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1058 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1059 |
* Handles an option. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1060 |
* If an argument for the option is required, depending on spec of the option, it will be found |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1061 |
* as part of the current arg (following ':' or '=') or in the following argument. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1062 |
* This is the recommended way to handle an option directly, instead of calling the underlying |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1063 |
* {@link #process process} methods. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1064 |
* @param helper a helper to provide access to the environment |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1065 |
* @param arg the arg string that identified this option |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1066 |
* @param rest the remaining strings to be analysed |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
1067 |
* @throws InvalidValueException if the value of the option was invalid |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1068 |
* @implNote The return value is the opposite of that used by {@link #process}. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1069 |
*/ |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
1070 |
public void handleOption(OptionHelper helper, String arg, Iterator<String> rest) throws InvalidValueException { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1071 |
if (hasArg()) { |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1072 |
String option; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1073 |
String operand; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1074 |
int sep = findSeparator(arg); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1075 |
if (getArgKind() == Option.ArgKind.ADJACENT) { |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1076 |
option = primaryName; // aliases not supported |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1077 |
operand = arg.substring(primaryName.length()); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1078 |
} else if (sep > 0) { |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1079 |
option = arg.substring(0, sep); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1080 |
operand = arg.substring(sep + 1); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1081 |
} else { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1082 |
if (!rest.hasNext()) { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
1083 |
throw helper.newInvalidValueException("err.req.arg", arg); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1084 |
} |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1085 |
option = arg; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1086 |
operand = rest.next(); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1087 |
} |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
1088 |
process(helper, option, operand); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1089 |
} else { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
1090 |
process(helper, arg); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1091 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1092 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1093 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1094 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1095 |
* Processes an option that either does not need an argument, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1096 |
* or which contains an argument within it, following a separator. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1097 |
* @param helper a helper to provide access to the environment |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1098 |
* @param option the option to be processed |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
1099 |
* @throws InvalidValueException if an error occurred |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1100 |
*/ |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
1101 |
public void process(OptionHelper helper, String option) throws InvalidValueException { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1102 |
if (argKind == ArgKind.NONE) { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
1103 |
process(helper, primaryName, option); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1104 |
} else { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1105 |
int sep = findSeparator(option); |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
1106 |
process(helper, primaryName, option.substring(sep + 1)); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1107 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1108 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1109 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1110 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1111 |
* Processes an option by updating the environment via a helper object. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1112 |
* @param helper a helper to provide access to the environment |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1113 |
* @param option the option to be processed |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1114 |
* @param arg the value to associate with the option, or a default value |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1115 |
* to be used if the option does not otherwise take an argument. |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42408
diff
changeset
|
1116 |
* @throws InvalidValueException if an error occurred |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1117 |
*/ |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41992
diff
changeset
|
1118 |
public void process(OptionHelper helper, String option, String arg) throws InvalidValueException { |
11315 | 1119 |
if (choices != null) { |
1120 |
if (choiceKind == ChoiceKind.ONEOF) { |
|
1121 |
// some clients like to see just one of option+choice set |
|
41637 | 1122 |
for (String s : choices) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1123 |
helper.remove(primaryName + s); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1124 |
String opt = primaryName + arg; |
11315 | 1125 |
helper.put(opt, opt); |
1126 |
// some clients like to see option (without trailing ":") |
|
1127 |
// set to arg |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1128 |
String nm = primaryName.substring(0, primaryName.length() - 1); |
11315 | 1129 |
helper.put(nm, arg); |
1130 |
} else { |
|
1131 |
// set option+word for each word in arg |
|
1132 |
for (String a: arg.split(",+")) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1133 |
String opt = primaryName + a; |
11315 | 1134 |
helper.put(opt, opt); |
1135 |
} |
|
1136 |
} |
|
1137 |
} |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1138 |
helper.put(primaryName, arg); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
24298
diff
changeset
|
1139 |
if (group == OptionGroup.FILEMANAGER) |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
24298
diff
changeset
|
1140 |
helper.handleFileManagerOption(this, arg); |
11315 | 1141 |
} |
1142 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1143 |
/** |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1144 |
* Returns a pattern to analyze the value for an option. |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1145 |
* @return the pattern |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1146 |
* @throws UnsupportedOperationException if an option does not provide a pattern. |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1147 |
*/ |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1148 |
public Pattern getPattern() { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1149 |
throw new UnsupportedOperationException(); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1150 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1151 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41637
diff
changeset
|
1152 |
/** |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1153 |
* Scans a word to find the first separator character, either colon or equals. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1154 |
* @param word the word to be scanned |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1155 |
* @return the position of the first':' or '=' character in the word, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1156 |
* or -1 if none found |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1157 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1158 |
private static int findSeparator(String word) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1159 |
for (int i = 0; i < word.length(); i++) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1160 |
switch (word.charAt(i)) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1161 |
case ':': case '=': |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1162 |
return i; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1163 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1164 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1165 |
return -1; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1166 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1167 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1168 |
/** The indent for the option synopsis. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1169 |
private static final String SMALL_INDENT = " "; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1170 |
/** The automatic indent for the description. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1171 |
private static final String LARGE_INDENT = " "; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1172 |
/** The space allowed for the synopsis, if the description is to be shown on the same line. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1173 |
private static final int DEFAULT_SYNOPSIS_WIDTH = 28; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1174 |
/** The nominal maximum line length, when seeing if text will fit on a line. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1175 |
private static final int DEFAULT_MAX_LINE_LENGTH = 80; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1176 |
/** The format for a single-line help entry. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1177 |
private static final String COMPACT_FORMAT = SMALL_INDENT + "%-" + DEFAULT_SYNOPSIS_WIDTH + "s %s"; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1178 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1179 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1180 |
* Writes help text for this option to the log. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1181 |
* @param log the log |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1182 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1183 |
protected void help(Log log) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1184 |
help(log, log.localize(PrefixKind.JAVAC, descrKey)); |
11315 | 1185 |
} |
1186 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1187 |
protected void help(Log log, String descr) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1188 |
String synopses = Arrays.stream(names) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1189 |
.map(s -> helpSynopsis(s, log)) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1190 |
.collect(Collectors.joining(", ")); |
11315 | 1191 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1192 |
// If option synopses and description fit on a single line of reasonable length, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1193 |
// display using COMPACT_FORMAT |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1194 |
if (synopses.length() < DEFAULT_SYNOPSIS_WIDTH |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1195 |
&& !descr.contains("\n") |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1196 |
&& (SMALL_INDENT.length() + DEFAULT_SYNOPSIS_WIDTH + 1 + descr.length() <= DEFAULT_MAX_LINE_LENGTH)) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1197 |
log.printRawLines(WriterKind.STDOUT, String.format(COMPACT_FORMAT, synopses, descr)); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1198 |
return; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1199 |
} |
11315 | 1200 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1201 |
// If option synopses fit on a single line of reasonable length, show that; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1202 |
// otherwise, show 1 per line |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1203 |
if (synopses.length() <= DEFAULT_MAX_LINE_LENGTH) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1204 |
log.printRawLines(WriterKind.STDOUT, SMALL_INDENT + synopses); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1205 |
} else { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1206 |
for (String name: names) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1207 |
log.printRawLines(WriterKind.STDOUT, SMALL_INDENT + helpSynopsis(name, log)); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1208 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1209 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1210 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1211 |
// Finally, show the description |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1212 |
log.printRawLines(WriterKind.STDOUT, LARGE_INDENT + descr.replace("\n", "\n" + LARGE_INDENT)); |
11315 | 1213 |
} |
1214 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1215 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1216 |
* Composes the initial synopsis of one of the forms for this option. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1217 |
* @param name the name of this form of the option |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1218 |
* @param log the log used to localize the description of the arguments |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1219 |
* @return the synopsis |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1220 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1221 |
private String helpSynopsis(String name, Log log) { |
11315 | 1222 |
StringBuilder sb = new StringBuilder(); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1223 |
sb.append(name); |
11315 | 1224 |
if (argsNameKey == null) { |
1225 |
if (choices != null) { |
|
43145
35ee451a5fd3
8172474: javac should enable doclint checking for HTML 5
jjg
parents:
42823
diff
changeset
|
1226 |
if (!name.endsWith(":")) |
35ee451a5fd3
8172474: javac should enable doclint checking for HTML 5
jjg
parents:
42823
diff
changeset
|
1227 |
sb.append(" "); |
11315 | 1228 |
String sep = "{"; |
41637 | 1229 |
for (String choice : choices) { |
1230 |
sb.append(sep); |
|
43145
35ee451a5fd3
8172474: javac should enable doclint checking for HTML 5
jjg
parents:
42823
diff
changeset
|
1231 |
sb.append(choice); |
41637 | 1232 |
sep = ","; |
11315 | 1233 |
} |
1234 |
sb.append("}"); |
|
1235 |
} |
|
1236 |
} else { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1237 |
if (!name.matches(".*[=:]$") && argKind != ArgKind.ADJACENT) |
11315 | 1238 |
sb.append(" "); |
1239 |
sb.append(log.localize(PrefixKind.JAVAC, argsNameKey)); |
|
1240 |
} |
|
1241 |
||
1242 |
return sb.toString(); |
|
1243 |
} |
|
1244 |
||
1245 |
// For -XpkgInfo:value |
|
1246 |
public enum PkgInfo { |
|
19670
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1247 |
/** |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1248 |
* Always generate package-info.class for every package-info.java file. |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1249 |
* The file may be empty if there annotations with a RetentionPolicy |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1250 |
* of CLASS or RUNTIME. This option may be useful in conjunction with |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1251 |
* build systems (such as Ant) that expect javac to generate at least |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1252 |
* one .class file for every .java file. |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1253 |
*/ |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1254 |
ALWAYS, |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1255 |
/** |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1256 |
* Generate a package-info.class file if package-info.java contains |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1257 |
* annotations. The file may be empty if all the annotations have |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1258 |
* a RetentionPolicy of SOURCE. |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1259 |
* This value is just for backwards compatibility with earlier behavior. |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1260 |
* Either of the other two values are to be preferred to using this one. |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1261 |
*/ |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1262 |
LEGACY, |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1263 |
/** |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1264 |
* Generate a package-info.class file if and only if there are annotations |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1265 |
* in package-info.java to be written into it. |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1266 |
*/ |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1267 |
NONEMPTY; |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1268 |
|
11315 | 1269 |
public static PkgInfo get(Options options) { |
1270 |
String v = options.get(XPKGINFO); |
|
1271 |
return (v == null |
|
1272 |
? PkgInfo.LEGACY |
|
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
19670
diff
changeset
|
1273 |
: PkgInfo.valueOf(StringUtils.toUpperCase(v))); |
11315 | 1274 |
} |
1275 |
} |
|
1276 |
||
41637 | 1277 |
private static Set<String> getXLintChoices() { |
1278 |
Set<String> choices = new LinkedHashSet<>(); |
|
1279 |
choices.add("all"); |
|
1280 |
for (Lint.LintCategory c : Lint.LintCategory.values()) { |
|
1281 |
choices.add(c.option); |
|
1282 |
choices.add("-" + c.option); |
|
1283 |
} |
|
1284 |
choices.add("none"); |
|
11315 | 1285 |
return choices; |
1286 |
} |
|
1287 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1288 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1289 |
* Returns the set of options supported by the command line tool. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1290 |
* @return the set of options. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1291 |
*/ |
11315 | 1292 |
static Set<Option> getJavaCompilerOptions() { |
1293 |
return EnumSet.allOf(Option.class); |
|
1294 |
} |
|
1295 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1296 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1297 |
* Returns the set of options supported by the built-in file manager. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1298 |
* @return the set of options. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1299 |
*/ |
11315 | 1300 |
public static Set<Option> getJavacFileManagerOptions() { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1301 |
return getOptions(FILEMANAGER); |
11315 | 1302 |
} |
1303 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1304 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1305 |
* Returns the set of options supported by this implementation of |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1306 |
* the JavaCompiler API, via {@link JavaCompiler#getTask}. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1307 |
* @return the set of options. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1308 |
*/ |
11315 | 1309 |
public static Set<Option> getJavacToolOptions() { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1310 |
return getOptions(BASIC); |
11315 | 1311 |
} |
1312 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1313 |
private static Set<Option> getOptions(OptionGroup group) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1314 |
return Arrays.stream(Option.values()) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1315 |
.filter(o -> o.group == group) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1316 |
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Option.class))); |
11315 | 1317 |
} |
1318 |
||
1319 |
} |