Search in sources :

Example 1 with Tool

use of javax.tools.Tool in project ceylon-compiler by ceylon.

the class T6350124 method compile.

// note: jtreg @compile does not allow -d to be specified
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");
}
Also used : Tool(javax.tools.Tool)

Example 2 with Tool

use of javax.tools.Tool in project ceylon-compiler by ceylon.

the class T6395981 method main.

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);
}
Also used : SourceVersion(javax.lang.model.SourceVersion) Tool(javax.tools.Tool)

Aggregations

Tool (javax.tools.Tool)2 SourceVersion (javax.lang.model.SourceVersion)1