Class AgentBuilder.Default.ExecutingTransformer

    • Method Detail

      • transform

        public byte[] transform​(java.lang.ClassLoader classLoader,
                                java.lang.String internalTypeName,
                                java.lang.Class<?> classBeingRedefined,
                                java.security.ProtectionDomain protectionDomain,
                                byte[] binaryRepresentation)
      • transform

        protected byte[] transform​(java.lang.Object rawModule,
                                   java.lang.ClassLoader classLoader,
                                   java.lang.String internalTypeName,
                                   java.lang.Class<?> classBeingRedefined,
                                   java.security.ProtectionDomain protectionDomain,
                                   byte[] binaryRepresentation)
        Applies a transformation for a class that was captured by this ClassFileTransformer. Invoking this method allows to process module information which is available since Java 9.
        Parameters:
        rawModule - The instrumented class's Java java.lang.Module.
        classLoader - The type's class loader or null if the type is loaded by the bootstrap loader.
        internalTypeName - The internal name of the instrumented class.
        classBeingRedefined - The loaded Class being redefined or null if no such class exists.
        protectionDomain - The instrumented type's protection domain.
        binaryRepresentation - The class file of the instrumented class in its current state.
        Returns:
        The transformed class file or an empty byte array if this transformer does not apply an instrumentation.
      • transform

        private byte[] transform​(JavaModule module,
                                 java.lang.ClassLoader classLoader,
                                 java.lang.String internalTypeName,
                                 java.lang.Class<?> classBeingRedefined,
                                 java.security.ProtectionDomain protectionDomain,
                                 byte[] binaryRepresentation)
        Applies a transformation for a class that was captured by this ClassFileTransformer.
        Parameters:
        module - The instrumented class's Java module in its wrapped form or null if the current VM does not support modules.
        classLoader - The instrumented class's class loader.
        internalTypeName - The internal name of the instrumented class.
        classBeingRedefined - The loaded Class being redefined or null if no such class exists.
        protectionDomain - The instrumented type's protection domain.
        binaryRepresentation - The class file of the instrumented class in its current state.
        Returns:
        The transformed class file or an empty byte array if this transformer does not apply an instrumentation.
      • doTransform

        private byte[] doTransform​(JavaModule module,
                                   java.lang.ClassLoader classLoader,
                                   java.lang.String typeName,
                                   java.lang.Class<?> classBeingRedefined,
                                   boolean loaded,
                                   java.security.ProtectionDomain protectionDomain,
                                   TypePool typePool,
                                   ClassFileLocator classFileLocator)
        Applies a transformation for a class that was captured by this ClassFileTransformer.
        Parameters:
        module - The instrumented class's Java module in its wrapped form or null if the current VM does not support modules.
        classLoader - The instrumented class's class loader.
        typeName - The binary name of the instrumented class.
        classBeingRedefined - The loaded Class being redefined or null if no such class exists.
        loaded - true if the instrumented type is loaded.
        protectionDomain - The instrumented type's protection domain.
        typePool - The type pool to use.
        classFileLocator - The class file locator to use.
        Returns:
        The transformed class file or an empty byte array if this transformer does not apply an instrumentation.
      • resolve

        private AgentBuilder.Default.Transformation.Resolution resolve​(JavaModule module,
                                                                       java.lang.ClassLoader classLoader,
                                                                       java.lang.String typeName,
                                                                       java.lang.Class<?> classBeingRedefined,
                                                                       boolean loaded,
                                                                       java.security.ProtectionDomain protectionDomain,
                                                                       TypePool typePool)
        Resolves the transformation and assures it is not ignored.
        Parameters:
        module - The instrumented class's Java module in its wrapped form or null if the current VM does not support modules.
        classLoader - The instrumented class's class loader.
        typeName - The binary name of the instrumented class.
        classBeingRedefined - The loaded Class being redefined or null if no such class exists.
        loaded - true if the instrumented type is loaded.
        protectionDomain - The instrumented type's protection domain.
        typePool - The type pool to use.
        Returns:
        The resolution for the transformation.
      • reset

        public boolean reset​(java.lang.instrument.Instrumentation instrumentation,
                             AgentBuilder.RedefinitionStrategy redefinitionStrategy,
                             AgentBuilder.RedefinitionStrategy.DiscoveryStrategy redefinitionDiscoveryStrategy,
                             AgentBuilder.RedefinitionStrategy.BatchAllocator redefinitionBatchAllocator,
                             AgentBuilder.RedefinitionStrategy.Listener redefinitionListener)

        Deregisters this class file transformer and redefines any transformed class to its state without this class file transformer applied, if the supplied redefinition strategy is enabled. If it is not enabled, only the AgentBuilder.InstallationListener is informed about the resetting without undoing any code changes.

        Note: A reset class file transformer should not be reinstalled. Instead, the AgentBuilder which built the transformer should be asked to install a new transformer.

        Important: Most JVMs do not support changes of a class's structure after a class was already loaded. Therefore, it is typically required that this class file transformer was built while enabling AgentBuilder.disableClassFormatChanges().

        Parameters:
        instrumentation - The instrumentation instance from which to deregister the transformer.
        redefinitionStrategy - The redefinition to apply.
        redefinitionDiscoveryStrategy - The discovery strategy for the types to reset.
        redefinitionBatchAllocator - The batch allocator to use.
        redefinitionListener - The redefinition listener to apply.
        Returns:
        true if a reset was applied and this transformer was not previously removed.