Enum CompilerUtils

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

public enum CompilerUtils
extends java.lang.Enum<CompilerUtils>
This class support loading and debugging Java Classes dynamically.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    java.lang.Enum.EnumDesc<E extends java.lang.Enum<E>>
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static CachedCompiler CACHED_COMPILER  
    static boolean DEBUGGING  
  • Method Summary

    Modifier and Type Method Description
    static boolean addClassPath​(java.lang.String dir)
    Add a directory to the class path for compiling.
    static void defineClass​(java.lang.String className, byte[] bytes)
    Define a class for byte code.
    static java.lang.Class defineClass​(MyClassLoader classLoader, java.lang.String className, byte[] bytes)
    Define a class for byte code.
    static java.lang.Class loadFromResource​(java.lang.String className, java.lang.String resourceName)
    Load a java class file from the classpath or local file system.
    static CompilerUtils valueOf​(java.lang.String name)
    Returns the enum constant of this type with the specified name.
    static CompilerUtils[] values()
    Returns an array containing the constants of this enum type, in the order they are declared.
    static boolean writeBytes​(java.io.File file, byte[] bytes)  
    static boolean writeText​(java.io.File file, java.lang.String text)  

    Methods inherited from class java.lang.Enum

    clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • 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​(java.lang.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:
      java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
      java.lang.NullPointerException - if the argument is null
    • loadFromResource

      public static java.lang.Class loadFromResource​(@NotNull java.lang.String className, @NotNull java.lang.String resourceName) throws java.io.IOException, java.lang.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:
      java.io.IOException - the resource could not be loaded.
      java.lang.ClassNotFoundException - the class name didn't match or failed to initialise.
    • addClassPath

      public static boolean addClassPath​(@NotNull java.lang.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 java.lang.String className, @NotNull byte[] bytes)
      Define a class for byte code.
      Parameters:
      className - expected to load.
      bytes - of the byte code.
    • defineClass

      public static java.lang.Class defineClass​(@Nullable MyClassLoader classLoader, @NotNull java.lang.String className, @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 java.io.File file, @NotNull java.lang.String text)
    • writeBytes

      public static boolean writeBytes​(@NotNull java.io.File file, @NotNull byte[] bytes)