Package javax.tools.JavaCompiler

Examples of javax.tools.JavaCompiler.CompilationTask


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


            javaFileManager.putFileForInput(StandardLocation.SOURCE_PATH, packageName,
                  className + JAVA_EXTENSION, source);
         }
      }
      // 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 JavaCompilerException("Compilation failed.", classes
               .keySet(), diagnostics);
      }
      try {
View Full Code Here

            StringWriter errors = new StringWriter();
            PrintWriter pw = new PrintWriter(errors);

            LOG.debug("コンパイルオプション: {}", arguments);
            CompilationTask task = compiler.getTask(
                    pw,
                    fileManager,
                    diagnostics,
                    arguments,
                    Collections.<String>emptyList(),
                    fileManager.getJavaFileObjectsFromFiles(sources));

            Boolean succeeded = task.call();
            pw.close();
            for (Diagnostic<?> diagnostic : diagnostics.getDiagnostics()) {
                switch (diagnostic.getKind()) {
                case ERROR:
                case MANDATORY_WARNING:
View Full Code Here

     */
    public List<Diagnostic<? extends JavaFileObject>> doCompile() {
        DiagnosticCollector<JavaFileObject> collector =
            new DiagnosticCollector<JavaFileObject>();

        CompilationTask task = compiler.getTask(
            new PrintWriter(new OutputStreamWriter(System.err, Charset.defaultCharset()), true),
            files,
            collector,
            arguments,
            Arrays.<String>asList(),
            targets);

        task.setProcessors(processors);

        task.call();
        return collector.getDiagnostics();
    }
View Full Code Here

            Collections.addAll(arguments, "-encoding", CHARSET.name());

            StringWriter errors = new StringWriter();
            PrintWriter pw = new PrintWriter(errors);

            CompilationTask task = compiler.getTask(
                    pw,
                    fileManager,
                    diagnostics,
                    arguments,
                    Collections.<String>emptyList(),
                    emitter.getEmitted());

            Boolean successed = task.call();
            pw.close();
            for (Diagnostic<?> diagnostic : diagnostics.getDiagnostics()) {
                switch (diagnostic.getKind()) {
                case ERROR:
                case MANDATORY_WARNING:
View Full Code Here

      }

      try {
        ContractJavaCompiler compiler =
            new ContractJavaCompiler(sourcePath, classPath, outputDirectory);
        CompilationTask task = compiler.getTask(sources, diagnosticManager);
        success = task.call();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
View Full Code Here

  }

  private void checkWellFormed(Iterable<JavaFileObject> sources, String[] args) {
    JavaCompiler compiler = JavacTool.create();
    OutputStream outputStream = new ByteArrayOutputStream();
    CompilationTask task = compiler.getTask(
        new PrintWriter(outputStream, /*autoFlush=*/true),
        fileManager,
        null,
        buildArguments(Arrays.asList(ErrorProneOptions.processArgs(args).getRemainingArgs())),
        null,
        sources);
    boolean result = task.call();
    assertTrue(String.format("Test program failed to compile with non error-prone error: %s",
        outputStream.toString()), result);
  }
View Full Code Here

  
    String pathOfFile = sourceFile.substring(0, sourceFile.lastIndexOf(File.separatorChar));
    String classpath =GlobalValues.jarFilePath+File.pathSeparatorChar+pathOfFile+File.pathSeparatorChar+".";
    Iterable <String> options = Arrays.asList("-cp", classpath);
   
    CompilationTask task = compiler.getTask(compileWriter, fileManager, null, options, null, compilationUnits);
  
    boolean compileResult = task.call();
    if (compileResult == false) {
        compilationResult = false// compilation errors
        JFrame compResultsFrame = new JFrame("Compilation Results");
        String diagnString = compileWriter.toString();
        JTextArea compResultsArea = new JTextArea(diagnString);
View Full Code Here

        }

        final JavaFileManager fileManager = new JciJavaFileManager(units, pStore);
        final DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();

        CompilationTask task = compiler.getTask(null, fileManager, diagnostics, null, null, units);

        if (task.call().booleanValue()) {
            log.debug("compiled");
        }

        final List<Diagnostic<? extends JavaFileObject>> jsrProblems = diagnostics.getDiagnostics();
        final CompilationProblem[] problems = new CompilationProblem[jsrProblems.size()];
View Full Code Here

    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fileManager =
      compiler.getStandardFileManager(null, null, null);
   
    CompilationTask cTask = compiler.getTask(null, fileManager, null, null,
        null,
        fileManager.getJavaFileObjects(
            javaFiles.toArray(new File[javaFiles.size()])));
    assertTrue(cTask.call());
  }
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.