Interface ClassInjector

All Known Implementing Classes:
ClassInjector.AbstractBase, ClassInjector.UsingInstrumentation, ClassInjector.UsingJna, ClassInjector.UsingLookup, ClassInjector.UsingReflection, ClassInjector.UsingUnsafe

public interface ClassInjector

A class injector is capable of injecting classes into a ClassLoader without requiring the class loader to being able to explicitly look up these classes.

Important: Byte Buddy does not supply privileges when injecting code. When using a java.lang.SecurityManager, the user of this injector is responsible for providing access to non-public properties.

  • Field Details

    • SUPPRESS_ACCESS_CHECKS

      static final Permission SUPPRESS_ACCESS_CHECKS
      A permission for the suppressAccessChecks permission.
    • ALLOW_EXISTING_TYPES

      static final boolean ALLOW_EXISTING_TYPES
      Determines the default behavior for type injections when a type is already loaded.
      See Also:
  • Method Details

    • isAlive

      boolean isAlive()
      Indicates if this class injector is available on the current VM.
      Returns:
      true if this injector is available on the current VM.
    • inject

      Map<TypeDescription,Class<?>> inject(Set<? extends TypeDescription> types, ClassFileLocator classFileLocator)
      Injects the given types into the represented class loader.
      Parameters:
      types - The types to load via injection.
      classFileLocator - The class file locator to use for resolving binary representations.
      Returns:
      The loaded types that were passed as arguments.
    • injectRaw

      Map<String,Class<?>> injectRaw(Set<String> names, ClassFileLocator classFileLocator)
      Injects the given types into the represented class loader.
      Parameters:
      names - The names of the types to load via injection.
      classFileLocator - The class file locator to use for resolving binary representations.
      Returns:
      The loaded types that were passed as arguments.
    • inject

      Map<TypeDescription,Class<?>> inject(Map<? extends TypeDescription,byte[]> types)
      Injects the given types into the represented class loader.
      Parameters:
      types - The types to load via injection.
      Returns:
      The loaded types that were passed as arguments.
    • injectRaw

      Map<String,Class<?>> injectRaw(Map<String,byte[]> types)
      Injects the given types into the represented class loader.
      Parameters:
      types - The names of the type to load via injection.
      Returns:
      The loaded types that were passed as arguments.