Top Description Inners Methods
org.easymock.bytebuddy.dynamic.scaffold.subclass

public Interface ConstructorStrategy

Known Direct Implementers
org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.Default, org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.Default.WithMethodAttributeAppenderFactory, org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.ForDefaultConstructor, org.easymock.bytebuddy.ByteBuddy.RecordConstructorStrategy
Imports
org.easymock.bytebuddy.build.HashCodeAndEqualsPlugin, org.easymock.bytebuddy.description.method.MethodDescription, .MethodList, org.easymock.bytebuddy.description.type.TypeDescription, org.easymock.bytebuddy.dynamic.Transformer, org.easymock.bytebuddy.dynamic.scaffold.MethodRegistry, org.easymock.bytebuddy.implementation.MethodCall, .SuperMethodCall, org.easymock.bytebuddy.implementation.attribute.MethodAttributeAppender, org.easymock.bytebuddy.matcher.ElementMatcher, .LatentMatcher, org.easymock.bytebuddy.jar.asm.Opcodes, java.util.ArrayList, .Collections, .List

A constructor strategy is responsible for creating bootstrap constructors for a SubclassDynamicTypeBuilder.
See Also
net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.Default

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ConstructorStrategy.Default

Default implementations of constructor strategies.

public static class
ConstructorStrategy.ForDefaultConstructor

A constructor strategy that creates a default constructor that invokes a super constructor with default arguments.

Method Summary

Modifier and TypeMethod and Description
public List<MethodDescription.Token>

Returns:

A list of tokens that describe the constructors that are to be implemented.
extractConstructors
(TypeDescription
The type for which the constructors should be created.
instrumentedType
)

Extracts constructors for a given super type.

public MethodRegistry

Returns:

A method registry that is capable of providing byte code for the constructors that were added by this strategy.
inject
(TypeDescription
The instrumented type.
instrumentedType
,
MethodRegistry
The original method registry.
methodRegistry
)

Returns a method registry that is capable of creating byte code for the constructors that were provided by the org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy#extractConstructors(TypeDescription) method of this instance.

Method Detail

extractConstructorsback to summary
public List<MethodDescription.Token> extractConstructors(TypeDescription instrumentedType)

Extracts constructors for a given super type. The extracted constructor signatures will then be imitated by the created dynamic type.

Parameters
instrumentedType:TypeDescription

The type for which the constructors should be created.

Returns:List<MethodDescription.Token>

A list of tokens that describe the constructors that are to be implemented.

injectback to summary
public MethodRegistry inject(TypeDescription instrumentedType, MethodRegistry methodRegistry)

Returns a method registry that is capable of creating byte code for the constructors that were provided by the org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy#extractConstructors(TypeDescription) method of this instance.

Parameters
instrumentedType:TypeDescription

The instrumented type.

methodRegistry:MethodRegistry

The original method registry.

Returns:MethodRegistry

A method registry that is capable of providing byte code for the constructors that were added by this strategy.

org.easymock.bytebuddy.dynamic.scaffold.subclass back to summary

public sealed Enum ConstructorStrategy.Default

extends Enum<ConstructorStrategy.Default>
implements ConstructorStrategy
Class Inheritance
All Implemented Interfaces
org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy

Default implementations of constructor strategies. Any such strategy offers to additionally apply an MethodAttributeAppender.Factory.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
ConstructorStrategy.Default.WithMethodAttributeAppenderFactory

A wrapper for a default constructor strategy which additionally applies a method attribute appender factory.

Field Summary

Modifier and TypeField and Description
public static final ConstructorStrategy.Default
DEFAULT_CONSTRUCTOR

This strategy is adding a default constructor that calls its super types default constructor.

public static final ConstructorStrategy.Default
IMITATE_SUPER_CLASS

This strategy is adding all constructors of the instrumented type's super class where each constructor is directly invoking its signature-equivalent super class constructor.

public static final ConstructorStrategy.Default
IMITATE_SUPER_CLASS_OPENING

This strategy is adding all constructors of the instrumented type's super class where each constructor is directly invoking its signature-equivalent super class constructor.

public static final ConstructorStrategy.Default
IMITATE_SUPER_CLASS_PUBLIC

This strategy is adding all constructors of the instrumented type's super class where each constructor is directly invoking its signature-equivalent super class constructor.

public static final ConstructorStrategy.Default
NO_CONSTRUCTORS

This strategy is adding no constructors such that the instrumented type will by default not have any.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected abstract List<MethodDescription.Token>

Returns:

A list of relevant method tokens.
doExtractConstructors
(TypeDescription
The type for which to extract the constructors.
instrumentedType
)

Extracts the relevant method tokens of the instrumented type's constructors.

protected abstract MethodRegistry

Returns:

The resulting method registry.
doInject
(MethodRegistry
The method registry into which to inject the constructors.
methodRegistry
,
MethodAttributeAppender.Factory
The method attribute appender to use.
methodAttributeAppenderFactory
)

Applies the actual injection with a method attribute appender factory supplied.

public List<MethodDescription.Token>
extractConstructors(TypeDescription
The type for which the constructors should be created.
instrumentedType
)

Implements org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.extractConstructors.

Extracts constructors for a given super type.
public MethodRegistry
inject(TypeDescription
The instrumented type.
instrumentedType
,
MethodRegistry
The original method registry.
methodRegistry
)

Implements org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.inject.

Returns a method registry that is capable of creating byte code for the constructors that were provided by the org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy#extractConstructors(TypeDescription) method of this instance.
protected int

Returns:

The resolved modifiers.
resolveModifier
(int
The actual constructor's modifiers.
modifiers
)

Resolves a constructor's modifiers.

public static ConstructorStrategy.Default
public static ConstructorStrategy.Default[]
public ConstructorStrategy

Returns:

A copy of this constructor strategy with the method attribute appender factory applied.
with
(MethodAttributeAppender.Factory
The method attribute appender factory to use.
methodAttributeAppenderFactory
)

Returns a constructor strategy that supplies the supplied method attribute appender factory.

public ConstructorStrategy

Returns:

A copy of this constructor strategy which retains any of the base constructor's annotations.
withInheritedAnnotations
()

Applies this constructor strategy while retaining any of the base constructor's annotations.

Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DEFAULT_CONSTRUCTORback to summary
public static final ConstructorStrategy.Default DEFAULT_CONSTRUCTOR

This strategy is adding a default constructor that calls its super types default constructor. If no such constructor is defined by the super class, an IllegalArgumentException is thrown. Note that the default constructor needs to be visible to its sub type for this strategy to work. The declared default constructor of the created class is declared public and without annotations.

IMITATE_SUPER_CLASSback to summary
public static final ConstructorStrategy.Default IMITATE_SUPER_CLASS

This strategy is adding all constructors of the instrumented type's super class where each constructor is directly invoking its signature-equivalent super class constructor. Only constructors that are visible to the instrumented type are added, i.e. package-private constructors are only added if the super type is defined in the same package as the instrumented type and private constructors are always skipped.

IMITATE_SUPER_CLASS_OPENINGback to summary
public static final ConstructorStrategy.Default IMITATE_SUPER_CLASS_OPENING

This strategy is adding all constructors of the instrumented type's super class where each constructor is directly invoking its signature-equivalent super class constructor. A constructor is added for any constructor of the super class that is invokable and is declared as public.

IMITATE_SUPER_CLASS_PUBLICback to summary
public static final ConstructorStrategy.Default IMITATE_SUPER_CLASS_PUBLIC

This strategy is adding all constructors of the instrumented type's super class where each constructor is directly invoking its signature-equivalent super class constructor. Only public constructors are added.

NO_CONSTRUCTORSback to summary
public static final ConstructorStrategy.Default NO_CONSTRUCTORS

This strategy is adding no constructors such that the instrumented type will by default not have any. This is legal by Java byte code requirements. However, if no constructor is added manually if this strategy is applied, the type is not constructable without using JVM non-public functionality.

Constructor Detail

Defaultback to summary
private Default()

Method Detail

doExtractConstructorsback to summary
protected abstract List<MethodDescription.Token> doExtractConstructors(TypeDescription instrumentedType)

Extracts the relevant method tokens of the instrumented type's constructors.

Parameters
instrumentedType:TypeDescription

The type for which to extract the constructors.

Returns:List<MethodDescription.Token>

A list of relevant method tokens.

doInjectback to summary
protected abstract MethodRegistry doInject(MethodRegistry methodRegistry, MethodAttributeAppender.Factory methodAttributeAppenderFactory)

Applies the actual injection with a method attribute appender factory supplied.

Parameters
methodRegistry:MethodRegistry

The method registry into which to inject the constructors.

methodAttributeAppenderFactory:MethodAttributeAppender.Factory

The method attribute appender to use.

Returns:MethodRegistry

The resulting method registry.

extractConstructorsback to summary
public List<MethodDescription.Token> extractConstructors(TypeDescription instrumentedType)

Implements org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.extractConstructors.

Doc from org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.extractConstructors.

Extracts constructors for a given super type. The extracted constructor signatures will then be imitated by the created dynamic type.

Parameters
instrumentedType:TypeDescription

The type for which the constructors should be created.

Returns:List<MethodDescription.Token>

A list of tokens that describe the constructors that are to be implemented.

injectback to summary
public MethodRegistry inject(TypeDescription instrumentedType, MethodRegistry methodRegistry)

Implements org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.inject.

Doc from org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.inject.

Returns a method registry that is capable of creating byte code for the constructors that were provided by the org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy#extractConstructors(TypeDescription) method of this instance.

Parameters
instrumentedType:TypeDescription

The instrumented type.

methodRegistry:MethodRegistry

The original method registry.

Returns:MethodRegistry

A method registry that is capable of providing byte code for the constructors that were added by this strategy.

resolveModifierback to summary
protected int resolveModifier(int modifiers)

Resolves a constructor's modifiers.

Parameters
modifiers:int

The actual constructor's modifiers.

Returns:int

The resolved modifiers.

valueOfback to summary
public static ConstructorStrategy.Default valueOf(String name)
valuesback to summary
public static ConstructorStrategy.Default[] values()
withback to summary
public ConstructorStrategy with(MethodAttributeAppender.Factory methodAttributeAppenderFactory)

Returns a constructor strategy that supplies the supplied method attribute appender factory.

Parameters
methodAttributeAppenderFactory:MethodAttributeAppender.Factory

The method attribute appender factory to use.

Returns:ConstructorStrategy

A copy of this constructor strategy with the method attribute appender factory applied.

withInheritedAnnotationsback to summary
public ConstructorStrategy withInheritedAnnotations()

Applies this constructor strategy while retaining any of the base constructor's annotations.

Returns:ConstructorStrategy

A copy of this constructor strategy which retains any of the base constructor's annotations.

org.easymock.bytebuddy.dynamic.scaffold.subclass back to summary

protected Class ConstructorStrategy.Default.WithMethodAttributeAppenderFactory

extends Object
implements ConstructorStrategy
Class Inheritance
  • java.lang.Object
  • org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.Default.WithMethodAttributeAppenderFactory
All Implemented Interfaces
org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy
Annotations
@Enhance

A wrapper for a default constructor strategy which additionally applies a method attribute appender factory.

Field Summary

Modifier and TypeField and Description
private final ConstructorStrategy.Default
delegate

The delegate default constructor strategy.

private final MethodAttributeAppender.Factory
methodAttributeAppenderFactory

The method attribute appender factory to apply.

Constructor Summary

AccessConstructor and Description
protected
WithMethodAttributeAppenderFactory(ConstructorStrategy.Default
The delegate default constructor strategy.
delegate
,
MethodAttributeAppender.Factory
The method attribute appender factory to apply.
methodAttributeAppenderFactory
)

Creates a new wrapper for a default constructor strategy.

Method Summary

Modifier and TypeMethod and Description
public List<MethodDescription.Token>
extractConstructors(TypeDescription
The type for which the constructors should be created.
instrumentedType
)

Implements org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.extractConstructors.

Extracts constructors for a given super type.
public MethodRegistry
inject(TypeDescription
The instrumented type.
instrumentedType
,
MethodRegistry
The original method registry.
methodRegistry
)

Implements org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.inject.

Returns a method registry that is capable of creating byte code for the constructors that were provided by the org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy#extractConstructors(TypeDescription) method of this instance.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final ConstructorStrategy.Default delegate

The delegate default constructor strategy.

methodAttributeAppenderFactoryback to summary
private final MethodAttributeAppender.Factory methodAttributeAppenderFactory

The method attribute appender factory to apply.

Constructor Detail

WithMethodAttributeAppenderFactoryback to summary
protected WithMethodAttributeAppenderFactory(ConstructorStrategy.Default delegate, MethodAttributeAppender.Factory methodAttributeAppenderFactory)

Creates a new wrapper for a default constructor strategy.

Parameters
delegate:ConstructorStrategy.Default

The delegate default constructor strategy.

methodAttributeAppenderFactory:MethodAttributeAppender.Factory

The method attribute appender factory to apply.

Method Detail

extractConstructorsback to summary
public List<MethodDescription.Token> extractConstructors(TypeDescription instrumentedType)

Implements org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.extractConstructors.

Doc from org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.extractConstructors.

Extracts constructors for a given super type. The extracted constructor signatures will then be imitated by the created dynamic type.

Parameters
instrumentedType:TypeDescription

The type for which the constructors should be created.

Returns:List<MethodDescription.Token>

A list of tokens that describe the constructors that are to be implemented.

injectback to summary
public MethodRegistry inject(TypeDescription instrumentedType, MethodRegistry methodRegistry)

Implements org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.inject.

Doc from org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.inject.

Returns a method registry that is capable of creating byte code for the constructors that were provided by the org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy#extractConstructors(TypeDescription) method of this instance.

Parameters
instrumentedType:TypeDescription

The instrumented type.

methodRegistry:MethodRegistry

The original method registry.

Returns:MethodRegistry

A method registry that is capable of providing byte code for the constructors that were added by this strategy.

org.easymock.bytebuddy.dynamic.scaffold.subclass back to summary

public Class ConstructorStrategy.ForDefaultConstructor

extends Object
implements ConstructorStrategy
Class Inheritance
  • java.lang.Object
  • org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.ForDefaultConstructor
All Implemented Interfaces
org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy
Annotations
@Enhance

A constructor strategy that creates a default constructor that invokes a super constructor with default arguments.

Field Summary

Modifier and TypeField and Description
private final ElementMatcher<? super MethodDescription>
elementMatcher

A matcher to select a super constructor among possible candidates.

private final MethodAttributeAppender.Factory
methodAttributeAppenderFactory

The method attribute appender factory to apply.

Constructor Summary

AccessConstructor and Description
public
ForDefaultConstructor()

Creates a constructor strategy for invoking a super constructor with default arguments.

public
ForDefaultConstructor(ElementMatcher<? super MethodDescription>
A matcher to select a super constructor among possible candidates.
elementMatcher
)

Creates a constructor strategy for invoking a super constructor with default arguments.

public
ForDefaultConstructor(MethodAttributeAppender.Factory
The method attribute appender factory to apply.
methodAttributeAppenderFactory
)

Creates a constructor strategy for invoking a super constructor with default arguments.

public
ForDefaultConstructor(ElementMatcher<? super MethodDescription>
A matcher to select a super constructor among possible candidates.
elementMatcher
,
MethodAttributeAppender.Factory
The method attribute appender factory to apply.
methodAttributeAppenderFactory
)

Creates a constructor strategy for invoking a super constructor with default arguments.

Method Summary

Modifier and TypeMethod and Description
public List<MethodDescription.Token>
extractConstructors(TypeDescription
The type for which the constructors should be created.
instrumentedType
)

Implements org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.extractConstructors.

Extracts constructors for a given super type.
public MethodRegistry
inject(TypeDescription
The instrumented type.
instrumentedType
,
MethodRegistry
The original method registry.
methodRegistry
)

Implements org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.inject.

Returns a method registry that is capable of creating byte code for the constructors that were provided by the org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy#extractConstructors(TypeDescription) method of this instance.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

elementMatcherback to summary
private final ElementMatcher<? super MethodDescription> elementMatcher

A matcher to select a super constructor among possible candidates.

methodAttributeAppenderFactoryback to summary
private final MethodAttributeAppender.Factory methodAttributeAppenderFactory

The method attribute appender factory to apply.

Constructor Detail

ForDefaultConstructorback to summary
public ForDefaultConstructor()

Creates a constructor strategy for invoking a super constructor with default arguments.

ForDefaultConstructorback to summary
public ForDefaultConstructor(ElementMatcher<? super MethodDescription> elementMatcher)

Creates a constructor strategy for invoking a super constructor with default arguments.

Parameters
elementMatcher:ElementMatcher<? super MethodDescription>

A matcher to select a super constructor among possible candidates.

ForDefaultConstructorback to summary
public ForDefaultConstructor(MethodAttributeAppender.Factory methodAttributeAppenderFactory)

Creates a constructor strategy for invoking a super constructor with default arguments.

Parameters
methodAttributeAppenderFactory:MethodAttributeAppender.Factory

The method attribute appender factory to apply.

ForDefaultConstructorback to summary
public ForDefaultConstructor(ElementMatcher<? super MethodDescription> elementMatcher, MethodAttributeAppender.Factory methodAttributeAppenderFactory)

Creates a constructor strategy for invoking a super constructor with default arguments.

Parameters
elementMatcher:ElementMatcher<? super MethodDescription>

A matcher to select a super constructor among possible candidates.

methodAttributeAppenderFactory:MethodAttributeAppender.Factory

The method attribute appender factory to apply.

Method Detail

extractConstructorsback to summary
public List<MethodDescription.Token> extractConstructors(TypeDescription instrumentedType)

Implements org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.extractConstructors.

Doc from org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.extractConstructors.

Extracts constructors for a given super type. The extracted constructor signatures will then be imitated by the created dynamic type.

Parameters
instrumentedType:TypeDescription

The type for which the constructors should be created.

Returns:List<MethodDescription.Token>

A list of tokens that describe the constructors that are to be implemented.

injectback to summary
public MethodRegistry inject(TypeDescription instrumentedType, MethodRegistry methodRegistry)

Implements org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.inject.

Doc from org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy.inject.

Returns a method registry that is capable of creating byte code for the constructors that were provided by the org.easymock.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy#extractConstructors(TypeDescription) method of this instance.

Parameters
instrumentedType:TypeDescription

The instrumented type.

methodRegistry:MethodRegistry

The original method registry.

Returns:MethodRegistry

A method registry that is capable of providing byte code for the constructors that were added by this strategy.