Package javax.tools.JavaCompiler

Examples of javax.tools.JavaCompiler.CompilationTask.call()


            }
        }

        // Get a CompliationTask from the compiler and compile the sources
        final CompilationTask task = compiler.getTask(null, javaFileManager, diagnostics, options, null, sources);
        final Boolean result = task.call();
        if (result == null || !result.booleanValue()) {
            throw new JdkCompileException("Compilation failed.", classes.keySet(), diagnostics);
        }

        try {
View Full Code Here


                                           DiagnosticListener<JavaFileObject> listener,
                                           Iterable<? extends JavaFileObject> fileList) {
        List<String> args = new ArrayList<String>();
        addArgs(args);
        CompilationTask task = compiler.getTask(null, fileManager, listener, args, null, fileList);
        Boolean ret = task.call();
        try {
            fileManager.close();
        } catch (IOException e) {
            System.err.print("[ERROR] IOException during compiling.");
            e.printStackTrace();
View Full Code Here

        new DiagnosticCollector<JavaFileObject>();
    CompilationTask expectedTask =
        compiler.getTask(errorWriter, fileManager, expectedCollector, Arrays.asList("-proc:only"),
            null, files);
    expectedTask.setProcessors(Arrays.asList(new ExpectCollector()));
    expectedTask.call();

    DiagnosticCollector<JavaFileObject> actualCollector = new DiagnosticCollector<JavaFileObject>();
    CompilationTask actualTask =
        compiler.getTask(errorWriter, fileManager, actualCollector, Arrays.asList("-proc:only"),
            null, files);
View Full Code Here

    DiagnosticCollector<JavaFileObject> actualCollector = new DiagnosticCollector<JavaFileObject>();
    CompilationTask actualTask =
        compiler.getTask(errorWriter, fileManager, actualCollector, Arrays.asList("-proc:only"),
            null, files);
    actualTask.setProcessors(Arrays.asList(rfValidator));
    actualTask.call();

    TreeSet<Diagnostic<? extends JavaFileObject>> expected =
        new TreeSet<Diagnostic<? extends JavaFileObject>>(new DiagnosticComparator());
    expected.addAll(expectedCollector.getDiagnostics());
    TreeSet<Diagnostic<? extends JavaFileObject>> actual =
View Full Code Here

      DrillJavaFileObject compilationUnit = new DrillJavaFileObject(className.dot, sourceCode);

      CompilationTask task = compiler.getTask(null, fileManager, listener, compilerOptions, null, Collections.singleton(compilationUnit));

      // Run the compiler.
      if(!task.call()) {
        throw new CompileException("Compilation failed", null);
      } else if (!compilationUnit.isCompiled()) {
        throw new ClassNotFoundException(className + ": Class file not created by compilation.");
      }
      // all good
View Full Code Here

        CompilationTask task = compiler.getTask(null,
            fileManager, null,
            Arrays.asList(options),
            null, compilationUnits1);
       
        boolean success = task.call();
        try {
        fileManager.flush();
      } catch (IOException e) {
        // what can we do here?
        System.err.println(e.getMessage() + " while flushing javac file manager.");
View Full Code Here

   
    CompilationTask cTask = compiler.getTask(null, fileManager, null, null,
        null,
        fileManager.getJavaFileObjects(
            javaFiles.toArray(new File[javaFiles.size()])));
    assertTrue(cTask.call());
  }
}
View Full Code Here

    Iterable<? extends JavaFileObject> fileobject = fileManager.getJavaFileObjects(new File(filename));
    CompilationTask parsingTask =  compiler.getTask(null, fileManager, null, null, null, fileobject);
    ArrayList<AbstractProcessor> processor = new ArrayList<AbstractProcessor>(1);
    processor.add(this);
    parsingTask.setProcessorsprocessor);
    parsingTask.call();
    fileManager.close();
   
  }
 
  public TreePath getSourcecode()
View Full Code Here

        CompilationTask task =
            compiler.getTask( null, fileManager, diagnostics, processorOptions, null, compilationUnits );
        task.setProcessors( Arrays.asList( new MappingProcessor() ) );

        CompilationResultHolder resultHolder = new CompilationResultHolder( diagnostics, task.call() );

        cache.lastRequest = request;
        cache.lastResult = resultHolder;
        return resultHolder;
    }
View Full Code Here

    // compiling it
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
    Iterable<? extends JavaFileObject> compilationUnits1 = fileManager.getJavaFileObjects(javaFile);
    CompilationTask task = compiler.getTask(null, fileManager, null, null, null, compilationUnits1);
    task.call();

    // here is the compiled file
    File classFile = new File(javaFile.getParentFile(), className+".class");
    Assert.assertTrue(classFile.exists());
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.