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

📄 main.java

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* gnu.classpath.tools.gjdoc.Main   Copyright (C) 2001 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version. GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307 USA. */package gnu.classpath.tools.gjdoc;import com.sun.javadoc.*;import java.io.*;import java.util.*;import java.lang.reflect.*;import java.text.Collator;import gnu.classpath.tools.FileSystemClassLoader;/** * Class that will launch the gjdoc tool. */public final class Main{  /**   * Do we load classes that are referenced as base class?   */  static final boolean DESCEND_SUPERCLASS = true;  /**   * Do we load classes that are referenced as interface?   */  static final boolean DESCEND_INTERFACES = false;  /**   * Do we load classes that are imported in a source file?   */  static final boolean DESCEND_IMPORTED = true;  /**   * Document only public members.   */  static final int COVERAGE_PUBLIC = 0;  /**   * Document only public and protected members.   */  static final int COVERAGE_PROTECTED = 1;  /**   * Document public, protected and package private members.   */  static final int COVERAGE_PACKAGE = 2;  /**   * Document all members.   */  static final int COVERAGE_PRIVATE = 3;  /*   *  FIXME: This should come from a ResourceBundle   */  private static final String STRING_TRY_GJDOC_HELP =      "Try `gjdoc --help' for more information.";  /**   * Grid for looking up whether a particular access level is included in the   * documentation.   */  static final boolean[][] coverageTemplates = new boolean[][]    { new boolean[]      { true, false, false, false }, // public        new boolean[]          { true, true, false, false }, // protected        new boolean[]          { true, true, true, false }, // package        new boolean[]          { true, true, true, true }, // private    };  /**   * Holds the Singleton instance of this class.   */  private static Main instance = new Main();  /**   * Avoid re-instantiation of this class.   */  private Main()  {  }  private static RootDocImpl rootDoc;  private ErrorReporter reporter;  /**   * Cache for version string from resource /version.properties   */  private String gjdocVersion;  /**   * <code>false</code> during Phase I: preparation of the documentation data.   * <code>true</code> during Phase II: documentation output by doclet.   */  boolean docletRunning = false;  //---- Command line options  /**   * Option "-doclet": name of the Doclet class to use.   */  private String option_doclet = "gnu.classpath.tools.doclets.htmldoclet.HtmlDoclet";  /**   * Option "-overview": path to the special overview file.   */  private String option_overview;  /**   * Option "-coverage": which members to include in generated documentation.   */  private int option_coverage = COVERAGE_PROTECTED;  /**   * Option "-help": display command line usage.   */  private boolean option_help;  /**   * Option "-docletpath": path to doclet classes.   */  private String option_docletpath;  /**   * Option "-classpath": path to additional classes.   */  private String option_classpath;  /**   * Option "-sourcepath": path to the Java source files to be documented.   * FIXME: this should be a list of paths   */  private List option_sourcepath = new ArrayList();  /**   * Option "-extdirs": path to Java extension files.   */  private String option_extdirs;  /**   * Option "-verbose": Be verbose when generating documentation.   */  private boolean option_verbose;  /**   * Option "-nowarn": Do not print warnings.   */  private boolean option_nowarn;  /**   * Option "-locale:" Specify the locale charset of Java source files.   */  private Locale option_locale = new Locale("en", "us");  /**   * Option "-encoding": Specify character encoding of Java source files.   */  private String option_encoding;  /**   * Option "-J": Specify flags to be passed to Java runtime.   */  private List option_java_flags = new LinkedList(); //ArrayList();  /**   * Option "-source:" should be 1.4 to handle assertions, 1.1 is no   * longer supported.   */  private String option_source = "1.2";  /**   * Option "-subpackages": list of subpackages to be recursively   * added.   */  private List option_subpackages = new ArrayList();  /**   * Option "-exclude": list of subpackages to exclude.   */  private List option_exclude = new ArrayList();  /**   * Option "-breakiterator" - whether to use BreakIterator for   * detecting the end of the first sentence.   */  private boolean option_breakiterator;  /**   * Option "-licensetext" - whether to copy license text.   */  private boolean option_licensetext;  /**   * The locale-dependent collator used for sorting.   */  private Collator collator;  /**   * true when --version has been specified on the command line.   */  private boolean option_showVersion;    /**   * true when -bootclasspath has been specified on the command line.   */  private boolean option_bootclasspath_specified;    /**   * true when -all has been specified on the command line.   */  private boolean option_all;  /**   * true when -reflection has been specified on the command line.   */  private boolean option_reflection;    // TODO: add the rest of the options as instance variables    /**   * Parse all source files/packages and subsequentially start the Doclet given   * on the command line.   *    * @param allOptions List of all command line tokens   */  private boolean startDoclet(List allOptions)  {    try    {      //--- Fetch the Class object for the Doclet.      Debug.log(1, "loading doclet class...");      Class docletClass;      if (null != option_docletpath) {        try {          FileSystemClassLoader docletPathClassLoader            = new FileSystemClassLoader(option_docletpath);          System.err.println("trying to load class  " + option_doclet + " from path " + option_docletpath);          docletClass = docletPathClassLoader.findClass(option_doclet);        }        catch (Exception e) {          docletClass = Class.forName(option_doclet);        }      }      else {        docletClass = Class.forName(option_doclet);      }      //Object docletInstance = docletClass.newInstance();      Debug.log(1, "doclet class loaded...");      Method startTempMethod = null;      Method startMethod = null;      Method optionLenMethod = null;      Method validOptionsMethod = null;      //--- Try to find the optionLength method in the Doclet class.      try      {        optionLenMethod = docletClass.getMethod("optionLength", new Class[]          { String.class });      }      catch (NoSuchMethodException e)      {        // Ignore if not found; it's OK it the Doclet class doesn't define        // this method.      }      //--- Try to find the validOptions method in the Doclet class.      try      {        validOptionsMethod = docletClass.getMethod("validOptions", new Class[]          { String[][].class, DocErrorReporter.class });      }      catch (NoSuchMethodException e)      {        // Ignore if not found; it's OK it the Doclet class doesn't define        // this method.      }      //--- Find the start method in the Doclet class; complain if not found      try      {        startTempMethod = docletClass.getMethod("start", new Class[]          { TemporaryStore.class });      }      catch (Exception e)      {        // ignore      }      startMethod = docletClass.getMethod("start", new Class[]        { RootDoc.class });      //--- Feed the custom command line tokens to the Doclet      // stores all recognized options      List options = new LinkedList();      // stores packages and classes defined on the command line      List packageAndClasses = new LinkedList();      for (Iterator it = allOptions.iterator(); it.hasNext();)      {        String option = (String) it.next();        Debug.log(9, "parsing option '" + option + "'");        if (option.startsWith("-"))        {          //--- Parse option          int optlen = optionLength(option);          //--- Try to get option length from Doclet class          if (optlen <= 0 && optionLenMethod != null)          {            optionLenMethod.invoke(null, new Object[]              { option });            Debug.log(3, "invoking optionLen method");            optlen = ((Integer) optionLenMethod.invoke(null, new Object[]              { option })).intValue();            Debug.log(3, "done");          }          if (optlen <= 0) {            if (option.startsWith("-JD")) {              // Simulate VM option -D              String propertyValue = option.substring(3);              int ndx = propertyValue.indexOf('=');              if (ndx <= 0) {                reporter.printError("Illegal format in option " + option + ": use -JDproperty=value");                return false;              }              else {                String property = propertyValue.substring(0, ndx);                String value = propertyValue.substring(ndx + 1);                System.setProperty(property, value);              }            }            else if (option.startsWith("-J")) {              //--- Warn if VM option is encountered              reporter.printWarning("Ignored option " + option + ". Pass this option to the VM if required.");            }            else {              //--- Complain if not found              reporter.printError("Unknown option " + option);              reporter.printNotice(STRING_TRY_GJDOC_HELP);              return false;            }          }          else          {            //--- Read option values            String[] optionAndValues = new String[optlen];            optionAndValues[0] = option;            for (int i = 1; i < optlen; ++i)            {              if (!it.hasNext())              {                reporter.printError("Missing value for option " + option);                return false;              }              else              {                optionAndValues[i] = (String) it.next();              }            }            //--- Store option for processing later            options.add(optionAndValues);          }        }        else if (option.length() > 0)        {          //--- Add to list of packages/classes if not option or option          // value          packageAndClasses.add(option);        }      }      Debug.log(9, "options parsed...");      //--- For each package specified with the -subpackages option on      //         the command line, recursively find all valid java files      //         beneath it.      //--- For each class or package specified on the command line,      //         check that it exists and find out whether it is a class      //         or a package      for (Iterator it = option_subpackages.iterator(); it.hasNext();)      {        String subpackage = (String) it.next();        Set foundPackages = new LinkedHashSet();        for (Iterator pit = option_sourcepath.iterator(); pit.hasNext(); ) {          File sourceDir = (File)pit.next();          File packageDir = new File(sourceDir, subpackage.replace('.', File.separatorChar));          findPackages(subpackage, packageDir, foundPackages);        }        addFoundPackages(subpackage, foundPackages);      }      if (option_all) {        Set foundPackages = new LinkedHashSet();        for (Iterator pit = option_sourcepath.iterator(); pit.hasNext(); ) {          File sourceDir = (File)pit.next();          findPackages("", sourceDir, foundPackages);        }        addFoundPackages(null, foundPackages);        for (Iterator packageIt = foundPackages.iterator(); packageIt.hasNext(); ) {          String packageName = (String)packageIt.next();          if (null == packageName) {            packageName = "";          }          rootDoc.addSpecifiedPackageName(packageName);        }      }

⌨️ 快捷键说明

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