public abstract class FieldLayoutContext extends Object
A FieldLayoutContext deals in an abstract offset space, where there is no header, and fields are laid out relative to 0.
This abstract superclass looks after the total object size and alignment.
Modifier and Type | Field and Description |
---|---|
private byte |
alignment
Alignment requirements.
|
protected static int |
OBJECT_SIZE_ALIGN |
private int |
objectSize
The size of the current object as laid out
|
Modifier | Constructor and Description |
---|---|
protected |
FieldLayoutContext(byte alignment) |
protected |
FieldLayoutContext(byte alignment,
FieldLayoutContext superLayout)
Constructor for an object with a superclass.
|
Modifier and Type | Method and Description |
---|---|
protected void |
adjustAlignment(int fieldSize)
Adjust alignment to the next highest value.
|
protected void |
ensureObjectSize(int size)
Adjust the size of the object if necessary to accommodate a field.
|
(package private) int |
getAlignment() |
protected int |
getObjectSize() |
(package private) abstract int |
nextOffset(int size,
boolean isReference) |
protected void |
setObjectSize(int size)
Set the current size of the object (excluding header)
|
protected static final int OBJECT_SIZE_ALIGN
private byte alignment
private int objectSize
protected FieldLayoutContext(byte alignment)
alignment
- the alignment to use for this contextprotected FieldLayoutContext(byte alignment, FieldLayoutContext superLayout)
alignment
- the alignment to use for this contextsuperLayout
- the super class' layoutabstract int nextOffset(int size, boolean isReference)
size
- the field's size in bytesisReference
- whether the field is a reference fieldprotected void adjustAlignment(int fieldSize)
fieldSize
- the size of the field in bytesint getAlignment()
protected int getObjectSize()
protected void setObjectSize(int size)
size
- the object's size, excluding the headerprotected void ensureObjectSize(int size)
size
- The size occupied by data fields in the object.