Class VarHandleUtil

java.lang.Object
eu.cloudnetservice.driver.util.VarHandleUtil

@Internal public final class VarHandleUtil extends Object
Small utility to make internal work with var handles easier.
Since:
4.0
  • Constructor Details

    • VarHandleUtil

      private VarHandleUtil()
  • Method Details

    • lookup

      @NonNull public static @NonNull VarHandle lookup(@NonNull MethodHandles.Lookup lookup, @NonNull @NonNull Class<?> declaringClass, @NonNull @NonNull String name, @NonNull @NonNull Class<?> fieldType)
      Finds a var handle for the field with the given name and type in the given class.
      Parameters:
      lookup - the lookup for the class to find the handle in.
      declaringClass - the declaring class of the field to find the handle for.
      name - the name of the field to find the handle for.
      fieldType - the type of the field to find the handle for.
      Returns:
      a var handle for the given field in the given class.
      Throws:
      NullPointerException - if the given lookup, declaring class, field name or field type is null.
      IllegalStateException - if the target field is unknown or the given lookup instance has no access to it.