Fri, 30 Nov 2012 15:14:48 +0000
8002099: Add support for intersection types in cast expression
Summary: Add parser and type-checking support for intersection types in cast expressions
Reviewed-by: jjg
1 /*
2 * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
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 */
26 package com.sun.tools.javac.main;
28 import java.util.Collections;
29 import com.sun.tools.javac.util.Log.PrefixKind;
30 import com.sun.tools.javac.util.Log.WriterKind;
31 import com.sun.tools.javac.util.Log;
32 import com.sun.tools.javac.code.Lint;
33 import com.sun.tools.javac.code.Source;
34 import com.sun.tools.javac.code.Type;
35 import com.sun.tools.javac.jvm.Target;
36 import com.sun.tools.javac.util.Options;
37 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
38 import java.io.File;
39 import java.io.FileWriter;
40 import java.io.PrintWriter;
41 import java.util.EnumSet;
42 import java.util.LinkedHashMap;
43 import java.util.Map;
44 import java.util.Set;
45 import javax.lang.model.SourceVersion;
47 import static com.sun.tools.javac.main.Option.ChoiceKind.*;
48 import static com.sun.tools.javac.main.Option.OptionKind.*;
49 import static com.sun.tools.javac.main.Option.OptionGroup.*;
51 /**
52 * Options for javac. The specific Option to handle a command-line option
53 * is identified by searching the members of this enum in order, looking
54 * the first {@link #matches match}. The action for an Option is performed
55 * by calling {@link #process process}, and by providing a suitable
56 * {@link OptionHelper} to provide access the compiler state.
57 *
58 * <p><b>This is NOT part of any supported API.
59 * If you write code that depends on this, you do so at your own
60 * risk. This code and its internal interfaces are subject to change
61 * or deletion without notice.</b></p>
62 */
63 public enum Option {
64 G("-g", "opt.g", STANDARD, BASIC),
66 G_NONE("-g:none", "opt.g.none", STANDARD, BASIC) {
67 @Override
68 public boolean process(OptionHelper helper, String option) {
69 helper.put("-g:", "none");
70 return false;
71 }
72 },
74 G_CUSTOM("-g:", "opt.g.lines.vars.source",
75 STANDARD, BASIC, ANYOF, "lines", "vars", "source"),
77 XLINT("-Xlint", "opt.Xlint", EXTENDED, BASIC),
79 XLINT_CUSTOM("-Xlint:", "opt.Xlint.suboptlist",
80 EXTENDED, BASIC, ANYOF, getXLintChoices()),
82 // -nowarn is retained for command-line backward compatibility
83 NOWARN("-nowarn", "opt.nowarn", STANDARD, BASIC) {
84 @Override
85 public boolean process(OptionHelper helper, String option) {
86 helper.put("-Xlint:none", option);
87 return false;
88 }
89 },
91 VERBOSE("-verbose", "opt.verbose", STANDARD, BASIC),
93 // -deprecation is retained for command-line backward compatibility
94 DEPRECATION("-deprecation", "opt.deprecation", STANDARD, BASIC) {
95 @Override
96 public boolean process(OptionHelper helper, String option) {
97 helper.put("-Xlint:deprecation", option);
98 return false;
99 }
100 },
102 CLASSPATH("-classpath", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER),
104 CP("-cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER) {
105 @Override
106 public boolean process(OptionHelper helper, String option, String arg) {
107 return super.process(helper, "-classpath", arg);
108 }
109 },
111 SOURCEPATH("-sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
113 BOOTCLASSPATH("-bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) {
114 @Override
115 public boolean process(OptionHelper helper, String option, String arg) {
116 helper.remove("-Xbootclasspath/p:");
117 helper.remove("-Xbootclasspath/a:");
118 return super.process(helper, option, arg);
119 }
120 },
122 XBOOTCLASSPATH_PREPEND("-Xbootclasspath/p:", "opt.arg.path", "opt.Xbootclasspath.p", EXTENDED, FILEMANAGER),
124 XBOOTCLASSPATH_APPEND("-Xbootclasspath/a:", "opt.arg.path", "opt.Xbootclasspath.a", EXTENDED, FILEMANAGER),
126 XBOOTCLASSPATH("-Xbootclasspath:", "opt.arg.path", "opt.bootclasspath", EXTENDED, FILEMANAGER) {
127 @Override
128 public boolean process(OptionHelper helper, String option, String arg) {
129 helper.remove("-Xbootclasspath/p:");
130 helper.remove("-Xbootclasspath/a:");
131 return super.process(helper, "-bootclasspath", arg);
132 }
133 },
135 EXTDIRS("-extdirs", "opt.arg.dirs", "opt.extdirs", STANDARD, FILEMANAGER),
137 DJAVA_EXT_DIRS("-Djava.ext.dirs=", "opt.arg.dirs", "opt.extdirs", EXTENDED, FILEMANAGER) {
138 @Override
139 public boolean process(OptionHelper helper, String option, String arg) {
140 return super.process(helper, "-extdirs", arg);
141 }
142 },
144 ENDORSEDDIRS("-endorseddirs", "opt.arg.dirs", "opt.endorseddirs", STANDARD, FILEMANAGER),
146 DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs=", "opt.arg.dirs", "opt.endorseddirs", EXTENDED, FILEMANAGER) {
147 @Override
148 public boolean process(OptionHelper helper, String option, String arg) {
149 return super.process(helper, "-endorseddirs", arg);
150 }
151 },
153 PROC("-proc:", "opt.proc.none.only", STANDARD, BASIC, ONEOF, "none", "only"),
155 PROCESSOR("-processor", "opt.arg.class.list", "opt.processor", STANDARD, BASIC),
157 PROCESSORPATH("-processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER),
159 D("-d", "opt.arg.directory", "opt.d", STANDARD, FILEMANAGER),
161 S("-s", "opt.arg.directory", "opt.sourceDest", STANDARD, FILEMANAGER),
163 H("-h", "opt.arg.directory", "opt.headerDest", STANDARD, FILEMANAGER),
165 IMPLICIT("-implicit:", "opt.implicit", STANDARD, BASIC, ONEOF, "none", "class"),
167 ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER) {
168 @Override
169 public boolean process(OptionHelper helper, String option, String operand) {
170 // System.err.println("process encoding " + operand);
171 return super.process(helper, option, operand);
172 }
174 },
176 SOURCE("-source", "opt.arg.release", "opt.source", STANDARD, BASIC) {
177 @Override
178 public boolean process(OptionHelper helper, String option, String operand) {
179 Source source = Source.lookup(operand);
180 if (source == null) {
181 helper.error("err.invalid.source", operand);
182 return true;
183 }
184 return super.process(helper, option, operand);
185 }
186 },
188 TARGET("-target", "opt.arg.release", "opt.target", STANDARD, BASIC) {
189 @Override
190 public boolean process(OptionHelper helper, String option, String operand) {
191 Target target = Target.lookup(operand);
192 if (target == null) {
193 helper.error("err.invalid.target", operand);
194 return true;
195 }
196 return super.process(helper, option, operand);
197 }
198 },
200 VERSION("-version", "opt.version", STANDARD, INFO) {
201 @Override
202 public boolean process(OptionHelper helper, String option) {
203 Log log = helper.getLog();
204 String ownName = helper.getOwnName();
205 log.printLines(PrefixKind.JAVAC, "version", ownName, JavaCompiler.version());
206 return super.process(helper, option);
207 }
208 },
210 FULLVERSION("-fullversion", null, HIDDEN, INFO) {
211 @Override
212 public boolean process(OptionHelper helper, String option) {
213 Log log = helper.getLog();
214 String ownName = helper.getOwnName();
215 log.printLines(PrefixKind.JAVAC, "fullVersion", ownName, JavaCompiler.fullVersion());
216 return super.process(helper, option);
217 }
218 },
220 DIAGS("-XDdiags=", null, HIDDEN, INFO) {
221 @Override
222 public boolean process(OptionHelper helper, String option) {
223 option = option.substring(option.indexOf('=') + 1);
224 String diagsOption = option.contains("%") ?
225 "-XDdiagsFormat=" :
226 "-XDdiags=";
227 diagsOption += option;
228 if (XD.matches(diagsOption))
229 return XD.process(helper, diagsOption);
230 else
231 return false;
232 }
233 },
235 HELP("-help", "opt.help", STANDARD, INFO) {
236 @Override
237 public boolean process(OptionHelper helper, String option) {
238 Log log = helper.getLog();
239 String ownName = helper.getOwnName();
240 log.printLines(PrefixKind.JAVAC, "msg.usage.header", ownName);
241 for (Option o: getJavaCompilerOptions()) {
242 o.help(log, OptionKind.STANDARD);
243 }
244 log.printNewline();
245 return super.process(helper, option);
246 }
247 },
249 A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC) {
250 { hasSuffix = true; }
252 @Override
253 public boolean matches(String arg) {
254 return arg.startsWith("-A");
255 }
257 @Override
258 public boolean hasArg() {
259 return false;
260 }
261 // Mapping for processor options created in
262 // JavacProcessingEnvironment
263 @Override
264 public boolean process(OptionHelper helper, String option) {
265 int argLength = option.length();
266 if (argLength == 2) {
267 helper.error("err.empty.A.argument");
268 return true;
269 }
270 int sepIndex = option.indexOf('=');
271 String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
272 if (!JavacProcessingEnvironment.isValidOptionName(key)) {
273 helper.error("err.invalid.A.key", option);
274 return true;
275 }
276 return process(helper, option, option);
277 }
278 },
280 X("-X", "opt.X", STANDARD, INFO) {
281 @Override
282 public boolean process(OptionHelper helper, String option) {
283 Log log = helper.getLog();
284 for (Option o: getJavaCompilerOptions()) {
285 o.help(log, OptionKind.EXTENDED);
286 }
287 log.printNewline();
288 log.printLines(PrefixKind.JAVAC, "msg.usage.nonstandard.footer");
289 return super.process(helper, option);
290 }
291 },
293 // This option exists only for the purpose of documenting itself.
294 // It's actually implemented by the launcher.
295 J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO) {
296 { hasSuffix = true; }
298 @Override
299 public boolean process(OptionHelper helper, String option) {
300 throw new AssertionError
301 ("the -J flag should be caught by the launcher.");
302 }
303 },
305 // stop after parsing and attributing.
306 // new HiddenOption("-attrparseonly"),
308 // new Option("-moreinfo", "opt.moreinfo") {
309 MOREINFO("-moreinfo", null, HIDDEN, BASIC) {
310 @Override
311 public boolean process(OptionHelper helper, String option) {
312 Type.moreInfo = true;
313 return super.process(helper, option);
314 }
315 },
317 // treat warnings as errors
318 WERROR("-Werror", "opt.Werror", STANDARD, BASIC),
320 // // use complex inference from context in the position of a method call argument
321 // COMPLEXINFERENCE("-complexinference", null, HIDDEN, BASIC),
323 // generare source stubs
324 // new HiddenOption("-stubs"),
326 // relax some constraints to allow compiling from stubs
327 // new HiddenOption("-relax"),
329 // output source after translating away inner classes
330 // new Option("-printflat", "opt.printflat"),
331 // new HiddenOption("-printflat"),
333 // display scope search details
334 // new Option("-printsearch", "opt.printsearch"),
335 // new HiddenOption("-printsearch"),
337 // prompt after each error
338 // new Option("-prompt", "opt.prompt"),
339 PROMPT("-prompt", null, HIDDEN, BASIC),
341 // dump stack on error
342 DOE("-doe", null, HIDDEN, BASIC),
344 // output source after type erasure
345 // new Option("-s", "opt.s"),
346 PRINTSOURCE("-printsource", null, HIDDEN, BASIC),
348 // output shrouded class files
349 // new Option("-scramble", "opt.scramble"),
350 // new Option("-scrambleall", "opt.scrambleall"),
352 // display warnings for generic unchecked operations
353 WARNUNCHECKED("-warnunchecked", null, HIDDEN, BASIC) {
354 @Override
355 public boolean process(OptionHelper helper, String option) {
356 helper.put("-Xlint:unchecked", option);
357 return false;
358 }
359 },
361 XMAXERRS("-Xmaxerrs", "opt.arg.number", "opt.maxerrs", EXTENDED, BASIC),
363 XMAXWARNS("-Xmaxwarns", "opt.arg.number", "opt.maxwarns", EXTENDED, BASIC),
365 XSTDOUT("-Xstdout", "opt.arg.file", "opt.Xstdout", EXTENDED, INFO) {
366 @Override
367 public boolean process(OptionHelper helper, String option, String arg) {
368 try {
369 Log log = helper.getLog();
370 // TODO: this file should be closed at the end of compilation
371 log.setWriters(new PrintWriter(new FileWriter(arg), true));
372 } catch (java.io.IOException e) {
373 helper.error("err.error.writing.file", arg, e);
374 return true;
375 }
376 return super.process(helper, option, arg);
377 }
378 },
380 XPRINT("-Xprint", "opt.print", EXTENDED, BASIC),
382 XPRINTROUNDS("-XprintRounds", "opt.printRounds", EXTENDED, BASIC),
384 XPRINTPROCESSORINFO("-XprintProcessorInfo", "opt.printProcessorInfo", EXTENDED, BASIC),
386 XPREFER("-Xprefer:", "opt.prefer", EXTENDED, BASIC, ONEOF, "source", "newer"),
388 XPKGINFO("-Xpkginfo:", "opt.pkginfo", EXTENDED, BASIC, ONEOF, "always", "legacy", "nonempty"),
390 /* -O is a no-op, accepted for backward compatibility. */
391 O("-O", null, HIDDEN, BASIC),
393 /* -Xjcov produces tables to support the code coverage tool jcov. */
394 XJCOV("-Xjcov", null, HIDDEN, BASIC),
396 PLUGIN("-Xplugin:", "opt.arg.plugin", "opt.plugin", EXTENDED, BASIC) {
397 @Override
398 public boolean process(OptionHelper helper, String option) {
399 String p = option.substring(option.indexOf(':') + 1);
400 String prev = helper.get(PLUGIN);
401 helper.put(PLUGIN.text, (prev == null) ? p : prev + '\0' + p.trim());
402 return false;
403 }
404 },
406 /* This is a back door to the compiler's option table.
407 * -XDx=y sets the option x to the value y.
408 * -XDx sets the option x to the value x.
409 */
410 XD("-XD", null, HIDDEN, BASIC) {
411 String s;
412 @Override
413 public boolean matches(String s) {
414 this.s = s;
415 return s.startsWith(text);
416 }
417 @Override
418 public boolean process(OptionHelper helper, String option) {
419 s = s.substring(text.length());
420 int eq = s.indexOf('=');
421 String key = (eq < 0) ? s : s.substring(0, eq);
422 String value = (eq < 0) ? s : s.substring(eq+1);
423 helper.put(key, value);
424 return false;
425 }
426 },
428 // This option exists only for the purpose of documenting itself.
429 // It's actually implemented by the CommandLine class.
430 AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO) {
431 { hasSuffix = true; }
433 @Override
434 public boolean process(OptionHelper helper, String option) {
435 throw new AssertionError("the @ flag should be caught by CommandLine.");
436 }
437 },
439 /*
440 * TODO: With apt, the matches method accepts anything if
441 * -XclassAsDecls is used; code elsewhere does the lookup to
442 * see if the class name is both legal and found.
443 *
444 * In apt, the process method adds the candidate class file
445 * name to a separate list.
446 */
447 SOURCEFILE("sourcefile", null, HIDDEN, INFO) {
448 String s;
449 @Override
450 public boolean matches(String s) {
451 this.s = s;
452 return s.endsWith(".java") // Java source file
453 || SourceVersion.isName(s); // Legal type name
454 }
455 @Override
456 public boolean process(OptionHelper helper, String option) {
457 if (s.endsWith(".java") ) {
458 File f = new File(s);
459 if (!f.exists()) {
460 helper.error("err.file.not.found", f);
461 return true;
462 }
463 if (!f.isFile()) {
464 helper.error("err.file.not.file", f);
465 return true;
466 }
467 helper.addFile(f);
468 }
469 else
470 helper.addClassName(s);
471 return false;
472 }
473 };
475 /** The kind of an Option. This is used by the -help and -X options. */
476 public enum OptionKind {
477 /** A standard option, documented by -help. */
478 STANDARD,
479 /** An extended option, documented by -X. */
480 EXTENDED,
481 /** A hidden option, not documented. */
482 HIDDEN,
483 }
485 /** The group for an Option. This determines the situations in which the
486 * option is applicable. */
487 enum OptionGroup {
488 /** A basic option, available for use on the command line or via the
489 * Compiler API. */
490 BASIC,
491 /** An option for javac's standard JavaFileManager. Other file managers
492 * may or may not support these options. */
493 FILEMANAGER,
494 /** A command-line option that requests information, such as -help. */
495 INFO,
496 /** A command-line "option" representing a file or class name. */
497 OPERAND
498 }
500 /** The kind of choice for "choice" options. */
501 enum ChoiceKind {
502 /** The expected value is exactly one of the set of choices. */
503 ONEOF,
504 /** The expected value is one of more of the set of choices. */
505 ANYOF
506 }
508 public final String text;
510 final OptionKind kind;
512 final OptionGroup group;
514 /** Documentation key for arguments.
515 */
516 final String argsNameKey;
518 /** Documentation key for description.
519 */
520 final String descrKey;
522 /** Suffix option (-foo=bar or -foo:bar)
523 */
524 boolean hasSuffix;
526 /** The kind of choices for this option, if any.
527 */
528 final ChoiceKind choiceKind;
530 /** The choices for this option, if any, and whether or not the choices
531 * are hidden
532 */
533 final Map<String,Boolean> choices;
536 Option(String text, String descrKey,
537 OptionKind kind, OptionGroup group) {
538 this(text, null, descrKey, kind, group, null, null);
539 }
541 Option(String text, String argsNameKey, String descrKey,
542 OptionKind kind, OptionGroup group) {
543 this(text, argsNameKey, descrKey, kind, group, null, null);
544 }
546 Option(String text, String descrKey,
547 OptionKind kind, OptionGroup group,
548 ChoiceKind choiceKind, Map<String,Boolean> choices) {
549 this(text, null, descrKey, kind, group, choiceKind, choices);
550 }
552 Option(String text, String descrKey,
553 OptionKind kind, OptionGroup group,
554 ChoiceKind choiceKind, String... choices) {
555 this(text, null, descrKey, kind, group, choiceKind, createChoices(choices));
556 }
557 // where
558 private static Map<String,Boolean> createChoices(String... choices) {
559 Map<String,Boolean> map = new LinkedHashMap<String,Boolean>();
560 for (String c: choices)
561 map.put(c, false);
562 return map;
563 }
565 private Option(String text, String argsNameKey, String descrKey,
566 OptionKind kind, OptionGroup group,
567 ChoiceKind choiceKind, Map<String,Boolean> choices) {
568 this.text = text;
569 this.argsNameKey = argsNameKey;
570 this.descrKey = descrKey;
571 this.kind = kind;
572 this.group = group;
573 this.choiceKind = choiceKind;
574 this.choices = choices;
575 char lastChar = text.charAt(text.length()-1);
576 hasSuffix = lastChar == ':' || lastChar == '=';
577 }
579 public String getText() {
580 return text;
581 }
583 public OptionKind getKind() {
584 return kind;
585 }
587 public boolean hasArg() {
588 return argsNameKey != null && !hasSuffix;
589 }
591 public boolean matches(String option) {
592 if (!hasSuffix)
593 return option.equals(text);
595 if (!option.startsWith(text))
596 return false;
598 if (choices != null) {
599 String arg = option.substring(text.length());
600 if (choiceKind == ChoiceKind.ONEOF)
601 return choices.keySet().contains(arg);
602 else {
603 for (String a: arg.split(",+")) {
604 if (!choices.keySet().contains(a))
605 return false;
606 }
607 }
608 }
610 return true;
611 }
613 public boolean process(OptionHelper helper, String option, String arg) {
614 if (choices != null) {
615 if (choiceKind == ChoiceKind.ONEOF) {
616 // some clients like to see just one of option+choice set
617 for (String s: choices.keySet())
618 helper.remove(option + s);
619 String opt = option + arg;
620 helper.put(opt, opt);
621 // some clients like to see option (without trailing ":")
622 // set to arg
623 String nm = option.substring(0, option.length() - 1);
624 helper.put(nm, arg);
625 } else {
626 // set option+word for each word in arg
627 for (String a: arg.split(",+")) {
628 String opt = option + a;
629 helper.put(opt, opt);
630 }
631 }
632 }
633 helper.put(option, arg);
634 return false;
635 }
637 public boolean process(OptionHelper helper, String option) {
638 if (hasSuffix)
639 return process(helper, text, option.substring(text.length()));
640 else
641 return process(helper, option, option);
642 }
644 void help(Log log, OptionKind kind) {
645 if (this.kind != kind)
646 return;
648 log.printRawLines(WriterKind.NOTICE,
649 String.format(" %-26s %s",
650 helpSynopsis(log),
651 log.localize(PrefixKind.JAVAC, descrKey)));
653 }
655 private String helpSynopsis(Log log) {
656 StringBuilder sb = new StringBuilder();
657 sb.append(text);
658 if (argsNameKey == null) {
659 if (choices != null) {
660 String sep = "{";
661 for (Map.Entry<String,Boolean> e: choices.entrySet()) {
662 if (!e.getValue()) {
663 sb.append(sep);
664 sb.append(e.getKey());
665 sep = ",";
666 }
667 }
668 sb.append("}");
669 }
670 } else {
671 if (!hasSuffix)
672 sb.append(" ");
673 sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
675 }
677 return sb.toString();
678 }
680 // For -XpkgInfo:value
681 public enum PkgInfo {
682 ALWAYS, LEGACY, NONEMPTY;
683 public static PkgInfo get(Options options) {
684 String v = options.get(XPKGINFO);
685 return (v == null
686 ? PkgInfo.LEGACY
687 : PkgInfo.valueOf(v.toUpperCase()));
688 }
689 }
691 private static Map<String,Boolean> getXLintChoices() {
692 Map<String,Boolean> choices = new LinkedHashMap<String,Boolean>();
693 choices.put("all", false);
694 for (Lint.LintCategory c : Lint.LintCategory.values())
695 choices.put(c.option, c.hidden);
696 for (Lint.LintCategory c : Lint.LintCategory.values())
697 choices.put("-" + c.option, c.hidden);
698 choices.put("none", false);
699 return choices;
700 }
702 static Set<Option> getJavaCompilerOptions() {
703 return EnumSet.allOf(Option.class);
704 }
706 public static Set<Option> getJavacFileManagerOptions() {
707 return getOptions(EnumSet.of(FILEMANAGER));
708 }
710 public static Set<Option> getJavacToolOptions() {
711 return getOptions(EnumSet.of(BASIC));
712 }
714 static Set<Option> getOptions(Set<OptionGroup> desired) {
715 Set<Option> options = EnumSet.noneOf(Option.class);
716 for (Option option : Option.values())
717 if (desired.contains(option.group))
718 options.add(option);
719 return Collections.unmodifiableSet(options);
720 }
722 }