当前位置: 首页>>代码示例>>Java>>正文


Java CommandLine类代码示例

本文整理汇总了Java中com.sun.tools.javac.main.CommandLine的典型用法代码示例。如果您正苦于以下问题:Java CommandLine类的具体用法?Java CommandLine怎么用?Java CommandLine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CommandLine类属于com.sun.tools.javac.main包,在下文中一共展示了CommandLine类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import com.sun.tools.javac.main.CommandLine; //导入依赖的package包/类
public Result run(String[] argv) {
  try {
    argv = CommandLine.parse(argv);
  } catch (IOException e) {
    throw new IOError(e);
  }
  List<String> javacOpts = new ArrayList<>();
  List<String> sources = new ArrayList<>();
  for (String arg : argv) {
    // TODO(cushon): is there a better way to categorize javacopts?
    if (!arg.startsWith("-") && arg.endsWith(".java")) {
      sources.add(arg);
    } else {
      javacOpts.add(arg);
    }
  }
  StandardJavaFileManager fileManager = new MaskedFileManager();
  return run(
      javacOpts.toArray(new String[0]),
      fileManager,
      ImmutableList.copyOf(fileManager.getJavaFileObjectsFromStrings(sources)),
      /* processors= */ null);
}
 
开发者ID:google,项目名称:error-prone,代码行数:24,代码来源:BaseErrorProneCompiler.java

示例2: traverse

import com.sun.tools.javac.main.CommandLine; //导入依赖的package包/类
/**
 * Traverses an array of arguments and performs the appropriate callbacks.
 *
 * @param args the arguments to traverse.
 */
void traverse(String[] args) {
    try {
        args = CommandLine.parse(args); // Detect @file and load it as a command line.
    } catch (java.io.IOException e) {
        throw new IllegalArgumentException("Problem reading @"+e.getMessage());
    }
    ArgumentIterator argIter = new ArgumentIterator(Arrays.asList(args));

    nextArg:
    while (argIter.hasNext()) {

        String arg = argIter.next();

        if (arg.startsWith("-")) {
            for (Option opt : Option.values()) {
                if (opt.processCurrent(argIter, this))
                    continue nextArg;
            }

            javacArg(arg);

            // Does this javac argument take an argument? If so, don't
            // let it pass on to sjavac as a source root directory.
            for (com.sun.tools.javac.main.Option javacOpt : com.sun.tools.javac.main.Option.values()) {
                if (javacOpt.matches(arg)) {
                    boolean takesArgument = javacOpt.hasArg();
                    boolean separateToken = !arg.contains(":") && !arg.contains("=");
                    if (takesArgument && separateToken)
                        javacArg(argIter.next());
                }
            }
        } else {
            sourceRoots(Arrays.asList(Paths.get(arg)));
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:42,代码来源:OptionHelper.java

示例3: begin

import com.sun.tools.javac.main.CommandLine; //导入依赖的package包/类
/**
 * Main program - external wrapper. In order to maintain backward
 * CLI compatibility, the execution is dispatched to the appropriate
 * Start mechanism, depending on the doclet variant.
 *
 * The doclet tests are performed in the begin method, further on,
 * this is to minimize argument processing and most importantly the impact
 * of class loader creation, needed to detect the doclet class variants.
 */
@SuppressWarnings("deprecation")
Result begin(String... argv) {
    // Preprocess @file arguments
    try {
        argv = CommandLine.parse(argv);
        return begin(Arrays.asList(argv), Collections.emptySet());
    } catch (IOException e) {
        error("main.cant.read", e.getMessage());
        return ERROR;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:Start.java

示例4: main

import com.sun.tools.javac.main.CommandLine; //导入依赖的package包/类
public static void main(String... args) throws IOException {
    try {
        String[] argv = CommandLine.parse("JDK_JAVAC_OPTIONS", EMPTY_ARRAY);
        System.out.print(arrayToString(argv));
    } catch (CommandLine.UnmatchedQuote ex) {
        System.out.print("Exception: " + ex.variableName);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:EnvVariableTest.java


注:本文中的com.sun.tools.javac.main.CommandLine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。