Interface ClassInjector

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  ClassInjector.AbstractBase
      An abstract base implementation of a class injector.
      static class  ClassInjector.UsingInstrumentation
      A class injector using a Instrumentation to append to either the boot classpath or the system class path.
      static class  ClassInjector.UsingJna
      A class injector using JNA to invoke JNI's define class utility for defining a class.
      static class  ClassInjector.UsingLookup
      A class injector that uses a java.lang.invoke.MethodHandles$Lookup object for defining a class.
      static class  ClassInjector.UsingReflection
      A class injector that uses reflective method calls.
      static class  ClassInjector.UsingUnsafe
      A class injector that uses sun.misc.Unsafe or jdk.internal.misc.Unsafe to inject classes.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean ALLOW_EXISTING_TYPES
      Determines the default behavior for type injections when a type is already loaded.
      static java.security.Permission SUPPRESS_ACCESS_CHECKS
      A permission for the suppressAccessChecks permission.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.Map<TypeDescription,​java.lang.Class<?>> inject​(java.util.Map<? extends TypeDescription,​byte[]> types)
      Injects the given types into the represented class loader.
      java.util.Map<TypeDescription,​java.lang.Class<?>> inject​(java.util.Set<? extends TypeDescription> types, ClassFileLocator classFileLocator)
      Injects the given types into the represented class loader.
      java.util.Map<java.lang.String,​java.lang.Class<?>> injectRaw​(java.util.Map<java.lang.String,​byte[]> types)
      Injects the given types into the represented class loader.
      java.util.Map<java.lang.String,​java.lang.Class<?>> injectRaw​(java.util.Set<java.lang.String> names, ClassFileLocator classFileLocator)
      Injects the given types into the represented class loader.
      boolean isAlive()
      Indicates if this class injector is available on the current VM.
    • Field Detail

      • SUPPRESS_ACCESS_CHECKS

        static final java.security.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:
        Constant Field Values
    • Method Detail

      • 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

        java.util.Map<TypeDescription,​java.lang.Class<?>> inject​(java.util.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

        java.util.Map<java.lang.String,​java.lang.Class<?>> injectRaw​(java.util.Set<java.lang.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

        java.util.Map<TypeDescription,​java.lang.Class<?>> inject​(java.util.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

        java.util.Map<java.lang.String,​java.lang.Class<?>> injectRaw​(java.util.Map<java.lang.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.