Class RuntimeCompiler

java.lang.Object
velo.ladealpha.fields.services.RuntimeCompiler

public class RuntimeCompiler extends Object
The Class RuntimeCompiler.
  • Constructor Details

    • RuntimeCompiler

      public RuntimeCompiler()
      Creates a new RuntimeCompiler.
      Throws:
      NullPointerException - If no JavaCompiler could be obtained. This is the case when the application was not started with a JDK, but only with a JRE. (More specifically: When the JDK tools are not in the classpath).
  • Method Details

    • addClass

      public void addClass(String className, String code)
      Add a class with the given name and source code to be compiled with the next call to compile().
      Parameters:
      className - The class name
      code - The code of the class
    • getCompiledClass

      public Class<?> getCompiledClass(String className)
      Obtain a class that was previously compiled by adding it with addClass(String, String) and calling compile().
      Parameters:
      className - The class name
      Returns:
      The class. Returns null if the compilation failed.