Class CompilerApiExamples

java.lang.Object
net.jrodolfo.java_evolution.java06.compiler_api.CompilerApiExamples

public class CompilerApiExamples extends Object
Demonstrates the Java 6 Compiler API with real source files and structured diagnostics.
  • Constructor Details

    • CompilerApiExamples

      public CompilerApiExamples()
  • Method Details

    • systemCompilerIsAvailable

      public boolean systemCompilerIsAvailable()
      Checks whether the current runtime image provides the standard system compiler.
      Returns:
      true when ToolProvider.getSystemJavaCompiler() can locate a compiler
    • compile

      public CompilerApiExamples.CompilationResult compile(List<File> sourceFiles, File outputDirectory) throws IOException
      Compiles Java source files into a class-output directory.
      Parameters:
      sourceFiles - Java source files to compile
      outputDirectory - directory where generated .class files should be written
      Returns:
      the compilation outcome and collected diagnostics
      Throws:
      IOException - when the file manager cannot access the supplied files
      IllegalStateException - when the code is running without a system compiler