Class LookupClassDefiner
java.lang.Object
eu.cloudnetservice.driver.util.define.LookupClassDefiner
- All Implemented Interfaces:
ClassDefiner
A class definer for modern jvm implementation (Java 15+) which makes use of the newly added defineHiddenClass method
in the Lookup class.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final MethodHandles.LookupThe jvm trusted lookup instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanGet if the lookup class definer requirements are met to use the definer in the current jvm.defineClass(@NonNull String name, @NonNull Class<?> parent, byte[] bytecode) Defines the given class bytecode and return the constructed class object.
-
Field Details
-
TRUSTED_LOOKUP
The jvm trusted lookup instance. It allows access to every lookup even if the access to these classes is denied for the current module.
-
-
Constructor Details
-
LookupClassDefiner
LookupClassDefiner()
-
-
Method Details
-
available
public static boolean available()Get if the lookup class definer requirements are met to use the definer in the current jvm.- Returns:
- if the lookup class definer requirements are met to use the definer in the current jvm.
-
defineClass
@NonNull public @NonNull Class<?> defineClass(@NonNull @NonNull String name, @NonNull @NonNull Class<?> parent, byte[] bytecode) Defines the given class bytecode and return the constructed class object.- Specified by:
defineClassin interfaceClassDefiner- Parameters:
name- the name of the class to construct.parent- the parent class of this class as we are assuming to define an anonymous class.bytecode- the bytecode of the class to define.- Returns:
- the constructed class object from the given bytecode.
-