Java 类javax.tools.Tool 实例源码

项目:openjdk-jdk10    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:openjdk9    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:lookaside_java-1.8.0-openjdk    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:jsr308-langtools    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:form-follows-function    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:infobip-open-jdk-8    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:openjdk-source-code-learn    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:OLD-OpenJDK8    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:s4j    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:jdk7-langtools    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:openjdk-icedtea7    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:metricgenerator-jdk-compiler    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:INF5000-StaticProxy    文件:T6395981.java   
public static void main(String... args) {
    Tool compiler = ToolProvider.getSystemJavaCompiler();
    Set<SourceVersion> expected = EnumSet.noneOf(SourceVersion.class);
    for (String arg : args)
        expected.add(SourceVersion.valueOf(arg));
    Set<SourceVersion> found = compiler.getSourceVersions();
    Set<SourceVersion> notExpected = EnumSet.copyOf(found);
    for (SourceVersion version : expected) {
        if (!found.contains(version))
            throw new AssertionError("Expected source version not found: " + version);
        else
            notExpected.remove(version);
    }
    if (!notExpected.isEmpty())
        throw new AssertionError("Unexpected source versions: " + notExpected);
}
项目:openjdk-jdk10    文件:TestName.java   
public void run() throws Exception {
    Optional<Tool> opt = findFirst("javadoc");
    if (!opt.isPresent()) {
        throw new Exception("tool not found");
    }
    if (!(opt.get() instanceof JavadocTool)) {
        throw new Exception("unexpected tool found");
    }
}
项目:openjdk-jdk10    文件:TestName.java   
Optional<Tool> findFirst(String name) {
    getClass().getModule().addUses(Tool.class);
    for (Tool p : ServiceLoader.load(Tool.class,
            ClassLoader.getSystemClassLoader())) {
        if (p.name().equals(name)) {
            return Optional.of(p);
        }
    }
    return Optional.empty();
}
项目:openjdk-jdk10    文件:ToolProviderTest.java   
private int runShellServiceLoader(String... args) {
    ServiceLoader<Tool> sl = ServiceLoader.load(Tool.class);
    for (Tool provider : sl) {
        if (provider.name().equals("jshell")) {
            return provider.run(cmdInStream, cmdout, cmderr, args);
        }
    }
    throw new AssertionError("Repl tool not found by ServiceLoader: " + sl);
}
项目:openjdk-jdk10    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}
项目:openjdk-jdk10    文件:TestName.java   
public void run() throws Exception {
    Optional<Tool> opt = findFirst("javac");
    if (!opt.isPresent()) {
        throw new Exception("tool not found");
    }
    if (!(opt.get() instanceof JavacTool)) {
        throw new Exception("unexpected tool found");
    }
}
项目:openjdk-jdk10    文件:TestName.java   
Optional<Tool> findFirst(String name) {
    getClass().getModule().addUses(Tool.class);
    for (Tool p : ServiceLoader.load(Tool.class,
            ClassLoader.getSystemClassLoader())) {
        if (p.name().equals(name)) {
            return Optional.of(p);
        }
    }
    return Optional.empty();
}
项目:openjdk9    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}
项目:wava    文件:InProcJavaCompiler.java   
public void compileJava(List<JavacOption> options, List<File> sourceFiles)
{
    List<String> args = ImmutableList.<String>builder()
            .addAll(options.stream().map(JavacOption::getArgs).flatMap(List::stream).iterator())
            .addAll(sourceFiles.stream().map(File::getPath).iterator())
            .build();
    Tool javac = ToolProvider.getSystemJavaCompiler();
    javac.run(null, null, null, args.toArray(new String[args.size()]));
}
项目:lookaside_java-1.8.0-openjdk    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}
项目:pro    文件:JShellWrapper.java   
static int run(InputStream in, OutputStream out, OutputStream err, String... arguments) {
  ServiceLoader<Tool> loader = ServiceLoader.load(Tool.class, JShellConfigRunner.class.getClassLoader());
  Tool jshell = loader.stream()
      .map(provider -> provider.get())
      .filter(tool -> tool.name().equals("jshell"))
      .findFirst()
      .orElseThrow(() -> new IllegalStateException("can not find jshell"));
  return jshell.run(in, out, err, arguments);
}
项目:jsr308-langtools    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}
项目:form-follows-function    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}
项目:form-follows-function    文件:TestHelper.java   
protected static int doCompile(String dir, String classpath, List<String> files, OutputStream out, OutputStream err) {
    List<String> args = new ArrayList<String>();
    args.add("-target");
    args.add("1.5");
    args.add("-d");
    args.add(dir);
    args.add("-cp");
    args.add(classpath);
    Tool compiler = null;
    for (String f : files) {
        Tool ftool;
        if (f.endsWith(".f3"))
            ftool = f3c;
        else if (f.endsWith(".java"))
            ftool = javac;
        else
            ftool = null;
        if (compiler != null && ftool != null && ftool != compiler) {
            throw new IllegalArgumentException("cannot compile both .java and .f3 with same compiler");
        }
        compiler = ftool;
        args.add(f);
    }
    if (compiler == null)
      compiler = f3c;
    return compiler.run(null, out, err, args.toArray(new String[args.size()]));
}
项目:infobip-open-jdk-8    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}
项目:openjdk-source-code-learn    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}
项目:OLD-OpenJDK8    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}
项目:s4j    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}
项目:jdk7-langtools    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}
项目:openjdk-icedtea7    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}
项目:metricgenerator-jdk-compiler    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}
项目:INF5000-StaticProxy    文件:T6350124.java   
static void compile(String... args) {
    StringBuffer sb = new StringBuffer("compile:");
    for (String a: args)
        sb.append(' ').append(a);
    System.err.println(sb);

    Tool t = ToolProvider.getSystemJavaCompiler();
    int rc = t.run(System.in, System.out, System.err, args);
    System.out.flush();
    System.err.flush();
    if (rc != 0)
        throw new Error("compilation failed");
}