Package com.sun.source.util

Examples of com.sun.source.util.JavacTask


    static void test(SourceLevel sourceLevel, TrustMe trustMe, SuppressLevel suppressLevelClient,
            SuppressLevel suppressLevelDecl, ModifierKind modKind, Signature vararg_meth, Signature client_meth) throws Exception {
        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
        JavaSource source = new JavaSource(trustMe, suppressLevelClient, suppressLevelDecl, modKind, vararg_meth, client_meth);
        DiagnosticChecker dc = new DiagnosticChecker();
        JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
                Arrays.asList("-Xlint:unchecked", "-source", sourceLevel.sourceKey),
                null, Arrays.asList(source));
        ct.generate(); //to get mandatory notes
        check(dc.warnings, sourceLevel,
                new boolean[] {vararg_meth.giveUnchecked(client_meth),
                               vararg_meth.giveVarargs(client_meth)},
                source, trustMe, suppressLevelClient, suppressLevelDecl, modKind);
    }
View Full Code Here


    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);
    }
View Full Code Here

                    error("class not found: " + c);
                else
                    files.add(fo);
            }

            JavacTask t = tool.getTask(null, fm, null, null, null, files);
            Iterable<? extends CompilationUnitTree> trees = t.parse();
            for (CompilationUnitTree tree: trees) {
                makeStub(fm, tree);
            }
        } catch (IOException e) {
            error("IO error " + e, e);
View Full Code Here

    }

    void compileAndCheck() throws Exception {
        JavaSource source = new JavaSource();
        ErrorChecker ec = new ErrorChecker();
        JavacTask ct = (JavacTask)tool.getTask(null, fm, ec,
                null, null, Arrays.asList(source));
        ct.analyze();
        if (ec.errorFound) {
            throw new Error("invalid diagnostics for source:\n" +
                    source.getCharContent(true) +
                    "\nCompiler diagnostics:\n" + ec.printDiags());
        }
View Full Code Here

    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);
    }
View Full Code Here

    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);
    }
View Full Code Here

                    error("Error pos for %s is incorrect (%s)!",
                          diag.getCode(), diag.getPosition());
                sawError[0] = true;
            }
        };
        JavacTask task = (JavacTask)javac.getTask(null, null, dl, null, null,
                                                  compilationUnits);
        Trees trees = Trees.instance(task);
        Iterable<? extends Tree> toplevels = task.parse();
        if (!sawError[0])
            error("No parse error detected");
        sawError[0] = false;
        new Scanner().scan(toplevels, trees);
        if (!sawError[0])
View Full Code Here

            return source;
        }
    }

    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
                null, null, Arrays.asList(source));
        ct.parse();
        check();
    }
View Full Code Here

    static void compileAndCheck(PackageKind pk, ConstructorKind ck) throws Exception {
        FooClass foo = new FooClass(pk, ck);
        ClientClass client = new ClientClass(pk);
        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
        ErrorListener el = new ErrorListener();
        JavacTask ct = (JavacTask)tool.getTask(null, null, el,
                null, null, Arrays.asList(foo, client));
        ct.analyze();
        if (el.errors > 0 == check(pk, ck)) {
            String msg = el.errors > 0 ?
                "Error compiling files" :
                "No error when compiling files";
            throw new AssertionError(msg + ": \n" + foo.source + "\n" + client.source);
View Full Code Here

            Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(testFile);

            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            JavacTask task = tool.getTask(pw, fm, null, null, null, files);
            boolean ok = task.call();
            String out = showOutput(sw.toString());

            checkCompilationOK(ok);
            checkOutput(out, expectWarnings);
        }
View Full Code Here

TOP

Related Classes of com.sun.source.util.JavacTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.