Enum AgentBuilder.RedefinitionStrategy

    • Enum Constant Detail

      • REDEFINITION

        public static final AgentBuilder.RedefinitionStrategy REDEFINITION

        Applies a redefinition to all classes that are already loaded and that would have been transformed if the built agent was registered before they were loaded. The created ClassFileTransformer is not registered for applying retransformations.

        Using this strategy, a redefinition is applied as a single transformation request. This means that a single illegal redefinition of a class causes the entire redefinition attempt to fail.

        Note: When applying a redefinition, it is normally required to use a AgentBuilder.TypeStrategy that applies a redefinition instead of rebasing classes such as AgentBuilder.TypeStrategy.Default.REDEFINE. Also, consider the constrains given by this type strategy.

      • RETRANSFORMATION

        public static final AgentBuilder.RedefinitionStrategy RETRANSFORMATION

        Applies a retransformation to all classes that are already loaded and that would have been transformed if the built agent was registered before they were loaded. The created ClassFileTransformer is registered for applying retransformations.

        Using this strategy, a retransformation is applied as a single transformation request. This means that a single illegal retransformation of a class causes the entire retransformation attempt to fail.

        Note: When applying a retransformation, it is normally required to use a AgentBuilder.TypeStrategy that applies a redefinition instead of rebasing classes such as AgentBuilder.TypeStrategy.Default.REDEFINE. Also, consider the constrains given by this type strategy.

    • Field Detail

      • enabled

        private final boolean enabled
        Indicates that this redefinition strategy is enabled.
      • retransforming

        private final boolean retransforming
        true if this strategy applies retransformation.
    • Constructor Detail

      • RedefinitionStrategy

        private RedefinitionStrategy​(boolean enabled,
                                     boolean retransforming)
        Creates a new redefinition strategy.
        Parameters:
        enabled - true if this strategy is enabled.
        retransforming - true if this strategy applies retransformation.
    • Method Detail

      • values

        public static AgentBuilder.RedefinitionStrategy[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (AgentBuilder.RedefinitionStrategy c : AgentBuilder.RedefinitionStrategy.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static AgentBuilder.RedefinitionStrategy valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • isRetransforming

        protected boolean isRetransforming()
        Indicates if this strategy requires a class file transformer to be registered with a hint to apply the transformer for retransformation.
        Returns:
        true if a class file transformer must be registered with a hint for retransformation.
      • check

        protected abstract void check​(java.lang.instrument.Instrumentation instrumentation)
        Checks if this strategy can be applied to the supplied instrumentation instance.
        Parameters:
        instrumentation - The instrumentation instance to validate.
      • isEnabled

        protected boolean isEnabled()
        Indicates that this redefinition strategy applies a modification of already loaded classes.
        Returns:
        true if this redefinition strategy applies a modification of already loaded classes.
      • make

        protected abstract AgentBuilder.RedefinitionStrategy.Collector make()
        Creates a collector instance that is responsible for collecting loaded classes for potential retransformation.
        Returns:
        A new collector for collecting already loaded classes for transformation.