public final class CompilerUtils extends Object
This class provides a method for defining a new class in the context of the specified class loader, using an array of bytes in the form of an ongoing Java class file containing a class or interface definition.
Note that this class is intended for use cases where there is a need to load classes into the JVM programmatically during runtime.
Modifier and Type | Method and Description |
---|---|
static Class |
defineClass(@NotNull ClassLoader classLoader,
@NotNull String className,
byte[] bytes)
Dynamically defines a new Java class in the context of the specified class loader, using
an array of bytes containing the class file.
|
public static Class defineClass(@NotNull @NotNull ClassLoader classLoader, @NotNull @NotNull String className, byte[] bytes)
classLoader
- The class loader into which the class should be loaded.className
- The expected fully qualified name of the class.bytes
- The bytes comprising the ongoing Java class file in the form of a class
or interface definition.Class
object representing the defined class.AssertionError
- if the class could not be defined for any reason.Copyright © 2023. All rights reserved.