Top Description Fields Constructors Methods
jnr.ffi

public abstract Class Pointer

extends Object
Class Inheritance
Known Direct Subclasses
jnr.ffi.provider.AbstractMemoryIO
Imports
java.nio.ByteBuffer, java.nio.charset.Charset, java.util.ArrayList, .List

A native memory address. This class provides operations on a native memory address. Most Pointerinstances will represent direct memory (that is, a fixed address in the process address space, directly accessible by native code), however, it is possible to wrap a java byte array in a Pointerinstance to pass to a native function as a memory address. See isDirect() for more information.

Field Summary

Modifier and TypeField and Description
private final long
private final boolean
private final Runtime

Constructor Summary

AccessConstructor and Description
protected
Pointer(Runtime runtime, long address, boolean direct)

Method Summary

Modifier and TypeMethod and Description
public final long

Returns:

the native address of this memory object. If this object is not a native memory address, an address of zero is returned.
address
()

Gets the native address of this memory object (optional operation).

public abstract Object

Returns:

The array that backs this pointer.
array
()

Returns the array that backs this pointer.

public abstract int

Returns:

The length of the backing array used
arrayLength
()

Returns the length of this pointer's backing array that is used by this pointer.

public abstract int

Returns:

The offset of the first element on the backing array
arrayOffset
()

Returns the offset within this pointer's backing array of the first element.

public abstract void
checkBounds(long
the starting point within this memory region.
offset
,
long
the length of the memory region in bytes
length
)

Checks that the memory region is within the bounds of this memory object

public abstract void
get(long
the offset from the start of the memory this Pointer represents at which the first value will be read.
offset
,
byte[]
the array into which values are to be stored.
dst
,
int
the start index in the dst array to begin storing the values.
idx
,
int
the number of values to be read.
len
)

Bulk get method for multiple byte values.

public abstract void
get(long
The offset from the start of the memory this Pointer represents at which the first value will be read.
offset
,
short[]
The array into which values are to be stored.
dst
,
int
the start index in the dst array to begin storing the values.
idx
,
int
the number of values to be read.
len
)

Bulk get method for multiple short values.

public abstract void
get(long
The offset from the start of the memory this Pointer represents at which the first value will be read.
offset
,
int[]
The array into which values are to be stored.
dst
,
int
the start index in the dst array to begin storing the values.
idx
,
int
the number of values to be read.
len
)

Bulk get method for multiple int values.

public abstract void
get(long
The offset from the start of the memory this Pointer represents at which the first value will be read.
offset
,
long[]
The array into which values are to be stored.
dst
,
int
the start index in the dst array to begin storing the values.
idx
,
int
the number of values to be read.
len
)

Bulk get method for multiple long values.

public abstract void
get(long
The offset from the start of the memory this Pointer represents at which the first value will be read.
offset
,
float[]
The array into which values are to be stored.
dst
,
int
the start index in the dst array to begin storing the values.
idx
,
int
the number of values to be read.
len
)

Bulk get method for multiple float values.

public abstract void
get(long
The offset from the start of the memory this Pointer represents at which the first value will be read.
offset
,
double[]
The array into which values are to be stored.
dst
,
int
the start index in the dst array to begin storing the values.
idx
,
int
the number of values to be read.
len
)

Bulk get method for multiple double values.

public void
get(long
The offset from the start of the memory this Pointer represents at which the first value will be read.
offset
,
Pointer[]
The array into which values are to be stored.
dst
,
int
the start index in the dst array to begin storing the values.
idx
,
int
the number of values to be read.
len
)

Bulk get method for multiple Pointer values.

public abstract long

Returns:

the native address value contained in the memory at the offset
getAddress
(long
The offset from the start of the memory this Pointer represents at which the value will be read.
offset
)

Reads a native memory address value at the given offset.

public abstract byte

Returns:

the byte value at the offset.
getByte
(long
The offset from the start of the memory this Pointer represents at which the value will be read.
offset
)

Reads an byte (8 bit) value at the given offset.

public abstract double

Returns:

the double value at the offset.
getDouble
(long
The offset from the start of the memory this Pointer represents at which the value will be read.
offset
)

Reads a double (64 bit) value at the given offset.

public abstract float

Returns:

the float value at the offset.
getFloat
(long
The offset from the start of the memory this Pointer represents at which the value will be read.
offset
)

Reads a float (32 bit) value at the given offset.

public abstract int

Returns:

the int value contained in the memory at the offset.
getInt
(long
The offset from the start of the memory this Pointer represents at which the value will be read.
offset
)

Reads an int (32 bit) value at the given offset.

public abstract long

Returns:

the int value contained in the memory at the offset.
getInt
(Type
Type of integer to read.
type
,
long
The offset from the start of the memory this Pointer represents at which the value will be read.
offset
)

Reads an integer value of the given type, at the given offset.

public abstract long

Returns:

the long value at the offset.
getLong
(long
The offset from the start of the memory this Pointer represents at which the value will be read.
offset
)

Reads a long (64 bit) value at the given offset.

public abstract long

Returns:

the long value at the offset.
getLongLong
(long
The offset from the start of the memory this Pointer represents at which the value will be read.
offset
)

Reads a long (64 bit) value at the given offset.

public abstract long

Returns:

the native long value at the offset.
getNativeLong
(long
The offset from the start of the memory this Pointer represents at which the value will be read.
offset
)

Reads a native long value at the given offset.

public Pointer[]
public String[]
public abstract Pointer

Returns:

the Pointer value read from memory.
getPointer
(long
the offset from the start of the memory this Pointer represents at which the value will be read.
offset
)

Reads an Pointer value at the given offset.

public abstract Pointer

Returns:

the Pointer value read from memory.
getPointer
(long
the offset from the start of the memory this Pointer represents at which the value will be read.
offset
,
long
the maximum size of the memory location the returned Pointer represents.
size
)

Reads an Pointer value at the given offset.

public final Runtime

Returns:

the Runtime instance of this Pointer.
getRuntime
()

Gets the Runtime this Pointer instance belongs to.

public abstract short

Returns:

the short value at the offset.
getShort
(long
The offset from the start of the memory this Pointer represents at which the value will be read.
offset
)

Reads a short (16 bit) value at the given offset.

public abstract String

Returns:

the String value read from memory.
getString
(long
the offset from the start of the memory this Pointer represents at which the value will be read.
offset
)

Reads an String value at the given offset.

public abstract String

Returns:

the String value read from memory.
getString
(long
the offset from the start of the memory this Pointer represents at which the value will be read.
offset
,
int
the maximum size of memory to search for a NUL byte.
maxLength
,
Charset
the Charset to use to decode the string.
cs
)

Reads a String value at the given offset, using a specific Charset

public abstract boolean

Returns:

true if, and only if, this memory object is backed by an array
hasArray
()

Indicates whether this Pointer instance is backed by an array.

public abstract int

Returns:

the offset from the start of the search area (i.e. relative to the offset parameter), or -1 if not found.
indexOf
(long
the offset from the start of the memory location this Pointer represents to begin searching.
offset
,
byte
the byte value to locate.
value
)

Returns the location of a byte value within the memory area represented by this Pointer.

public abstract int

Returns:

the offset from the start of the search area (i.e. relative to the offset parameter), or -1 if not found.
indexOf
(long
the offset from the start of the memory location this Pointer represents to begin searching.
offset
,
byte
the byte value to locate.
value
,
int
the maximum number of bytes to search for the desired value.
maxlen
)

Returns the location of a byte value within the memory area represented by this Pointer.

public final boolean

Returns:

true if, and only if, this memory object represents a native address.
isDirect
()

Indicates whether or not this memory object represents a native memory address.

public static Pointer

Returns:

a Pointer instance.
newIntPointer
(Runtime
the Runtime of the pointer.
runtime
,
long
the address to wrap in a Pointer instance.
address
)

Wraps an integer value in an opaque Pointer instance.

public abstract void
put(long
the offset from the start of the memory this Pointer represents at which the first value will be written.
offset
,
byte[]
the array to get values from.
src
,
int
the start index in the dst array to begin reading values.
idx
,
int
the number of values to be written.
len
)

Bulk put method for multiple byte values.

public abstract void
put(long
the offset from the start of the memory this Pointer represents at which the first value will be written.
offset
,
short[]
the array to get values from.
src
,
int
the start index in the dst array to begin reading values.
idx
,
int
the number of values to be written.
len
)

Bulk put method for multiple short values.

public abstract void
put(long
the offset from the start of the memory this Pointer represents at which the first value will be written.
offset
,
int[]
the array to get values from.
src
,
int
the start index in the dst array to begin reading values.
idx
,
int
the number of values to be written.
len
)

Bulk put method for multiple int values.

public abstract void
put(long
the offset from the start of the memory this Pointer represents at which the first value will be written.
offset
,
long[]
the array to get values from.
src
,
int
the start index in the dst array to begin reading values.
idx
,
int
the number of values to be written.
len
)

Bulk put method for multiple long values.

public abstract void
put(long
the offset from the start of the memory this Pointer represents at which the first value will be written.
offset
,
float[]
the array to get values from.
src
,
int
the start index in the dst array to begin reading values.
idx
,
int
the number of values to be written.
len
)

Bulk put method for multiple float values.

public abstract void
put(long
the offset from the start of the memory this Pointer represents at which the first value will be written.
offset
,
double[]
the array to get values from.
src
,
int
the start index in the dst array to begin reading values.
idx
,
int
the number of values to be written.
len
)

Bulk put method for multiple double values.

public void
put(long
the offset from the start of the memory this Pointer represents at which the first value will be written.
offset
,
Pointer[]
the array to get values from.
src
,
int
the start index in the src array to begin reading values.
idx
,
int
the number of values to be written.
len
)

Bulk put method for multiple Pointer values.

public abstract void
putAddress(long
The offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
long
The native address value to be written.
value
)

Writes a native memory address value at the given offset.

public abstract void
putAddress(long
The offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
Address
The native address value to be written.
value
)

Writes a native memory address value at the given offset.

public abstract void
putByte(long
The offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
byte
the byte value to be written.
value
)

Writes a byte (8 bit) value at the given offset.

public abstract void
putDouble(long
The offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
double
the double value to be written.
value
)

Writes a double (64 bit, double precision) value at the given offset.

public abstract void
putFloat(long
The offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
float
the float value to be written.
value
)

Writes a float (32 bit, single precision) value at the given offset.

public abstract void
putInt(long
The offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
int
the int value to be written.
value
)

Writes an int (32 bit) value at the given offset.

public abstract void
putInt(Type
The integer type.
type
,
long
The offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
long
the int value to be written.
value
)

Writes an integer of a specific type, at the given offset.

public abstract void
putLong(long
The offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
long
the long value to be written.
value
)

Writes a native long value at the given offset.

public abstract void
putLongLong(long
The offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
long
the long value to be written.
value
)

Writes a long (64 bit) value at the given offset.

public abstract void
putNativeLong(long
The offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
long
the native long value to be written.
value
)

Writes a native long value at the given offset.

public abstract void
putPointer(long
The offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
Pointer
the Pointer value to be written to memory.
value
)

Writes a Pointer value at the given offset.

public abstract void
putShort(long
The offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
short
the short value to be written.
value
)

Writes a short (16 bit) value at the given offset.

public abstract void
putString(long
the offset from the start of the memory this Pointer represents at which the value will be written.
offset
,
String
the string to be written.
string
,
int
the maximum size of memory to use to store the string.
maxLength
,
Charset
the Charset to use to decode the string.
cs
)

Writes a String value at the given offset, using a specific Charset

public abstract void
setMemory(long
the offset from the start of the memory location this Pointer represents to begin writing to.
offset
,
long
the number of bytes to set to the value.
size
,
byte
the value to set each byte to.
value
)

Sets the value of each byte in the memory area represented by this Pointer.

public abstract long

Returns:

the size of the memory area this Pointer points to. If the size is unknown, java.lang.Long#MAX_VALUE is returned}.
size
()

Gets the size of this memory object in bytes (optional operation).

public abstract Pointer

Returns:

a Pointer instance representing the new sub-region.
slice
(long
the offset from the start of the memory this Pointer represents at which the new Pointer will start.
offset
)

Creates a new Pointer representing a sub-region of the memory referred to by this Pointer.

public abstract Pointer

Returns:

a Pointer instance representing the new sub-region.
slice
(long
the offset from the start of the memory this Pointer represents at which the new Pointer will start.
offset
,
long
the maximum size of the memory sub-region.
size
)

Creates a new Pointer representing a sub-region of the memory referred to by this Pointer.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public abstract void
transferFrom(long
the offset from the start of the memory location this Pointer represents to begin copying to.
offset
,
Pointer
the destination memory location to transfer data from.
src
,
long
the offset from the start of the memory location the destination Pointer represents to begin copying from.
srcOffset
,
long
the number of bytes to transfer.
count
)

Bulk data transfer from one memory location to another.

public abstract void
transferTo(long
the offset from the start of the memory location this Pointer represents to begin copying from.
offset
,
Pointer
the destination memory location to transfer data to.
dst
,
long
the offset from the start of the memory location the destination Pointer represents to begin copying to.
dstOffset
,
long
the number of bytes to transfer.
count
)

Bulk data transfer from one memory location to another.

public static Pointer

Returns:

a Pointer instance.
wrap
(Runtime
the Runtime of the pointer.
runtime
,
long
the address to wrap in a Pointer instance.
address
)

Wraps a native address in a Pointer instance.

public static Pointer

Returns:

a Pointer instance.
wrap
(Runtime
the Runtime of the pointer.
runtime
,
long
the address to wrap in a Pointer instance.
address
,
long
the size of the native memory region.
size
)

Wraps a native address in a Pointer instance.

public static Pointer

Returns:

a Pointer instance that will proxy all accesses to the ByteBuffer contents.
wrap
(Runtime
the Runtime the wrapped ByteBuffer will be used with.
runtime
,
ByteBuffer
the ByteBuffer to wrap.
buffer
)

Wraps an existing ByteBuffer in a Pointer implementation so it can be used as a parameter to native functions.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

addressback to summary
private final long address
isDirectback to summary
private final boolean isDirect
runtimeback to summary
private final Runtime runtime

Constructor Detail

Pointerback to summary
protected Pointer(Runtime runtime, long address, boolean direct)

Method Detail

addressback to summary
public final long address()

Gets the native address of this memory object (optional operation).

Returns:long

the native address of this memory object. If this object is not a native memory address, an address of zero is returned.

arrayback to summary
public abstract Object array()

Returns the array that backs this pointer.

Returns:Object

The array that backs this pointer.

Exceptions
UnsupportedOperationException:
if this pointer does not have a backing array.
arrayLengthback to summary
public abstract int arrayLength()

Returns the length of this pointer's backing array that is used by this pointer.

Returns:int

The length of the backing array used

Exceptions
UnsupportedOperationException:
if this pointer does not have a backing array
arrayOffsetback to summary
public abstract int arrayOffset()

Returns the offset within this pointer's backing array of the first element.

Returns:int

The offset of the first element on the backing array

Exceptions
UnsupportedOperationException:
if this pointer does not have a backing array
checkBoundsback to summary
public abstract void checkBounds(long offset, long length)

Checks that the memory region is within the bounds of this memory object

Parameters
offset:long

the starting point within this memory region.

length:long

the length of the memory region in bytes

Exceptions
IndexOutOfBoundsException:
if the memory region is not within the bounds.
getback to summary
public abstract void get(long offset, byte[] dst, int idx, int len)

Bulk get method for multiple byte values. This method reads multiple byte values from consecutive addresses, beginning at the given offset, and stores them in an array.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the first value will be read.

dst:byte[]

the array into which values are to be stored.

idx:int

the start index in the dst array to begin storing the values.

len:int

the number of values to be read.

getback to summary
public abstract void get(long offset, short[] dst, int idx, int len)

Bulk get method for multiple short values. This method reads multiple short values from consecutive addresses, beginning at the given offset, and stores them in an array.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the first value will be read.

dst:short[]

The array into which values are to be stored.

idx:int

the start index in the dst array to begin storing the values.

len:int

the number of values to be read.

getback to summary
public abstract void get(long offset, int[] dst, int idx, int len)

Bulk get method for multiple int values. This method reads multiple int values from consecutive addresses, beginning at the given offset, and stores them in an array.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the first value will be read.

dst:int[]

The array into which values are to be stored.

idx:int

the start index in the dst array to begin storing the values.

len:int

the number of values to be read.

getback to summary
public abstract void get(long offset, long[] dst, int idx, int len)

Bulk get method for multiple long values. This method reads multiple long values from consecutive addresses, beginning at the given offset, and stores them in an array.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the first value will be read.

dst:long[]

The array into which values are to be stored.

idx:int

the start index in the dst array to begin storing the values.

len:int

the number of values to be read.

getback to summary
public abstract void get(long offset, float[] dst, int idx, int len)

Bulk get method for multiple float values. This method reads multiple float values from consecutive addresses, beginning at the given offset, and stores them in an array.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the first value will be read.

dst:float[]

The array into which values are to be stored.

idx:int

the start index in the dst array to begin storing the values.

len:int

the number of values to be read.

getback to summary
public abstract void get(long offset, double[] dst, int idx, int len)

Bulk get method for multiple double values. This method reads multiple double values from consecutive addresses, beginning at the given offset, and stores them in an array.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the first value will be read.

dst:double[]

The array into which values are to be stored.

idx:int

the start index in the dst array to begin storing the values.

len:int

the number of values to be read.

getback to summary
public void get(long offset, Pointer[] dst, int idx, int len)

Bulk get method for multiple Pointer values. This method reads multiple Pointer values from consecutive addresses, beginning at the given offset, and stores them in an array.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the first value will be read.

dst:Pointer[]

The array into which values are to be stored.

idx:int

the start index in the dst array to begin storing the values.

len:int

the number of values to be read.

getAddressback to summary
public abstract long getAddress(long offset)

Reads a native memory address value at the given offset.

A native address can be either 32 or 64 bits in size, depending on the cpu architecture.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be read.

Returns:long

the native address value contained in the memory at the offset

See Also
Address
getByteback to summary
public abstract byte getByte(long offset)

Reads an byte (8 bit) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be read.

Returns:byte

the byte value at the offset.

getDoubleback to summary
public abstract double getDouble(long offset)

Reads a double (64 bit) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be read.

Returns:double

the double value at the offset.

getFloatback to summary
public abstract float getFloat(long offset)

Reads a float (32 bit) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be read.

Returns:float

the float value at the offset.

getIntback to summary
public abstract int getInt(long offset)

Reads an int (32 bit) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be read.

Returns:int

the int value contained in the memory at the offset.

getIntback to summary
public abstract long getInt(Type type, long offset)

Reads an integer value of the given type, at the given offset.

Parameters
type:Type

Type of integer to read.

offset:long

The offset from the start of the memory this Pointer represents at which the value will be read.

Returns:long

the int value contained in the memory at the offset.

getLongback to summary
public abstract long getLong(long offset)

Reads a long (64 bit) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be read.

Returns:long

the long value at the offset.

getLongLongback to summary
public abstract long getLongLong(long offset)

Reads a long (64 bit) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be read.

Returns:long

the long value at the offset.

getNativeLongback to summary
public abstract long getNativeLong(long offset)

Reads a native long value at the given offset.

A native long can be either 32 or 64 bits in size, depending on the cpu architecture, and the C ABI in use.

For windows, a long is always 32 bits (4 bytes) in size, but on unix systems, a long on a 32bit system is 32 bits, and on a 64bit system, is 64 bits.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be read.

Returns:long

the native long value at the offset.

See Also
NativeLong
getNullTerminatedPointerArrayback to summary
public Pointer[] getNullTerminatedPointerArray(long offset)
getNullTerminatedStringArrayback to summary
public String[] getNullTerminatedStringArray(long offset)
getPointerback to summary
public abstract Pointer getPointer(long offset)

Reads an Pointer value at the given offset.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the value will be read.

Returns:Pointer

the Pointer value read from memory.

getPointerback to summary
public abstract Pointer getPointer(long offset, long size)

Reads an Pointer value at the given offset.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the value will be read.

size:long

the maximum size of the memory location the returned Pointer represents.

Returns:Pointer

the Pointer value read from memory.

getRuntimeback to summary
public final Runtime getRuntime()

Gets the Runtime this Pointer instance belongs to.

Returns:Runtime

the Runtime instance of this Pointer.

getShortback to summary
public abstract short getShort(long offset)

Reads a short (16 bit) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be read.

Returns:short

the short value at the offset.

getStringback to summary
public abstract String getString(long offset)

Reads an String value at the given offset.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the value will be read.

Returns:String

the String value read from memory.

getStringback to summary
public abstract String getString(long offset, int maxLength, Charset cs)

Reads a String value at the given offset, using a specific Charset

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the value will be read.

maxLength:int

the maximum size of memory to search for a NUL byte.

cs:Charset

the Charset to use to decode the string.

Returns:String

the String value read from memory.

hasArrayback to summary
public abstract boolean hasArray()

Indicates whether this Pointer instance is backed by an array.

Returns:boolean

true if, and only if, this memory object is backed by an array

indexOfback to summary
public abstract int indexOf(long offset, byte value)

Returns the location of a byte value within the memory area represented by this Pointer.

Parameters
offset:long

the offset from the start of the memory location this Pointer represents to begin searching.

value:byte

the byte value to locate.

Returns:int

the offset from the start of the search area (i.e. relative to the offset parameter), or -1 if not found.

indexOfback to summary
public abstract int indexOf(long offset, byte value, int maxlen)

Returns the location of a byte value within the memory area represented by this Pointer.

Parameters
offset:long

the offset from the start of the memory location this Pointer represents to begin searching.

value:byte

the byte value to locate.

maxlen:int

the maximum number of bytes to search for the desired value.

Returns:int

the offset from the start of the search area (i.e. relative to the offset parameter), or -1 if not found.

isDirectback to summary
public final boolean isDirect()

Indicates whether or not this memory object represents a native memory address.

Memory objects can be either direct (representing native memory), or non-direct (representing java heap memory).

Non-direct memory objects can still be passed to native functions as pointer (void *, char *, etc) parameters, but the java memory will first be copied to a temporary native memory area. The temporary memory area will then be used as the parameter value for the call. If needed, the java memory will be automatically reloaded from the temporary native memory after the native function returns.

Note

the transient nature of the temporary memory allocated for non-direct memory means native functions which store the address value passed to them will fail in unpredictable ways when using non-direct memory. You will need to explicitly allocate direct memory to use those types of functions.

Returns:boolean

true if, and only if, this memory object represents a native address.

newIntPointerback to summary
public static Pointer newIntPointer(Runtime runtime, long address)

Wraps an integer value in an opaque Pointer instance. This is a Pointer instance that throws errors when any of the memory access methods are used, but can be otherwise used interchangeably with a real Pointer.

Parameters
runtime:Runtime

the Runtime of the pointer.

address:long

the address to wrap in a Pointer instance.

Returns:Pointer

a Pointer instance.

putback to summary
public abstract void put(long offset, byte[] src, int idx, int len)

Bulk put method for multiple byte values. This method writes multiple byte values to consecutive addresses, beginning at the given offset, from an array.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the first value will be written.

src:byte[]

the array to get values from.

idx:int

the start index in the dst array to begin reading values.

len:int

the number of values to be written.

putback to summary
public abstract void put(long offset, short[] src, int idx, int len)

Bulk put method for multiple short values. This method writes multiple short values to consecutive addresses, beginning at the given offset, from an array.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the first value will be written.

src:short[]

the array to get values from.

idx:int

the start index in the dst array to begin reading values.

len:int

the number of values to be written.

putback to summary
public abstract void put(long offset, int[] src, int idx, int len)

Bulk put method for multiple int values. This method writes multiple int values to consecutive addresses, beginning at the given offset, from an array.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the first value will be written.

src:int[]

the array to get values from.

idx:int

the start index in the dst array to begin reading values.

len:int

the number of values to be written.

putback to summary
public abstract void put(long offset, long[] src, int idx, int len)

Bulk put method for multiple long values. This method writes multiple long values to consecutive addresses, beginning at the given offset, from an array.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the first value will be written.

src:long[]

the array to get values from.

idx:int

the start index in the dst array to begin reading values.

len:int

the number of values to be written.

putback to summary
public abstract void put(long offset, float[] src, int idx, int len)

Bulk put method for multiple float values. This method writes multiple float values to consecutive addresses, beginning at the given offset, from an array.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the first value will be written.

src:float[]

the array to get values from.

idx:int

the start index in the dst array to begin reading values.

len:int

the number of values to be written.

putback to summary
public abstract void put(long offset, double[] src, int idx, int len)

Bulk put method for multiple double values. This method writes multiple double values to consecutive addresses, beginning at the given offset, from an array.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the first value will be written.

src:double[]

the array to get values from.

idx:int

the start index in the dst array to begin reading values.

len:int

the number of values to be written.

putback to summary
public void put(long offset, Pointer[] src, int idx, int len)

Bulk put method for multiple Pointer values. This method writes multiple Pointer values to consecutive addresses, beginning at the given offset, from an array.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the first value will be written.

src:Pointer[]

the array to get values from.

idx:int

the start index in the src array to begin reading values.

len:int

the number of values to be written.

putAddressback to summary
public abstract void putAddress(long offset, long value)

Writes a native memory address value at the given offset.

A native address can be either 32 or 64 bits in size, depending on the cpu architecture.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be written.

value:long

The native address value to be written.

See Also
Address
putAddressback to summary
public abstract void putAddress(long offset, Address value)

Writes a native memory address value at the given offset.

A native address can be either 32 or 64 bits in size, depending on the cpu architecture.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be written.

value:Address

The native address value to be written.

See Also
Address
putByteback to summary
public abstract void putByte(long offset, byte value)

Writes a byte (8 bit) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be written.

value:byte

the byte value to be written.

putDoubleback to summary
public abstract void putDouble(long offset, double value)

Writes a double (64 bit, double precision) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be written.

value:double

the double value to be written.

putFloatback to summary
public abstract void putFloat(long offset, float value)

Writes a float (32 bit, single precision) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be written.

value:float

the float value to be written.

putIntback to summary
public abstract void putInt(long offset, int value)

Writes an int (32 bit) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be written.

value:int

the int value to be written.

putIntback to summary
public abstract void putInt(Type type, long offset, long value)

Writes an integer of a specific type, at the given offset.

Parameters
type:Type

The integer type.

offset:long

The offset from the start of the memory this Pointer represents at which the value will be written.

value:long

the int value to be written.

putLongback to summary
public abstract void putLong(long offset, long value)

Writes a native long value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be written.

value:long

the long value to be written.

putLongLongback to summary
public abstract void putLongLong(long offset, long value)

Writes a long (64 bit) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be written.

value:long

the long value to be written.

putNativeLongback to summary
public abstract void putNativeLong(long offset, long value)

Writes a native long value at the given offset.

A native long can be either 32 or 64 bits in size, depending on the cpu architecture, and the C ABI in use.

For windows, a long is always 32 bits (4 bytes) in size, but on unix systems, a long on a 32bit system is 32 bits, and on a 64bit system, is 64 bits.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be written.

value:long

the native long value to be written.

putPointerback to summary
public abstract void putPointer(long offset, Pointer value)

Writes a Pointer value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be written.

value:Pointer

the Pointer value to be written to memory.

putShortback to summary
public abstract void putShort(long offset, short value)

Writes a short (16 bit) value at the given offset.

Parameters
offset:long

The offset from the start of the memory this Pointer represents at which the value will be written.

value:short

the short value to be written.

putStringback to summary
public abstract void putString(long offset, String string, int maxLength, Charset cs)

Writes a String value at the given offset, using a specific Charset

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the value will be written.

string:String

the string to be written.

maxLength:int

the maximum size of memory to use to store the string.

cs:Charset

the Charset to use to decode the string.

setMemoryback to summary
public abstract void setMemory(long offset, long size, byte value)

Sets the value of each byte in the memory area represented by this Pointer. to a specified value.

Parameters
offset:long

the offset from the start of the memory location this Pointer represents to begin writing to.

size:long

the number of bytes to set to the value.

value:byte

the value to set each byte to.

sizeback to summary
public abstract long size()

Gets the size of this memory object in bytes (optional operation).

Returns:long

the size of the memory area this Pointer points to. If the size is unknown, java.lang.Long#MAX_VALUE is returned}.

sliceback to summary
public abstract Pointer slice(long offset)

Creates a new Pointer representing a sub-region of the memory referred to by this Pointer.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the new Pointer will start.

Returns:Pointer

a Pointer instance representing the new sub-region.

sliceback to summary
public abstract Pointer slice(long offset, long size)

Creates a new Pointer representing a sub-region of the memory referred to by this Pointer.

Parameters
offset:long

the offset from the start of the memory this Pointer represents at which the new Pointer will start.

size:long

the maximum size of the memory sub-region.

Returns:Pointer

a Pointer instance representing the new sub-region.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

transferFromback to summary
public abstract void transferFrom(long offset, Pointer src, long srcOffset, long count)

Bulk data transfer from one memory location to another.

Parameters
offset:long

the offset from the start of the memory location this Pointer represents to begin copying to.

src:Pointer

the destination memory location to transfer data from.

srcOffset:long

the offset from the start of the memory location the destination Pointer represents to begin copying from.

count:long

the number of bytes to transfer.

transferToback to summary
public abstract void transferTo(long offset, Pointer dst, long dstOffset, long count)

Bulk data transfer from one memory location to another.

Parameters
offset:long

the offset from the start of the memory location this Pointer represents to begin copying from.

dst:Pointer

the destination memory location to transfer data to.

dstOffset:long

the offset from the start of the memory location the destination Pointer represents to begin copying to.

count:long

the number of bytes to transfer.

wrapback to summary
public static Pointer wrap(Runtime runtime, long address)

Wraps a native address in a Pointer instance.

Parameters
runtime:Runtime

the Runtime of the pointer.

address:long

the address to wrap in a Pointer instance.

Returns:Pointer

a Pointer instance.

wrapback to summary
public static Pointer wrap(Runtime runtime, long address, long size)

Wraps a native address in a Pointer instance.

Parameters
runtime:Runtime

the Runtime of the pointer.

address:long

the address to wrap in a Pointer instance.

size:long

the size of the native memory region.

Returns:Pointer

a Pointer instance.

wrapback to summary
public static Pointer wrap(Runtime runtime, ByteBuffer buffer)

Wraps an existing ByteBuffer in a Pointer implementation so it can be used as a parameter to native functions.

Wrapping a ByteBuffer is only neccessary if the native function parameter was declared as a Pointer. The if the method will always be used with ByteBuffer parameters, then the parameter type can just be declared as ByteBuffer and the conversion will be performed automatically.

Parameters
runtime:Runtime

the Runtime the wrapped ByteBuffer will be used with.

buffer:ByteBuffer

the ByteBuffer to wrap.

Returns:Pointer

a Pointer instance that will proxy all accesses to the ByteBuffer contents.