Class ModuleRuntimeAccess

java.lang.Object
com.netflix.module.ModuleRuntimeAccess

public final class ModuleRuntimeAccess extends Object
Reads, writes, combines, and validates module runtime access requirements.
  • Method Details

    • forModule

      public static ModuleRuntimeAccessOptions forModule(ModuleRuntimeAccessOptions options, String moduleName)
      Selects options whose access is granted to one target module.
      Parameters:
      options - the options to filter
      moduleName - the target module
      Returns:
      the options applying to the target module
    • write

      public static byte[] write(byte[] moduleInfo, ModuleRuntimeAccessOptions options)
      Replaces the runtime access attribute in a module descriptor.
      Parameters:
      moduleInfo - the module-info.class bytes
      options - the requirements to record; an empty set removes the attribute
      Returns:
      the transformed class-file bytes
      Throws:
      IllegalArgumentException - if the bytes do not represent a module descriptor
    • parseArguments

      public static ModuleRuntimeAccessOptions parseArguments(List<String> arguments)
      Parses recognized runtime access options from launcher arguments. Unrecognized arguments are ignored.
      Parameters:
      arguments - launcher arguments
      Returns:
      the parsed runtime access options
      Throws:
      IllegalArgumentException - if a recognized option has an invalid operand
    • checkLaunch

      public static void checkLaunch(List<String> arguments) throws IOException
      Resolves a modular launch and verifies recorded requirements against its arguments.
      Parameters:
      arguments - launcher arguments
      Throws:
      IllegalArgumentException - if a runtime access requirement is unsatisfied
      IOException - if a module descriptor cannot be read
    • checkRequirements

      public static void checkRequirements(ModuleRuntimeAccessOptions required, ModuleRuntimeAccessOptions supplied)
      Verifies that supplied options include every required authorization.
      Parameters:
      required - the required runtime access
      supplied - the authorized runtime access
      Throws:
      IllegalArgumentException - if an authorization is missing
    • add

      public static void add(ModuleRuntimeAccessOptions.Builder builder, ModuleRuntimeAccessOptions options)
      Adds all options to a builder.
      Parameters:
      builder - the destination builder
      options - the options to add
    • read

      public static Optional<ModuleRuntimeAccessOptions> read(ModuleReference reference) throws IOException
      Reads the runtime access attribute from a module descriptor.
      Parameters:
      reference - the module to inspect
      Returns:
      the recorded options, or an empty value when no attribute is present
      Throws:
      IOException - if an explicit module descriptor cannot be read