⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
       else {         // success         return 0;       }     }     catch (Exception e)     {       // unexpected error       return 1;     }   }  /**   * @param programName Name of the program (for error messages). *disregarded*   * @param args The command line parameters.   * @returns The return code.   */  public static int execute(String programName,                            String[] args)  {    return execute(args);  }   /**   * @param programName Name of the program (for error messages).   * @param defaultDocletClassName Fully qualified class name.   * @param args The command line parameters.   * @returns The return code.   *//*  public static int execute(String programName,                            String defaultDocletClassName,                            String[] args)  {    // not yet implemented  }*/   /**   * @param programName Name of the program (for error messages).   * @param defaultDocletClassName Fully qualified class name.   * @param args The command line parameters.   * @returns The return code.   *//*  public static int execute(String programName,                            String defaultDocletClassName,                            String[] args)  {    // not yet implemented  }*/   /**   * @param programName Name of the program (for error messages).   * @param errWriter PrintWriter to receive error messages.   * @param warnWriter PrintWriter to receive error messages.   * @param noticeWriter PrintWriter to receive error messages.   * @param defaultDocletClassName Fully qualified class name.   * @param args The command line parameters.   * @returns The return code.   *//*  public static int execute(String programName,                            PrintWriter errWriter,                            PrintWriter warnWriter,                            PrintWriter noticeWriter,                            String defaultDocletClassName,                            String[] args)  {    // not yet implemented  }*/  /**   * Parses command line arguments and subsequentially handles control to the   * startDoclet() method   *    * @param args   *          Command line arguments, as passed to the main() method   * @return {@code -1} in case of a fatal error (invalid arguments),   * or the number of errors encountered.   * @exception ParseException   *              FIXME   * @exception IOException   *              if an IO problem occur   */  public int start(String[] args) throws ParseException, IOException  {    //--- Collect unparsed arguments in array and resolve references    //         to external argument files.    List arguments = new ArrayList(args.length);    for (int i = 0; i < args.length; ++i)    {      if (!args[i].startsWith("@"))      {        arguments.add(args[i]);      }      else      {        FileReader reader = new FileReader(args[i].substring(1));        StreamTokenizer st = new StreamTokenizer(reader);        st.resetSyntax();        st.wordChars('\u0000', '\uffff');        st.quoteChar('\"');        st.quoteChar('\'');        st.whitespaceChars(' ', ' ');        st.whitespaceChars('\t', '\t');        st.whitespaceChars('\r', '\r');        st.whitespaceChars('\n', '\n');        while (st.nextToken() != StreamTokenizer.TT_EOF)        {          arguments.add(st.sval);        }      }    }    //--- Initialize Map for option parsing    initOptions();    //--- This will hold all options recognized by gjdoc itself    //         and their associated arguments.    //         Contains objects of type String[], where each entry    //         specifies an option along with its aguments.    List options = new LinkedList();    //--- This will hold all command line tokens not recognized    //         to be part of a standard option.    //         These options are intended to be processed by the doclet    //         Contains objects of type String, where each entry is    //         one unrecognized token.    List customOptions = new LinkedList();    rootDoc = new RootDocImpl();    reporter = rootDoc.getReporter();    //--- Iterate over all options given on the command line    for (Iterator it = arguments.iterator(); it.hasNext();)    {      String arg = (String) it.next();      //--- Check if gjdoc recognizes this option as a standard option      //         and remember the options' argument count      int optlen = optionLength(arg);      //--- Argument count == 0 indicates that the option is not recognized.      //         Add it to the list of custom option tokens      //--- Otherwise the option is recognized as a standard option.      //         if all required arguments are supplied. Create a new String      //         array for the option and its arguments, and store it      //         in the options array.      if (optlen > 0)      {        String[] option = new String[optlen];        option[0] = arg;        boolean optargs_ok = true;        for (int j = 1; j < optlen && optargs_ok; ++j)        {          if (it.hasNext())          {            option[j] = (String) it.next();            if (option[j].startsWith("-"))            {              optargs_ok = false;            }          }          else          {            optargs_ok = false;          }        }        if (optargs_ok)          options.add(option);        else        {          //         If the option requires more arguments than given on the          //         command line, issue a fatal error          reporter.printFatal("Missing value for option " + arg + ".");        }      }    }    //--- Create an array of String arrays from the dynamic array built above    String[][] optionArr = (String[][]) options.toArray(new String[options        .size()][0]);    //--- Validate all options and issue warnings/errors    if (validOptions(optionArr, rootDoc))    {      //--- We got valid options; parse them and store the parsed values      //         in 'option_*' fields.      readOptions(optionArr);      //--- Show version and exit if requested by user      if (option_showVersion) {        System.out.println("gjdoc " + getGjdocVersion());        System.exit(0);      }      if (option_bootclasspath_specified) {        reporter.printWarning("-bootclasspath ignored: not supported by"                              + " gjdoc wrapper script, or no wrapper script in use.");      }      // If we have an empty source path list, add the current directory ('.')      if (option_sourcepath.size() == 0)        option_sourcepath.add(new File("."));      //--- We have all information we need to start the doclet at this time          if (null != option_encoding) {        rootDoc.setSourceEncoding(option_encoding);      }      else {        // be quiet about this for now:        // reporter.printNotice("No encoding specified, using platform default: " + System.getProperty("file.encoding"));        rootDoc.setSourceEncoding(System.getProperty("file.encoding"));      }      rootDoc.setSourcePath(option_sourcepath);      //addJavaLangClasses();      if (!startDoclet(arguments)) {        return -1;      }    }    return reporter.getErrorCount();  }  private void addJavaLangClasses()    throws IOException  {    String resourceName = "/java.lang-classes-" + option_source + ".txt";    InputStream in = getClass().getResourceAsStream(resourceName);    BufferedReader reader = new BufferedReader(new InputStreamReader(in));    String line;    while ((line = reader.readLine()) != null) {            String className = line.trim();      if (className.length() > 0) {        ClassDocImpl classDoc =          new ClassDocImpl(null, new PackageDocImpl("java.lang"),                           ProgramElementDocImpl.ACCESS_PUBLIC,                           false, false, null);        classDoc.setClass(className);        rootDoc.addClassDoc(classDoc);      }    }  }  /**   * Helper class for parsing command line arguments. An instance of this class   * represents a particular option accepted by gjdoc (e.g. '-sourcepath') along   * with the number of expected arguments and behavior to parse the arguments.   */  private abstract class OptionProcessor  {    /**     * Number of arguments expected by this option.     */    private int argCount;    /**     * Initializes this instance.     *      * @param argCount     *          number of arguments     */    public OptionProcessor(int argCount)    {      this.argCount = argCount;    }    /**     * Overridden by derived classes with behavior to parse the arguments     * specified with this option.     *      * @param args     *          command line arguments     */    abstract void process(String[] args);  }  /**   * Maps option tags (e.g. '-sourcepath') to OptionProcessor objects.   * Initialized only once by method initOptions(). FIXME: Rename to   * 'optionProcessors'.   */  private static Map options = null;  /**   * Initialize all OptionProcessor objects needed to scan/parse command line   * options. This cannot be done in a static initializer block because   * OptionProcessors need access to the Singleton instance of the Main class.   */  private void initOptions()  {    options = new HashMap();    //--- Put one OptionProcessor object into the map    //         for each option recognized.    options.put("-overview", new OptionProcessor(2)      {        void process(String[] args)        {          option_overview = args[0];        }      });    options.put("-public", new OptionProcessor(1)      {        void process(String[] args)        {          option_coverage = COVERAGE_PUBLIC;        }      });    options.put("-protected", new OptionProcessor(1)      {        void process(String[] args)        {          option_coverage = COVERAGE_PROTECTED;        }      });    options.put("-package", new OptionProcessor(1)      {        void process(String[] args)        {          option_coverage = COVERAGE_PACKAGE;        }      });    options.put("-private", new OptionProcessor(1)      {        void process(String[] args)        {          option_coverage = COVERAGE_PRIVATE;        }      });    OptionProcessor helpProcessor = new OptionProcessor(1)      {        void process(String[] args)        {          option_help = true;        }      };    options.put("-help", helpProcessor);    options.put("--help", helpProcessor);    options.put("-doclet", new OptionProcessor(2)        {          void process(String[] args)          {            option_doclet = args[0];          }        });    options.put("-docletpath", new OptionProcessor(2)        {          void process(String[] args)          {            option_docletpath = args[0];          }        });    options.put("-nowarn", new OptionProcessor(1)        {          void process(String[] args)          {            option_nowarn = true;          }        });    options.put("-source", new OptionProcessor(2)        {          void process(String[] args)          {            option_source = args[0];            if (!"1.2".equals(option_source)                 && !"1.3".equals(option_source)                && !"1.4".equals(option_source)) {              throw new RuntimeException("Only he following values are currently"                                         + " supported for option -source: 1.2, 1.3, 1.4.");            }          }        });    OptionProcessor sourcePathProcessor = new OptionProcessor(2) {        void process(String[] args)        {          Debug.log(1, "-sourcepath is '" + args[0] + "'");          for (StringTokenizer st = new StringTokenizer(args[0],              File.pathSeparator); st.hasMoreTokens();)          {            String path = st.nextToken();            File file = new File(path);            if (!(file.exists()))            {              throw new RuntimeException("The source path " + path                  + " does not exist.");            }            option_sourcepath.add(file);          }        }      };    options.put("-s", sourcePathProcessor);    options.put("-sourcepath", sourcePathProcessor);    options.put("-subpackages", new OptionProcessor(2)      {        void process(String[] args)        {          StringTokenizer st = new StringTokenizer(args[0], ":");           while (st.hasMoreTokens()) {            String packageName = st.nextToken();            if (packageName.startsWith(".")                || packageName.endsWith(".")                || packageName.indexOf("..") > 0                || !checkCharSet(packageName,                                 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_.")) {              throw new RuntimeException("Illegal package name '"                                         + packageName + "'");            }            option_subpackages.add(packageName);          }        }      });    options.put("-exclude", new OptionProcessor(2)      {        void process(String[] args)        {          StringTokenizer st = new StringTokenizer(args[0], ":");           while (st.hasMoreTokens()) {            String packageName = st.nextToken();            if (packageName.startsWith(".")                || packageName.endsWith(".")                || packageName.indexOf("..") > 0                || !checkCharSet(packageName,                                 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_.")) {              throw new RuntimeException("Illegal package name '"                                         + packageName + "'");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -