Class ClassInjector.UsingInstrumentation

    • Field Detail

      • JAR

        private static final java.lang.String JAR
        The jar file name extension.
        See Also:
        Constant Field Values
      • CLASS_FILE_EXTENSION

        private static final java.lang.String CLASS_FILE_EXTENSION
        The class file extension.
        See Also:
        Constant Field Values
      • instrumentation

        private final java.lang.instrument.Instrumentation instrumentation
        The instrumentation to use for appending to the class path or the boot path.
      • folder

        private final java.io.File folder
        The folder to be used for storing jar files.
      • randomString

        private final RandomString randomString
        A random string generator for creating file names.
    • Constructor Detail

      • UsingInstrumentation

        protected UsingInstrumentation​(java.io.File folder,
                                       ClassInjector.UsingInstrumentation.Target target,
                                       java.lang.instrument.Instrumentation instrumentation,
                                       RandomString randomString)
        Creates an instrumentation-based class injector.
        Parameters:
        folder - The folder to be used for storing jar files.
        target - A representation of the target path to which classes are to be appended.
        instrumentation - The instrumentation to use for appending to the class path or the boot path.
        randomString - The random string generator to use.
    • Method Detail

      • of

        public static ClassInjector of​(java.io.File folder,
                                       ClassInjector.UsingInstrumentation.Target target,
                                       java.lang.instrument.Instrumentation instrumentation)
        Creates an instrumentation-based class injector.
        Parameters:
        folder - The folder to be used for storing jar files.
        target - A representation of the target path to which classes are to be appended.
        instrumentation - The instrumentation to use for appending to the class path or the boot path.
        Returns:
        An appropriate class injector that applies instrumentation.
      • isAlive

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

        public java.util.Map<java.lang.String,​java.lang.Class<?>> injectRaw​(java.util.Map<? extends java.lang.String,​byte[]> types)
        Injects the given types into the represented class loader using a mapping from name to binary representation.
        Parameters:
        types - The types to load via injection.
        Returns:
        The loaded types that were passed as arguments.
      • isAvailable

        public static boolean isAvailable()
        Returns true if this class injector is available on this VM.
        Returns:
        true if this class injector is available on this VM.