Package net.openhft.compiler
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
-
Field Summary
Fields Modifier and Type Field Description static CachedCompilerCACHED_COMPILERstatic booleanDEBUGGING -
Method Summary
Modifier and Type Method Description static booleanaddClassPath(java.lang.String dir)Add a directory to the class path for compiling.static voiddefineClass(java.lang.String className, byte[] bytes)Define a class for byte code.static java.lang.ClassdefineClass(MyClassLoader classLoader, java.lang.String className, byte[] bytes)Define a class for byte code.static java.lang.ClassloadFromResource(java.lang.String className, java.lang.String resourceName)Load a java class file from the classpath or local file system.static CompilerUtilsvalueOf(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 booleanwriteBytes(java.io.File file, byte[] bytes)static booleanwriteText(java.io.File file, java.lang.String text)
-
Field Details
-
DEBUGGING
public static final boolean DEBUGGING -
CACHED_COMPILER
-
-
Method Details
-
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
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 namejava.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.ClassNotFoundExceptionLoad 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)
-