author | jjg |
Wed, 10 Aug 2016 15:47:46 -0700 | |
changeset 40308 | 274367a99f98 |
parent 40232 | 4995ab1a4558 |
child 40762 | f8883aa0053c |
permissions | -rw-r--r-- |
11315 | 1 |
/* |
36153 | 2 |
* Copyright (c) 2006, 2016, 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; |
|
36157
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
30 |
import java.nio.file.Files; |
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
31 |
import java.nio.file.Path; |
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
32 |
import java.nio.file.Paths; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
33 |
import java.text.Collator; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
34 |
import java.util.Arrays; |
11315 | 35 |
import java.util.Collections; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
36 |
import java.util.Comparator; |
14960 | 37 |
import java.util.EnumSet; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
38 |
import java.util.Iterator; |
14960 | 39 |
import java.util.LinkedHashMap; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
40 |
import java.util.Locale; |
14960 | 41 |
import java.util.Map; |
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; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
45 |
import java.util.stream.Collectors; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
46 |
import java.util.stream.StreamSupport; |
14960 | 47 |
|
48 |
import javax.lang.model.SourceVersion; |
|
49 |
||
50 |
import com.sun.tools.doclint.DocLint; |
|
11315 | 51 |
import com.sun.tools.javac.code.Lint; |
23114 | 52 |
import com.sun.tools.javac.code.Lint.LintCategory; |
11315 | 53 |
import com.sun.tools.javac.code.Source; |
54 |
import com.sun.tools.javac.code.Type; |
|
15724 | 55 |
import com.sun.tools.javac.jvm.Profile; |
11315 | 56 |
import com.sun.tools.javac.jvm.Target; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
57 |
import com.sun.tools.javac.platform.PlatformProvider; |
14960 | 58 |
import com.sun.tools.javac.processing.JavacProcessingEnvironment; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
59 |
import com.sun.tools.javac.resources.CompilerProperties.Errors; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
60 |
import com.sun.tools.javac.util.Assert; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
61 |
import com.sun.tools.javac.util.JDK9Wrappers; |
14960 | 62 |
import com.sun.tools.javac.util.Log; |
63 |
import com.sun.tools.javac.util.Log.PrefixKind; |
|
64 |
import com.sun.tools.javac.util.Log.WriterKind; |
|
11315 | 65 |
import com.sun.tools.javac.util.Options; |
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
19670
diff
changeset
|
66 |
import com.sun.tools.javac.util.StringUtils; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
67 |
|
11315 | 68 |
import static com.sun.tools.javac.main.Option.ChoiceKind.*; |
14960 | 69 |
import static com.sun.tools.javac.main.Option.OptionGroup.*; |
11315 | 70 |
import static com.sun.tools.javac.main.Option.OptionKind.*; |
71 |
||
72 |
/** |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
73 |
* Options for javac. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
74 |
* 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
|
75 |
* {@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
|
76 |
* looking for the first {@link #matches match}. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
77 |
* 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
|
78 |
* 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
|
79 |
* {@code handleOption} then calls {@link #process process} providing a suitable |
11315 | 80 |
* {@link OptionHelper} to provide access the compiler state. |
81 |
* |
|
82 |
* <p><b>This is NOT part of any supported API. |
|
83 |
* If you write code that depends on this, you do so at your own |
|
84 |
* risk. This code and its internal interfaces are subject to change |
|
85 |
* or deletion without notice.</b></p> |
|
86 |
*/ |
|
87 |
public enum Option { |
|
88 |
G("-g", "opt.g", STANDARD, BASIC), |
|
89 |
||
90 |
G_NONE("-g:none", "opt.g.none", STANDARD, BASIC) { |
|
91 |
@Override |
|
92 |
public boolean process(OptionHelper helper, String option) { |
|
93 |
helper.put("-g:", "none"); |
|
94 |
return false; |
|
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()) { |
|
114 |
if (lc.hidden) continue; |
|
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
115 |
log.printRawLines(WriterKind.STDOUT, |
23114 | 116 |
String.format(LINT_KEY_FORMAT, |
117 |
lc.option, |
|
118 |
log.localize(PrefixKind.JAVAC, |
|
119 |
"opt.Xlint.desc." + lc.option))); |
|
120 |
} |
|
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
121 |
log.printRawLines(WriterKind.STDOUT, |
23114 | 122 |
String.format(LINT_KEY_FORMAT, |
123 |
"none", |
|
124 |
log.localize(PrefixKind.JAVAC, "opt.Xlint.none"))); |
|
125 |
} |
|
126 |
}, |
|
11315 | 127 |
|
14960 | 128 |
XDOCLINT("-Xdoclint", "opt.Xdoclint", EXTENDED, BASIC), |
129 |
||
130 |
XDOCLINT_CUSTOM("-Xdoclint:", "opt.Xdoclint.subopts", "opt.Xdoclint.custom", EXTENDED, BASIC) { |
|
131 |
@Override |
|
132 |
public boolean matches(String option) { |
|
133 |
return DocLint.isValidOption( |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
134 |
option.replace(XDOCLINT_CUSTOM.primaryName, DocLint.XMSGS_CUSTOM_PREFIX)); |
14960 | 135 |
} |
136 |
||
137 |
@Override |
|
138 |
public boolean process(OptionHelper helper, String option) { |
|
139 |
String prev = helper.get(XDOCLINT_CUSTOM); |
|
140 |
String next = (prev == null) ? option : (prev + " " + option); |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
141 |
helper.put(XDOCLINT_CUSTOM.primaryName, next); |
14960 | 142 |
return false; |
143 |
} |
|
144 |
}, |
|
145 |
||
29427
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
146 |
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
|
147 |
@Override |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
148 |
public boolean matches(String option) { |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
149 |
return DocLint.isValidOption( |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
150 |
option.replace(XDOCLINT_PACKAGE.primaryName, DocLint.XCHECK_PACKAGE)); |
29427
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
151 |
} |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
152 |
|
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
153 |
@Override |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
154 |
public boolean process(OptionHelper helper, String option) { |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
155 |
String prev = helper.get(XDOCLINT_PACKAGE); |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
156 |
String next = (prev == null) ? option : (prev + " " + option); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
157 |
helper.put(XDOCLINT_PACKAGE.primaryName, next); |
29427
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
158 |
return false; |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
159 |
} |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
160 |
}, |
44f4e6905b67
8071851: Provide filtering of doclint checking based on packages
jlahoda
parents:
26264
diff
changeset
|
161 |
|
11315 | 162 |
// -nowarn is retained for command-line backward compatibility |
163 |
NOWARN("-nowarn", "opt.nowarn", STANDARD, BASIC) { |
|
164 |
@Override |
|
165 |
public boolean process(OptionHelper helper, String option) { |
|
166 |
helper.put("-Xlint:none", option); |
|
167 |
return false; |
|
168 |
} |
|
169 |
}, |
|
170 |
||
171 |
VERBOSE("-verbose", "opt.verbose", STANDARD, BASIC), |
|
172 |
||
173 |
// -deprecation is retained for command-line backward compatibility |
|
174 |
DEPRECATION("-deprecation", "opt.deprecation", STANDARD, BASIC) { |
|
175 |
@Override |
|
176 |
public boolean process(OptionHelper helper, String option) { |
|
177 |
helper.put("-Xlint:deprecation", option); |
|
178 |
return false; |
|
179 |
} |
|
180 |
}, |
|
181 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
182 |
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
|
183 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
184 |
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
|
185 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
186 |
MODULE_SOURCE_PATH("--module-source-path -modulesourcepath", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
187 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
188 |
MODULE_PATH("--module-path -p -modulepath -mp", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER), |
11315 | 189 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
190 |
UPGRADE_MODULE_PATH("--upgrade-module-path -upgrademodulepath", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
191 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
192 |
SYSTEM("--system -system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
193 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
194 |
PATCH_MODULE("--patch-module -Xpatch:", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
195 |
// 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
|
196 |
// 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
|
197 |
// 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
|
198 |
// 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
|
199 |
// The standard file manager code knows to split apart the NULL-separated components. |
11315 | 200 |
@Override |
201 |
public boolean process(OptionHelper helper, String option, String arg) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
202 |
if (!arg.contains("=")) { // could be more strict regeex, e.g. "(?i)[a-z0-9_.]+=.*" |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
203 |
helper.error(Errors.LocnInvalidArgForXpatch(arg)); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
204 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
205 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
206 |
String previous = helper.get(this); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
207 |
if (previous == null) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
208 |
return super.process(helper, option, arg); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
209 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
210 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
211 |
Map<String,String> map = new LinkedHashMap<>(); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
212 |
for (String s : previous.split("\0")) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
213 |
int sep = s.indexOf('='); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
214 |
map.put(s.substring(0, sep), s.substring(sep + 1)); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
215 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
216 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
217 |
int sep = arg.indexOf('='); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
218 |
map.put(arg.substring(0, sep), arg.substring(sep + 1)); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
219 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
220 |
StringBuilder sb = new StringBuilder(); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
221 |
map.forEach((m, p) -> { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
222 |
if (sb.length() > 0) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
223 |
sb.append('\0'); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
224 |
sb.append(m).append('=').append(p); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
225 |
}); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
226 |
return super.process(helper, option, sb.toString()); |
11315 | 227 |
} |
228 |
}, |
|
229 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
230 |
BOOT_CLASS_PATH("--boot-class-path -bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) { |
11315 | 231 |
@Override |
232 |
public boolean process(OptionHelper helper, String option, String arg) { |
|
233 |
helper.remove("-Xbootclasspath/p:"); |
|
234 |
helper.remove("-Xbootclasspath/a:"); |
|
235 |
return super.process(helper, option, arg); |
|
236 |
} |
|
237 |
}, |
|
238 |
||
239 |
XBOOTCLASSPATH_PREPEND("-Xbootclasspath/p:", "opt.arg.path", "opt.Xbootclasspath.p", EXTENDED, FILEMANAGER), |
|
240 |
||
241 |
XBOOTCLASSPATH_APPEND("-Xbootclasspath/a:", "opt.arg.path", "opt.Xbootclasspath.a", EXTENDED, FILEMANAGER), |
|
242 |
||
243 |
XBOOTCLASSPATH("-Xbootclasspath:", "opt.arg.path", "opt.bootclasspath", EXTENDED, FILEMANAGER) { |
|
244 |
@Override |
|
245 |
public boolean process(OptionHelper helper, String option, String arg) { |
|
246 |
helper.remove("-Xbootclasspath/p:"); |
|
247 |
helper.remove("-Xbootclasspath/a:"); |
|
248 |
return super.process(helper, "-bootclasspath", arg); |
|
249 |
} |
|
250 |
}, |
|
251 |
||
252 |
EXTDIRS("-extdirs", "opt.arg.dirs", "opt.extdirs", STANDARD, FILEMANAGER), |
|
253 |
||
254 |
DJAVA_EXT_DIRS("-Djava.ext.dirs=", "opt.arg.dirs", "opt.extdirs", EXTENDED, FILEMANAGER) { |
|
255 |
@Override |
|
256 |
public boolean process(OptionHelper helper, String option, String arg) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
257 |
return EXTDIRS.process(helper, "-extdirs", arg); |
11315 | 258 |
} |
259 |
}, |
|
260 |
||
261 |
ENDORSEDDIRS("-endorseddirs", "opt.arg.dirs", "opt.endorseddirs", STANDARD, FILEMANAGER), |
|
262 |
||
263 |
DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs=", "opt.arg.dirs", "opt.endorseddirs", EXTENDED, FILEMANAGER) { |
|
264 |
@Override |
|
265 |
public boolean process(OptionHelper helper, String option, String arg) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
266 |
return ENDORSEDDIRS.process(helper, "-endorseddirs", arg); |
11315 | 267 |
} |
268 |
}, |
|
269 |
||
270 |
PROC("-proc:", "opt.proc.none.only", STANDARD, BASIC, ONEOF, "none", "only"), |
|
271 |
||
272 |
PROCESSOR("-processor", "opt.arg.class.list", "opt.processor", STANDARD, BASIC), |
|
273 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
274 |
PROCESSOR_PATH("--processor-path -processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER), |
11315 | 275 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
276 |
PROCESSOR_MODULE_PATH("--processor-module-path -processormodulepath", "opt.arg.path", "opt.processormodulepath", STANDARD, FILEMANAGER), |
36526 | 277 |
|
15031
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14960
diff
changeset
|
278 |
PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC), |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14960
diff
changeset
|
279 |
|
11315 | 280 |
D("-d", "opt.arg.directory", "opt.d", STANDARD, FILEMANAGER), |
281 |
||
282 |
S("-s", "opt.arg.directory", "opt.sourceDest", STANDARD, FILEMANAGER), |
|
283 |
||
12213
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
11317
diff
changeset
|
284 |
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
|
285 |
|
11315 | 286 |
IMPLICIT("-implicit:", "opt.implicit", STANDARD, BASIC, ONEOF, "none", "class"), |
287 |
||
36155
1555ce1fcb4f
8149772: cleanup handling of -encoding in JavacFileManager
jjg
parents:
36153
diff
changeset
|
288 |
ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER), |
11315 | 289 |
|
290 |
SOURCE("-source", "opt.arg.release", "opt.source", STANDARD, BASIC) { |
|
291 |
@Override |
|
292 |
public boolean process(OptionHelper helper, String option, String operand) { |
|
293 |
Source source = Source.lookup(operand); |
|
294 |
if (source == null) { |
|
295 |
helper.error("err.invalid.source", operand); |
|
296 |
return true; |
|
297 |
} |
|
298 |
return super.process(helper, option, operand); |
|
299 |
} |
|
300 |
}, |
|
301 |
||
302 |
TARGET("-target", "opt.arg.release", "opt.target", STANDARD, BASIC) { |
|
303 |
@Override |
|
304 |
public boolean process(OptionHelper helper, String option, String operand) { |
|
305 |
Target target = Target.lookup(operand); |
|
306 |
if (target == null) { |
|
307 |
helper.error("err.invalid.target", operand); |
|
308 |
return true; |
|
309 |
} |
|
310 |
return super.process(helper, option, operand); |
|
311 |
} |
|
312 |
}, |
|
313 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
314 |
RELEASE("--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
|
315 |
@Override |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
316 |
protected void help(Log log) { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
317 |
Iterable<PlatformProvider> providers = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
318 |
ServiceLoader.load(PlatformProvider.class, Arguments.class.getClassLoader()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
319 |
Set<String> platforms = StreamSupport.stream(providers.spliterator(), false) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
320 |
.flatMap(provider -> StreamSupport.stream(provider.getSupportedPlatformNames() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
321 |
.spliterator(), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
322 |
false)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
323 |
.collect(Collectors.toCollection(TreeSet :: new)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
324 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
325 |
StringBuilder targets = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
326 |
String delim = ""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
327 |
for (String platform : platforms) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
328 |
targets.append(delim); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
329 |
targets.append(platform); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
330 |
delim = ", "; |
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 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
333 |
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
|
334 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
335 |
}, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29427
diff
changeset
|
336 |
|
15724 | 337 |
PROFILE("-profile", "opt.arg.profile", "opt.profile", STANDARD, BASIC) { |
338 |
@Override |
|
339 |
public boolean process(OptionHelper helper, String option, String operand) { |
|
340 |
Profile profile = Profile.lookup(operand); |
|
341 |
if (profile == null) { |
|
342 |
helper.error("err.invalid.profile", operand); |
|
343 |
return true; |
|
344 |
} |
|
345 |
return super.process(helper, option, operand); |
|
346 |
} |
|
347 |
}, |
|
348 |
||
11315 | 349 |
VERSION("-version", "opt.version", STANDARD, INFO) { |
350 |
@Override |
|
351 |
public boolean process(OptionHelper helper, String option) { |
|
352 |
Log log = helper.getLog(); |
|
353 |
String ownName = helper.getOwnName(); |
|
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
354 |
log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "version", ownName, JavaCompiler.version()); |
11315 | 355 |
return super.process(helper, option); |
356 |
} |
|
357 |
}, |
|
358 |
||
359 |
FULLVERSION("-fullversion", null, HIDDEN, INFO) { |
|
360 |
@Override |
|
361 |
public boolean process(OptionHelper helper, String option) { |
|
362 |
Log log = helper.getLog(); |
|
363 |
String ownName = helper.getOwnName(); |
|
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
364 |
log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "fullVersion", ownName, JavaCompiler.fullVersion()); |
11315 | 365 |
return super.process(helper, option); |
366 |
} |
|
367 |
}, |
|
368 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
369 |
// 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
|
370 |
HELP("--help -help", "opt.help", STANDARD, INFO) { |
11315 | 371 |
@Override |
372 |
public boolean process(OptionHelper helper, String option) { |
|
373 |
Log log = helper.getLog(); |
|
374 |
String ownName = helper.getOwnName(); |
|
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
375 |
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
|
376 |
showHelp(log, OptionKind.STANDARD); |
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
377 |
log.printNewline(WriterKind.STDOUT); |
11315 | 378 |
return super.process(helper, option); |
379 |
} |
|
380 |
}, |
|
381 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
382 |
A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, ArgKind.ADJACENT) { |
11315 | 383 |
@Override |
384 |
public boolean matches(String arg) { |
|
385 |
return arg.startsWith("-A"); |
|
386 |
} |
|
387 |
||
388 |
@Override |
|
389 |
public boolean hasArg() { |
|
390 |
return false; |
|
391 |
} |
|
392 |
// Mapping for processor options created in |
|
393 |
// JavacProcessingEnvironment |
|
394 |
@Override |
|
395 |
public boolean process(OptionHelper helper, String option) { |
|
396 |
int argLength = option.length(); |
|
397 |
if (argLength == 2) { |
|
398 |
helper.error("err.empty.A.argument"); |
|
399 |
return true; |
|
400 |
} |
|
401 |
int sepIndex = option.indexOf('='); |
|
402 |
String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) ); |
|
403 |
if (!JavacProcessingEnvironment.isValidOptionName(key)) { |
|
404 |
helper.error("err.invalid.A.key", option); |
|
405 |
return true; |
|
406 |
} |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
407 |
helper.put(option, option); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
408 |
return false; |
11315 | 409 |
} |
410 |
}, |
|
411 |
||
412 |
X("-X", "opt.X", STANDARD, INFO) { |
|
413 |
@Override |
|
414 |
public boolean process(OptionHelper helper, String option) { |
|
415 |
Log log = helper.getLog(); |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
416 |
showHelp(log, OptionKind.EXTENDED); |
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
417 |
log.printNewline(WriterKind.STDOUT); |
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39812
diff
changeset
|
418 |
log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "msg.usage.nonstandard.footer"); |
11315 | 419 |
return super.process(helper, option); |
420 |
} |
|
421 |
}, |
|
422 |
||
423 |
// This option exists only for the purpose of documenting itself. |
|
424 |
// It's actually implemented by the launcher. |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
425 |
J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, ArgKind.ADJACENT) { |
11315 | 426 |
@Override |
427 |
public boolean process(OptionHelper helper, String option) { |
|
428 |
throw new AssertionError |
|
429 |
("the -J flag should be caught by the launcher."); |
|
430 |
} |
|
431 |
}, |
|
432 |
||
433 |
MOREINFO("-moreinfo", null, HIDDEN, BASIC) { |
|
434 |
@Override |
|
435 |
public boolean process(OptionHelper helper, String option) { |
|
436 |
Type.moreInfo = true; |
|
437 |
return super.process(helper, option); |
|
438 |
} |
|
439 |
}, |
|
440 |
||
441 |
// treat warnings as errors |
|
442 |
WERROR("-Werror", "opt.Werror", STANDARD, BASIC), |
|
443 |
||
444 |
// prompt after each error |
|
445 |
// new Option("-prompt", "opt.prompt"), |
|
446 |
PROMPT("-prompt", null, HIDDEN, BASIC), |
|
447 |
||
448 |
// dump stack on error |
|
449 |
DOE("-doe", null, HIDDEN, BASIC), |
|
450 |
||
451 |
// output source after type erasure |
|
452 |
PRINTSOURCE("-printsource", null, HIDDEN, BASIC), |
|
453 |
||
454 |
// display warnings for generic unchecked operations |
|
455 |
WARNUNCHECKED("-warnunchecked", null, HIDDEN, BASIC) { |
|
456 |
@Override |
|
457 |
public boolean process(OptionHelper helper, String option) { |
|
458 |
helper.put("-Xlint:unchecked", option); |
|
459 |
return false; |
|
460 |
} |
|
461 |
}, |
|
462 |
||
463 |
XMAXERRS("-Xmaxerrs", "opt.arg.number", "opt.maxerrs", EXTENDED, BASIC), |
|
464 |
||
465 |
XMAXWARNS("-Xmaxwarns", "opt.arg.number", "opt.maxwarns", EXTENDED, BASIC), |
|
466 |
||
11316
4dcad625e72e
7111022: javac no long prints last round of processing
jjg
parents:
11315
diff
changeset
|
467 |
XSTDOUT("-Xstdout", "opt.arg.file", "opt.Xstdout", EXTENDED, INFO) { |
11315 | 468 |
@Override |
469 |
public boolean process(OptionHelper helper, String option, String arg) { |
|
470 |
try { |
|
471 |
Log log = helper.getLog(); |
|
472 |
log.setWriters(new PrintWriter(new FileWriter(arg), true)); |
|
473 |
} catch (java.io.IOException e) { |
|
474 |
helper.error("err.error.writing.file", arg, e); |
|
475 |
return true; |
|
476 |
} |
|
477 |
return super.process(helper, option, arg); |
|
478 |
} |
|
479 |
}, |
|
480 |
||
481 |
XPRINT("-Xprint", "opt.print", EXTENDED, BASIC), |
|
482 |
||
483 |
XPRINTROUNDS("-XprintRounds", "opt.printRounds", EXTENDED, BASIC), |
|
484 |
||
485 |
XPRINTPROCESSORINFO("-XprintProcessorInfo", "opt.printProcessorInfo", EXTENDED, BASIC), |
|
486 |
||
487 |
XPREFER("-Xprefer:", "opt.prefer", EXTENDED, BASIC, ONEOF, "source", "newer"), |
|
488 |
||
24298
cc4f0f71a505
8028196: Javac allows timestamps inside rt.jar to affect compilation when using -sourcepath.
alundblad
parents:
23792
diff
changeset
|
489 |
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
|
490 |
|
19670
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
491 |
// see enum PkgInfo |
11315 | 492 |
XPKGINFO("-Xpkginfo:", "opt.pkginfo", EXTENDED, BASIC, ONEOF, "always", "legacy", "nonempty"), |
493 |
||
494 |
/* -O is a no-op, accepted for backward compatibility. */ |
|
495 |
O("-O", null, HIDDEN, BASIC), |
|
496 |
||
497 |
/* -Xjcov produces tables to support the code coverage tool jcov. */ |
|
498 |
XJCOV("-Xjcov", null, HIDDEN, BASIC), |
|
499 |
||
14548
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
12213
diff
changeset
|
500 |
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
|
501 |
@Override |
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
12213
diff
changeset
|
502 |
public boolean process(OptionHelper helper, String option) { |
36526 | 503 |
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
|
504 |
String prev = helper.get(PLUGIN); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
505 |
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
|
506 |
return false; |
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
12213
diff
changeset
|
507 |
} |
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
12213
diff
changeset
|
508 |
}, |
aa687b312c97
8001098: Provide a simple light-weight "plug-in" mechanism for javac
jjg
parents:
12213
diff
changeset
|
509 |
|
17582
4079713129dd
8012003: Method diagnostics resolution need to be simplified in some cases
mcimadamore
parents:
15724
diff
changeset
|
510 |
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
|
511 |
|
39599 | 512 |
XDEBUG("-Xdebug:", null, HIDDEN, BASIC) { |
513 |
@Override |
|
514 |
public boolean process(OptionHelper helper, String option) { |
|
515 |
String p = option.substring(option.indexOf(':') + 1).trim(); |
|
516 |
String[] subOptions = p.split(";"); |
|
517 |
for (String subOption : subOptions) { |
|
518 |
subOption = "debug." + subOption.trim(); |
|
519 |
XD.process(helper, subOption, subOption); |
|
520 |
} |
|
521 |
return false; |
|
522 |
} |
|
523 |
}, |
|
524 |
||
39601 | 525 |
XSHOULDSTOP("-Xshouldstop:", null, HIDDEN, BASIC) { |
526 |
@Override |
|
527 |
public boolean process(OptionHelper helper, String option) { |
|
528 |
String p = option.substring(option.indexOf(':') + 1).trim(); |
|
529 |
String[] subOptions = p.split(";"); |
|
530 |
for (String subOption : subOptions) { |
|
531 |
subOption = "shouldstop." + subOption.trim(); |
|
532 |
XD.process(helper, subOption, subOption); |
|
533 |
} |
|
534 |
return false; |
|
535 |
} |
|
536 |
}, |
|
537 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
538 |
DIAGS("-diags:", null, HIDDEN, BASIC) { |
39812 | 539 |
@Override |
540 |
public boolean process(OptionHelper helper, String option) { |
|
541 |
return HiddenGroup.DIAGS.process(helper, option); |
|
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 |
|
555 |
public boolean process(OptionHelper helper, String option) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
556 |
return process(helper, option, option.substring(primaryName.length())); |
39812 | 557 |
} |
558 |
||
559 |
@Override |
|
560 |
public boolean process(OptionHelper helper, String option, String arg) { |
|
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 |
return false; |
|
566 |
} |
|
567 |
}, |
|
568 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
569 |
ADD_EXPORTS("--add-exports -XaddExports:", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) { |
36526 | 570 |
@Override |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
571 |
public boolean process(OptionHelper helper, String option, String arg) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
572 |
String prev = helper.get(ADD_EXPORTS); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
573 |
helper.put(ADD_EXPORTS.primaryName, (prev == null) ? arg : prev + '\0' + arg); |
36526 | 574 |
return false; |
575 |
} |
|
576 |
}, |
|
577 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
578 |
ADD_READS("--add-reads -XaddReads:", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) { |
36526 | 579 |
@Override |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
580 |
public boolean process(OptionHelper helper, String option, String arg) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
581 |
String prev = helper.get(ADD_READS); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
582 |
helper.put(ADD_READS.primaryName, (prev == null) ? arg : prev + '\0' + arg); |
36526 | 583 |
return false; |
584 |
} |
|
585 |
}, |
|
586 |
||
587 |
XMODULE("-Xmodule:", "opt.arg.module", "opt.module", EXTENDED, BASIC) { |
|
588 |
@Override |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
589 |
public boolean process(OptionHelper helper, String option, String arg) { |
36526 | 590 |
String prev = helper.get(XMODULE); |
591 |
if (prev != null) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
592 |
helper.error("err.option.too.many", XMODULE.primaryName); |
36526 | 593 |
} |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
594 |
helper.put(XMODULE.primaryName, arg); |
36526 | 595 |
return false; |
596 |
} |
|
597 |
}, |
|
598 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
599 |
MODULE("--module -m", "opt.arg.m", "opt.m", STANDARD, BASIC), |
36526 | 600 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
601 |
ADD_MODULES("--add-modules -addmods", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
602 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
603 |
LIMIT_MODULES("--limit-modules -limitmods", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC), |
36526 | 604 |
|
11315 | 605 |
// This option exists only for the purpose of documenting itself. |
606 |
// 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
|
607 |
AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, ArgKind.ADJACENT) { |
11315 | 608 |
@Override |
609 |
public boolean process(OptionHelper helper, String option) { |
|
610 |
throw new AssertionError("the @ flag should be caught by CommandLine."); |
|
611 |
} |
|
612 |
}, |
|
613 |
||
36526 | 614 |
// Standalone positional argument: source file or type name. |
11315 | 615 |
SOURCEFILE("sourcefile", null, HIDDEN, INFO) { |
616 |
@Override |
|
617 |
public boolean matches(String s) { |
|
36526 | 618 |
if (s.endsWith(".java")) // Java source file |
619 |
return true; |
|
620 |
int sep = s.indexOf('/'); |
|
621 |
if (sep != -1) { |
|
622 |
return SourceVersion.isName(s.substring(0, sep)) |
|
623 |
&& SourceVersion.isName(s.substring(sep + 1)); |
|
624 |
} else { |
|
625 |
return SourceVersion.isName(s); // Legal type name |
|
626 |
} |
|
11315 | 627 |
} |
628 |
@Override |
|
629 |
public boolean process(OptionHelper helper, String option) { |
|
14801
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
630 |
if (option.endsWith(".java") ) { |
36157
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
631 |
Path p = Paths.get(option); |
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
632 |
if (!Files.exists(p)) { |
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
633 |
helper.error("err.file.not.found", p); |
11315 | 634 |
return true; |
635 |
} |
|
36157
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
636 |
if (!Files.isRegularFile(p)) { |
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
637 |
helper.error("err.file.not.file", p); |
11315 | 638 |
return true; |
639 |
} |
|
36157
fdbf6c9be2ab
8145472: replace remaining java.io.File with java.nio.file.Path
jjg
parents:
36155
diff
changeset
|
640 |
helper.addFile(p); |
14801
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
641 |
} else { |
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
642 |
helper.addClassName(option); |
11315 | 643 |
} |
644 |
return false; |
|
645 |
} |
|
37394
c36230ee15d9
8149757: Implement Multi-Release JAR aware JavacFileManager for javac
jjg
parents:
36526
diff
changeset
|
646 |
}, |
c36230ee15d9
8149757: Implement Multi-Release JAR aware JavacFileManager for javac
jjg
parents:
36526
diff
changeset
|
647 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
648 |
MULTIRELEASE("--multi-release -multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
649 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
650 |
INHERIT_RUNTIME_ENVIRONMENT("--inherit-runtime-environment", "opt.inherit_runtime_environment", |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
651 |
EXTENDED, BASIC) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
652 |
@Override |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
653 |
public boolean process(OptionHelper helper, String option) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
654 |
try { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
655 |
Class.forName(JDK9Wrappers.VMHelper.VM_CLASSNAME); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
656 |
String[] runtimeArgs = JDK9Wrappers.VMHelper.getRuntimeArguments(); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
657 |
for (String arg : runtimeArgs) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
658 |
// Handle any supported runtime options; ignore all others. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
659 |
// The runtime arguments always use the single token form, e.g. "--name=value". |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
660 |
for (Option o : getSupportedRuntimeOptions()) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
661 |
if (o.matches(arg)) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
662 |
o.handleOption(helper, arg, Collections.emptyIterator()); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
663 |
break; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
664 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
665 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
666 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
667 |
} catch (ClassNotFoundException | SecurityException e) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
668 |
helper.error("err.cannot.access.runtime.env"); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
669 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
670 |
return false; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
671 |
} |
11315 | 672 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
673 |
private Option[] getSupportedRuntimeOptions() { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
674 |
Option[] supportedRuntimeOptions = { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
675 |
ADD_EXPORTS, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
676 |
ADD_MODULES, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
677 |
LIMIT_MODULES, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
678 |
MODULE_PATH, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
679 |
UPGRADE_MODULE_PATH, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
680 |
PATCH_MODULE |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
681 |
}; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
682 |
return supportedRuntimeOptions; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
683 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
684 |
}; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
685 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
686 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
687 |
* 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
|
688 |
* by characters in the name of the option. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
689 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
690 |
public enum ArgKind { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
691 |
/** This option does not take any argument. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
692 |
NONE, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
693 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
694 |
// Not currently supported |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
695 |
// /** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
696 |
// * 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
|
697 |
// * 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
|
698 |
// * to be the name of an option. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
699 |
// */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
700 |
// OPTIONAL, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
701 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
702 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
703 |
* This option takes an argument. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
704 |
* 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
|
705 |
* after that separator. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
706 |
* Otherwise, if may appear after an '=' or in the following argument position. |
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 |
REQUIRED, |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
709 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
710 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
711 |
* 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
|
712 |
* character. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
713 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
714 |
ADJACENT |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
715 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
716 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
717 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
718 |
* 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
|
719 |
*/ |
11315 | 720 |
public enum OptionKind { |
721 |
/** A standard option, documented by -help. */ |
|
722 |
STANDARD, |
|
723 |
/** An extended option, documented by -X. */ |
|
724 |
EXTENDED, |
|
725 |
/** A hidden option, not documented. */ |
|
726 |
HIDDEN, |
|
727 |
} |
|
728 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
729 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
730 |
* 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
|
731 |
* option is applicable. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
732 |
*/ |
11315 | 733 |
enum OptionGroup { |
734 |
/** A basic option, available for use on the command line or via the |
|
735 |
* Compiler API. */ |
|
736 |
BASIC, |
|
737 |
/** An option for javac's standard JavaFileManager. Other file managers |
|
738 |
* may or may not support these options. */ |
|
739 |
FILEMANAGER, |
|
740 |
/** A command-line option that requests information, such as -help. */ |
|
741 |
INFO, |
|
742 |
/** A command-line "option" representing a file or class name. */ |
|
743 |
OPERAND |
|
744 |
} |
|
745 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
746 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
747 |
* The kind of choice for "choice" options. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
748 |
*/ |
11315 | 749 |
enum ChoiceKind { |
750 |
/** The expected value is exactly one of the set of choices. */ |
|
751 |
ONEOF, |
|
752 |
/** The expected value is one of more of the set of choices. */ |
|
753 |
ANYOF |
|
754 |
} |
|
755 |
||
39812 | 756 |
enum HiddenGroup { |
757 |
DIAGS("diags"); |
|
758 |
||
759 |
final String text; |
|
760 |
||
761 |
HiddenGroup(String text) { |
|
762 |
this.text = text; |
|
763 |
} |
|
764 |
||
765 |
public boolean process(OptionHelper helper, String option) { |
|
766 |
String p = option.substring(option.indexOf(':') + 1).trim(); |
|
767 |
String[] subOptions = p.split(";"); |
|
768 |
for (String subOption : subOptions) { |
|
769 |
subOption = text + "." + subOption.trim(); |
|
770 |
XD.process(helper, subOption, subOption); |
|
771 |
} |
|
772 |
return false; |
|
773 |
} |
|
774 |
} |
|
775 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
776 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
777 |
* The "primary name" for this option. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
778 |
* 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
|
779 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
780 |
public final String primaryName; |
11315 | 781 |
|
40308
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 |
* 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
|
784 |
* 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
|
785 |
* 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
|
786 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
787 |
public final String[] names; |
11315 | 788 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
789 |
/** Documentation key for arguments. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
790 |
protected final String argsNameKey; |
11315 | 791 |
|
792 |
/** Documentation key for description. |
|
793 |
*/ |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
794 |
protected final String descrKey; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
795 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
796 |
/** The kind of this option. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
797 |
private final OptionKind kind; |
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 |
/** The group for this option. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
800 |
private final OptionGroup group; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
801 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
802 |
/** The kind of argument for this option. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
803 |
private final ArgKind argKind; |
11315 | 804 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
805 |
/** 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
|
806 |
private final ChoiceKind choiceKind; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
807 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
808 |
/** The choices for this option, if any, and whether or not the choices are hidden. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
809 |
private final Map<String,Boolean> choices; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
810 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
811 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
812 |
* 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
|
813 |
* @param arg the argument to be matches |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
814 |
* @return the first option that matches, or null if none. |
11315 | 815 |
*/ |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
816 |
public static Option lookup(String arg) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
817 |
return lookup(arg, EnumSet.allOf(Option.class)); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
818 |
} |
11315 | 819 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
820 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
821 |
* Looks up the first option matching the given argument within a set of options. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
822 |
* @param arg the argument to be matches |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
823 |
* @return the first option that matches, or null if none. |
11315 | 824 |
*/ |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
825 |
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
|
826 |
for (Option option: options) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
827 |
if (option.matches(arg)) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
828 |
return option; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
829 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
830 |
return null; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
831 |
} |
11315 | 832 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
833 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
834 |
* 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
|
835 |
* @param log the log |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
836 |
* @param kind the kind of options to select |
11315 | 837 |
*/ |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
838 |
private static void showHelp(Log log, OptionKind kind) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
839 |
Comparator<Option> comp = new Comparator<Option>() { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
840 |
final Collator collator = Collator.getInstance(Locale.US); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
841 |
{ collator.setStrength(Collator.PRIMARY); } |
11315 | 842 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
843 |
@Override |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
844 |
public int compare(Option o1, Option o2) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
845 |
return collator.compare(o1.primaryName, o2.primaryName); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
846 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
847 |
}; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
848 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
849 |
getJavaCompilerOptions() |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
850 |
.stream() |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
851 |
.filter(o -> o.kind == kind) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
852 |
.sorted(comp) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
853 |
.forEach(o -> { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
854 |
o.help(log); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
855 |
}); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
856 |
} |
11315 | 857 |
|
858 |
Option(String text, String descrKey, |
|
859 |
OptionKind kind, OptionGroup group) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
860 |
this(text, null, descrKey, kind, group, null, null, ArgKind.NONE); |
39812 | 861 |
} |
862 |
||
11315 | 863 |
Option(String text, String argsNameKey, String descrKey, |
864 |
OptionKind kind, OptionGroup group) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
865 |
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
|
866 |
} |
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
867 |
|
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
868 |
Option(String text, String argsNameKey, String descrKey, |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
869 |
OptionKind kind, OptionGroup group, ArgKind ak) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
870 |
this(text, argsNameKey, descrKey, kind, group, null, null, ak); |
11315 | 871 |
} |
872 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
873 |
Option(String text, String argsNameKey, String descrKey, OptionKind kind, OptionGroup group, |
11315 | 874 |
ChoiceKind choiceKind, Map<String,Boolean> choices) { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
875 |
this(text, argsNameKey, descrKey, kind, group, choiceKind, choices, ArgKind.REQUIRED); |
11315 | 876 |
} |
877 |
||
878 |
Option(String text, String descrKey, |
|
879 |
OptionKind kind, OptionGroup group, |
|
880 |
ChoiceKind choiceKind, String... choices) { |
|
14801
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
881 |
this(text, null, descrKey, kind, group, choiceKind, |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
882 |
createChoices(choices), ArgKind.REQUIRED); |
11315 | 883 |
} |
884 |
// where |
|
885 |
private static Map<String,Boolean> createChoices(String... choices) { |
|
22163 | 886 |
Map<String,Boolean> map = new LinkedHashMap<>(); |
11315 | 887 |
for (String c: choices) |
888 |
map.put(c, false); |
|
889 |
return map; |
|
890 |
} |
|
891 |
||
892 |
private Option(String text, String argsNameKey, String descrKey, |
|
893 |
OptionKind kind, OptionGroup group, |
|
14801
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14548
diff
changeset
|
894 |
ChoiceKind choiceKind, Map<String,Boolean> choices, |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
895 |
ArgKind argKind) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
896 |
this.names = text.trim().split("\\s+"); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
897 |
Assert.check(names.length >= 1); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
898 |
this.primaryName = names[0]; |
11315 | 899 |
this.argsNameKey = argsNameKey; |
900 |
this.descrKey = descrKey; |
|
901 |
this.kind = kind; |
|
902 |
this.group = group; |
|
903 |
this.choiceKind = choiceKind; |
|
904 |
this.choices = choices; |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
905 |
this.argKind = argKind; |
11315 | 906 |
} |
907 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
908 |
public String getPrimaryName() { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
909 |
return primaryName; |
11315 | 910 |
} |
911 |
||
912 |
public OptionKind getKind() { |
|
913 |
return kind; |
|
914 |
} |
|
915 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
916 |
public ArgKind getArgKind() { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
917 |
return argKind; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
918 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
919 |
|
11315 | 920 |
public boolean hasArg() { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
921 |
return (argKind != ArgKind.NONE); |
11315 | 922 |
} |
923 |
||
924 |
public boolean matches(String option) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
925 |
for (String name: names) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
926 |
if (matches(option, name)) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
927 |
return true; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
928 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
929 |
return false; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
930 |
} |
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 |
private boolean matches(String option, String name) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
933 |
if (name.startsWith("--")) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
934 |
return option.equals(name) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
935 |
|| hasArg() && option.startsWith(name + "="); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
936 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
937 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
938 |
boolean hasSuffix = (argKind == ArgKind.ADJACENT) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
939 |
|| name.endsWith(":") || name.endsWith("="); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
940 |
|
11315 | 941 |
if (!hasSuffix) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
942 |
return option.equals(name); |
11315 | 943 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
944 |
if (!option.startsWith(name)) |
11315 | 945 |
return false; |
946 |
||
947 |
if (choices != null) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
948 |
String arg = option.substring(name.length()); |
11315 | 949 |
if (choiceKind == ChoiceKind.ONEOF) |
950 |
return choices.keySet().contains(arg); |
|
951 |
else { |
|
952 |
for (String a: arg.split(",+")) { |
|
953 |
if (!choices.keySet().contains(a)) |
|
954 |
return false; |
|
955 |
} |
|
956 |
} |
|
957 |
} |
|
958 |
||
959 |
return true; |
|
960 |
} |
|
961 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
962 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
963 |
* Handles an option. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
964 |
* 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
|
965 |
* 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
|
966 |
* 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
|
967 |
* {@link #process process} methods. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
968 |
* @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
|
969 |
* @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
|
970 |
* @param rest the remaining strings to be analysed |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
971 |
* @return true if the operation was successful, and false otherwise |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
972 |
* @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
|
973 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
974 |
public boolean handleOption(OptionHelper helper, String arg, Iterator<String> rest) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
975 |
if (hasArg()) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
976 |
String operand; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
977 |
int sep = findSeparator(arg); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
978 |
if (getArgKind() == Option.ArgKind.ADJACENT) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
979 |
operand = arg.substring(primaryName.length()); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
980 |
} else if (sep > 0) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
981 |
operand = arg.substring(sep + 1); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
982 |
} else { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
983 |
if (!rest.hasNext()) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
984 |
helper.error("err.req.arg", arg); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
985 |
return false; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
986 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
987 |
operand = rest.next(); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
988 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
989 |
return !process(helper, arg, operand); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
990 |
} else { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
991 |
return !process(helper, arg); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
992 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
993 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
994 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
995 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
996 |
* 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
|
997 |
* 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
|
998 |
* @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
|
999 |
* @param option the option to be processed |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1000 |
* @return true if an error occurred |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1001 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1002 |
public boolean process(OptionHelper helper, String option) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1003 |
if (argKind == ArgKind.NONE) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1004 |
return process(helper, primaryName, option); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1005 |
} else { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1006 |
int sep = findSeparator(option); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1007 |
return process(helper, primaryName, option.substring(sep + 1)); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1008 |
} |
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 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1011 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1012 |
* 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
|
1013 |
* @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
|
1014 |
* @param option the option to be processed |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1015 |
* @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
|
1016 |
* to be used if the option does not otherwise take an argument. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1017 |
* @return true if an error occurred |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1018 |
*/ |
11315 | 1019 |
public boolean process(OptionHelper helper, String option, String arg) { |
1020 |
if (choices != null) { |
|
1021 |
if (choiceKind == ChoiceKind.ONEOF) { |
|
1022 |
// some clients like to see just one of option+choice set |
|
1023 |
for (String s: choices.keySet()) |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1024 |
helper.remove(primaryName + s); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1025 |
String opt = primaryName + arg; |
11315 | 1026 |
helper.put(opt, opt); |
1027 |
// some clients like to see option (without trailing ":") |
|
1028 |
// set to arg |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1029 |
String nm = primaryName.substring(0, primaryName.length() - 1); |
11315 | 1030 |
helper.put(nm, arg); |
1031 |
} else { |
|
1032 |
// set option+word for each word in arg |
|
1033 |
for (String a: arg.split(",+")) { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1034 |
String opt = primaryName + a; |
11315 | 1035 |
helper.put(opt, opt); |
1036 |
} |
|
1037 |
} |
|
1038 |
} |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1039 |
helper.put(primaryName, arg); |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
24298
diff
changeset
|
1040 |
if (group == OptionGroup.FILEMANAGER) |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
24298
diff
changeset
|
1041 |
helper.handleFileManagerOption(this, arg); |
11315 | 1042 |
return false; |
1043 |
} |
|
1044 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1045 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1046 |
* 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
|
1047 |
* @param word the word to be scanned |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1048 |
* @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
|
1049 |
* or -1 if none found |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1050 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1051 |
private static int findSeparator(String word) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1052 |
for (int i = 0; i < word.length(); i++) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1053 |
switch (word.charAt(i)) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1054 |
case ':': case '=': |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1055 |
return i; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1056 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1057 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1058 |
return -1; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1059 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1060 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1061 |
/** The indent for the option synopsis. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1062 |
private static final String SMALL_INDENT = " "; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1063 |
/** The automatic indent for the description. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1064 |
private static final String LARGE_INDENT = " "; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1065 |
/** 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
|
1066 |
private static final int DEFAULT_SYNOPSIS_WIDTH = 28; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1067 |
/** 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
|
1068 |
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
|
1069 |
/** The format for a single-line help entry. */ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1070 |
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
|
1071 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1072 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1073 |
* 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
|
1074 |
* @param log the log |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1075 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1076 |
protected void help(Log log) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1077 |
help(log, log.localize(PrefixKind.JAVAC, descrKey)); |
11315 | 1078 |
} |
1079 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1080 |
protected void help(Log log, String descr) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1081 |
String synopses = Arrays.stream(names) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1082 |
.map(s -> helpSynopsis(s, log)) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1083 |
.collect(Collectors.joining(", ")); |
11315 | 1084 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1085 |
// 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
|
1086 |
// display using COMPACT_FORMAT |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1087 |
if (synopses.length() < DEFAULT_SYNOPSIS_WIDTH |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1088 |
&& !descr.contains("\n") |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1089 |
&& (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
|
1090 |
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
|
1091 |
return; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1092 |
} |
11315 | 1093 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1094 |
// 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
|
1095 |
// otherwise, show 1 per line |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1096 |
if (synopses.length() <= DEFAULT_MAX_LINE_LENGTH) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1097 |
log.printRawLines(WriterKind.STDOUT, SMALL_INDENT + synopses); |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1098 |
} else { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1099 |
for (String name: names) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1100 |
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
|
1101 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1102 |
} |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1103 |
|
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1104 |
// Finally, show the description |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1105 |
log.printRawLines(WriterKind.STDOUT, LARGE_INDENT + descr.replace("\n", "\n" + LARGE_INDENT)); |
11315 | 1106 |
} |
1107 |
||
40308
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 |
* 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
|
1110 |
* @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
|
1111 |
* @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
|
1112 |
* @return the synopsis |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1113 |
*/ |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1114 |
private String helpSynopsis(String name, Log log) { |
11315 | 1115 |
StringBuilder sb = new StringBuilder(); |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1116 |
sb.append(name); |
11315 | 1117 |
if (argsNameKey == null) { |
1118 |
if (choices != null) { |
|
1119 |
String sep = "{"; |
|
1120 |
for (Map.Entry<String,Boolean> e: choices.entrySet()) { |
|
1121 |
if (!e.getValue()) { |
|
1122 |
sb.append(sep); |
|
1123 |
sb.append(e.getKey()); |
|
1124 |
sep = ","; |
|
1125 |
} |
|
1126 |
} |
|
1127 |
sb.append("}"); |
|
1128 |
} |
|
1129 |
} else { |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1130 |
if (!name.matches(".*[=:]$") && argKind != ArgKind.ADJACENT) |
11315 | 1131 |
sb.append(" "); |
1132 |
sb.append(log.localize(PrefixKind.JAVAC, argsNameKey)); |
|
1133 |
} |
|
1134 |
||
1135 |
return sb.toString(); |
|
1136 |
} |
|
1137 |
||
1138 |
// For -XpkgInfo:value |
|
1139 |
public enum PkgInfo { |
|
19670
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1140 |
/** |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1141 |
* 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
|
1142 |
* 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
|
1143 |
* 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
|
1144 |
* 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
|
1145 |
* one .class file for every .java file. |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1146 |
*/ |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1147 |
ALWAYS, |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1148 |
/** |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1149 |
* 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
|
1150 |
* 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
|
1151 |
* a RetentionPolicy of SOURCE. |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1152 |
* This value is just for backwards compatibility with earlier behavior. |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1153 |
* 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
|
1154 |
*/ |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1155 |
LEGACY, |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1156 |
/** |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1157 |
* 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
|
1158 |
* in package-info.java to be written into it. |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1159 |
*/ |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1160 |
NONEMPTY; |
197392292aad
8022744: javac -Xpkginfo command's documentation is sparse
jjg
parents:
17582
diff
changeset
|
1161 |
|
11315 | 1162 |
public static PkgInfo get(Options options) { |
1163 |
String v = options.get(XPKGINFO); |
|
1164 |
return (v == null |
|
1165 |
? PkgInfo.LEGACY |
|
22153
f9f06fcca59d
8029800: Flags.java uses String.toLowerCase without specifying Locale
jlahoda
parents:
19670
diff
changeset
|
1166 |
: PkgInfo.valueOf(StringUtils.toUpperCase(v))); |
11315 | 1167 |
} |
1168 |
} |
|
1169 |
||
1170 |
private static Map<String,Boolean> getXLintChoices() { |
|
22163 | 1171 |
Map<String,Boolean> choices = new LinkedHashMap<>(); |
11315 | 1172 |
choices.put("all", false); |
1173 |
for (Lint.LintCategory c : Lint.LintCategory.values()) |
|
1174 |
choices.put(c.option, c.hidden); |
|
1175 |
for (Lint.LintCategory c : Lint.LintCategory.values()) |
|
1176 |
choices.put("-" + c.option, c.hidden); |
|
1177 |
choices.put("none", false); |
|
1178 |
return choices; |
|
1179 |
} |
|
1180 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1181 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1182 |
* 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
|
1183 |
* @return the set of options. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1184 |
*/ |
11315 | 1185 |
static Set<Option> getJavaCompilerOptions() { |
1186 |
return EnumSet.allOf(Option.class); |
|
1187 |
} |
|
1188 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1189 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1190 |
* 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
|
1191 |
* @return the set of options. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1192 |
*/ |
11315 | 1193 |
public static Set<Option> getJavacFileManagerOptions() { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1194 |
return getOptions(FILEMANAGER); |
11315 | 1195 |
} |
1196 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1197 |
/** |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1198 |
* 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
|
1199 |
* the JavaCompiler API, via {@link JavaCompiler#getTask}. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1200 |
* @return the set of options. |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1201 |
*/ |
11315 | 1202 |
public static Set<Option> getJavacToolOptions() { |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1203 |
return getOptions(BASIC); |
11315 | 1204 |
} |
1205 |
||
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1206 |
private static Set<Option> getOptions(OptionGroup group) { |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1207 |
return Arrays.stream(Option.values()) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1208 |
.filter(o -> o.group == group) |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
1209 |
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Option.class))); |
11315 | 1210 |
} |
1211 |
||
1212 |
} |