Class LookupClassDefiner

java.lang.Object
eu.cloudnetservice.driver.util.define.LookupClassDefiner
All Implemented Interfaces:
ClassDefiner

@Internal final class LookupClassDefiner extends Object implements 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 Details

    • TRUSTED_LOOKUP

      private static final MethodHandles.Lookup 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:
      defineClass in interface ClassDefiner
      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.