Examples of XOption


Examples of com.sun.tools.javac.main.JavacOption.XOption

        },

        new Option(G_CUSTOM,                                    "opt.g.lines.vars.source",
                Option.ChoiceKind.ANYOF, "lines", "vars", "source"),

        new XOption(XLINT,                                      "opt.Xlint"),
        new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist",
                Option.ChoiceKind.ANYOF, getXLintChoices()),

        // -nowarn is retained for command-line backward compatibility
        new Option(NOWARN,                                      "opt.nowarn") {
            @Override
            public boolean process(Options options, String option) {
                options.put("-Xlint:none", option);
                return false;
            }
        },

        new Option(VERBOSE,                                     "opt.verbose"),

        // -deprecation is retained for command-line backward compatibility
        new Option(DEPRECATION,                                 "opt.deprecation") {
            @Override
            public boolean process(Options options, String option) {
                options.put("-Xlint:deprecation", option);
                return false;
            }
        },

        new Option(CLASSPATH,              "opt.arg.path",      "opt.classpath"),
        new Option(CP,                     "opt.arg.path",      "opt.classpath") {
            @Override
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-classpath", arg);
            }
        },
        new Option(SOURCEPATH,             "opt.arg.path",      "opt.sourcepath"),
        new Option(BOOTCLASSPATH,          "opt.arg.path",      "opt.bootclasspath") {
            @Override
            public boolean process(Options options, String option, String arg) {
                options.remove("-Xbootclasspath/p:");
                options.remove("-Xbootclasspath/a:");
                return super.process(options, option, arg);
            }
        },
        new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
        new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
        new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
            @Override
            public boolean process(Options options, String option, String arg) {
                options.remove("-Xbootclasspath/p:");
                options.remove("-Xbootclasspath/a:");
                return super.process(options, "-bootclasspath", arg);
            }
        },
        new Option(EXTDIRS,                "opt.arg.dirs",      "opt.extdirs"),
        new XOption(DJAVA_EXT_DIRS,        "opt.arg.dirs",      "opt.extdirs") {
            @Override
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-extdirs", arg);
            }
        },
        new Option(ENDORSEDDIRS,            "opt.arg.dirs",     "opt.endorseddirs"),
        new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs",     "opt.endorseddirs") {
            @Override
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-endorseddirs", arg);
            }
        },
        new Option(PROC,                                 "opt.proc.none.only",
                Option.ChoiceKind.ONEOF, "none", "only"),
        new Option(PROCESSOR,           "opt.arg.class.list",   "opt.processor"),
        new Option(PROCESSORPATH,       "opt.arg.path",         "opt.processorpath"),
        new Option(D,                   "opt.arg.directory",    "opt.d"),
        new Option(S,                   "opt.arg.directory",    "opt.sourceDest"),
        new Option(IMPLICIT,                                    "opt.implicit",
                Option.ChoiceKind.ONEOF, "none", "class"),
        new Option(ENCODING,            "opt.arg.encoding",     "opt.encoding"),
        new Option(SOURCE,              "opt.arg.release",      "opt.source") {
            @Override
            public boolean process(Options options, String option, String operand) {
                Source source = Source.lookup(operand);
                if (source == null) {
                    helper.error("err.invalid.source", operand);
                    return true;
                }
                return super.process(options, option, operand);
            }
        },
        new Option(TARGET,              "opt.arg.release",      "opt.target") {
            @Override
            public boolean process(Options options, String option, String operand) {
                Target target = Target.lookup(operand);
                if (target == null) {
                    helper.error("err.invalid.target", operand);
                    return true;
                }
                return super.process(options, option, operand);
            }
        },
        new Option(VERSION,                                     "opt.version") {
            @Override
            public boolean process(Options options, String option) {
                helper.printVersion();
                return super.process(options, option);
            }
        },
        new HiddenOption(FULLVERSION) {
            @Override
            public boolean process(Options options, String option) {
                helper.printFullVersion();
                return super.process(options, option);
            }
        },
        new HiddenOption(DIAGS) {
            @Override
            public boolean process(Options options, String option) {
                Option xd = getOptions(helper, EnumSet.of(XD))[0];
                option = option.substring(option.indexOf('=') + 1);
                String diagsOption = option.contains("%") ?
                    "-XDdiagsFormat=" :
                    "-XDdiags=";
                diagsOption += option;
                if (xd.matches(diagsOption))
                    return xd.process(options, diagsOption);
                else
                    return false;
            }
        },
        new Option(HELP,                                        "opt.help") {
            @Override
            public boolean process(Options options, String option) {
                helper.printHelp();
                return super.process(options, option);
            }
        },
        new Option(A,                "opt.arg.key.equals.value","opt.A") {
            @Override
            String helpSynopsis() {
                hasSuffix = true;
                return super.helpSynopsis();
            }

            @Override
            public boolean matches(String arg) {
                return arg.startsWith("-A");
            }

            @Override
            public boolean hasArg() {
                return false;
            }
            // Mapping for processor options created in
            // JavacProcessingEnvironment
            @Override
            public boolean process(Options options, String option) {
                int argLength = option.length();
                if (argLength == 2) {
                    helper.error("err.empty.A.argument");
                    return true;
                }
                int sepIndex = option.indexOf('=');
                String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
                if (!JavacProcessingEnvironment.isValidOptionName(key)) {
                    helper.error("err.invalid.A.key", option);
                    return true;
                }
                return process(options, option, option);
            }
        },
        new Option(X,                                           "opt.X") {
            @Override
            public boolean process(Options options, String option) {
                helper.printXhelp();
                return super.process(options, option);
            }
        },

        // This option exists only for the purpose of documenting itself.
        // It's actually implemented by the launcher.
        new Option(J,                   "opt.arg.flag",         "opt.J") {
            @Override
            String helpSynopsis() {
                hasSuffix = true;
                return super.helpSynopsis();
            }
            @Override
            public boolean process(Options options, String option) {
                throw new AssertionError
                    ("the -J flag should be caught by the launcher.");
            }
        },

        // stop after parsing and attributing.
        // new HiddenOption("-attrparseonly"),

        // new Option("-moreinfo",                                      "opt.moreinfo") {
        new HiddenOption(MOREINFO) {
            @Override
            public boolean process(Options options, String option) {
                Type.moreInfo = true;
                return super.process(options, option);
            }
        },

        // treat warnings as errors
        new Option(WERROR,                                      "opt.Werror"),

        // use complex inference from context in the position of a method call argument
        new HiddenOption(COMPLEXINFERENCE),

        // generare source stubs
        // new HiddenOption("-stubs"),

        // relax some constraints to allow compiling from stubs
        // new HiddenOption("-relax"),

        // output source after translating away inner classes
        // new Option("-printflat",                             "opt.printflat"),
        // new HiddenOption("-printflat"),

        // display scope search details
        // new Option("-printsearch",                           "opt.printsearch"),
        // new HiddenOption("-printsearch"),

        // prompt after each error
        // new Option("-prompt",                                        "opt.prompt"),
        new HiddenOption(PROMPT),

        // dump stack on error
        new HiddenOption(DOE),

        // output source after type erasure
        // new Option("-s",                                     "opt.s"),
        new HiddenOption(PRINTSOURCE),

        // output shrouded class files
        // new Option("-scramble",                              "opt.scramble"),
        // new Option("-scrambleall",                           "opt.scrambleall"),

        // display warnings for generic unchecked operations
        new HiddenOption(WARNUNCHECKED) {
            @Override
            public boolean process(Options options, String option) {
                options.put("-Xlint:unchecked", option);
                return false;
            }
        },

        new XOption(XMAXERRS,           "opt.arg.number",       "opt.maxerrs"),
        new XOption(XMAXWARNS,          "opt.arg.number",       "opt.maxwarns"),
        new XOption(XSTDOUT,            "opt.arg.file",         "opt.Xstdout") {
            @Override
            public boolean process(Options options, String option, String arg) {
                try {
                    helper.setOut(new PrintWriter(new FileWriter(arg), true));
                } catch (java.io.IOException e) {
                    helper.error("err.error.writing.file", arg, e);
                    return true;
                }
                return super.process(options, option, arg);
            }
        },

        new XOption(XPRINT,                                     "opt.print"),

        new XOption(XPRINTROUNDS,                               "opt.printRounds"),

        new XOption(XPRINTPROCESSORINFO,                        "opt.printProcessorInfo"),

        new XOption(XPREFER,                                    "opt.prefer",
                Option.ChoiceKind.ONEOF, "source", "newer"),

        new XOption(XPKGINFO,                                   "opt.pkginfo",
                Option.ChoiceKind.ONEOF, "always", "legacy", "nonempty"),

        /* -O is a no-op, accepted for backward compatibility. */
        new HiddenOption(O),

View Full Code Here

Examples of com.sun.tools.javac.main.JavacOption.XOption

                }
                return false;
            }
        },

        new XOption(XLINT,                                      "opt.Xlint"),
        new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist") {
            public boolean matches(String s) {
                return s.startsWith("-Xlint:");
            }
            public boolean process(Options options, String option) {
                String suboptions = option.substring(7);
                options.put("-Xlint:", suboptions);
                // enter all the -Xlint suboptions as "-Xlint:suboption"
                for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) {
                    String tok = t.nextToken();
                    String opt = "-Xlint:" + tok;
                    options.put(opt, opt);
                }
                return false;
            }
        },

        // -nowarn is retained for command-line backward compatibility
        new Option(NOWARN,                                      "opt.nowarn") {
                public boolean process(Options options, String option) {
                    options.put("-Xlint:none", option);
                    return false;
                }
            },

        new Option(VERBOSE,                                     "opt.verbose"),

        // -deprecation is retained for command-line backward compatibility
        new Option(DEPRECATION,                                 "opt.deprecation") {
                public boolean process(Options options, String option) {
                    options.put("-Xlint:deprecation", option);
                    return false;
                }
            },

        new Option(CLASSPATH,              "opt.arg.path",      "opt.classpath"),
        new Option(CP,                     "opt.arg.path",      "opt.classpath") {
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-classpath", arg);
            }
        },
        new Option(SOURCEPATH,             "opt.arg.path",      "opt.sourcepath"),
        new Option(BOOTCLASSPATH,          "opt.arg.path",      "opt.bootclasspath") {
            public boolean process(Options options, String option, String arg) {
                options.remove("-Xbootclasspath/p:");
                options.remove("-Xbootclasspath/a:");
                return super.process(options, option, arg);
            }
        },
        new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
        new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
        new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
            public boolean process(Options options, String option, String arg) {
                options.remove("-Xbootclasspath/p:");
                options.remove("-Xbootclasspath/a:");
                return super.process(options, "-bootclasspath", arg);
            }
        },
        new Option(EXTDIRS,                "opt.arg.dirs",      "opt.extdirs"),
        new XOption(DJAVA_EXT_DIRS,        "opt.arg.dirs",      "opt.extdirs") {
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-extdirs", arg);
            }
        },
        new Option(ENDORSEDDIRS,            "opt.arg.dirs",     "opt.endorseddirs"),
        new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs",     "opt.endorseddirs") {
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-endorseddirs", arg);
            }
        },
        new Option(PROC_CUSTOM,                                 "opt.proc.none.only") {
            public boolean matches(String s) {
                return s.equals("-proc:none") || s.equals("-proc:only");
            }

            public boolean process(Options options, String option) {
                if (option.equals("-proc:none")) {
                    options.remove("-proc:only");
                } else {
                    options.remove("-proc:none");
                }
                options.put(option, option);
                return false;
            }
        },
        new Option(PROCESSOR,           "opt.arg.class.list",   "opt.processor"),
        new Option(PROCESSORPATH,       "opt.arg.path",         "opt.processorpath"),
        new Option(D,                   "opt.arg.directory",    "opt.d"),
        new Option(S,                   "opt.arg.directory",    "opt.sourceDest"),
        new Option(IMPLICIT,                                    "opt.implicit") {
            public boolean matches(String s) {
                return s.equals("-implicit:none") || s.equals("-implicit:class");
            }
            public boolean process(Options options, String option, String operand) {
                int sep = option.indexOf(":");
                options.put(option.substring(0, sep), option.substring(sep+1));
                options.put(option,option);
                return false;
            }
        },
        new Option(ENCODING,            "opt.arg.encoding",     "opt.encoding"),
        new Option(SOURCE,              "opt.arg.release",      "opt.source") {
            public boolean process(Options options, String option, String operand) {
                Source source = Source.lookup(operand);
                if (source == null) {
                    helper.error("err.invalid.source", operand);
                    return true;
                }
                return super.process(options, option, operand);
            }
        },
        new Option(TARGET,              "opt.arg.release",      "opt.target") {
            public boolean process(Options options, String option, String operand) {
                Target target = Target.lookup(operand);
                if (target == null) {
                    helper.error("err.invalid.target", operand);
                    return true;
                }
                return super.process(options, option, operand);
            }
        },
        new Option(VERSION,                                     "opt.version") {
            public boolean process(Options options, String option) {
                helper.printVersion();
                return super.process(options, option);
            }
        },
        new HiddenOption(FULLVERSION) {
            public boolean process(Options options, String option) {
                helper.printFullVersion();
                return super.process(options, option);
            }
        },
        new Option(HELP,                                        "opt.help") {
            public boolean process(Options options, String option) {
                helper.printHelp();
                return super.process(options, option);
            }
        },
        new Option(A,                "opt.arg.key.equals.value","opt.A") {
                String helpSynopsis() {
                    hasSuffix = true;
                    return super.helpSynopsis();
                }

                public boolean matches(String arg) {
                    return arg.startsWith("-A");
                }

                public boolean hasArg() {
                    return false;
                }
                // Mapping for processor options created in
                // JavacProcessingEnvironment
                public boolean process(Options options, String option) {
                    int argLength = option.length();
                    if (argLength == 2) {
                        helper.error("err.empty.A.argument");
                        return true;
                    }
                    int sepIndex = option.indexOf('=');
                    String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
                    if (!JavacProcessingEnvironment.isValidOptionName(key)) {
                        helper.error("err.invalid.A.key", option);
                        return true;
                    }
                    return process(options, option, option);
                }
        },
        new Option(X,                                           "opt.X") {
            public boolean process(Options options, String option) {
                helper.printXhelp();
                return super.process(options, option);
            }
        },

        // This option exists only for the purpose of documenting itself.
        // It's actually implemented by the launcher.
        new Option(J,                   "opt.arg.flag",         "opt.J") {
            String helpSynopsis() {
                hasSuffix = true;
                return super.helpSynopsis();
            }
            public boolean process(Options options, String option) {
                throw new AssertionError
                    ("the -J flag should be caught by the launcher.");
            }
        },

        // stop after parsing and attributing.
  new HiddenOption(ATTRPARSEONLY),

        // dump pql after attribution and analysis
  new HiddenOption(DUMPPQL),
  new HiddenOption(PRINTPQLGEN),
  new HiddenOption(INTERPRETPQL),

        // new Option("-moreinfo",                                      "opt.moreinfo") {
        new HiddenOption(MOREINFO) {
            public boolean process(Options options, String option) {
                Type.moreInfo = true;
                return super.process(options, option);
            }
        },

        // treat warnings as errors
        new Option(WERROR,                                      "opt.Werror"),

        // use complex inference from context in the position of a method call argument
        new HiddenOption(COMPLEXINFERENCE),

        // generare source stubs
        // new HiddenOption("-stubs"),

        // relax some constraints to allow compiling from stubs
        // new HiddenOption("-relax"),

        // output source after translating away inner classes
        // new Option("-printflat",                             "opt.printflat"),
        // new HiddenOption("-printflat"),

        // display scope search details
        // new Option("-printsearch",                           "opt.printsearch"),
        // new HiddenOption("-printsearch"),

        // prompt after each error
        // new Option("-prompt",                                        "opt.prompt"),
        new HiddenOption(PROMPT),

        // dump stack on error
        new HiddenOption(DOE),

        // output source after type erasure
        // new Option("-s",                                     "opt.s"),
        new HiddenOption(PRINTSOURCE),

        // output shrouded class files
        // new Option("-scramble",                              "opt.scramble"),
        // new Option("-scrambleall",                           "opt.scrambleall"),

        // display warnings for generic unchecked operations
        new HiddenOption(WARNUNCHECKED) {
            public boolean process(Options options, String option) {
                options.put("-Xlint:unchecked", option);
                return false;
            }
        },

        new XOption(XMAXERRS,           "opt.arg.number",       "opt.maxerrs"),
        new XOption(XMAXWARNS,          "opt.arg.number",       "opt.maxwarns"),
        new XOption(XSTDOUT,            "opt.arg.file",         "opt.Xstdout") {
            public boolean process(Options options, String option, String arg) {
                try {
                    helper.setOut(new PrintWriter(new FileWriter(arg), true));
                } catch (java.io.IOException e) {
                    helper.error("err.error.writing.file", arg, e);
                    return true;
                }
                return super.process(options, option, arg);
            }
        },

        new XOption(XPRINT,                                     "opt.print"),

        new XOption(XPRINTROUNDS,                               "opt.printRounds"),

        new XOption(XPRINTPROCESSORINFO,                        "opt.printProcessorInfo"),

        new XOption(XPREFER,                                     "opt.prefer") {
            public boolean matches(String s) {
                return s.equals("-Xprefer:source") || s.equals("-Xprefer:newer");
            }
            public boolean process(Options options, String option, String operand) {
                int sep = option.indexOf(":");
View Full Code Here

Examples of com.sun.tools.javac.main.JavacOption.XOption

                }
                return false;
            }
        },

        new XOption(XLINT,                                      "opt.Xlint"),
        new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist") {
            public boolean matches(String s) {
                return s.startsWith("-Xlint:");
            }
            public boolean process(Options options, String option) {
                String suboptions = option.substring(7);
                options.put("-Xlint:", suboptions);
                // enter all the -Xlint suboptions as "-Xlint:suboption"
                for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) {
                    String tok = t.nextToken();
                    String opt = "-Xlint:" + tok;
                    options.put(opt, opt);
                }
                return false;
            }
        },

        // -nowarn is retained for command-line backward compatibility
        new Option(NOWARN,                                      "opt.nowarn") {
                public boolean process(Options options, String option) {
                    options.put("-Xlint:none", option);
                    return false;
                }
            },

        new Option(VERBOSE,                                     "opt.verbose"),

        // -deprecation is retained for command-line backward compatibility
        new Option(DEPRECATION,                                 "opt.deprecation") {
                public boolean process(Options options, String option) {
                    options.put("-Xlint:deprecation", option);
                    return false;
                }
            },

        new Option(CLASSPATH,              "opt.arg.path",      "opt.classpath"),
        new Option(CP,                     "opt.arg.path",      "opt.classpath") {
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-classpath", arg);
            }
        },
        new Option(SOURCEPATH,             "opt.arg.path",      "opt.sourcepath"),
        new Option(BOOTCLASSPATH,          "opt.arg.path",      "opt.bootclasspath") {
            public boolean process(Options options, String option, String arg) {
                options.remove("-Xbootclasspath/p:");
                options.remove("-Xbootclasspath/a:");
                return super.process(options, option, arg);
            }
        },
        new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
        new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
        new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
            public boolean process(Options options, String option, String arg) {
                options.remove("-Xbootclasspath/p:");
                options.remove("-Xbootclasspath/a:");
                return super.process(options, "-bootclasspath", arg);
            }
        },
        new Option(EXTDIRS,                "opt.arg.dirs",      "opt.extdirs"),
        new XOption(DJAVA_EXT_DIRS,        "opt.arg.dirs",      "opt.extdirs") {
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-extdirs", arg);
            }
        },
        new Option(ENDORSEDDIRS,            "opt.arg.dirs",     "opt.endorseddirs"),
        new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs",     "opt.endorseddirs") {
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-endorseddirs", arg);
            }
        },
        new Option(PROC_CUSTOM,                                 "opt.proc.none.only") {
            public boolean matches(String s) {
                return s.equals("-proc:none") || s.equals("-proc:only");
            }

            public boolean process(Options options, String option) {
                if (option.equals("-proc:none")) {
                    options.remove("-proc:only");
                } else {
                    options.remove("-proc:none");
                }
                options.put(option, option);
                return false;
            }
        },
        new Option(PROCESSOR,           "opt.arg.class.list",   "opt.processor"),
        new Option(PROCESSORPATH,       "opt.arg.path",         "opt.processorpath"),
        new Option(D,                   "opt.arg.directory",    "opt.d"),
        new Option(S,                   "opt.arg.directory",    "opt.sourceDest"),
        new Option(IMPLICIT,                                    "opt.implicit") {
            public boolean matches(String s) {
                return s.equals("-implicit:none") || s.equals("-implicit:class");
            }
            public boolean process(Options options, String option, String operand) {
                int sep = option.indexOf(":");
                options.put(option.substring(0, sep), option.substring(sep+1));
                options.put(option,option);
                return false;
            }
        },
        new Option(ENCODING,            "opt.arg.encoding",     "opt.encoding"),
        new Option(SOURCE,              "opt.arg.release",      "opt.source") {
            public boolean process(Options options, String option, String operand) {
                Source source = Source.lookup(operand);
                if (source == null) {
                    helper.error("err.invalid.source", operand);
                    return true;
                }
                return super.process(options, option, operand);
            }
        },
        new Option(TARGET,              "opt.arg.release",      "opt.target") {
            public boolean process(Options options, String option, String operand) {
                Target target = Target.lookup(operand);
                if (target == null) {
                    helper.error("err.invalid.target", operand);
                    return true;
                }
                return super.process(options, option, operand);
            }
        },
        new Option(VERSION,                                     "opt.version") {
            public boolean process(Options options, String option) {
                helper.printVersion();
                return super.process(options, option);
            }
        },
        new HiddenOption(FULLVERSION) {
            public boolean process(Options options, String option) {
                helper.printFullVersion();
                return super.process(options, option);
            }
        },
        new Option(HELP,                                        "opt.help") {
            public boolean process(Options options, String option) {
                helper.printHelp();
                return super.process(options, option);
            }
        },
        new Option(A,                "opt.arg.key.equals.value","opt.A") {
                String helpSynopsis() {
                    hasSuffix = true;
                    return super.helpSynopsis();
                }

                public boolean matches(String arg) {
                    return arg.startsWith("-A");
                }

                public boolean hasArg() {
                    return false;
                }
                // Mapping for processor options created in
                // JavacProcessingEnvironment
                public boolean process(Options options, String option) {
                    int argLength = option.length();
                    if (argLength == 2) {
                        helper.error("err.empty.A.argument");
                        return true;
                    }
                    int sepIndex = option.indexOf('=');
                    String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
                    if (!JavacProcessingEnvironment.isValidOptionName(key)) {
                        helper.error("err.invalid.A.key", option);
                        return true;
                    }
                    return process(options, option, option);
                }
        },
        new Option(X,                                           "opt.X") {
            public boolean process(Options options, String option) {
                helper.printXhelp();
                return super.process(options, option);
            }
        },

        // This option exists only for the purpose of documenting itself.
        // It's actually implemented by the launcher.
        new Option(J,                   "opt.arg.flag",         "opt.J") {
            String helpSynopsis() {
                hasSuffix = true;
                return super.helpSynopsis();
            }
            public boolean process(Options options, String option) {
                throw new AssertionError
                    ("the -J flag should be caught by the launcher.");
            }
        },

        // stop after parsing and attributing.
        // new HiddenOption("-attrparseonly"),

        // new Option("-moreinfo",                                      "opt.moreinfo") {
        new HiddenOption(MOREINFO) {
            public boolean process(Options options, String option) {
                Type.moreInfo = true;
                return super.process(options, option);
            }
        },

        // treat warnings as errors
        new Option(WERROR,                                      "opt.Werror"),

        // use complex inference from context in the position of a method call argument
        new HiddenOption(COMPLEXINFERENCE),

        // generare source stubs
        // new HiddenOption("-stubs"),

        // relax some constraints to allow compiling from stubs
        // new HiddenOption("-relax"),

        // output source after translating away inner classes
        // new Option("-printflat",                             "opt.printflat"),
        // new HiddenOption("-printflat"),

        // display scope search details
        // new Option("-printsearch",                           "opt.printsearch"),
        // new HiddenOption("-printsearch"),

        // prompt after each error
        // new Option("-prompt",                                        "opt.prompt"),
        new HiddenOption(PROMPT),

        // dump stack on error
        new HiddenOption(DOE),

        // output source after type erasure
        // new Option("-s",                                     "opt.s"),
        new HiddenOption(PRINTSOURCE),

        // output shrouded class files
        // new Option("-scramble",                              "opt.scramble"),
        // new Option("-scrambleall",                           "opt.scrambleall"),

        // display warnings for generic unchecked operations
        new HiddenOption(WARNUNCHECKED) {
            public boolean process(Options options, String option) {
                options.put("-Xlint:unchecked", option);
                return false;
            }
        },

        new XOption(XMAXERRS,           "opt.arg.number",       "opt.maxerrs"),
        new XOption(XMAXWARNS,          "opt.arg.number",       "opt.maxwarns"),
        new XOption(XSTDOUT,            "opt.arg.file",         "opt.Xstdout") {
            public boolean process(Options options, String option, String arg) {
                try {
                    helper.setOut(new PrintWriter(new FileWriter(arg), true));
                } catch (java.io.IOException e) {
                    helper.error("err.error.writing.file", arg, e);
                    return true;
                }
                return super.process(options, option, arg);
            }
        },

        new XOption(XPRINT,                                     "opt.print"),

        new XOption(XPRINTROUNDS,                               "opt.printRounds"),

        new XOption(XPRINTPROCESSORINFO,                        "opt.printProcessorInfo"),

        new XOption(XPREFER,                                     "opt.prefer") {
            public boolean matches(String s) {
                return s.equals("-Xprefer:source") || s.equals("-Xprefer:newer");
            }
            public boolean process(Options options, String option, String operand) {
                int sep = option.indexOf(":");
View Full Code Here

Examples of com.sun.tools.javac.main.JavacOption.XOption

                }
                return false;
            }
        },

        new XOption(XLINT,                                      "opt.Xlint"),
        new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist") {
            public boolean matches(String s) {
                return s.startsWith("-Xlint:");
            }
            public boolean process(Options options, String option) {
                String suboptions = option.substring(7);
                options.put("-Xlint:", suboptions);
                // enter all the -Xlint suboptions as "-Xlint:suboption"
                for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) {
                    String tok = t.nextToken();
                    String opt = "-Xlint:" + tok;
                    options.put(opt, opt);
                }
                return false;
            }
        },

        // -nowarn is retained for command-line backward compatibility
        new Option(NOWARN,                                      "opt.nowarn") {
                public boolean process(Options options, String option) {
                    options.put("-Xlint:none", option);
                    return false;
                }
            },

        new Option(VERBOSE,                                     "opt.verbose"),

        // -deprecation is retained for command-line backward compatibility
        new Option(DEPRECATION,                                 "opt.deprecation") {
                public boolean process(Options options, String option) {
                    options.put("-Xlint:deprecation", option);
                    return false;
                }
            },

        new Option(CLASSPATH,              "opt.arg.path",      "opt.classpath"),
        new Option(CP,                     "opt.arg.path",      "opt.classpath") {
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-classpath", arg);
            }
        },
        new Option(SOURCEPATH,             "opt.arg.path",      "opt.sourcepath"),
        new Option(BOOTCLASSPATH,          "opt.arg.path",      "opt.bootclasspath") {
            public boolean process(Options options, String option, String arg) {
                options.remove("-Xbootclasspath/p:");
                options.remove("-Xbootclasspath/a:");
                return super.process(options, option, arg);
            }
        },
        new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
        new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
        new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
            public boolean process(Options options, String option, String arg) {
                options.remove("-Xbootclasspath/p:");
                options.remove("-Xbootclasspath/a:");
                return super.process(options, "-bootclasspath", arg);
            }
        },
        new Option(EXTDIRS,                "opt.arg.dirs",      "opt.extdirs"),
        new XOption(DJAVA_EXT_DIRS,        "opt.arg.dirs",      "opt.extdirs") {
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-extdirs", arg);
            }
        },
        new Option(ENDORSEDDIRS,            "opt.arg.dirs",     "opt.endorseddirs"),
        new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs",     "opt.endorseddirs") {
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-endorseddirs", arg);
            }
        },
        new Option(PROC_CUSTOM,                                 "opt.proc.none.only") {
            public boolean matches(String s) {
                return s.equals("-proc:none") || s.equals("-proc:only");
            }

            public boolean process(Options options, String option) {
                if (option.equals("-proc:none")) {
                    options.remove("-proc:only");
                } else {
                    options.remove("-proc:none");
                }
                options.put(option, option);
                return false;
            }
        },
        new Option(PROCESSOR,           "opt.arg.class.list",   "opt.processor"),
        new Option(PROCESSORPATH,       "opt.arg.path",         "opt.processorpath"),
        new Option(D,                   "opt.arg.directory",    "opt.d"),
        new Option(S,                   "opt.arg.directory",    "opt.sourceDest"),
        new Option(IMPLICIT,                                    "opt.implicit") {
            public boolean matches(String s) {
                return s.equals("-implicit:none") || s.equals("-implicit:class");
            }
            public boolean process(Options options, String option, String operand) {
                int sep = option.indexOf(":");
                options.put(option.substring(0, sep), option.substring(sep+1));
                options.put(option,option);
                return false;
            }
        },
        new Option(ENCODING,            "opt.arg.encoding",     "opt.encoding"),
        new Option(SOURCE,              "opt.arg.release",      "opt.source") {
            public boolean process(Options options, String option, String operand) {
                Source source = Source.lookup(operand);
                if (source == null) {
                    helper.error("err.invalid.source", operand);
                    return true;
                }
                return super.process(options, option, operand);
            }
        },
        new Option(TARGET,              "opt.arg.release",      "opt.target") {
            public boolean process(Options options, String option, String operand) {
                Target target = Target.lookup(operand);
                if (target == null) {
                    helper.error("err.invalid.target", operand);
                    return true;
                }
                return super.process(options, option, operand);
            }
        },
        new Option(VERSION,                                     "opt.version") {
            public boolean process(Options options, String option) {
                helper.printVersion();
                return super.process(options, option);
            }
        },
        new HiddenOption(FULLVERSION) {
            public boolean process(Options options, String option) {
                helper.printFullVersion();
                return super.process(options, option);
            }
        },
        new Option(HELP,                                        "opt.help") {
            public boolean process(Options options, String option) {
                helper.printHelp();
                return super.process(options, option);
            }
        },
        new Option(A,                "opt.arg.key.equals.value","opt.A") {
                String helpSynopsis() {
                    hasSuffix = true;
                    return super.helpSynopsis();
                }

                public boolean matches(String arg) {
                    return arg.startsWith("-A");
                }

                public boolean hasArg() {
                    return false;
                }
                // Mapping for processor options created in
                // JavacProcessingEnvironment
                public boolean process(Options options, String option) {
                    int argLength = option.length();
                    if (argLength == 2) {
                        helper.error("err.empty.A.argument");
                        return true;
                    }
                    int sepIndex = option.indexOf('=');
                    String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
                    if (!JavacProcessingEnvironment.isValidOptionName(key)) {
                        helper.error("err.invalid.A.key", option);
                        return true;
                    }
                    return process(options, option, option);
                }
        },
        new Option(X,                                           "opt.X") {
            public boolean process(Options options, String option) {
                helper.printXhelp();
                return super.process(options, option);
            }
        },

        // This option exists only for the purpose of documenting itself.
        // It's actually implemented by the launcher.
        new Option(J,                   "opt.arg.flag",         "opt.J") {
            String helpSynopsis() {
                hasSuffix = true;
                return super.helpSynopsis();
            }
            public boolean process(Options options, String option) {
                throw new AssertionError
                    ("the -J flag should be caught by the launcher.");
            }
        },

        // stop after parsing and attributing.
        // new HiddenOption("-attrparseonly"),

        // new Option("-moreinfo",                                      "opt.moreinfo") {
        new HiddenOption(MOREINFO) {
            public boolean process(Options options, String option) {
                Type.moreInfo = true;
                return super.process(options, option);
            }
        },

        // treat warnings as errors
        new Option(WERROR,                                      "opt.Werror"),

        // use complex inference from context in the position of a method call argument
        new HiddenOption(COMPLEXINFERENCE),

        // generare source stubs
        // new HiddenOption("-stubs"),

        // relax some constraints to allow compiling from stubs
        // new HiddenOption("-relax"),

        // output source after translating away inner classes
        // new Option("-printflat",                             "opt.printflat"),
        // new HiddenOption("-printflat"),

        // display scope search details
        // new Option("-printsearch",                           "opt.printsearch"),
        // new HiddenOption("-printsearch"),

        // prompt after each error
        // new Option("-prompt",                                        "opt.prompt"),
        new HiddenOption(PROMPT),

        // dump stack on error
        new HiddenOption(DOE),

        // output source after type erasure
        // new Option("-s",                                     "opt.s"),
        new HiddenOption(PRINTSOURCE),

        // output shrouded class files
        // new Option("-scramble",                              "opt.scramble"),
        // new Option("-scrambleall",                           "opt.scrambleall"),

        // display warnings for generic unchecked operations
        new HiddenOption(WARNUNCHECKED) {
            public boolean process(Options options, String option) {
                options.put("-Xlint:unchecked", option);
                return false;
            }
        },

        new XOption(XMAXERRS,           "opt.arg.number",       "opt.maxerrs"),
        new XOption(XMAXWARNS,          "opt.arg.number",       "opt.maxwarns"),
        new XOption(XSTDOUT,            "opt.arg.file",         "opt.Xstdout") {
            public boolean process(Options options, String option, String arg) {
                try {
                    helper.setOut(new PrintWriter(new FileWriter(arg), true));
                } catch (java.io.IOException e) {
                    helper.error("err.error.writing.file", arg, e);
                    return true;
                }
                return super.process(options, option, arg);
            }
        },

        new XOption(XPRINT,                                     "opt.print"),

        new XOption(XPRINTROUNDS,                               "opt.printRounds"),

        new XOption(XPRINTPROCESSORINFO,                        "opt.printProcessorInfo"),

        new XOption(XPREFER,                                     "opt.prefer") {
            public boolean matches(String s) {
                return s.equals("-Xprefer:source") || s.equals("-Xprefer:newer");
            }
            public boolean process(Options options, String option, String operand) {
                int sep = option.indexOf(":");
View Full Code Here

Examples of com.sun.tools.javac.main.JavacOption.XOption

        },

        new Option(G_CUSTOM,                                    "opt.g.lines.vars.source",
                Option.ChoiceKind.ANYOF, "lines", "vars", "source"),

        new XOption(XLINT,                                      "opt.Xlint"),
        new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist",
                Option.ChoiceKind.ANYOF, getXLintChoices()),

        // -nowarn is retained for command-line backward compatibility
        new Option(NOWARN,                                      "opt.nowarn") {
            @Override
            public boolean process(Options options, String option) {
                options.put("-Xlint:none", option);
                return false;
            }
        },

        new Option(VERBOSE,                                     "opt.verbose"),
        new Option(VERBOSE_CUSTOM,                              "opt.verbose.suboptlist") {
            public boolean matches(String s) {
                return s.startsWith("-verbose:");
            }
            public boolean process(Options options, String option) {
                String suboptions = option.substring(9);
                options.put("-verbose:", suboptions);
                // enter all the -verbose suboptions as "-verbose:suboption"
                for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) {
                    String tok = t.nextToken();
                    String opt = "-verbose:" + tok;
                    options.put(opt, opt);
                }
                return false;
            }
        },

        // -deprecation is retained for command-line backward compatibility
        new Option(DEPRECATION,                                 "opt.deprecation") {
            @Override
            public boolean process(Options options, String option) {
                options.put("-Xlint:deprecation", option);
                return false;
            }
        },

        new Option(CLASSPATH,              "opt.arg.path",      "opt.classpath"),
        new Option(CP,                     "opt.arg.path",      "opt.classpath") {
            @Override
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-classpath", arg);
            }
        },
        new COption(CEYLONCWD,              "opt.arg.path",     "opt.ceyloncwd"),
        new COption(CEYLONREPO,             "opt.arg.url",      "opt.ceylonrepo"){
            @Override
            public boolean process(Options options, String option, String arg) {
                if(options != null)
                    options.addMulti(CEYLONREPO, arg);
                return false;
            }
        },
        new COption(CEYLONSYSTEMREPO,       "opt.arg.url",       "opt.ceylonsystemrepo"),
        new COption(CEYLONCACHEREPO,        "opt.arg.url",       "opt.ceyloncacherepo"),
        new COption(CEYLONNODEFREPOS,                            "opt.ceylonnodefrepos"),
        new COption(CEYLONUSER,             "opt.arg.value",     "opt.ceylonuser"),
        new COption(CEYLONPASS,             "opt.arg.value",     "opt.ceylonpass"),
        new COption(CEYLONNOOSGI,                                "opt.ceylonnoosgi"),
        new COption(CEYLONNOPOM,                                 "opt.ceylonnopom"),
        new COption(CEYLONPACK200,                               "opt.ceylonpack200"),
        new COption(CEYLONRESOURCEROOT,     "opt.arg.path",      "opt.ceylonresourceroot"),
        new COption(CEYLONDISABLEOPT,                            "opt.ceylondisableopt"),
        new COption(CEYLONDISABLEOPT_CUSTOM,                     "opt.ceylondisableopt.suboptlist"),
        new COption(CEYLONSUPPRESSWARNINGS, "opt.arg.value",     "opt.ceylonsuppresswarnings"),
        new Option(SOURCEPATH,              "opt.arg.path",      "opt.sourcepath"){
            @Override
            public boolean process(Options options, String option, String arg) {
                if(options != null)
                    options.addMulti(SOURCEPATH, arg);
                return false;
            }
        },
        new COption(CEYLONSOURCEPATH,       "opt.arg.directory", "opt.ceylonsourcepath"){
            @Override
            public boolean process(Options options, String option, String arg) {
                if(options != null)
                    options.addMulti(SOURCEPATH, arg);
                return false;
            }
        },
        new COption(CEYLONRESOURCEPATH,     "opt.arg.url",      "opt.ceylonresourcepath"){
            @Override
            public boolean process(Options options, String option, String arg) {
                if(options != null)
                    options.addMulti(CEYLONRESOURCEPATH, arg);
                return false;
            }
        },
        new Option(BOOTCLASSPATH,           "opt.arg.path",      "opt.bootclasspath") {
            @Override
            public boolean process(Options options, String option, String arg) {
                options.remove("-Xbootclasspath/p:");
                options.remove("-Xbootclasspath/a:");
                return super.process(options, option, arg);
            }
        },
        new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
        new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
        new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
            @Override
            public boolean process(Options options, String option, String arg) {
                options.remove("-Xbootclasspath/p:");
                options.remove("-Xbootclasspath/a:");
                return super.process(options, "-bootclasspath", arg);
            }
        },
        new Option(EXTDIRS,                "opt.arg.dirs",      "opt.extdirs"),
        new XOption(DJAVA_EXT_DIRS,        "opt.arg.dirs",      "opt.extdirs") {
            @Override
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-extdirs", arg);
            }
        },
        new Option(ENDORSEDDIRS,            "opt.arg.dirs",     "opt.endorseddirs"),
        new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs",     "opt.endorseddirs") {
            @Override
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-endorseddirs", arg);
            }
        },
        new Option(PROC,                                 "opt.proc.none.only",
                Option.ChoiceKind.ONEOF, "none", "only"),
        new Option(PROCESSOR,           "opt.arg.class.list",   "opt.processor"),
        new Option(PROCESSORPATH,       "opt.arg.path",         "opt.processorpath"),
        new Option(D,                   "opt.arg.directory",    "opt.d"),
        new COption(CEYLONOUT,           "opt.arg.url",         "opt.ceylonout"){
            @Override
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-d", arg);
            }
        },
        new COption(CEYLONOFFLINE,      "opt.ceylonoffline"),
        new COption(CEYLONCONTINUE,     "opt.ceyloncontinue"),
        new COption(CEYLONMAVENOVERRIDES, "opt.arg.url",        "opt.ceylonmavenoverrides"),
        new Option(S,                   "opt.arg.directory",    "opt.sourceDest"),
        new Option(IMPLICIT,                                    "opt.implicit",
                Option.ChoiceKind.ONEOF, "none", "class"),
        new Option(ENCODING,            "opt.arg.encoding",     "opt.encoding") {
            @Override
            public boolean process(Options options, String option, String operand) {
                try {
                    Charset.forName(operand);
                    options.put(option, operand);
                    return false;
                } catch (UnsupportedCharsetException e) {
                    helper.error("err.unsupported.encoding", operand);
                    return true;
                } catch (IllegalCharsetNameException e) {
                    helper.error("err.unsupported.encoding", operand);
                    return true;
                }
            }
        },
        new Option(SOURCE,              "opt.arg.release",      "opt.source") {
            @Override
            public boolean process(Options options, String option, String operand) {
                Source source = Source.lookup(operand);
                if (source == null) {
                    helper.error("err.invalid.source", operand);
                    return true;
                }
                return super.process(options, option, operand);
            }
        },
        new Option(TARGET,              "opt.arg.release",      "opt.target") {
            @Override
            public boolean process(Options options, String option, String operand) {
                Target target = Target.lookup(operand);
                if (target == null) {
                    helper.error("err.invalid.target", operand);
                    return true;
                }
                return super.process(options, option, operand);
            }
        },
        new COption(VERSION,                                     "opt.version") {
            @Override
            public boolean process(Options options, String option) {
                helper.printVersion();
                return super.process(options, option);
            }
        },
        new HiddenOption(FULLVERSION) {
            @Override
            public boolean process(Options options, String option) {
                helper.printFullVersion();
                return super.process(options, option);
            }
        },
        new HiddenOption(DIAGS) {
            @Override
            public boolean process(Options options, String option) {
                Option xd = getOptions(helper, EnumSet.of(XD))[0];
                option = option.substring(option.indexOf('=') + 1);
                String diagsOption = option.contains("%") ?
                    "-XDdiagsFormat=" :
                    "-XDdiags=";
                diagsOption += option;
                if (xd.matches(diagsOption))
                    return xd.process(options, diagsOption);
                else
                    return false;
            }
        },
        new COption(HELP,                                        "opt.help") {
            @Override
            public boolean process(Options options, String option) {
                helper.printHelp();
                return super.process(options, option);
            }
        },
        new Option(A,                "opt.arg.key.equals.value","opt.A") {
            @Override
            String helpSynopsis() {
                hasSuffix = true;
                return super.helpSynopsis();
            }

            @Override
            public boolean matches(String arg) {
                return arg.startsWith("-A");
            }

            @Override
            public boolean hasArg() {
                return false;
            }
            // Mapping for processor options created in
            // JavacProcessingEnvironment
            @Override
            public boolean process(Options options, String option) {
                int argLength = option.length();
                if (argLength == 2) {
                    helper.error("err.empty.A.argument");
                    return true;
                }
                int sepIndex = option.indexOf('=');
                String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
                if (!JavacProcessingEnvironment.isValidOptionName(key)) {
                    helper.error("err.invalid.A.key", option);
                    return true;
                }
                return process(options, option, option);
            }
        },
        new Option(X,                                           "opt.X") {
            @Override
            public boolean process(Options options, String option) {
                helper.printXhelp();
                return super.process(options, option);
            }
        },

        // This option exists only for the purpose of documenting itself.
        // It's actually implemented by the launcher.
        new Option(J,                   "opt.arg.flag",         "opt.J") {
            @Override
            String helpSynopsis() {
                hasSuffix = true;
                return super.helpSynopsis();
            }
            @Override
            public boolean process(Options options, String option) {
                throw new AssertionError
                    ("the -J flag should be caught by the launcher.");
            }
        },

        // stop after parsing and attributing.
        // new HiddenOption("-attrparseonly"),

        // new Option("-moreinfo",                                      "opt.moreinfo") {
        new HiddenOption(MOREINFO) {
            @Override
            public boolean process(Options options, String option) {
                Type.moreInfo = true;
                return super.process(options, option);
            }
        },

        // treat warnings as errors
        new Option(WERROR,                                      "opt.Werror"),


        new Option(SRC,                     "opt.arg.src",      "opt.src") {
            public boolean process(Options options, String option, String arg) {
                return super.process(options, "-src", arg);
            }
        },

        // use complex inference from context in the position of a method call argument
        new HiddenOption(COMPLEXINFERENCE),

        // generare source stubs
        // new HiddenOption("-stubs"),

        // relax some constraints to allow compiling from stubs
        // new HiddenOption("-relax"),

        // output source after translating away inner classes
        // new Option("-printflat",                             "opt.printflat"),
        // new HiddenOption("-printflat"),

        // display scope search details
        // new Option("-printsearch",                           "opt.printsearch"),
        // new HiddenOption("-printsearch"),

        // prompt after each error
        // new Option("-prompt",                                        "opt.prompt"),
        new HiddenOption(PROMPT),

        // dump stack on error
        new HiddenOption(DOE),

        // output source after type erasure
        // new Option("-s",                                     "opt.s"),
        new HiddenOption(PRINTSOURCE),

        // allow us to compile ceylon.language
        new HiddenOption(BOOTSTRAPCEYLON),

        // output shrouded class files
        // new Option("-scramble",                              "opt.scramble"),
        // new Option("-scrambleall",                           "opt.scrambleall"),

        // display warnings for generic unchecked operations
        new HiddenOption(WARNUNCHECKED) {
            @Override
            public boolean process(Options options, String option) {
                options.put("-Xlint:unchecked", option);
                return false;
            }
        },

        new XOption(XMAXERRS,           "opt.arg.number",       "opt.maxerrs"),
        new XOption(XMAXWARNS,          "opt.arg.number",       "opt.maxwarns"),
        new XOption(XSTDOUT,            "opt.arg.file",         "opt.Xstdout") {
            @Override
            public boolean process(Options options, String option, String arg) {
                try {
                    helper.setOut(new PrintWriter(new FileWriter(arg), true));
                } catch (java.io.IOException e) {
                    helper.error("err.error.writing.file", arg, e);
                    return true;
                }
                return super.process(options, option, arg);
            }
        },

        new XOption(XPRINT,                                     "opt.print"),

        new XOption(XPRINTROUNDS,                               "opt.printRounds"),

        new XOption(XPRINTPROCESSORINFO,                        "opt.printProcessorInfo"),

        new XOption(XPREFER,                                    "opt.prefer",
                Option.ChoiceKind.ONEOF, "source", "newer"),

        new XOption(XPKGINFO,                                   "opt.pkginfo",
                Option.ChoiceKind.ONEOF, "always", "legacy", "nonempty"),

        /* -O is a no-op, accepted for backward compatibility. */
        new HiddenOption(O),

View Full Code Here

Examples of com.sun.tools.javac.main.JavacOption.XOption

    }
    return false;
      }
  },

  new XOption(XLINT,          "opt.Xlint"),
  new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist") {
      public boolean matches(String s) {
    return s.startsWith("-Xlint:");
      }
      //处理方式与G_CUSTOM相同
      public boolean process(Options options, String option) {
    String suboptions = option.substring(7);
    options.put("-Xlint:", suboptions);
    // enter all the -Xlint suboptions as "-Xlint:suboption"
    for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) {
        String tok = t.nextToken();
        String opt = "-Xlint:" + tok;
        options.put(opt, opt);
    }
    return false;
      }
  },

  // -nowarn is retained for command-line backward compatibility
  //“-nowarn”选项只是为了向后兼容而保留下来的,
  //“-nowarn”与“-Xlint:none”等价
  new Option(NOWARN,          "opt.nowarn") {
    public boolean process(Options options, String option) {
        options.put("-Xlint:none", option);
        return false;
    }
      },

  new Option(VERBOSE,          "opt.verbose"),

  // -deprecation is retained for command-line backward compatibility
  //“-deprecation”选项只是为了向后兼容而保留下来的,
  //“-deprecation”与“-Xlint:deprecation”等价
  new Option(DEPRECATION,                                 "opt.deprecation") {
    public boolean process(Options options, String option) {
        options.put("-Xlint:deprecation", option);
        return false;
    }
      },

  new Option(CLASSPATH,              "opt.arg.path""opt.classpath"),
  new Option(CP,                     "opt.arg.path""opt.classpath") {
      public boolean process(Options options, String option, String arg) {
    return super.process(options, "-classpath", arg);
      }
  },
  new Option(SOURCEPATH,             "opt.arg.path""opt.sourcepath"),
  new Option(BOOTCLASSPATH,     "opt.arg.path""opt.bootclasspath") {
      public boolean process(Options options, String option, String arg) {
     options.remove("-Xbootclasspath/p:");
     options.remove("-Xbootclasspath/a:");
    return super.process(options, option, arg);
      }
  },
  new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
  new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
  //选项“-Xbootclasspath:<路径>”与“-bootclasspath <路径>”等价
  //从这个例子说明了非标准选项(或称扩展选项)在运用成熟后会转换成标准选项
  new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
      public boolean process(Options options, String option, String arg) {
     options.remove("-Xbootclasspath/p:");
     options.remove("-Xbootclasspath/a:");
     return super.process(options, "-bootclasspath", arg);
      }
  },
  new Option(EXTDIRS,       "opt.arg.dirs""opt.extdirs"),
  new XOption(DJAVA_EXT_DIRS,     "opt.arg.dirs""opt.extdirs") {
      public boolean process(Options options, String option, String arg) {
     return super.process(options, "-extdirs", arg);
      }
  },
  new Option(ENDORSEDDIRS,      "opt.arg.dirs""opt.endorseddirs"),
  new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs""opt.endorseddirs") {
      public boolean process(Options options, String option, String arg) {
     return super.process(options, "-endorseddirs", arg);
      }
  },
  new Option(PROC_CUSTOM,                                 "opt.proc.none.only") {
      public boolean matches(String s) {
    return s.equals("-proc:none") || s.equals("-proc:only");
      }
      //"-proc:none"与"-proc:only"同时出现在命令行选项中时,只取其中之一
      public boolean process(Options options, String option) {
    if (option.equals("-proc:none")) {
        options.remove("-proc:only");
    } else {
        options.remove("-proc:none");
    }
    options.put(option, option);
    return false;
      }
        },
  new Option(PROCESSOR,           "opt.arg.class.list""opt.processor"),
  new Option(PROCESSORPATH,       "opt.arg.path",    "opt.processorpath"),
  new Option(D,                   "opt.arg.directory""opt.d"),
  new Option(S,                   "opt.arg.directory""opt.sourceDest"),
 
    //IMPLICIT: 1.7新增标准选项,指定是否为隐式引用文件生成类文件
        new Option(IMPLICIT,                                    "opt.implicit") {
            public boolean matches(String s) {
                return s.equals("-implicit:none") || s.equals("-implicit:class");
            }
            public boolean process(Options options, String option, String operand) {
                int sep = option.indexOf(":");
                options.put(option.substring(0, sep), option.substring(sep+1));
                options.put(option,option);
                /*例子:java -classpath bin\classes com.sun.tools.javac.Main -implicit:none -implicit:class
                打印:
                option=-implicit:none
        option.substring(0, sep)=-implicit
        option.substring(sep+1)=none
        option=-implicit:class
        option.substring(0, sep)=-implicit
        option.substring(sep+1)=class
        options.keySet()=[-implicit, -implicit:none, -implicit:class]
        */
        /*
                DEBUG.P("option="+option);
                DEBUG.P("option.substring(0, sep)="+option.substring(0, sep));
                DEBUG.P("option.substring(sep+1)="+option.substring(sep+1));
                DEBUG.P("options.keySet()="+options.keySet());
                */
                return false;
            }
        },
  new Option(ENCODING,    "opt.arg.encoding""opt.encoding"),
  new Option(SOURCE,    "opt.arg.release""opt.source") {
      public boolean process(Options options, String option, String operand) {
      //指com.sun.tools.javac.code.Source类
      //只能是-source 1.2 到 -source 1.7
    Source source = Source.lookup(operand);
    if (source == null) {
      /*如指定 -source 1.1 选项参数时,报错如下:
     
      javac: 无效的源版本: 1.1
      用法: javac <options> <source files>
      -help 用于列出可能的选项
     
     
      错误提示“key”与内容在下面的文件中:
      com\sun\tools\javac\resources\javac.properties(分国际化版本)
      */
        helper.error("err.invalid.source", operand);
        return true;
    }
    return super.process(options, option, operand);
      }
  },
  new Option(TARGET,    "opt.arg.release""opt.target") {
      public boolean process(Options options, String option, String operand) {
      /*
      指com.sun.tools.javac.jvm.Target类
      只能是下列格式之一:
      -target 1.1、-target 1.2、
      -target 1.3、-target 1.4、-target jsr14、-target 1.4.1、-target 1.4.2
      -target 1.5、-target 1.6、-target 1.7、
      -target 5  、-target 6  、-target 7
      */
    Target target = Target.lookup(operand);
    if (target == null) {
      //与SOURCE选项类似
        helper.error("err.invalid.target", operand);
        return true;
    }
    return super.process(options, option, operand);
      }
  },
  new Option(VERSION,          "opt.version") {
      public boolean process(Options options, String option) {
                helper.printVersion();
    return super.process(options, option);
      }
  },
  new HiddenOption(FULLVERSION) {
      public boolean process(Options options, String option) {
                helper.printFullVersion();
    return super.process(options, option);
      }
  },
  new Option(HELP,          "opt.help") {
    //当处理命令行选项时(在Main类的processArgs()方法中处理),
    //如果有"-help"选项,则在这里直接调用printHelp()打印标准选项信息
    //(调用printHelp()会间接调用Main类的help()方法)
      public boolean process(Options options, String option) {
                helper.printHelp();
    return super.process(options, option);
      }
  },
  new Option(A,                "opt.arg.key.equals.value","opt.A") {
    String helpSynopsis() {
        hasSuffix = true;
        return super.helpSynopsis();
    }

    public boolean matches(String arg) {
        return arg.startsWith("-A");
    }
   
    public boolean hasArg() {
        return false;
    }
    // Mapping for processor options created in
    // JavacProcessingEnvironment
    public boolean process(Options options, String option) {
      //在com.sun.tools.javac.main.Main===>processArgs(1)方法中会先
      //调用matches()方法,若返回true后,再调用hasArg()方法,
      //hasArg()方法总是返回false,接着转到这里,
      //参数option一定是以“-A”开头的
        int argLength = option.length();
        if (argLength == 2) {
        //-A 需要一个参数;使用 '-Akey' 或 '-Akey=value'
      helper.error("err.empty.A.argument");
      return true;
        }
        int sepIndex = option.indexOf('=');
        String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
        if (!JavacProcessingEnvironment.isValidOptionName(key)) {
      helper.error("err.invalid.A.key", option);
      return true;
        }
        return process(options, option, option);
    }
  },
  new Option(X,             "opt.X") {
    //当处理命令行选项时(在Main类的processArgs()方法中处理),
    //如果有"-X"选项,则在这里直接调用printXhelp()打印扩展选项信息
    //(调用printXhelp()会间接调用Main类的xhelp()方法)
      public boolean process(Options options, String option) {
    helper.printXhelp();
    return super.process(options, option);
      }
  },

  // This option exists only for the purpose of documenting itself.
  // It's actually implemented by the launcher.
  new Option(J,       "opt.arg.flag",    "opt.J") {
      String helpSynopsis() {
    hasSuffix = true;
    return super.helpSynopsis();
      }
      //要是这样运行:java -classpath bin\classes com.sun.tools.javac.Main -help -J
      //就会调用到这里,因为加-help会先调用helpSynopsis()使得hasSuffix = true
            //这样当在Main.processArgs方法中运行到option.hasArg()时就返回false
      public boolean process(Options options, String option) {
      //DEBUG.P("option="+option);
    throw new AssertionError
        ("the -J flag should be caught by the launcher.");
      }
  },

  // stop after parsing and attributing.
  // new HiddenOption("-attrparseonly"),

  // new Option("-moreinfo",          "opt.moreinfo") {
  new HiddenOption(MOREINFO) {
      public boolean process(Options options, String option) {
      //moreInfo是一个static boolean字段
      //在com.sun.tools.javac.code.Type类定义
    Type.moreInfo = true;
    return super.process(options, option);
      }
  },

  // treat warnings as errors
  new HiddenOption(WERROR),

  // use complex inference from context in the position of a method call argument
  new HiddenOption(COMPLEXINFERENCE),

  // generare source stubs
  // new HiddenOption("-stubs"),

  // relax some constraints to allow compiling from stubs
  // new HiddenOption("-relax"),

  // output source after translating away inner classes
  // new Option("-printflat",        "opt.printflat"),
  // new HiddenOption("-printflat"),

  // display scope search details
  // new Option("-printsearch",        "opt.printsearch"),
  // new HiddenOption("-printsearch"),

  // prompt after each error
  // new Option("-prompt",          "opt.prompt"),
  new HiddenOption(PROMPT),

  // dump stack on error
  new HiddenOption(DOE),

  // output source after type erasure
  // new Option("-s",          "opt.s"),
  new HiddenOption(PRINTSOURCE),

  // output shrouded class files
  // new Option("-scramble",        "opt.scramble"),
  // new Option("-scrambleall",        "opt.scrambleall"),

  // display warnings for generic unchecked operations
  new HiddenOption(WARNUNCHECKED) {
      public boolean process(Options options, String option) {
    options.put("-Xlint:unchecked", option);
    return false;
      }
  },

  new XOption(XMAXERRS,     "opt.arg.number""opt.maxerrs"),
  new XOption(XMAXWARNS,    "opt.arg.number""opt.maxwarns"),
  new XOption(XSTDOUT,    "opt.arg.file",    "opt.Xstdout") {
      public boolean process(Options options, String option, String arg) {
    try {
        helper.setOut(new PrintWriter(new FileWriter(arg), true));
    } catch (java.io.IOException e) {
        helper.error("err.error.writing.file", arg, e);
        return true;
    }
    return super.process(options, option, arg);
      }
  },

  new XOption(XPRINT,             "opt.print"),

  new XOption(XPRINTROUNDS,           "opt.printRounds"),

  new XOption(XPRINTPROCESSORINFO,      "opt.printProcessorInfo"),
 
        //1.7新增扩展选项,
        //当同时找到隐式编译类的源文件和类文件时,指定读取文件,
        //-Xprefer:source在com.sun.tools.javac.jvm.ClassReader类
        //的includeClassFile()方法中有相关应用
        new XOption(XPREFER,                                     "opt.prefer") {
            public boolean matches(String s) {
                return s.equals("-Xprefer:source") || s.equals("-Xprefer:newer");
            }
            public boolean process(Options options, String option, String operand) {
                int sep = option.indexOf(":");
View Full Code Here

Examples of com.sun.tools.javac.main.JavacOption.XOption

    }
    return false;
      }
  },

  new XOption(XLINT,          "opt.Xlint"),
  new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist") {
      public boolean matches(String s) {
    return s.startsWith("-Xlint:");
      }
      public boolean process(Options options, String option) {
    String suboptions = option.substring(7);
    options.put("-Xlint:", suboptions);
    // enter all the -Xlint suboptions as "-Xlint:suboption"
    for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) {
        String tok = t.nextToken();
        String opt = "-Xlint:" + tok;
        options.put(opt, opt);
    }
    return false;
      }
  },

  // -nowarn is retained for command-line backward compatibility
  new Option(NOWARN,          "opt.nowarn") {
    public boolean process(Options options, String option) {
        options.put("-Xlint:none", option);
        return false;
    }
      },

  new Option(VERBOSE,          "opt.verbose"),

  // -deprecation is retained for command-line backward compatibility
  new Option(DEPRECATION,                                 "opt.deprecation") {
    public boolean process(Options options, String option) {
        options.put("-Xlint:deprecation", option);
        return false;
    }
      },

  new Option(CLASSPATH,              "opt.arg.path""opt.classpath"),
  new Option(CP,                     "opt.arg.path""opt.classpath") {
      public boolean process(Options options, String option, String arg) {
    return super.process(options, "-classpath", arg);
      }
  },
  new Option(SOURCEPATH,             "opt.arg.path""opt.sourcepath"),
  new Option(BOOTCLASSPATH,     "opt.arg.path""opt.bootclasspath") {
      public boolean process(Options options, String option, String arg) {
     options.remove("-Xbootclasspath/p:");
     options.remove("-Xbootclasspath/a:");
    return super.process(options, option, arg);
      }
  },
  new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
  new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
  new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
      public boolean process(Options options, String option, String arg) {
     options.remove("-Xbootclasspath/p:");
     options.remove("-Xbootclasspath/a:");
     return super.process(options, "-bootclasspath", arg);
      }
  },
  new Option(EXTDIRS,       "opt.arg.dirs""opt.extdirs"),
  new XOption(DJAVA_EXT_DIRS,     "opt.arg.dirs""opt.extdirs") {
      public boolean process(Options options, String option, String arg) {
     return super.process(options, "-extdirs", arg);
      }
  },
  new Option(ENDORSEDDIRS,      "opt.arg.dirs""opt.endorseddirs"),
  new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs""opt.endorseddirs") {
      public boolean process(Options options, String option, String arg) {
     return super.process(options, "-endorseddirs", arg);
      }
  },
  new Option(PROC_CUSTOM,                                 "opt.proc.none.only") {
      public boolean matches(String s) {
    return s.equals("-proc:none") || s.equals("-proc:only");
      }

      public boolean process(Options options, String option) {
    if (option.equals("-proc:none")) {
        options.remove("-proc:only");
    } else {
        options.remove("-proc:none");
    }
    options.put(option, option);
    return false;
      }
        },
  new Option(PROCESSOR,           "opt.arg.class.list""opt.processor"),
  new Option(PROCESSORPATH,       "opt.arg.path",    "opt.processorpath"),
  new Option(D,                   "opt.arg.directory""opt.d"),
  new Option(S,                   "opt.arg.directory""opt.sourceDest"),
        new Option(IMPLICIT,                                    "opt.implicit") {
            public boolean matches(String s) {
                return s.equals("-implicit:none") || s.equals("-implicit:class");
            }
            public boolean process(Options options, String option, String operand) {
                int sep = option.indexOf(":");
                options.put(option.substring(0, sep), option.substring(sep+1));
                options.put(option,option);
                return false;
            }
        },
  new Option(ENCODING,    "opt.arg.encoding""opt.encoding"),
  new Option(SOURCE,    "opt.arg.release""opt.source") {
      public boolean process(Options options, String option, String operand) {
    Source source = Source.lookup(operand);
    if (source == null) {
        helper.error("err.invalid.source", operand);
        return true;
    }
    return super.process(options, option, operand);
      }
  },
  new Option(TARGET,    "opt.arg.release""opt.target") {
      public boolean process(Options options, String option, String operand) {
    Target target = Target.lookup(operand);
    if (target == null) {
        helper.error("err.invalid.target", operand);
        return true;
    }
    return super.process(options, option, operand);
      }
  },
  new Option(VERSION,          "opt.version") {
      public boolean process(Options options, String option) {
                helper.printVersion();
    return super.process(options, option);
      }
  },
  new HiddenOption(FULLVERSION) {
      public boolean process(Options options, String option) {
                helper.printFullVersion();
    return super.process(options, option);
      }
  },
  new Option(HELP,          "opt.help") {
      public boolean process(Options options, String option) {
                helper.printHelp();
    return super.process(options, option);
      }
  },
  new Option(A,                "opt.arg.key.equals.value","opt.A") {
    String helpSynopsis() {
        hasSuffix = true;
        return super.helpSynopsis();
    }

    public boolean matches(String arg) {
        return arg.startsWith("-A");
    }
   
    public boolean hasArg() {
        return false;
    }
    // Mapping for processor options created in
    // JavacProcessingEnvironment
    public boolean process(Options options, String option) {
        int argLength = option.length();
        if (argLength == 2) {
      helper.error("err.empty.A.argument");
      return true;
        }
        int sepIndex = option.indexOf('=');
        String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
        if (!JavacProcessingEnvironment.isValidOptionName(key)) {
      helper.error("err.invalid.A.key", option);
      return true;
        }
        return process(options, option, option);
    }
  },
  new Option(X,             "opt.X") {
      public boolean process(Options options, String option) {
    helper.printXhelp();
    return super.process(options, option);
      }
  },

  // This option exists only for the purpose of documenting itself.
  // It's actually implemented by the launcher.
  new Option(J,       "opt.arg.flag",    "opt.J") {
      String helpSynopsis() {
    hasSuffix = true;
    return super.helpSynopsis();
      }
      public boolean process(Options options, String option) {
    throw new AssertionError
        ("the -J flag should be caught by the launcher.");
      }
  },

  // stop after parsing and attributing.
  // new HiddenOption("-attrparseonly"),

  // new Option("-moreinfo",          "opt.moreinfo") {
  new HiddenOption(MOREINFO) {
      public boolean process(Options options, String option) {
    Type.moreInfo = true;
    return super.process(options, option);
      }
  },

  // treat warnings as errors
  new HiddenOption(WERROR),

  // use complex inference from context in the position of a method call argument
  new HiddenOption(COMPLEXINFERENCE),

  // generare source stubs
  // new HiddenOption("-stubs"),

  // relax some constraints to allow compiling from stubs
  // new HiddenOption("-relax"),

  // output source after translating away inner classes
  // new Option("-printflat",        "opt.printflat"),
  // new HiddenOption("-printflat"),

  // display scope search details
  // new Option("-printsearch",        "opt.printsearch"),
  // new HiddenOption("-printsearch"),

  // prompt after each error
  // new Option("-prompt",          "opt.prompt"),
  new HiddenOption(PROMPT),

  // dump stack on error
  new HiddenOption(DOE),

  // output source after type erasure
  // new Option("-s",          "opt.s"),
  new HiddenOption(PRINTSOURCE),

  // output shrouded class files
  // new Option("-scramble",        "opt.scramble"),
  // new Option("-scrambleall",        "opt.scrambleall"),

  // display warnings for generic unchecked operations
  new HiddenOption(WARNUNCHECKED) {
      public boolean process(Options options, String option) {
    options.put("-Xlint:unchecked", option);
    return false;
      }
  },

  new XOption(XMAXERRS,     "opt.arg.number""opt.maxerrs"),
  new XOption(XMAXWARNS,    "opt.arg.number""opt.maxwarns"),
  new XOption(XSTDOUT,    "opt.arg.file",    "opt.Xstdout") {
      public boolean process(Options options, String option, String arg) {
    try {
        helper.setOut(new PrintWriter(new FileWriter(arg), true));
    } catch (java.io.IOException e) {
        helper.error("err.error.writing.file", arg, e);
        return true;
    }
    return super.process(options, option, arg);
      }
  },

  new XOption(XPRINT,             "opt.print"),

  new XOption(XPRINTROUNDS,           "opt.printRounds"),

  new XOption(XPRINTPROCESSORINFO,      "opt.printProcessorInfo"),
       
        new XOption(XPREFER,                                     "opt.prefer") {
            public boolean matches(String s) {
                return s.equals("-Xprefer:source") || s.equals("-Xprefer:newer");
            }
            public boolean process(Options options, String option, String operand) {
                int sep = option.indexOf(":");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.