Package javax.tools.JavaCompiler

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


        diagnosticCollector,
        ImmutableSet.<String>of(),
        ImmutableSet.<String>of(),
        sources);
    task.setProcessors(processors);
    boolean successful = task.call();
    return new Result(successful, sortDiagnosticsByKind(diagnosticCollector.getDiagnostics()),
        fileManager.getOutputFiles());
  }

  /**
 
View Full Code Here


        Boolean result;
        if (isJdk6) {
            // jdk6 的 compiler 是线程不安全的,需要手动同步
            synchronized (this) {
                result = task.call();
            }
        } else {
            // jdk7+ 的 compiler 是线程安全的
            result = task.call();
        }
View Full Code Here

            synchronized (this) {
                result = task.call();
            }
        } else {
            // jdk7+ 的 compiler 是线程安全的
            result = task.call();
        }

        // 返回编译结果
        if ((result == null) || !result.booleanValue()) {
            String[] sourceCodeLines = source.getSourceCode().split("\r?\n", -1);
View Full Code Here

                                                           diagnosticListener,
                                                           null,
                                                           null,
                                                           compilationUnitsJavaObjects );
            task.setProcessors( Arrays.asList( annotationProcessor ) );
            task.call();
            fileManager.close();

        } catch ( IOException ioe ) {
            fail( ioe.getMessage() );
        }
View Full Code Here

    // Create the compilation task
    CompilationTask task =
        compiler.getTask(null, fileManager, null, null, null, Arrays
            .asList(new FakeJavaFileObject()));
    task.setProcessors(Arrays.asList(processor));
    if (!task.call()) {
      return false;
    }
    // Save data only on successful compilation
    fileManager.close();
    return true;
View Full Code Here

        if(addToClassPath != null){
            options.add("-cp");
            options.add(addToClassPath.getPath());
        }
        CompilationTask task = compiler.getTask(null, null, null, options, null, units);
        Boolean result = task.call();
        assertTrue(result != null && result.booleanValue());

        File compiledModuleFile = new File(destDir, javaModulePath+"/"+javaClassName+".class");
        assertTrue(compiledModuleFile.isFile());
       
View Full Code Here

        Iterable<? extends JavaFileObject> units = fileManager.getJavaFileObjects(moduleFile);
        File destDir = new File("build/mainTest");
        FileUtil.delete(destDir);
        destDir.mkdirs();
        CompilationTask task = compiler.getTask(null, null, null, Arrays.asList("-d", destDir.getPath(), "-cp", "build/classes"), null, units);
        Boolean result = task.call();
        assertTrue(result != null && result.booleanValue());

        File compiledModuleFile = new File(destDir, "foo/foo/$module_.class");
        assertTrue(compiledModuleFile.isFile());
       
View Full Code Here

    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    File tempDir = getTempDir();
    tempDir.mkdirs();
    List<String> options = Arrays.asList("-proc:none", "-d", tempDir.getAbsolutePath());
    CompilationTask task = compiler.getTask(null, null, null, options, null, Collections.singleton(new ContentBasedJavaFileObject(source.getName(), source.getRawInput())));
    assertTrue(task.call());
  }
 
  private File getTempDir() {
    String[] rawDirs = {
        System.getProperty("java.io.tmpdir"),
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.