Top Description Inners Fields Constructors Methods
net.bytebuddy.implementation.bytecode.collection

public Class ArrayFactory

extends Object
implements CollectionFactory
Class Inheritance
All Implemented Interfaces
net.bytebuddy.implementation.bytecode.collection.CollectionFactory
Annotations
@Enhance
Imports
net.bytebuddy.build.HashCodeAndEqualsPlugin, net.bytebuddy.description.type.TypeDefinition, .TypeDescription, net.bytebuddy.implementation.Implementation, net.bytebuddy.implementation.bytecode.StackManipulation, .StackSize, net.bytebuddy.implementation.bytecode.constant.IntegerConstant, net.bytebuddy.jar.asm.MethodVisitor, .Opcodes, java.util.List

A net.bytebuddy.implementation.bytecode.collection.CollectionFactory that is capable of creating an array of a given type with any number of given values.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static interface
ArrayFactory.ArrayCreator

An array creator is responsible for providing correct byte code instructions for creating an array and for storing values into it.

protected class
ArrayFactory.ArrayStackManipulation

A stack manipulation for creating an array as defined by the enclosing array factory.

Field Summary

Modifier and TypeField and Description
private final ArrayFactory.ArrayCreator
arrayCreator

The array creator delegate that supplies suitable opcodes for the creation of an array and the storage of values inside it.

private final TypeDescription.Generic
componentType

The component type of the array this array factory is creating.

private final StackManipulation.Size
sizeDecrease

The decrease of stack size after each value storage operation.

Constructor Summary

AccessConstructor and Description
protected
ArrayFactory(TypeDescription.Generic
The component type of the array factory.
componentType
,
ArrayFactory.ArrayCreator
The array creator responsible for providing the correct byte code instructions.
arrayCreator
)

Creates a new array factory with a given net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayCreator without inferring the type from the component type.

Method Summary

Modifier and TypeMethod and Description
public static ArrayFactory

Returns:

A new array factory for the given type.
forType
(TypeDescription.Generic
The component type of the array that is to be build.
componentType
)

Creates a new array factory for a given component type.

public TypeDescription.Generic
private static ArrayFactory.ArrayCreator

Returns:

A suitable array creator.
makeArrayCreatorFor
(TypeDefinition
The component type of the array to be created.
componentType
)

Creates a suitable array creator for the given component type.

public StackManipulation
withValues(List<? extends StackManipulation>
A list of stack manipulations loading the values to be stored in the collection that is created by this factory in their given order.
stackManipulations
)

Implements net.bytebuddy.implementation.bytecode.collection.CollectionFactory.withValues.

Applies this collection factory in order to build a new collection where each element is represented by the given stack manipulations.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrayCreatorback to summary
private final ArrayFactory.ArrayCreator arrayCreator

The array creator delegate that supplies suitable opcodes for the creation of an array and the storage of values inside it.

componentTypeback to summary
private final TypeDescription.Generic componentType

The component type of the array this array factory is creating.

sizeDecreaseback to summary
private final StackManipulation.Size sizeDecrease

The decrease of stack size after each value storage operation.

Annotations
@ValueHandling:IGNORE

Constructor Detail

ArrayFactoryback to summary
protected ArrayFactory(TypeDescription.Generic componentType, ArrayFactory.ArrayCreator arrayCreator)

Creates a new array factory with a given net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayCreator without inferring the type from the component type. Normally, net.bytebuddy.implementation.bytecode.collection.ArrayFactory#forType(net.bytebuddy.description.type.TypeDescription.Generic) should be used.

Parameters
componentType:TypeDescription.Generic

The component type of the array factory.

arrayCreator:ArrayFactory.ArrayCreator

The array creator responsible for providing the correct byte code instructions.

Method Detail

forTypeback to summary
public static ArrayFactory forType(TypeDescription.Generic componentType)

Creates a new array factory for a given component type.

Parameters
componentType:TypeDescription.Generic

The component type of the array that is to be build.

Returns:ArrayFactory

A new array factory for the given type.

getComponentTypeback to summary
public TypeDescription.Generic getComponentType()

Implements net.bytebuddy.implementation.bytecode.collection.CollectionFactory.getComponentType.

Doc from net.bytebuddy.implementation.bytecode.collection.CollectionFactory.getComponentType.

The component type of this factory.

Returns:TypeDescription.Generic

A type description of this factory's component type.

makeArrayCreatorForback to summary
private static ArrayFactory.ArrayCreator makeArrayCreatorFor(TypeDefinition componentType)

Creates a suitable array creator for the given component type.

Parameters
componentType:TypeDefinition

The component type of the array to be created.

Returns:ArrayFactory.ArrayCreator

A suitable array creator.

withValuesback to summary
public StackManipulation withValues(List<? extends StackManipulation> stackManipulations)

Implements net.bytebuddy.implementation.bytecode.collection.CollectionFactory.withValues.

Doc from net.bytebuddy.implementation.bytecode.collection.CollectionFactory.withValues.

Applies this collection factory in order to build a new collection where each element is represented by the given stack manipulations.

Parameters
stackManipulations:List<? extends StackManipulation>

A list of stack manipulations loading the values to be stored in the collection that is created by this factory in their given order.

Returns:StackManipulation

A stack manipulation that creates the collection represented by this collection factory.

net.bytebuddy.implementation.bytecode.collection back to summary

protected Interface ArrayFactory.ArrayCreator

extends StackManipulation
Known Direct Implementers
net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayCreator.ForPrimitiveType, net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayCreator.ForReferenceType

An array creator is responsible for providing correct byte code instructions for creating an array and for storing values into it.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ArrayFactory.ArrayCreator.ForPrimitiveType

An array creator implementation for primitive types.

public static class
ArrayFactory.ArrayCreator.ForReferenceType

An array creator implementation for reference types.

Field Summary

Modifier and TypeField and Description
public static final StackManipulation.Size
ARRAY_CREATION_SIZE_CHANGE

The creation of an array consumes one slot on the operand stack and adds a new value to it.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The correct storage opcode for the represented type.
getStorageOpcode
()

The opcode instruction for storing a value of the component type inside an array.

Inherited from net.bytebuddy.implementation.bytecode.StackManipulation:
applyisValid

Field Detail

ARRAY_CREATION_SIZE_CHANGEback to summary
public static final StackManipulation.Size ARRAY_CREATION_SIZE_CHANGE

The creation of an array consumes one slot on the operand stack and adds a new value to it. Therefore, the operand stack's size is not altered.

Method Detail

getStorageOpcodeback to summary
public int getStorageOpcode()

The opcode instruction for storing a value of the component type inside an array.

Returns:int

The correct storage opcode for the represented type.

net.bytebuddy.implementation.bytecode.collection back to summary

public final Enum ArrayFactory.ArrayCreator.ForPrimitiveType

extends Enum<ArrayFactory.ArrayCreator.ForPrimitiveType>
implements ArrayCreator
Class Inheritance
All Implemented Interfaces
net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayCreator, net.bytebuddy.implementation.bytecode.StackManipulation

An array creator implementation for primitive types.

Field Summary

Modifier and TypeField and Description
public static final ArrayFactory.ArrayCreator.ForPrimitiveType
BOOLEAN

An array creator for creating boolean[] arrays.

public static final ArrayFactory.ArrayCreator.ForPrimitiveType
BYTE

An array creator for creating byte[] arrays.

public static final ArrayFactory.ArrayCreator.ForPrimitiveType
CHARACTER

An array creator for creating char[] arrays.

private final int
creationOpcode

The opcode for creating an array of this type.

public static final ArrayFactory.ArrayCreator.ForPrimitiveType
DOUBLE

An array creator for creating double[] arrays.

public static final ArrayFactory.ArrayCreator.ForPrimitiveType
FLOAT

An array creator for creating float[] arrays.

public static final ArrayFactory.ArrayCreator.ForPrimitiveType
INTEGER

An array creator for creating int[] arrays.

public static final ArrayFactory.ArrayCreator.ForPrimitiveType
LONG

An array creator for creating long[] arrays.

public static final ArrayFactory.ArrayCreator.ForPrimitiveType
SHORT

An array creator for creating short[] arrays.

private final int
storageOpcode

The opcode for storing a value in an array of this type.

Constructor Summary

AccessConstructor and Description
private
ForPrimitiveType(int
The opcode for creating an array of this type.
creationOpcode
,
int
The opcode for storing a value in an array of this type.
storageOpcode
)

Creates a new primitive array creator.

Method Summary

Modifier and TypeMethod and Description
public StackManipulation.Size
apply(MethodVisitor
The method visitor used to write the method implementation to.
methodVisitor
,
Implementation.Context
The context of the current implementation.
implementationContext
)

Implements net.bytebuddy.implementation.bytecode.StackManipulation.apply.

Applies the stack manipulation that is described by this instance.
public int
getStorageOpcode()

Implements net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayCreator.getStorageOpcode.

The opcode instruction for storing a value of the component type inside an array.
public boolean
isValid()

Implements net.bytebuddy.implementation.bytecode.StackManipulation.isValid.

Determines if this stack manipulation is valid.
public static ArrayFactory.ArrayCreator.ForPrimitiveType
public static ArrayFactory.ArrayCreator.ForPrimitiveType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BOOLEANback to summary
public static final ArrayFactory.ArrayCreator.ForPrimitiveType BOOLEAN

An array creator for creating boolean[] arrays.

BYTEback to summary
public static final ArrayFactory.ArrayCreator.ForPrimitiveType BYTE

An array creator for creating byte[] arrays.

CHARACTERback to summary
public static final ArrayFactory.ArrayCreator.ForPrimitiveType CHARACTER

An array creator for creating char[] arrays.

creationOpcodeback to summary
private final int creationOpcode

The opcode for creating an array of this type.

DOUBLEback to summary
public static final ArrayFactory.ArrayCreator.ForPrimitiveType DOUBLE

An array creator for creating double[] arrays.

FLOATback to summary
public static final ArrayFactory.ArrayCreator.ForPrimitiveType FLOAT

An array creator for creating float[] arrays.

INTEGERback to summary
public static final ArrayFactory.ArrayCreator.ForPrimitiveType INTEGER

An array creator for creating int[] arrays.

LONGback to summary
public static final ArrayFactory.ArrayCreator.ForPrimitiveType LONG

An array creator for creating long[] arrays.

SHORTback to summary
public static final ArrayFactory.ArrayCreator.ForPrimitiveType SHORT

An array creator for creating short[] arrays.

storageOpcodeback to summary
private final int storageOpcode

The opcode for storing a value in an array of this type.

Constructor Detail

ForPrimitiveTypeback to summary
private ForPrimitiveType(int creationOpcode, int storageOpcode)

Creates a new primitive array creator.

Parameters
creationOpcode:int

The opcode for creating an array of this type.

storageOpcode:int

The opcode for storing a value in an array of this type.

Method Detail

applyback to summary
public StackManipulation.Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext)

Implements net.bytebuddy.implementation.bytecode.StackManipulation.apply.

Doc from net.bytebuddy.implementation.bytecode.StackManipulation.apply.

Applies the stack manipulation that is described by this instance.

Parameters
methodVisitor:MethodVisitor

The method visitor used to write the method implementation to.

implementationContext:Implementation.Context

The context of the current implementation.

Returns:StackManipulation.Size

The changes to the size of the operand stack that are implied by this stack manipulation.

getStorageOpcodeback to summary
public int getStorageOpcode()

Implements net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayCreator.getStorageOpcode.

Doc from net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayCreator.getStorageOpcode.

The opcode instruction for storing a value of the component type inside an array.

Returns:int

The correct storage opcode for the represented type.

isValidback to summary
public boolean isValid()

Implements net.bytebuddy.implementation.bytecode.StackManipulation.isValid.

Doc from net.bytebuddy.implementation.bytecode.StackManipulation.isValid.

Determines if this stack manipulation is valid.

Returns:boolean

If false, this manipulation cannot be applied and should throw an exception.

valueOfback to summary
public static ArrayFactory.ArrayCreator.ForPrimitiveType valueOf(String name)
valuesback to summary
public static ArrayFactory.ArrayCreator.ForPrimitiveType[] values()
net.bytebuddy.implementation.bytecode.collection back to summary

public Class ArrayFactory.ArrayCreator.ForReferenceType

extends AbstractBase
implements ArrayCreator
Class Inheritance
All Implemented Interfaces
net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayCreator, net.bytebuddy.implementation.bytecode.StackManipulation
Annotations
@Enhance

An array creator implementation for reference types.

Field Summary

Modifier and TypeField and Description
private final String
internalTypeName

The internal name of this array's non-primitive component type.

Constructor Summary

AccessConstructor and Description
protected
ForReferenceType(TypeDescription
The internal name of this array's non-primitive component type.
referenceType
)

Creates a new array creator for a reference type.

Method Summary

Modifier and TypeMethod and Description
public StackManipulation.Size
apply(MethodVisitor
The method visitor used to write the method implementation to.
methodVisitor
,
Implementation.Context
The context of the current implementation.
implementationContext
)

Implements net.bytebuddy.implementation.bytecode.StackManipulation.apply.

Applies the stack manipulation that is described by this instance.
public int
getStorageOpcode()

Implements net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayCreator.getStorageOpcode.

The opcode instruction for storing a value of the component type inside an array.
Inherited from net.bytebuddy.implementation.bytecode.StackManipulation.AbstractBase:
isValid

Field Detail

internalTypeNameback to summary
private final String internalTypeName

The internal name of this array's non-primitive component type.

Constructor Detail

ForReferenceTypeback to summary
protected ForReferenceType(TypeDescription referenceType)

Creates a new array creator for a reference type.

Parameters
referenceType:TypeDescription

The internal name of this array's non-primitive component type.

Method Detail

applyback to summary
public StackManipulation.Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext)

Implements net.bytebuddy.implementation.bytecode.StackManipulation.apply.

Doc from net.bytebuddy.implementation.bytecode.StackManipulation.apply.

Applies the stack manipulation that is described by this instance.

Parameters
methodVisitor:MethodVisitor

The method visitor used to write the method implementation to.

implementationContext:Implementation.Context

The context of the current implementation.

Returns:StackManipulation.Size

The changes to the size of the operand stack that are implied by this stack manipulation.

getStorageOpcodeback to summary
public int getStorageOpcode()

Implements net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayCreator.getStorageOpcode.

Doc from net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayCreator.getStorageOpcode.

The opcode instruction for storing a value of the component type inside an array.

Returns:int

The correct storage opcode for the represented type.

net.bytebuddy.implementation.bytecode.collection back to summary

protected Class ArrayFactory.ArrayStackManipulation

extends Object
implements StackManipulation
Class Inheritance
  • java.lang.Object
  • net.bytebuddy.implementation.bytecode.collection.ArrayFactory.ArrayStackManipulation
All Implemented Interfaces
net.bytebuddy.implementation.bytecode.StackManipulation
Annotations
@Enhance
includeSyntheticFields:true

A stack manipulation for creating an array as defined by the enclosing array factory.

Field Summary

Modifier and TypeField and Description
private final List<? extends StackManipulation>
stackManipulations

A list of value load instructions that are to be stored inside the created array.

Constructor Summary

AccessConstructor and Description
protected
ArrayStackManipulation(List<? extends StackManipulation>
A list of value load instructions that are to be stored inside the created array.
stackManipulations
)

Creates a new array loading instruction.

Method Summary

Modifier and TypeMethod and Description
public StackManipulation.Size
apply(MethodVisitor
The method visitor used to write the method implementation to.
methodVisitor
,
Implementation.Context
The context of the current implementation.
implementationContext
)

Implements net.bytebuddy.implementation.bytecode.StackManipulation.apply.

Applies the stack manipulation that is described by this instance.
public boolean
isValid()

Implements net.bytebuddy.implementation.bytecode.StackManipulation.isValid.

Determines if this stack manipulation is valid.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

stackManipulationsback to summary
private final List<? extends StackManipulation> stackManipulations

A list of value load instructions that are to be stored inside the created array.

Constructor Detail

ArrayStackManipulationback to summary
protected ArrayStackManipulation(List<? extends StackManipulation> stackManipulations)

Creates a new array loading instruction.

Parameters
stackManipulations:List<? extends StackManipulation>

A list of value load instructions that are to be stored inside the created array.

Method Detail

applyback to summary
public StackManipulation.Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext)

Implements net.bytebuddy.implementation.bytecode.StackManipulation.apply.

Doc from net.bytebuddy.implementation.bytecode.StackManipulation.apply.

Applies the stack manipulation that is described by this instance.

Parameters
methodVisitor:MethodVisitor

The method visitor used to write the method implementation to.

implementationContext:Implementation.Context

The context of the current implementation.

Returns:StackManipulation.Size

The changes to the size of the operand stack that are implied by this stack manipulation.

isValidback to summary
public boolean isValid()

Implements net.bytebuddy.implementation.bytecode.StackManipulation.isValid.

Doc from net.bytebuddy.implementation.bytecode.StackManipulation.isValid.

Determines if this stack manipulation is valid.

Returns:boolean

If false, this manipulation cannot be applied and should throw an exception.