167 public void process(OptionHelper helper, String option) {
168 helper.put("-Xlint:none", option);
169 }
170 },
171
172 VERBOSE("-verbose", "opt.verbose", STANDARD, BASIC),
173
174 // -deprecation is retained for command-line backward compatibility
175 DEPRECATION("-deprecation", "opt.deprecation", STANDARD, BASIC) {
176 @Override
177 public void process(OptionHelper helper, String option) {
178 helper.put("-Xlint:deprecation", option);
179 }
180 },
181
182 CLASS_PATH("--class-path -classpath -cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER),
183
184 SOURCE_PATH("--source-path -sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
185
186 MODULE_SOURCE_PATH("--module-source-path", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER) {
187 // The deferred filemanager diagnostics mechanism assumes a single value per option,
188 // but --module-source-path-module can be used multiple times, once in the old form
189 // and once per module in the new form. Therefore we compose an overall value for the
190 // option containing the individual values given on the command line, separated by NULL.
191 // The standard file manager code knows to split apart the NULL-separated components.
192 @Override
193 public void process(OptionHelper helper, String option, String arg) throws InvalidValueException {
194 if (arg.isEmpty()) {
195 throw helper.newInvalidValueException(Errors.NoValueForOption(option));
196 }
197 Pattern moduleSpecificForm = getPattern();
198 String prev = helper.get(MODULE_SOURCE_PATH);
199 if (prev == null) {
200 super.process(helper, option, arg);
201 } else if (moduleSpecificForm.matcher(arg).matches()) {
202 String argModule = arg.substring(0, arg.indexOf('='));
203 boolean isRepeated = Arrays.stream(prev.split("\0"))
204 .filter(s -> moduleSpecificForm.matcher(s).matches())
205 .map(s -> s.substring(0, s.indexOf('=')))
206 .anyMatch(s -> s.equals(argModule));
207 if (isRepeated) {
216 throw helper.newInvalidValueException(Errors.MultipleValuesForModuleSourcePath);
217 } else {
218 super.process(helper, option, prev + '\0' + arg);
219 }
220 }
221 }
222
223 @Override
224 public Pattern getPattern() {
225 return Pattern.compile("([\\p{Alnum}$_.]+)=(.*)");
226 }
227 },
228
229 MODULE_PATH("--module-path -p", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER),
230
231 UPGRADE_MODULE_PATH("--upgrade-module-path", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER),
232
233 SYSTEM("--system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER),
234
235 PATCH_MODULE("--patch-module", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER) {
236 // The deferred filemanager diagnostics mechanism assumes a single value per option,
237 // but --patch-module can be used multiple times, once per module. Therefore we compose
238 // a value for the option containing the last value specified for each module, and separate
239 // the module=path pairs by an invalid path character, NULL.
240 // The standard file manager code knows to split apart the NULL-separated components.
241 @Override
242 public void process(OptionHelper helper, String option, String arg) throws InvalidValueException {
243 if (arg.isEmpty()) {
244 throw helper.newInvalidValueException(Errors.NoValueForOption(option));
245 } else if (getPattern().matcher(arg).matches()) {
246 String prev = helper.get(PATCH_MODULE);
247 if (prev == null) {
248 super.process(helper, option, arg);
249 } else {
250 String argModulePackage = arg.substring(0, arg.indexOf('='));
251 boolean isRepeated = Arrays.stream(prev.split("\0"))
252 .map(s -> s.substring(0, s.indexOf('=')))
253 .collect(Collectors.toSet())
254 .contains(argModulePackage);
255 if (isRepeated) {
256 throw helper.newInvalidValueException(Errors.RepeatedValueForPatchModule(argModulePackage));
|
167 public void process(OptionHelper helper, String option) {
168 helper.put("-Xlint:none", option);
169 }
170 },
171
172 VERBOSE("-verbose", "opt.verbose", STANDARD, BASIC),
173
174 // -deprecation is retained for command-line backward compatibility
175 DEPRECATION("-deprecation", "opt.deprecation", STANDARD, BASIC) {
176 @Override
177 public void process(OptionHelper helper, String option) {
178 helper.put("-Xlint:deprecation", option);
179 }
180 },
181
182 CLASS_PATH("--class-path -classpath -cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER),
183
184 SOURCE_PATH("--source-path -sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
185
186 MODULE_SOURCE_PATH("--module-source-path", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER) {
187 // The deferred file manager diagnostics mechanism assumes a single value per option,
188 // but --module-source-path-module can be used multiple times, once in the old form
189 // and once per module in the new form. Therefore we compose an overall value for the
190 // option containing the individual values given on the command line, separated by NULL.
191 // The standard file manager code knows to split apart the NULL-separated components.
192 @Override
193 public void process(OptionHelper helper, String option, String arg) throws InvalidValueException {
194 if (arg.isEmpty()) {
195 throw helper.newInvalidValueException(Errors.NoValueForOption(option));
196 }
197 Pattern moduleSpecificForm = getPattern();
198 String prev = helper.get(MODULE_SOURCE_PATH);
199 if (prev == null) {
200 super.process(helper, option, arg);
201 } else if (moduleSpecificForm.matcher(arg).matches()) {
202 String argModule = arg.substring(0, arg.indexOf('='));
203 boolean isRepeated = Arrays.stream(prev.split("\0"))
204 .filter(s -> moduleSpecificForm.matcher(s).matches())
205 .map(s -> s.substring(0, s.indexOf('=')))
206 .anyMatch(s -> s.equals(argModule));
207 if (isRepeated) {
216 throw helper.newInvalidValueException(Errors.MultipleValuesForModuleSourcePath);
217 } else {
218 super.process(helper, option, prev + '\0' + arg);
219 }
220 }
221 }
222
223 @Override
224 public Pattern getPattern() {
225 return Pattern.compile("([\\p{Alnum}$_.]+)=(.*)");
226 }
227 },
228
229 MODULE_PATH("--module-path -p", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER),
230
231 UPGRADE_MODULE_PATH("--upgrade-module-path", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER),
232
233 SYSTEM("--system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER),
234
235 PATCH_MODULE("--patch-module", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER) {
236 // The deferred file manager diagnostics mechanism assumes a single value per option,
237 // but --patch-module can be used multiple times, once per module. Therefore we compose
238 // a value for the option containing the last value specified for each module, and separate
239 // the module=path pairs by an invalid path character, NULL.
240 // The standard file manager code knows to split apart the NULL-separated components.
241 @Override
242 public void process(OptionHelper helper, String option, String arg) throws InvalidValueException {
243 if (arg.isEmpty()) {
244 throw helper.newInvalidValueException(Errors.NoValueForOption(option));
245 } else if (getPattern().matcher(arg).matches()) {
246 String prev = helper.get(PATCH_MODULE);
247 if (prev == null) {
248 super.process(helper, option, arg);
249 } else {
250 String argModulePackage = arg.substring(0, arg.indexOf('='));
251 boolean isRepeated = Arrays.stream(prev.split("\0"))
252 .map(s -> s.substring(0, s.indexOf('=')))
253 .collect(Collectors.toSet())
254 .contains(argModulePackage);
255 if (isRepeated) {
256 throw helper.newInvalidValueException(Errors.RepeatedValueForPatchModule(argModulePackage));
|