Class SubclassDynamicTypeBuilder<T>

  • Type Parameters:
    T - A loaded type that the dynamic type is guaranteed to be a subtype of.
    All Implemented Interfaces:
    DynamicType.Builder<T>

    @Enhance
    public class SubclassDynamicTypeBuilder<T>
    extends DynamicType.Builder.AbstractBase.Adapter<T>
    A type builder that creates an instrumented type as a subclass, i.e. a type that is not based on an existing class file.
    • Field Detail

      • constructorStrategy

        private final ConstructorStrategy constructorStrategy
        The constructor strategy to apply onto the instrumented type.
    • Constructor Detail

      • SubclassDynamicTypeBuilder

        public SubclassDynamicTypeBuilder​(InstrumentedType.WithFlexibleName instrumentedType,
                                          ClassFileVersion classFileVersion,
                                          AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                                          AnnotationValueFilter.Factory annotationValueFilterFactory,
                                          AnnotationRetention annotationRetention,
                                          Implementation.Context.Factory implementationContextFactory,
                                          MethodGraph.Compiler methodGraphCompiler,
                                          TypeValidation typeValidation,
                                          VisibilityBridgeStrategy visibilityBridgeStrategy,
                                          ClassWriterStrategy classWriterStrategy,
                                          LatentMatcher<? super MethodDescription> ignoredMethods,
                                          ConstructorStrategy constructorStrategy)
        Creates a new type builder for creating a subclass.
        Parameters:
        instrumentedType - An instrumented type representing the subclass.
        classFileVersion - The class file version to use for types that are not based on an existing class file.
        auxiliaryTypeNamingStrategy - The naming strategy to use for naming auxiliary types.
        annotationValueFilterFactory - The annotation value filter factory to use.
        annotationRetention - The annotation retention strategy to use.
        implementationContextFactory - The implementation context factory to use.
        methodGraphCompiler - The method graph compiler to use.
        typeValidation - Determines if a type should be explicitly validated.
        visibilityBridgeStrategy - The visibility bridge strategy to apply.
        classWriterStrategy - The class writer strategy to use.
        ignoredMethods - A matcher for identifying methods that should be excluded from instrumentation.
        constructorStrategy - The constructor strategy to apply onto the instrumented type.
      • SubclassDynamicTypeBuilder

        protected SubclassDynamicTypeBuilder​(InstrumentedType.WithFlexibleName instrumentedType,
                                             FieldRegistry fieldRegistry,
                                             MethodRegistry methodRegistry,
                                             RecordComponentRegistry recordComponentRegistry,
                                             TypeAttributeAppender typeAttributeAppender,
                                             AsmVisitorWrapper asmVisitorWrapper,
                                             ClassFileVersion classFileVersion,
                                             AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
                                             AnnotationValueFilter.Factory annotationValueFilterFactory,
                                             AnnotationRetention annotationRetention,
                                             Implementation.Context.Factory implementationContextFactory,
                                             MethodGraph.Compiler methodGraphCompiler,
                                             TypeValidation typeValidation,
                                             VisibilityBridgeStrategy visibilityBridgeStrategy,
                                             ClassWriterStrategy classWriterStrategy,
                                             LatentMatcher<? super MethodDescription> ignoredMethods,
                                             java.util.List<? extends DynamicType> auxiliaryTypes,
                                             ConstructorStrategy constructorStrategy)
        Creates a new type builder for creating a subclass.
        Parameters:
        instrumentedType - An instrumented type representing the subclass.
        fieldRegistry - The field registry to use.
        methodRegistry - The method registry to use.
        recordComponentRegistry - The record component registry to use.
        typeAttributeAppender - The type attribute appender to apply onto the instrumented type.
        asmVisitorWrapper - The ASM visitor wrapper to apply onto the class writer.
        classFileVersion - The class file version to use for types that are not based on an existing class file.
        auxiliaryTypeNamingStrategy - The naming strategy to use for naming auxiliary types.
        annotationValueFilterFactory - The annotation value filter factory to use.
        annotationRetention - The annotation retention strategy to use.
        implementationContextFactory - The implementation context factory to use.
        methodGraphCompiler - The method graph compiler to use.
        typeValidation - Determines if a type should be explicitly validated.
        visibilityBridgeStrategy - The visibility bridge strategy to apply.
        classWriterStrategy - The class writer strategy to use.
        ignoredMethods - A matcher for identifying methods that should be excluded from instrumentation.
        constructorStrategy - The constructor strategy to apply onto the instrumented type.
        auxiliaryTypes - A list of explicitly required auxiliary types.
    • Method Detail

      • make

        public DynamicType.Unloaded<T> make​(TypeResolutionStrategy typeResolutionStrategy)

        Creates the dynamic type this builder represents. If the specified dynamic type is not legal, an IllegalStateException is thrown.

        The dynamic type is initialized using a TypeResolutionStrategy.Passive strategy. Using this strategy, no LoadedTypeInitializer is run during the execution of the type's initializer such that no Implementation used for executing the initializer must rely on such an initializer.

        Parameters:
        typeResolutionStrategy - The type resolution strategy to use for the created type's initialization.
        Returns:
        An unloaded dynamic type representing the type specified by this builder.
      • make

        public DynamicType.Unloaded<T> make​(TypeResolutionStrategy typeResolutionStrategy,
                                            TypePool typePool)
        Creates the dynamic type this builder represents. If the specified dynamic type is not legal, an IllegalStateException is thrown.
        Parameters:
        typeResolutionStrategy - The type resolution strategy to use for the created type's initialization.
        typePool - A type pool that is used for computing stack map frames by the underlying class writer, if required.
        Returns:
        An unloaded dynamic type representing the type specified by this builder.
      • applyConstructorStrategy

        private InstrumentedType applyConstructorStrategy​(InstrumentedType instrumentedType)
        Applies this builder's constructor strategy to the given instrumented type.
        Parameters:
        instrumentedType - The instrumented type to apply the constructor onto.
        Returns:
        The instrumented type with the constructor strategy applied onto.