Enum CompilerUtils

java.lang.Object
java.lang.Enum<CompilerUtils>
net.openhft.compiler.CompilerUtils
All Implemented Interfaces:
Serializable, Comparable<CompilerUtils>

public enum CompilerUtils extends Enum<CompilerUtils>
This class support loading and debugging Java Classes dynamically.
  • Field Details

    • DEBUGGING

      public static final boolean DEBUGGING
    • CACHED_COMPILER

      public static final CachedCompiler CACHED_COMPILER
  • Method Details

    • values

      public static CompilerUtils[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static CompilerUtils valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • loadFromResource

      public static Class loadFromResource(@NotNull @NotNull String className, @NotNull @NotNull String resourceName) throws IOException, ClassNotFoundException
      Load a java class file from the classpath or local file system.
      Parameters:
      className - expected class name of the outer class.
      resourceName - as the full file name with extension.
      Returns:
      the outer class loaded.
      Throws:
      IOException - the resource could not be loaded.
      ClassNotFoundException - the class name didn't match or failed to initialise.
    • addClassPath

      public static boolean addClassPath(@NotNull @NotNull String dir)
      Add a directory to the class path for compiling. This can be required with custom
      Parameters:
      dir - to add.
      Returns:
      whether the directory was found, if not it is not added either.
    • defineClass

      public static void defineClass(@NotNull @NotNull String className, @NotNull @NotNull byte[] bytes)
      Define a class for byte code.
      Parameters:
      className - expected to load.
      bytes - of the byte code.
    • defineClass

      public static Class defineClass(@Nullable @Nullable ClassLoader classLoader, @NotNull @NotNull String className, @NotNull @NotNull byte[] bytes)
      Define a class for byte code.
      Parameters:
      classLoader - to load the class into.
      className - expected to load.
      bytes - of the byte code.
    • writeText

      public static boolean writeText(@NotNull @NotNull File file, @NotNull @NotNull String text)
    • writeBytes

      public static boolean writeBytes(@NotNull @NotNull File file, @NotNull @NotNull byte[] bytes)