RawMemoryFactory
to create the
appropriate RawMemory
object.@Deprecated
public class RawMemoryAccess
extends java.lang.Object
RawMemoryAccess
models a range of
physical memory as a fixed sequence of bytes. A complement of
accessor methods enable the contents of the physical area to be
accessed through offsets from the base, interpreted as byte, short,
int, or long data values or as arrays of these types.
Whether an offset addresses the high-order or low-order byte is
normally based on the value of the RealtimeSystem.BYTE_ORDER
static byte variable in class RealtimeSystem
. When the type of
memory used for this RawMemoryAccess
region implements
non-standard byte ordering, accessor methods in this class continue
to select bytes starting at offset
from the base address
and continuing toward greater addresses. The memory type may control
the mapping of these bytes into the primitive data type. The memory
type could even select bytes that are not contiguous. In each case
the documentation for the PhysicalMemoryTypeFilter
must
document any mapping other than the "normal" one specified above.
The RawMemoryAccess
class allows a realtime program
to implement device drivers, memory-mapped I/O, flash memory,
battery-backed RAM, and similar low-level software.
A raw memory area cannot contain references to Java objects. Such a capability would be unsafe (since it could be used to defeat Java's type checking) and error-prone (since it is sensitive to the specific representational choices made by the Java compiler).
Many of the constructors and methods in this class throw OffsetOutOfBoundsException
. This exception means that the value
given in the offset parameter is either negative or outside the
memory area.
Many of the constructors and methods in this class throw SizeOutOfBoundsException
. This exception means that the value given
in the size parameter is either negative, larger than an allowable
range, or would cause an accessor method to access an address outside
of the memory area.
Unlike other integral parameters in this chapter, negative values
are valid for
byte, short, int,
and long
values that are
copied in and out of memory by the set
and get
methods of this class.
All offset values used in this class are measured in bytes.
Atomic loads and stores on raw memory are defined in terms of physical memory. This memory may be accessible to threads outside the JVM and to non-programmed access (e.g., DMA), consequently atomic access must be supported by hardware. This specification is written with the assumption that all suitable hardware platforms support atomic loads for aligned bytes, shorts, and ints. Atomic access beyond the specified minimum may be supported by the implementation.
Storing values into raw memory is more hardware-dependent than loading values. Many processor architectures do not support atomic stores of variables except for aligned stores of the processor's word size. For instance, storing a byte into memory might require reading a 32-bit quantity into a processor register, updating the register to reflect the new byte value, then re-storing the whole 32-bit quantity. Changes to other bytes in the 32-bit quantity that take place between the load and the store will be lost.
Some processors have mechanisms that can be used to implement an atomic store of a byte, but those mechanisms are often slow and not universally supported.
This class supports unaligned access to data, but it does not require the implementation to make such access atomic. Accesses to data aligned on its natural boundary will be atomic when the processor implements atomic loads and stores of that data size.
Except where noted, accesses to raw memory are not atomic with respect to the memory or with respect to schedulables. A raw memory area could be updated by another schedulable, or even unmapped in the middle of a method.
The characteristics of raw-memory access are necessarily platform dependent. This specification provides a minimum requirement for the RTSJ platform, but it also supports optional system properties that identify a platform's level of support for atomic raw put and get. The properties represent a four-dimensional sparse array with boolean values indicating whether that combination of access attributes is atomic. The default value for array entries is false. The dimension are
Attribute |
Values |
Comment |
Access type | read, write | |
Data type | byte, short, int, long, float, double | |
Alignment | 0 | aligned |
1 to one less than data type size | the first byte of the data is alignment bytes away from natural alignment. | |
Atomicity | processor | means access is atomic with respect to other taska on processor. |
smp | means access is processor atomic, and atomic with respect to all processors in an SMP. | |
memory | means that access is smp atomic, and atomic with respect to all access to the memory including DMA. |
javax.realtime.atomicaccess_read_byte_0_memory=trueTable entries with a value of false may be explicitly represented, but since false is the default value, such properties are redundant.
All raw memory access is treated as volatile, and
serialized. The run-time must be forced to re-read memory
or write to memory on each call to a raw memory get<type>
or put<type>
method, where type
is defined in the table above, and to complete
the reads and writes in the order they appear in the program order.
Constructor and Description |
---|
RawMemoryAccess(java.lang.Object type,
long size)
Deprecated.
Constructs an instance of
RawMemoryAccess with the
given parameters, and sets the object to the mapped state. |
RawMemoryAccess(java.lang.Object type,
long base,
long size)
Deprecated.
Constructs an instance of
RawMemoryAccess with the
given parameters, and sets the object to the mapped state. |
Modifier and Type | Method and Description |
---|---|
byte |
getByte(long offset)
Deprecated.
Gets the
byte at the given offset in the memory area
associated with this object. |
void |
getBytes(long offset,
byte[] bytes,
int low,
int number)
Deprecated.
Gets
number bytes starting at the given offset in the
memory area associated with this object and assigns them to the
byte array passed starting at position low . |
int |
getInt(long offset)
Deprecated.
Gets the
int at the given offset in the memory area
associated with this object. |
void |
getInts(long offset,
int[] ints,
int low,
int number)
Deprecated.
Gets
number integers starting at the given offset in
the memory area associated with this object and assign them to the
int array passed starting at position low . |
long |
getLong(long offset)
Deprecated.
Gets the
long at the given offset in the memory area
associated with this object. |
void |
getLongs(long offset,
long[] longs,
int low,
int number)
Deprecated.
Gets
number longs starting at the given offset in the
memory area associated with this object and assign them to the longs
array passed starting at position low . |
long |
getMappedAddress()
Deprecated.
Gets the virtual memory location at which the memory region is mapped.
|
short |
getShort(long offset)
Deprecated.
Gets the
short at the given offset in the memory area
associated with this object. |
void |
getShorts(long offset,
short[] shorts,
int low,
int number)
Deprecated.
Gets
number shorts starting at the given offset in the
memory area associated with this object and assign them to the
short array passed starting at position low . |
long |
map()
Deprecated.
Maps the physical memory range into virtual memory.
|
long |
map(long base)
Deprecated.
Maps the physical memory range into virtual memory at the specified
location.
|
long |
map(long base,
long size)
Deprecated.
Maps the physical memory range into virtual memory.
|
void |
setByte(long offset,
byte value)
Deprecated.
Sets the
byte at the given offset in the memory area
associated with this object. |
void |
setBytes(long offset,
byte[] bytes,
int low,
int number)
Deprecated.
Sets
number bytes starting at the given offset in the
memory area associated with this object from the
byte array passed starting at position low . |
void |
setInt(long offset,
int value)
Deprecated.
Sets the
int at the given offset in the memory area
associated with this object. |
void |
setInts(long offset,
int[] ints,
int low,
int number)
Deprecated.
Sets
number ints starting at the given offset in the
memory area associated with this object from the int array passed
starting at position low . |
void |
setLong(long offset,
long value)
Deprecated.
Sets the
long at the given offset in the memory area
associated with this object. |
void |
setLongs(long offset,
long[] longs,
int low,
int number)
Deprecated.
Sets
number longs starting at the given offset in the
memory area associated with this object from the long array passed
starting at position low . |
void |
setShort(long offset,
short value)
Deprecated.
Sets the
short at the given offset in the memory area
associated with this object. |
void |
setShorts(long offset,
short[] shorts,
int low,
int number)
Deprecated.
Sets
number shorts starting at the given offset in the
memory area associated with this object from the short array
passed starting at position low . |
void |
unmap()
Deprecated.
Unmaps the physical memory range from virtual memory.
|
public RawMemoryAccess(java.lang.Object type, long base, long size)
RawMemoryAccess
with the
given parameters, and sets the object to the mapped state. When the
platform supports virtual memory, maps the raw memory into virtual
memory.
The run time environment is allowed to choose the virtual
address where the raw memory area corresponding to this object will
be mapped. The attributes of the mapping operation are controlled
by the vMFlags and vMAttributes of the
PhysicalMemoryTypeFilter
objects that matched this
object's type
parameter.
(See PhysicalMemoryTypeFilter.getVMAttributes()
and
PhysicalMemoryTypeFilter.getVMFlags()
.
type
- An instance of Object
representing the
type of memory required (e.g., dma, shared) - used
to define the base address and control the mapping. When the
required memory has more than one attribute,
type
may be an array of objects. When
type
is null
or a reference to an
array with no entries, any type of memory is
acceptable. Note that type
values are compared
by reference (==), not by value (equals
).base
- The physical memory address of the region.size
- The size of the area in bytes.StaticSecurityException
- when application doesn't have
permissions to access physical memory, the
specified range of addresses, or the given type of memory.OffsetOutOfBoundsException
- when the address is invalid.SizeOutOfBoundsException
- when the size is negative or
extends into an invalid range of memory.UnsupportedPhysicalMemoryException
- when the underlying
hardware does not support the given type, or when no matching
PhysicalMemoryTypeFilter
has been registered with
the PhysicalMemoryManager
.MemoryTypeConflictException
- when the specified base
does not point to memory that matches the request type,
or when type
specifies incompatible memory
attributes.java.lang.OutOfMemoryError
- when the requested type of memory
exists, but there is not enough of it free to satisfy the
request.public RawMemoryAccess(java.lang.Object type, long size)
RawMemoryAccess
with the
given parameters, and sets the object to the mapped state. When the
platform supports virtual memory, maps the raw memory into virtual
memory.
The run time environment is allowed to choose the virtual
address where the raw memory area corresponding to this object will
be mapped. The attributes of the mapping operation are controlled
by the vMFlags and vMAttributes of the
PhysicalMemoryTypeFilter
objects that matched this
object's type
parameter. (See
PhysicalMemoryTypeFilter.getVMAttributes()
and
PhysicalMemoryTypeFilter.getVMFlags()
.
type
- An instance of Object
representing the
type of memory required (e.g., dma, shared) - used
to define the base address and control the mapping. When the
required memory has more than one attribute,
type
may be an array of objects. When
type
is null
or a reference to an
array with no entries, any type of memory is
acceptable. Note that type
values are compared
by reference (==), not by value (equals
).size
- The size of the area in bytes.StaticSecurityException
- when the application doesn't have
permissions to access physical memory, the
specified range of addresses, or the given type of memory.SizeOutOfBoundsException
- when the size is negative or
extends into an invalid range of memory.UnsupportedPhysicalMemoryException
- when the underlying
hardware does not support the given type, or when no matching
PhysicalMemoryTypeFilter
has been registered with
the PhysicalMemoryManager
.MemoryTypeConflictException
- when the specified base
does not point to memory that matches the request type,
or when type
specifies incompatible memory
attributes.java.lang.OutOfMemoryError
- when the requested type of memory
exists, but there is not enough of it free to satisfy the
request.StaticSecurityException
- when the application doesn't have
permissions to access physical memory or the given range
of memory.public byte getByte(long offset)
byte
at the given offset in the memory area
associated with this object. The byte is always loaded from memory
in a single atomic operation.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw memory
from which to load the byte.SizeOutOfBoundsException
- when the object is not mapped,
or when the byte falls in an invalid address range.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public void getBytes(long offset, byte[] bytes, int low, int number)
number
bytes starting at the given offset in the
memory area associated with this object and assigns them to the
byte array passed starting at position low
. Each byte
is loaded from memory in a single atomic operation. Groups of
bytes may be loaded together, but this is unspecified.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory from which to start loading.bytes
- The array into which the loaded items are placed.low
- The offset which is the starting point in the given
array for the loaded items to be placed.number
- The number of items to load.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not
mapped, or when a byte falls in an invalid address range.
This is checked at every entry in the array to allow for the
possibility that the memory area could be unmapped or
remapped. The byte
array could, therefore, be
partially updated when the raw memory is unmapped or remapped
mid-method.java.lang.ArrayIndexOutOfBoundsException
- when low
is less than 0 or greater than bytes.length -
1
, or when low + number
is greater
than or equal to bytes.length
.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public int getInt(long offset)
int
at the given offset in the memory area
associated with this object. When the integer is aligned on a
"natural" boundary it is always loaded from memory in a single
atomic operation. When it is not on a natural boundary it may not be
loaded atomically, and the number and order of the load operations
is unspecified.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory area from which to load the integer.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not mapped,
or when the integer falls in an invalid address range.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public void getInts(long offset, int[] ints, int low, int number)
number
integers starting at the given offset in
the memory area associated with this object and assign them to the
int
array passed starting at position low
.
When the integers are aligned on natural boundaries each integer is loaded from memory in a single atomic operation. Groups of integers may be loaded together, but this is unspecified.
When the integers are not aligned on natural boundaries they may not be loaded atomically and the number and order of load operations is unspecified.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory area at which to start loading.ints
- The array into which the integers read from the raw
memory are placed.low
- The offset which is the starting point in the given
array for the loaded items to be placed.number
- The number of integers to load.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not
mapped, or when an integer falls in an invalid address range.
This is checked at every entry in the array to allow for the
possibility that the memory area could be unmapped or
remapped. The int
array could, therefore, be
partially updated when the raw memory is unmapped or remapped
mid-method.java.lang.ArrayIndexOutOfBoundsException
- when low
is less than 0 or greater than bytes.length -
1
, or when low + number
is greater
than or equal to bytes.length
.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public long getLong(long offset)
long
at the given offset in the memory area
associated with this object.
The load is not required to be atomic even it is located on a natural boundary.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw memory area
from which to load the long.OffsetOutOfBoundsException
- when the offset is invalid.SizeOutOfBoundsException
- when the object is not mapped,
or when the long falls in an invalid address range.StaticSecurityException
- when this access is not permitted by
the security manager.public void getLongs(long offset, long[] longs, int low, int number)
number
longs starting at the given offset in the
memory area associated with this object and assign them to the longs
array passed starting at position low
.
The loads are not required to be atomic even when they are located on natural boundaries.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw memory area
at which to start loading.longs
- The array into which the loaded items are placed.low
- The offset which is the starting point in the given
array for the loaded items to be placed.number
- The number of longs to load.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not
mapped, or when a long falls in an invalid address range. This
is checked at every entry in the array to allow for the
possibility that the memory area could be unmapped or
remapped. The long
array could, therefore, be
partially updated when the raw memory is unmapped or remapped
mid-method.java.lang.ArrayIndexOutOfBoundsException
- when low
is less than 0 or greater than bytes.length -
1
, or when low + number
is greater
than or equal to bytes.length
.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public long getMappedAddress()
this
is mapped, for reference
purposes. When virtual memory is not supported, this is
the same as the physical base address.java.lang.IllegalStateException
- when the raw memory object is
not in the mapped state.public short getShort(long offset)
short
at the given offset in the memory area
associated with this object. When the short is aligned on a natural
boundary it is always loaded from memory in a single atomic
operation. When it is not on a natural boundary it may not be loaded
atomically, and the number and order of the load operations is
unspecified.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory area from which to load the short.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not mapped,
or when the short falls in an invalid address range.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public void getShorts(long offset, short[] shorts, int low, int number)
number
shorts starting at the given offset in the
memory area associated with this object and assign them to the
short
array passed starting at position low
.
When the shorts are located on natural boundaries each short is loaded from memory in a single atomic operation. Groups of shorts may be loaded together, but this is unspecified.
When the shorts are not located on natural boundaries the load may not be atomic, and the number and order of load operations is unspecified.
Caching of the memory access is controlled by the
memory type
requested when the
RawMemoryAccess
instance was created. When the memory
is not cached, this method guarantees serialized access (that is,
the memory access at the memory occurs in the same order as in the
program. Multiple writes to the same location may not be
coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory area from which to start loading.shorts
- The array into which the loaded items are placed.low
- The offset which is the starting point in the given
array for the loaded shorts to be placed.number
- The number of shorts to load.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not
mapped, or when a short falls in an invalid address range. This
is checked at every entry in the array to allow for the
possibility that the memory area could be unmapped or
remapped. The short
array could, therefore, be
partially updated when the raw memory is unmapped or remapped
mid-method.java.lang.ArrayIndexOutOfBoundsException
- when low
is less than 0 or greater than bytes.length -
1
, or when low + number
is greater
than or equal to bytes.length
.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public long map()
The run time environment is allowed to choose the virtual
address where the raw memory area corresponding to this object will
be mapped. The attributes of the mapping operation are controlled
by the vMFlags and vMAttributes of the
PhysicalMemoryTypeFilter
objects that matched this
object's type
parameter.
(See PhysicalMemoryTypeFilter.getVMAttributes()
and
PhysicalMemoryTypeFilter.getVMFlags()
.
When the object is already mapped into virtual memory, this method does not change anything.
java.lang.OutOfMemoryError
- when there is insufficient free
virtual address space to map the object.public long map(long base)
The attributes of the mapping operation are controlled by the vMFlags and
vMAttributes of the PhysicalMemoryTypeFilter
objects
that matched this object's type
parameter. (See
PhysicalMemoryTypeFilter.getVMAttributes()
and PhysicalMemoryTypeFilter.getVMFlags()
.
When the object is already mapped into virtual memory at a different
address, this method remaps it to base
.
When a remap is requested while another schedulable is accessing the raw memory, the map will block until one load or store completes. It can interrupt an array operation between entries.
base
- The location to map at the virtual memory space.java.lang.OutOfMemoryError
- when there is insufficient free virtual
memory at the specified address.java.lang.IllegalArgumentException
- when base
is
not a legal value for a virtual address, or the memory-mapping
hardware cannot place the physical memory at the designated
address.public long map(long base, long size)
The attributes of the mapping operation are controlled by the vMFlags and
vMAttributes of the PhysicalMemoryTypeFilter
objects
that matched this object's type
parameter.
(See PhysicalMemoryTypeFilter.getVMAttributes()
and PhysicalMemoryTypeFilter.getVMFlags()
.
When the object is already mapped into virtual memory at a different
address, this method remaps it to base
.
When a remap is requested while another schedulable is accessing the raw memory, the map will block until one load or store completes. It can interrupt an array operation between entries.
base
- The location to map at the virtual memory space.size
- The size of the block to map in. When the size of the
raw memory area is greater than size
, the object
is unchanged but accesses beyond the mapped region will throw
SizeOutOfBoundsException
. When the size of the raw
memory area is smaller than the mapped region, access to the raw
memory will behave as if the mapped region matched the raw
memory area, but additional virtual address space will be
consumed after the end of the raw memory area.java.lang.IllegalArgumentException
- when size is not greater than
zero, base
is not a legal value for a virtual
address, or the memory-mapping hardware cannot place the
physical memory at the designated address.public void setByte(long offset, byte value)
byte
at the given offset in the memory area
associated with this object.
This memory access may involve a load and a store, and it may have unspecified effects on surrounding bytes in the presence of concurrent access.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple
writes to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory area to which to write the byte.value
- The byte to write.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not mapped,
or when the byte falls in an invalid address range.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public void setBytes(long offset, byte[] bytes, int low, int number)
number
bytes starting at the given offset in the
memory area associated with this object from the
byte
array passed starting at position low
.
This memory access may involve multiple load and a store operations, and it may have unspecified effects on surrounding bytes (even bytes in the range being stored) in the presence of concurrent access.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory area to which to start writing.bytes
- The array from which the items are obtained.low
- The offset which is the starting point in the given
array for the items to be obtained.number
- The number of items to write.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not
mapped, or when a byte falls in an invalid address range.
This is checked at every entry in the array to allow for the
possibility that the memory area could be unmapped or
remapped. The store of the array into memory could,
therefore, be only partially complete when the raw memory is
unmapped or remapped mid-method.java.lang.ArrayIndexOutOfBoundsException
- when low
is less than 0 or greater than bytes.length -
1
, or when low + number
is greater
than or equal to bytes.length
.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public void setInt(long offset, int value)
int
at the given offset in the memory area
associated with this object. On most processor architectures an
aligned integer can be stored in an atomic operation, but this is
not required.
This memory access may involve multiple load and a store operations, and it may have unspecified effects on surrounding bytes (even bytes in the range being stored) in the presence of concurrent access.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory area at which to write the integer.value
- The integer to write.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not mapped,
or when the integer falls in an invalid address range.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public void setInts(long offset, int[] ints, int low, int number)
number
ints starting at the given offset in the
memory area associated with this object from the int
array passed
starting at position low
. On most processor
architectures each aligned integer can be stored in an atomic
operation, but this is not required.
This memory access may involve multiple load and a store operations, and it may have unspecified effects on surrounding bytes (even bytes in the range being stored) in the presence of concurrent access.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory area at which to start writing.ints
- The array from which the items are obtained.low
- The offset which is the starting point in the given
array for the items to be obtained.number
- The number of items to write.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not
mapped, or when an integer falls in an invalid address range. This
is checked at every entry in the array to allow for the
possibility that the memory area could be unmapped or
remapped. The store of the array into memory could,
therefore, be only partially complete when the raw memory is
unmapped or remapped mid-method.java.lang.ArrayIndexOutOfBoundsException
- when low
is less than 0 or greater than bytes.length -
1
, or when low + number
is greater
than or equal to bytes.length
.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public void setLong(long offset, long value)
long
at the given offset in the memory area
associated with this object. Even when it is aligned, the long
value may not be updated atomically. It is unspecified how many
load and store operations will be used or in what order.
This memory access may involve multiple load and a store operations, and it may have unspecified effects on surrounding bytes (even bytes in the range being stored) in the presence of concurrent access.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory area at which to write the long.value
- The long to write.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not mapped,
or when the long falls in an invalid address range.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public void setLongs(long offset, long[] longs, int low, int number)
number
longs starting at the given offset in the
memory area associated with this object from the long
array passed
starting at position low
. Even when they are aligned,
the long values may not be updated atomically. It is unspecified
how many load and store operations will be used or in what order.
This memory access may involve multiple load and a store operations, and it may have unspecified effects on surrounding bytes (even bytes in the range being stored) in the presence of concurrent access.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory area at which to start writing.longs
- The array from which the items are obtained.low
- The offset which is the starting point in the given
array for the items to be obtained.number
- The number of items to write.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not
mapped, or when a long falls in an invalid address range.
This is checked at every entry in the array to allow for the
possibility that the memory area could be unmapped or
remapped. The store of the array into memory could,
therefore, be only partially complete when the raw memory is
unmapped or remapped mid-method.java.lang.ArrayIndexOutOfBoundsException
- when low
is less than 0 or greater than bytes.length -
1
, or when low + number
is greater
than or equal to bytes.length
.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public void setShort(long offset, short value)
short
at the given offset in the memory area
associated with this object.
This memory access may involve a load and a store, and it may have unspecified effects on surrounding shorts in the presence of concurrent access.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory area at which to write the short.value
- The short to write.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not mapped,
or when the short falls in an invalid address range.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public void setShorts(long offset, short[] shorts, int low, int number)
number
shorts starting at the given offset in the
memory area associated with this object from the short
array
passed starting at position low
.
Each write of a short value may involve a load and a store, and it may have unspecified effects on surrounding shorts in the presence of concurrent access - even on other shorts in the array.
Caching of the memory access is controlled by the memory
type
requested when the RawMemoryAccess
instance was created. When the memory is not cached, this method
guarantees serialized access (that is, the memory access at the
memory occurs in the same order as in the program. Multiple writes
to the same location may not be coalesced.)
offset
- The offset in bytes from the beginning of the raw
memory area at which to start writing.shorts
- The array from which the items are obtained.low
- The offset which is the starting point in the given
array for the items to be obtained.number
- The number of items to write.OffsetOutOfBoundsException
- when the offset is negative
or greater than the size of the raw memory area. The role of
the SizeOutOfBoundsException
somewhat overlaps this
exception since it is when the offset is within the
object but outside the mapped area.SizeOutOfBoundsException
- when the object is not
mapped, or when a short falls in an invalid address range.
This is checked at every entry in the array to allow for the
possibility that the memory area could be unmapped or
remapped. The store of the array into memory could,
therefore, be only partially complete when the raw memory is
unmapped or remapped mid-method.java.lang.ArrayIndexOutOfBoundsException
- when low
is less than 0 or greater than bytes.length -
1
, or when low + number
is greater
than or equal to bytes.length
.StaticSecurityException
- when this access is not permitted by
the security manager.map(long,long)
public void unmap()
When the object is already in the unmapped state, this method has no effect.
While a raw memory object is unmapped all attempts to set or
get values in the raw memory will throw SizeOutOfBoundsException
.
An unmapped raw memory object can be returned to mapped state
with any of the object's map
methods.
When an unmap is requested while another schedulable is
accessing the raw memory, the unmap
will throw an
IllegalStateException
. The unmap
method
can interrupt an array operation between entries.