Package com.sun.source.util

Examples of com.sun.source.util.JavacTask.analyze()


        fileToRemove.delete();
        JavaSource newSource = new JavaSource(clazz, sup);
        DiagnosticChecker checker = new DiagnosticChecker();
        ct = (JavacTask)tool.getTask(null, null, checker,
                Arrays.asList("-cp", destPath), null, Arrays.asList(newSource));
        ct.analyze();
        if (!checker.errorFound) {
            throw new AssertionError(newSource.source);
        }
    }
View Full Code Here


        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);
    }

    static void check(SourceLevel sourceLevel, DiagnosticChecker dc, JavaSource source,
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

        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

    }

    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
                Arrays.asList(xlint.getXlintOption()), null, Arrays.asList(source));
        ct.analyze();
        check();
    }

    void check() {
View Full Code Here

        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
        JavaSource source = new JavaSource(suppressLevel, usage1, usage2, usage3);
        DiagnosticChecker dc = new DiagnosticChecker();
        JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
                Arrays.asList(xlint.getXlintOption()), null, Arrays.asList(source));
        ct.analyze();
        check(source, xlint, suppressLevel, usage1, usage2, usage3, dc);
    }

    static void check(JavaSource source, XlintOption xlint, SuppressLevel suppressLevel,
                ResourceUsage usage1, ResourceUsage usage2, ResourceUsage usage3, DiagnosticChecker dc) {
View Full Code Here

        fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(testClasses)));
        Iterable<? extends JavaFileObject> files =
            fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6410706.class.getName()+".java")));
        JavacTask task = tool.getTask(null, fm, dl, null, null, files);
        task.parse();
        task.analyze();
        task.generate();

        // expect 2 notes:
        // Note: T6410706.java uses or overrides a deprecated API.
        // Note: Recompile with -Xlint:deprecation for details.
View Full Code Here

        List<? extends JavaFileObject> files = Arrays.asList(new SourceFile());
        JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
        JavacTask ct = (JavacTask)tool.getTask(null, null, null, null, null, files);
        Context ctx = new Context();
        JavacFileManager.preRegister(ctx);
        checkImplementationCache(ct.analyze(), Types.instance(ctx));
    }

    static void checkImplementationCache(Iterable<? extends Element> elements, Types types) {
        if (types == null) {
            throw new AssertionError("problems initializing Types");
View Full Code Here

            public void finished(TaskEvent e) { }
        });

        try {
            Iterable<? extends CompilationUnitTree> trees = task.parse();
            task.analyze();
            List<Pair<JCCompilationUnit, JCTree>> res = new ArrayList<>();
            //System.out.println("Try to add pairs. Elems are " + analyzedElems);
            for (CompilationUnitTree t : trees) {
               JCCompilationUnit cu = (JCCompilationUnit)t;
               for (JCTree def : cu.defs) {
View Full Code Here

        System.err.println("1- javac given java source JavaFileObjects " + sourceFileObjects);
        JavaCompiler.CompilationTask task = compiler.getTask(compilerOutputStream, fileManager, null, compileOptions, null, sourceFileObjects);
        JavacTask javacTask = (JavacTask) task;

        Iterable<? extends CompilationUnitTree> parsedTrees = javacTask.parse();
        Iterable<? extends Element> analyzedTrees = javacTask.analyze();
        Iterable<? extends JavaFileObject> generatedFiles = javacTask.generate();

        System.err.println("2- parsed:" + size(parsedTrees) + " analysed:" + size(analyzedTrees) + " generated:" + size(generatedFiles));

        System.err.print("3-");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.