Class ClassInjector.UsingLookup

  • All Implemented Interfaces:
    ClassInjector
    Enclosing interface:
    ClassInjector

    public static class ClassInjector.UsingLookup
    extends java.lang.Object
    implements ClassInjector

    A class injector that uses a java.lang.invoke.MethodHandles$Lookup object for defining a class.

    Important: This functionality is only available starting from Java 9.

    • Constructor Detail

      • UsingLookup

        protected UsingLookup​(java.lang.Object lookup)
        Creates a new class injector using a lookup instance.
        Parameters:
        lookup - The java.lang.invoke.MethodHandles$Lookup instance to use.
    • Method Detail

      • of

        public static ClassInjector.UsingLookup of​(java.lang.Object lookup)
        Creates class injector that defines a class using a method handle lookup.
        Parameters:
        lookup - The java.lang.invoke.MethodHandles$Lookup instance to use.
        Returns:
        An appropriate class injector.
      • isAvailable

        public static boolean isAvailable()
        Checks if the current VM is capable of defining classes using a method handle lookup.
        Returns:
        true if the current VM is capable of defining classes using a lookup.
      • lookupType

        public java.lang.Class<?> lookupType()
        Returns the lookup type this injector is based upon.
        Returns:
        The lookup type.
      • inject

        public java.util.Map<TypeDescription,​java.lang.Class<?>> inject​(java.util.Map<? extends TypeDescription,​byte[]> types)
        Description copied from interface: ClassInjector
        Injects the given types into the represented class loader.
        Specified by:
        inject in interface ClassInjector
        Parameters:
        types - The types to load via injection.
        Returns:
        The loaded types that were passed as arguments.