Package javax.tools.JavaCompiler

Examples of javax.tools.JavaCompiler.CompilationTask


    }
   
    // tests before we renamed module_.class to $module_.class
    @Test
    public void testBinaryVersionIncompatibleModule1() throws IOException {
        CompilationTask compiler = compileJava("binaryVersionOld/module_.java");
        Assert.assertTrue(compiler.call());
       
        // so now make a jar containing the java module
        File jarFolder = new File(destDir, "com/redhat/ceylon/compiler/java/test/bc/binaryVersionOld/1/");
        jarFolder.mkdirs();
        File jarFile = new File(jarFolder, "com.redhat.ceylon.compiler.java.test.bc.binaryVersionOld-1.jar");
View Full Code Here


    }

    // tests after we renamed module_.class to $module_.class
    @Test
    public void testBinaryVersionIncompatibleModule2() throws IOException {
        CompilationTask compiler = compileJava("binaryVersionOld2/$module_.java");
        Assert.assertTrue(compiler.call());
       
        // so now make a jar containing the java module
        File jarFolder = new File(destDir, "com/redhat/ceylon/compiler/java/test/bc/binaryVersionOld2/1/");
        jarFolder.mkdirs();
        File jarFile = new File(jarFolder, "com.redhat.ceylon.compiler.java.test.bc.binaryVersionOld2-1.jar");
View Full Code Here

            throw new RuntimeException("can't get javax.tools.JavaCompiler!");
        }
        StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
        List<File> files = new ArrayList<File>();
        files.add(new File(T6956462.class.getResource("TestClass.java").toURI()));
        final CompilationTask task = compiler.getTask(null, fm, null,
            null, null, fm.getJavaFileObjectsFromFiles(files));
        JavacTask javacTask = (JavacTask) task;
        for (CompilationUnitTree cu : javacTask.parse()) {
            cu.accept(new MyVisitor(javacTask), null);
        }
View Full Code Here

        compile(new DiagnosticChecker(), testKind.source);
    }

    void compile(DiagnosticChecker dc, JavaSource... sources) {
        try {
            CompilationTask ct = javacTool.getTask(null, null, dc,
                    Arrays.asList("-d", testDir.getAbsolutePath(), "-cp", testDir.getAbsolutePath()),
                    null, Arrays.asList(sources));
            ct.call();
        }
        catch (Exception e) {
            error("Internal compilation error");
        }
    }
View Full Code Here

        options.add("-processor");
        options.add("MyProcessor");
        options.add("-proc:only");
        List<File> files = new ArrayList<File>();
        files.add(new File(T6458823.class.getResource("TestClass.java").toURI()));
        final CompilationTask task = compiler.getTask(null, fm, diagColl,
            options, null, fm.getJavaFileObjectsFromFiles(files));
        task.call();
        int diagCount = 0;
        for (Diagnostic<? extends JavaFileObject> diag : diagColl.getDiagnostics()) {
            if (diag.getKind() != Diagnostic.Kind.WARNING) {
                throw new AssertionError("Only warnings expected");
            }
View Full Code Here

        List<String> opts = new ArrayList<String>();
        if (processor != null) {
            // opts.add("-verbose");
            opts.addAll(Arrays.asList("-processor", processor));
        }
        CompilationTask task = comp.getTask(null, fm, dl, opts, null, Arrays.asList(files));
        boolean ok = task.call();
        if (dl == null && !ok)
            throw new Exception("compilation failed");
    }
View Full Code Here

        // For source files, we add a .java extension
        this.javaFileManager.putFileForInput(StandardLocation.SOURCE_PATH, packageName, className + CharSequenceCompiler.JAVA_EXTENSION, source);
      }
    }
    // Get a CompliationTask from the compiler and compile the sources
    final CompilationTask task = this.compiler.getTask(null, this.javaFileManager, this.diagnostics, this.options, null, sources);
    final Boolean result = task.call();
    if (result == null || !result.booleanValue()) {
      throw new CharSequenceCompilerException("Compilation failed.", classes.keySet(), this.diagnostics);
    }
    try {
      // For each class name in the inpput map, get its compiled
View Full Code Here

        JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        JavaFileObject f = new MyFileObject("myfo://test", "class Bad { Missing x; }");
        List<? extends JavaFileObject> files = Arrays.asList(f);
        CompilationTask task = javac.getTask(pw, null, null, options, null, files);
        boolean ok = task.call();
        pw.close();
        String out = sw.toString();
        if (!out.isEmpty())
            System.err.println(out);
        if (ok)
View Full Code Here

        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
        String srcdir = System.getProperty("test.src");
        File source = new File(srcdir, "T6378728.java");
        StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);

        CompilationTask task =
            compiler.getTask(null,
                             new ExceptionalFileManager(fm),
                             null,
                             Arrays.asList("-proc:only"),
                             null,
                             fm.getJavaFileObjectsFromFiles(Arrays.asList(source)));
        if (!task.call())
            throw new RuntimeException("Unexpected compilation failure");
    }
View Full Code Here

        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
        List<String> options = Arrays.asList(
                "-proc:only",
                "-processor", thisName,
                "-processorpath", testClasses);
        CompilationTask t = c.getTask(null, fm, null, options, null, files);
        boolean ok = t.call();
        if (!ok)
            throw new Exception("processing failed");
    }
View Full Code Here

TOP

Related Classes of javax.tools.JavaCompiler.CompilationTask

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.