Examples of HiddenOption


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

            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),

        /* -Xjcov produces tables to support the code coverage tool jcov. */
        new HiddenOption(XJCOV),

        /* This is a back door to the compiler's option table.
         * -XDx=y sets the option x to the value y.
         * -XDx sets the option x to the value x.
         */
        new HiddenOption(XD) {
            String s;
            @Override
            public boolean matches(String s) {
                this.s = s;
                return s.startsWith(name.optionName);
            }
            @Override
            public boolean process(Options options, String option) {
                s = s.substring(name.optionName.length());
                int eq = s.indexOf('=');
                String key = (eq < 0) ? s : s.substring(0, eq);
                String value = (eq < 0) ? s : s.substring(eq+1);
                options.put(key, value);
                return false;
            }
        },

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

        /*
         * TODO: With apt, the matches method accepts anything if
         * -XclassAsDecls is used; code elsewhere does the lookup to
         * see if the class name is both legal and found.
         *
         * In apt, the process method adds the candidate class file
         * name to a separate list.
         */
        new HiddenOption(SOURCEFILE) {
            String s;
            @Override
            public boolean matches(String s) {
                this.s = s;
                return s.endsWith(".java"// Java source file
View Full Code Here

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

            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(":");
                options.put(option.substring(0, sep), option.substring(sep+1));
                options.put(option,option);
                return false;
            }
        },

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

        /* -Xjcov produces tables to support the code coverage tool jcov. */
        new HiddenOption(XJCOV),

        /* This is a back door to the compiler's option table.
         * -XDx=y sets the option x to the value y.
         * -XDx sets the option x to the value x.
         */
        new HiddenOption(XD) {
            String s;
            public boolean matches(String s) {
                this.s = s;
                return s.startsWith(name.optionName);
            }
            public boolean process(Options options, String option) {
                s = s.substring(name.optionName.length());
                int eq = s.indexOf('=');
                String key = (eq < 0) ? s : s.substring(0, eq);
                String value = (eq < 0) ? s : s.substring(eq+1);
                options.put(key, value);
                return false;
            }
        },

        /*
         * TODO: With apt, the matches method accepts anything if
         * -XclassAsDecls is used; code elsewhere does the lookup to
         * see if the class name is both legal and found.
         *
         * In apt, the process method adds the candiate class file
         * name to a separate list.
         */
        new HiddenOption(SOURCEFILE) {
            String s;
            public boolean matches(String s) {
                this.s = s;
                return s.endsWith(".java"// Java source file
                    || SourceVersion.isName(s);   // Legal type name
View Full Code Here

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

            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(":");
                options.put(option.substring(0, sep), option.substring(sep+1));
                options.put(option,option);
                return false;
            }
        },

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

        /* -Xjcov produces tables to support the code coverage tool jcov. */
        new HiddenOption(XJCOV),

        /* This is a back door to the compiler's option table.
         * -XDx=y sets the option x to the value y.
         * -XDx sets the option x to the value x.
         */
        new HiddenOption(XD) {
            String s;
            public boolean matches(String s) {
                this.s = s;
                return s.startsWith(name.optionName);
            }
            public boolean process(Options options, String option) {
                s = s.substring(name.optionName.length());
                int eq = s.indexOf('=');
                String key = (eq < 0) ? s : s.substring(0, eq);
                String value = (eq < 0) ? s : s.substring(eq+1);
                options.put(key, value);
                return false;
            }
        },

        /*
         * TODO: With apt, the matches method accepts anything if
         * -XclassAsDecls is used; code elsewhere does the lookup to
         * see if the class name is both legal and found.
         *
         * In apt, the process method adds the candiate class file
         * name to a separate list.
         */
        new HiddenOption(SOURCEFILE) {
            String s;
            public boolean matches(String s) {
                this.s = s;
                return s.endsWith(".java"// Java source file
                    || SourceVersion.isName(s);   // Legal type name
View Full Code Here

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

            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(":");
                options.put(option.substring(0, sep), option.substring(sep+1));
                options.put(option,option);
                return false;
            }
        },

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

        /* -Xjcov produces tables to support the code coverage tool jcov. */
        new HiddenOption(XJCOV),

        /* This is a back door to the compiler's option table.
         * -XDx=y sets the option x to the value y.
         * -XDx sets the option x to the value x.
         */
        new HiddenOption(XD) {
            String s;
            public boolean matches(String s) {
                this.s = s;
                return s.startsWith(name.optionName);
            }
            public boolean process(Options options, String option) {
                s = s.substring(name.optionName.length());
                int eq = s.indexOf('=');
                String key = (eq < 0) ? s : s.substring(0, eq);
                String value = (eq < 0) ? s : s.substring(eq+1);
                options.put(key, value);
                return false;
            }
        },

        /*
         * TODO: With apt, the matches method accepts anything if
         * -XclassAsDecls is used; code elsewhere does the lookup to
         * see if the class name is both legal and found.
         *
         * In apt, the process method adds the candiate class file
         * name to a separate list.
         */
        new HiddenOption(SOURCEFILE) {
            String s;
            public boolean matches(String s) {
                this.s = s;
                return s.endsWith(".java"// Java source file
                    || SourceVersion.isName(s);   // Legal type name
View Full Code Here

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

            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),

        /* -Xjcov produces tables to support the code coverage tool jcov. */
        new HiddenOption(XJCOV),

        /* This is a back door to the compiler's option table.
         * -XDx=y sets the option x to the value y.
         * -XDx sets the option x to the value x.
         */
        new HiddenOption(XD) {
            String s;
            @Override
            public boolean matches(String s) {
                this.s = s;
                return s.startsWith(name.optionName);
            }
            @Override
            public boolean process(Options options, String option) {
                s = s.substring(name.optionName.length());
                int eq = s.indexOf('=');
                String key = (eq < 0) ? s : s.substring(0, eq);
                String value = (eq < 0) ? s : s.substring(eq+1);
                options.put(key, value);
                return false;
            }
        },

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

        /*
         * TODO: With apt, the matches method accepts anything if
         * -XclassAsDecls is used; code elsewhere does the lookup to
         * see if the class name is both legal and found.
         *
         * In apt, the process method adds the candidate class file
         * name to a separate list.
         */
        new HiddenOption(SOURCEFILE) {
            String s;
            @Override
            public boolean matches(String s) {
                this.s = s;
                return s.endsWith(".java"// Java source file
View Full Code Here

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

      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(":");
                options.put(option.substring(0, sep), option.substring(sep+1));
                options.put(option,option);
                return false;
            }
        },

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

  /* -Xjcov produces tables to support the code coverage tool jcov. */
  new HiddenOption(XJCOV),

  /* This is a back door to the compiler's option table.
   * -XDx=y sets the option x to the value y.
   * -XDx sets the option x to the value x.
   */
  new HiddenOption(XD) {
      String s;
      public boolean matches(String s) {
    this.s = s;
    return s.startsWith(name.optionName);
      }
     
      //这里隐藏了一个细节
      //比如当指定“-XDcompilePolicy=check”时,将生
      //成<compilePolicy,check>这一条目放入options中,以后
      //就可以用options.get("compilePolicy")取值了
      //后面会有很多options.get(字符串)调用,以前我看到
      //options.get(字符串)里的字符串不是以字符“-"开头的觉得
      //很奇怪,原来是在这里动的手脚。。。
      //在JavaCompiler类的构造方法中就
      //有options.get("compilePolicy")这样的例子
      public boolean process(Options options, String option) {
    s = s.substring(name.optionName.length());
    int eq = s.indexOf('=');
    String key = (eq < 0) ? s : s.substring(0, eq);
    String value = (eq < 0) ? s : s.substring(eq+1);
    options.put(key, value);
    return false;
      }
  },

  /*
   * TODO: With apt, the matches method accepts anything if
   * -XclassAsDecls is used; code elsewhere does the lookup to
   * see if the class name is both legal and found.
   *
   * In apt, the process method adds the candiate class file
   * name to a separate list.
   */
  new HiddenOption(SOURCEFILE) {
      String s;
      public boolean matches(String s) {
    this.s = s;
    return s.endsWith(".java"// Java source file
        || SourceVersion.isName(s);   // Legal type name
View Full Code Here

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

      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(":");
                options.put(option.substring(0, sep), option.substring(sep+1));
                options.put(option,option);
                return false;
            }
        },

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

  /* -Xjcov produces tables to support the code coverage tool jcov. */
  new HiddenOption(XJCOV),

  /* This is a back door to the compiler's option table.
   * -XDx=y sets the option x to the value y.
   * -XDx sets the option x to the value x.
   */
  new HiddenOption(XD) {
      String s;
      public boolean matches(String s) {
    this.s = s;
    return s.startsWith(name.optionName);
      }
      public boolean process(Options options, String option) {
    s = s.substring(name.optionName.length());
    int eq = s.indexOf('=');
    String key = (eq < 0) ? s : s.substring(0, eq);
    String value = (eq < 0) ? s : s.substring(eq+1);
    options.put(key, value);
    return false;
      }
  },

  /*
   * TODO: With apt, the matches method accepts anything if
   * -XclassAsDecls is used; code elsewhere does the lookup to
   * see if the class name is both legal and found.
   *
   * In apt, the process method adds the candiate class file
   * name to a separate list.
   */
  new HiddenOption(SOURCEFILE) {
      String s;
      public boolean matches(String s) {
    this.s = s;
    return s.endsWith(".java"// Java source file
        || SourceVersion.isName(s);   // Legal type name
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.