Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.squawk
Class Unsafe

    java.lang.Object
      com.sun.squawk.Unsafe

    public final class Unsafe

extends Object

A collection of methods for performing peek and poke operations on memory addresses.

The Unsafe class is primarily concerned with accessing memory ouside of the Java heap, but improper use of the Unsafe class can corrupt the Java heap (hence the name).

Only "trusted" Isolates may use the methods of this class. Calls to Any memory accessor methods by an untrusted Isolate will throw a SecurityException.

See Also:
  `Isolate`

Method Summary
`static Address` | `getAddress(Address base, int offset)` Gets a pointer from memory as an Address.
`static int` | `getByte(Address base, int offset)` Gets a signed 8 bit value from memory.
`static void` | `getBytes(Address src, int boffset, byte[] bytes, int low, int number)` Copy from memory to byte array.
`static int` | `getChar(Address base, int offset)` Gets an unsigned 16 bit value from memory.
`static int` | `getInt(Address base, int offset)` Gets a signed 32 bit value from memory.
`static void` | `getInts(Address src, int boffset, int[] ints, int low, int number)` Copy from memory to int array.
`static long` | `getLong(Address base, int offset)` Gets a 64 bit value from memory using a 64 bit word offset.
`static long` | `getLongAtWord(Address base, int offset)` Gets a 64 bit value from memory using a 32 bit word offset.
`static void` | `getLongs(Address src, int boffset, long[] longs, int low, int number)` Copy from memory to long array.
`static int` | `getShort(Address base, int offset)` Gets a signed 16 bit value from memory.
`static void` | `getShorts(Address src, int boffset, short[] shorts, int low, int number)` Copy from memory to short array.
`static int` | `getUByte(Address base, int offset)` Gets an unsigned 8 bit value from memory.
`static int` | `getUnalignedInt(Address base, int boffset)` Gets the `int` at the given byte offset in the memory, starting from base.
`static long` | `getUnalignedLong(Address base, int boffset)` Gets the `long` at the given byte offset in the memory, starting from base.
`static int` | `getUnalignedShort(Address base, int boffset)` Gets the `short` at the given byte offset in the memory, starting from base.
`static UWord` | `getUWord(Address base, int offset)` Gets an unsigned 32 or 64 bit value from memory.
`static void` | `setAddress(Address base, int offset, Address value)` Sets a pointer value in memory without updating the write barrier.
`static void` | `setByte(Address base, int offset, int value)` Sets an 8 bit value in memory.
`static void` | `setBytes(Address dst, int boffset, byte[] bytes, int low, int number)` Copy from byte array to memory.
`static void` | `setChar(Address base, int offset, int value)` Sets an unsigned 16 bit value in memory.
`static void` | `setInt(Address base, int offset, int value)` Sets a 32 bit value in memory.
`static void` | `setInts(Address dst, int boffset, int[] ints, int low, int number)` Copy from int array to memory.
`static void` | `setLong(Address base, int offset, long value)` Sets a 64 bit value in memory.
`static void` | `setLongAtWord(Address base, int offset, long value)` Sets a 64 bit value in memory at a 32 bit word offset.
`static void` | `setLongs(Address dst, int boffset, long[] longs, int low, int number)` Copy from long array to memory.
`static void` | `setShort(Address base, int offset, int value)` Sets a signed 16 bit value in memory.
`static void` | `setShorts(Address dst, int boffset, short[] shorts, int low, int number)` Copy from short array to memory.
`static void` | `setUnalignedInt(Address base, int boffset, int value)` Gets the `int` at the given byte offset in the memory, starting from base.
`static void` | `setUnalignedLong(Address base, int boffset, long value)` Gets the `long` at the given byte offset in the memory, starting from base.
`static void` | `setUnalignedShort(Address base, int boffset, int value)` Sets the `short` at the given byte offset in the memory, starting from base.
`static void` | `setUWord(Address base, int offset, UWord value)` Sets a UWord value in memory.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### setByte

    public static void setByte(Address base,
                               int offset,
                               int value)

  Sets an 8 bit value in memory.

  Parameters:
    `base` - the base address
    `offset` - the offset (in bytes) from `base` at which to write
    `value` - the value to write

### setShort

    public static void setShort(Address base,
                                int offset,
                                int value)

  Sets a signed 16 bit value in memory.

  Parameters:
    `base` - the base address
    `offset` - the offset (in 16 bit words) from `base` at which to write
    `value` - the value to write

### setChar

    public static void setChar(Address base,
                               int offset,
                               int value)

  Sets an unsigned 16 bit value in memory.

  Parameters:
    `base` - the base address
    `offset` - the offset (in 16 bit words) from `base` at which to write
    `value` - the value to write

### setInt

    public static void setInt(Address base,
                              int offset,
                              int value)

  Sets a 32 bit value in memory.

  Parameters:
    `base` - the base address
    `offset` - the offset (in 32 bit words) from `base` at which to write
    `value` - the value to write

### setUWord

    public static void setUWord(Address base,
                                int offset,
                                UWord value)

  Sets a UWord value in memory.

  Parameters:
    `base` - the base address
    `offset` - the offset (in UWords) from `base` at which to write
    `value` - the value to write

### setLong

    public static void setLong(Address base,
                               int offset,
                               long value)

  Sets a 64 bit value in memory.

  Parameters:
    `base` - the base address
    `offset` - the offset (in 64 bit words) from `base` at which to write
    `value` - the value to write

### setLongAtWord

    public static void setLongAtWord(Address base,
                                     int offset,
                                     long value)

  Sets a 64 bit value in memory at a 32 bit word offset.

  Parameters:
    `base` - the base address
    `offset` - the offset (in 32 bit words) from `base` at which to write
    `value` - the value to write

### setAddress

    public static void setAddress(Address base,
                                  int offset,
                                  Address value)

  Sets a pointer value in memory without updating the write barrier. If this method is being called in a `hosted` environment then the corresponding bit in the oop map (if any) is also set.

  Parameters:
    `base` - the base address
    `offset` - the offset (in UWords) from `base` at which to write
    `value` - the value to write

### getByte

    public static int getByte(Address base,
                              int offset)

  Gets a signed 8 bit value from memory.

  Parameters:
    `base` - the base address
    `offset` - the offset (in bytes) from `base` from which to load
  Returns:
    the value

### getUByte

    public static int getUByte(Address base,
                               int offset)

  Gets an unsigned 8 bit value from memory.

  Parameters:
    `base` - the base address
    `offset` - the offset (in bytes) from `base` from which to load
  Returns:
    the value

### getShort

    public static int getShort(Address base,
                               int offset)

  Gets a signed 16 bit value from memory.

  Parameters:
    `base` - the base address
    `offset` - the offset (in 16 bit words) from `base` from which to load
  Returns:
    the value

### getChar

    public static int getChar(Address base,
                              int offset)

  Gets an unsigned 16 bit value from memory.

  Parameters:
    `base` - the base address
    `offset` - the offset (in 16 bit words) from `base` from which to load
  Returns:
    the value

### getInt

    public static int getInt(Address base,
                             int offset)

  Gets a signed 32 bit value from memory.

  Parameters:
    `base` - the base address
    `offset` - the offset (in 32 bit words) from `base` from which to load
  Returns:
    the value

### getUWord

    public static UWord getUWord(Address base,
                                 int offset)

  Gets an unsigned 32 or 64 bit value from memory.

  Parameters:
    `base` - the base address
    `offset` - the offset (in UWords) from `base` from which to load
  Returns:
    the value

### getLong

    public static long getLong(Address base,
                               int offset)

  Gets a 64 bit value from memory using a 64 bit word offset.

  Parameters:
    `base` - the base address
    `offset` - the offset (in 64 bit words) from `base` from which to load
  Returns:
    the value

### getLongAtWord

    public static long getLongAtWord(Address base,
                                     int offset)

  Gets a 64 bit value from memory using a 32 bit word offset.

  Parameters:
    `base` - the base address
    `offset` - the offset (in 32 bit words) from `base` from which to load
  Returns:
    the value

### getAddress

    public static Address getAddress(Address base,
                                     int offset)

  Gets a pointer from memory as an Address.

  Parameters:
    `base` - the base address
    `offset` - the offset (in UWords) from `base` from which to load
  Returns:
    the value

### getBytes

    public static void getBytes(Address src,
                                int boffset,
                                byte[] bytes,
                                int low,
                                int number)

  Copy from memory to byte array. Copy `number` bytes from the memory location specified by the address `dst` and byte offset `boffset` to the byte array `bytes` starting at position `low`.

  Parameters:
    `src` - the base memory address
    `boffset` - the byte offset to add to the base memory address
    `bytes` - the destination byte array
    `low` - the offset in the destination array
    `number` - the number of bytes to copy
  Throws:
    `ArrayIndexOutOfBoundsException` - if the range specified by low and number does not fit within the dst array

### getShorts

    public static void getShorts(Address src,
                                 int boffset,
                                 short[] shorts,
                                 int low,
                                 int number)

  Copy from memory to short array. Copy `number` shorts from the memory location specified by the address `dst` and byte offset `boffset` to the short array `shorts` starting at position `low`.

  Parameters:
    `src` - the base memory address
    `boffset` - the byte offset to add to the base memory address
    `shorts` - the destination short array
    `low` - the offset in the destination array
    `number` - the number of shorts to copy
  Throws:
    `ArrayIndexOutOfBoundsException` - if the range specified by low and number does not fit within the dst array

### getInts

    public static void getInts(Address src,
                               int boffset,
                               int[] ints,
                               int low,
                               int number)

  Copy from memory to int array. Copy `number` ints from the memory location specified by the address `dst` and byte offset `boffset` to the int array `ints` starting at position `low`.

  Parameters:
    `src` - the base memory address
    `boffset` - the byte offset to add to the base memory address
    `ints` - the destination int array
    `low` - the offset in the destination array
    `number` - the number of ints to copy
  Throws:
    `ArrayIndexOutOfBoundsException` - if the range specified by low and number does not fit within the dst array

### getLongs

    public static void getLongs(Address src,
                                int boffset,
                                long[] longs,
                                int low,
                                int number)

  Copy from memory to long array. Copy `number` longs from the memory location specified by the address `dst` and byte offset `boffset` to the long array `longs` starting at position `low`.

  Parameters:
    `src` - the base memory address
    `boffset` - the byte offset to add to the base memory address
    `longs` - the destination long array
    `low` - the offset in the destination array
    `number` - the number of ints to copy
  Throws:
    `ArrayIndexOutOfBoundsException` - if the range specified by low and number does not fit within the dst array

### setBytes

    public static void setBytes(Address dst,
                                int boffset,
                                byte[] bytes,
                                int low,
                                int number)

  Copy from byte array to memory. Copy `number` bytes from byte array `bytes` starting at position `low`.to the memory location specified by the address `dst` and byte offset `boffset`.

  Parameters:
    `dst` - the base memory address
    `boffset` - the byte offset to add to the base memory address
    `bytes` - the src byte array
    `low` - the offset in the src array
    `number` - the number of bytes to copy
  Throws:
    `ArrayIndexOutOfBoundsException` - if the range specified by low and number does not fit within the src array

### setShorts

    public static void setShorts(Address dst,
                                 int boffset,
                                 short[] shorts,
                                 int low,
                                 int number)

  Copy from short array to memory. Copy `number` shorts from short array `shorts` starting at position `low`.to the memory location specified by the address `dst` and byte offset `boffset`.

  Parameters:
    `dst` - the base memory address
    `boffset` - the byte offset to add to the base memory address
    `shorts` - the src short array
    `low` - the offset in the src array
    `number` - the number of bytes to copy
  Throws:
    `ArrayIndexOutOfBoundsException` - if the range specified by low and number does not fit within the src array

### setInts

    public static void setInts(Address dst,
                               int boffset,
                               int[] ints,
                               int low,
                               int number)

  Copy from int array to memory. Copy `number` int from int array `ints` starting at position `low`.to the memory location specified by the address `dst` and byte offset `boffset`.

  Parameters:
    `dst` - the base memory address
    `boffset` - the byte offset to add to the base memory address
    `ints` - the src int array
    `low` - the offset in the src array
    `number` - the number of bytes to copy
  Throws:
    `ArrayIndexOutOfBoundsException` - if the range specified by low and number does not fit within the src array

### setLongs

    public static void setLongs(Address dst,
                                int boffset,
                                long[] longs,
                                int low,
                                int number)

  Copy from long array to memory. Copy `number` longs from long array `longs` starting at position `low`.to the memory location specified by the address `dst` and byte offset `boffset`.

  Parameters:
    `dst` - the base memory address
    `boffset` - the byte offset to add to the base memory address
    `longs` - the src long array
    `low` - the offset in the src array
    `number` - the number of bytes to copy
  Throws:
    `ArrayIndexOutOfBoundsException` - if the range specified by low and number does not fit within the src array

### getUnalignedShort

    public static int getUnalignedShort(Address base,
                                        int boffset)

  Gets the `short` at the given byte offset in the memory, starting from base. If the short is aligned on a "natural" boundary it is always loaded from memory in a single atomic operation. If it is not on a natural boundary it may not be loaded atomically, and the number and order of the load operations is unspecified.

  Parameters:
    `base` - address of to region of memory
    `boffset` - The offset in bytes from base to the short to be loaded
  Returns:
    The short from raw memory.

### getUnalignedInt

    public static int getUnalignedInt(Address base,
                                      int boffset)

  Gets the `int` at the given byte offset in the memory, starting from base. If the integer is aligned on a "natural" boundary it is always loaded from memory in a single atomic operation. If it is not on a natural boundary it may not be loaded atomically, and the number and order of the load operations is unspecified.

  Parameters:
    `base` - address of to region of memory
    `boffset` - The offset in bytes from base to the int to be loaded
  Returns:
    The integer from raw memory.

### getUnalignedLong

    public static long getUnalignedLong(Address base,
                                        int boffset)

  Gets the `long` at the given byte offset in the memory, starting from base. If the long is aligned on a "natural" boundary it is always loaded from memory in a single atomic operation. If it is not on a natural boundary it may not be loaded atomically, and the number and order of the load operations is unspecified.

  Parameters:
    `base` - address of to region of memory
    `boffset` - The offset in bytes from base to the long to be loaded
  Returns:
    The long from raw memory.

### setUnalignedShort

    public static void setUnalignedShort(Address base,
                                         int boffset,
                                         int value)

  Sets the `short` at the given byte offset in the memory, starting from base. If the short is aligned on a "natural" boundary it is always stored to memory in a single atomic operation. If it is not on a natural boundary it may not be stored atomically, and the number and order of the store operations is unspecified.

  Parameters:
    `base` - address of to region of memory
    `boffset` - The offset in bytes from base to the location to be stored
    `value` -

### setUnalignedInt

    public static void setUnalignedInt(Address base,
                                       int boffset,
                                       int value)

  Gets the `int` at the given byte offset in the memory, starting from base. If the integer is aligned on a "natural" boundary it is always stored to memory in a single atomic operation. If it is not on a natural boundary it may not be stored atomically, and the number and order of the store operations is unspecified.

  Parameters:
    `base` - address of to region of memory
    `boffset` - The offset in bytes from base to the location to be stored
    `value` -

### setUnalignedLong

    public static void setUnalignedLong(Address base,
                                        int boffset,
                                        long value)

  Gets the `long` at the given byte offset in the memory, starting from base. If the long is aligned on a "natural" boundary it is always stored to memory in a single atomic operation. If it is not on a natural boundary it may not be stored atomically, and the number and order of the store operations is unspecified.

  Parameters:
    `base` - address of to region of memory
    `boffset` - The offset in bytes from base to the location to be stored
    `value` -

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"