public enum CompilerUtils extends Enum<CompilerUtils>
| Modifier and Type | Field and Description |
|---|---|
static CachedCompiler |
CACHED_COMPILER
In-memory singleton compiler reused across calls.
|
static boolean |
DEBUGGING
Indicates whether the JVM started with debugging enabled.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
addClassPath(@NotNull String dir)
Adds a directory to the compilation class-path.
|
static Class<?> |
defineClass(@Nullable ClassLoader classLoader,
@NotNull String className,
@NotNull byte[] bytes)
Defines a class from the supplied bytecode.
|
static void |
defineClass(@NotNull String className,
@NotNull byte[] bytes)
Define a class for byte code.
|
static Class<?> |
loadFromResource(@NotNull String className,
@NotNull String resourceName)
Loads a class from a source file found on the class-path or local file system.
|
static CompilerUtils |
valueOf(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(@NotNull File file,
@NotNull byte[] bytes)
Writes the given bytes to the specified file.
|
static boolean |
writeText(@NotNull File file,
@NotNull String text)
Writes the provided text to the target file using UTF-8.
|
public static final boolean DEBUGGING
public static final CachedCompiler CACHED_COMPILER
public static CompilerUtils[] values()
for (CompilerUtils c : CompilerUtils.values()) System.out.println(c);
public static CompilerUtils valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static Class<?> loadFromResource(@NotNull @NotNull String className, @NotNull @NotNull String resourceName) throws IOException, ClassNotFoundException
className - expected class name of the outer class.resourceName - full file name with extension.IOException - if the resource cannot be read.ClassNotFoundException - if the compiled class name differs or fails to initialise.public static boolean addClassPath(@NotNull
@NotNull String dir)
dir - directory to add.true if the directory exists and was appended.AssertionError - if the compiler cannot be reinitialised.public static void defineClass(@NotNull
@NotNull String className,
@NotNull
@NotNull byte[] bytes)
className - expected to load.bytes - of the byte code.public static Class<?> defineClass(@Nullable @Nullable ClassLoader classLoader, @NotNull @NotNull String className, @NotNull @NotNull byte[] bytes)
Unsafe to bypass access checks.classLoader - class loader to define the class within.className - expected binary name.bytes - compiled bytecode for the class.AssertionError - if defineClass cannot be invoked.public static boolean writeText(@NotNull
@NotNull File file,
@NotNull
@NotNull String text)
file - destination file.text - text to write.true if the contents changed.IllegalStateException - if the file cannot be written.public static boolean writeBytes(@NotNull
@NotNull File file,
@NotNull
@NotNull byte[] bytes)
file - destination file.bytes - bytes to write.true if the file contents were updated.IllegalStateException - if the write fails.Copyright © 2025. All rights reserved.