Search in sources :

Example 46 with JavaCompiler

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

the class Xprint method main.

public static void main(String[] args) {
    JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
    javac.run(System.in, null, null, "-Xprint", "com.sun.tools.javac.code.Types", "com.sun.tools.javac.parser.Parser", "java.util.EnumSet");
}
Also used : JavaCompiler(javax.tools.JavaCompiler)

Example 47 with JavaCompiler

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

the class T6199075 method compileAndCheck.

void compileAndCheck(VarargsMethod m1, VarargsMethod m2, TypeKind actual, ArgumentsArity argsArity) throws Exception {
    final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    JavaSource source = new JavaSource(m1, m2, actual, argsArity);
    ErrorChecker ec = new ErrorChecker();
    JavacTask ct = (JavacTask) tool.getTask(null, fm, ec, null, null, Arrays.asList(source));
    ct.generate();
    check(source, ec, m1, m2, actual, argsArity);
}
Also used : JavaCompiler(javax.tools.JavaCompiler) JavacTask(com.sun.source.util.JavacTask)

Example 48 with JavaCompiler

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

the class T7042566 method compileAndCheck.

void compileAndCheck() throws Exception {
    final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    JavaSource source = new JavaSource();
    ErrorChecker ec = new ErrorChecker();
    JavacTask ct = (JavacTask) tool.getTask(null, fm, ec, null, null, Arrays.asList(source));
    ct.call();
    check(source, ec);
}
Also used : JavaCompiler(javax.tools.JavaCompiler) JavacTask(com.sun.source.util.JavacTask)

Example 49 with JavaCompiler

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

the class TestSuperclass method main.

public static void main(String... args) throws Exception {
    JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
    int errors = 0;
    for (ClassKind ck : ClassKind.values()) {
        for (GenericKind gk : GenericKind.values()) {
            for (SuperKind sk : SuperKind.values()) {
                errors += new TestSuperclass(ck, gk, sk).run(comp, fm);
            }
        }
    }
    if (errors > 0)
        throw new Exception(errors + " errors found");
}
Also used : JavaCompiler(javax.tools.JavaCompiler) StandardJavaFileManager(javax.tools.StandardJavaFileManager) IOException(java.io.IOException)

Example 50 with JavaCompiler

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

the class Warn5 method test.

static void test(SourceLevel sourceLevel, XlintOption xlint, TrustMe trustMe, SuppressLevel suppressLevel, ModifierKind modKind, MethodKind methKind, SignatureKind sig, BodyKind body) throws Exception {
    final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    JavaSource source = new JavaSource(trustMe, suppressLevel, modKind, methKind, sig, body);
    DiagnosticChecker dc = new DiagnosticChecker();
    JavacTask ct = (JavacTask) tool.getTask(null, fm, dc, Arrays.asList(xlint.getXlintOption(), "-source", sourceLevel.sourceKey), null, Arrays.asList(source));
    ct.analyze();
    check(sourceLevel, dc, source, xlint, trustMe, suppressLevel, modKind, methKind, sig, body);
}
Also used : JavaCompiler(javax.tools.JavaCompiler) JavacTask(com.sun.source.util.JavacTask)

Aggregations

JavaCompiler (javax.tools.JavaCompiler)101 StandardJavaFileManager (javax.tools.StandardJavaFileManager)43 JavaFileObject (javax.tools.JavaFileObject)39 File (java.io.File)31 DiagnosticCollector (javax.tools.DiagnosticCollector)24 ArrayList (java.util.ArrayList)22 JavacTask (com.sun.source.util.JavacTask)20 IOException (java.io.IOException)17 CompilationTask (javax.tools.JavaCompiler.CompilationTask)16 SimpleJavaFileObject (javax.tools.SimpleJavaFileObject)15 CompilationUnitTree (com.sun.source.tree.CompilationUnitTree)11 Diagnostic (javax.tools.Diagnostic)11 PrintWriter (java.io.PrintWriter)9 Test (org.junit.Test)9 JavacTaskImpl (com.sun.tools.javac.api.JavacTaskImpl)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 FileOutputStream (java.io.FileOutputStream)5 StringWriter (java.io.StringWriter)5 JavaFileManager (javax.tools.JavaFileManager)5 OutputStream (java.io.OutputStream)4