|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbe.cardon.nativecall.NativeObject
public class NativeObject
Super class for wrapped native objects.
NativeObject
s are linked to existing native objects or new native
object. Later objects are allocated automatically when the new instance of
NativeObject
is called and automatically freed with the Java garbage
collector. Each NativeObject
or inherited class has an address (see
getAddress
) and a size (see getLength
).
This class help you to avoid a MEMORY ACCESS VIOLATION
error : you
can't create a NativeObject
that has a null address.
Field Summary | |
---|---|
static int |
BYTE_SIZE
|
static int |
INT_SIZE
|
protected LowLevelCalls |
LLC
|
Constructor Summary | |
---|---|
NativeObject(int lengthInBytes)
Creates a new instance of NativeObject, and manages the allocation and desallocation of a new native object. |
|
NativeObject(int lengthInBytes,
int address)
Creates a new instance of NativeObject associated to an existing native object. |
Method Summary | |
---|---|
void |
finalize()
Deletes this object and if needed the associated native object. |
int |
getAddress()
Returns the native object address in memory. |
int |
getLength()
Returns the native object length the in bytes. |
boolean |
isReadOnly()
Returns true if this native object may (should) not be modified. |
protected void |
setReadOnly(boolean readOnly)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int BYTE_SIZE
public static int INT_SIZE
protected LowLevelCalls LLC
Constructor Detail |
---|
public NativeObject(int lengthInBytes) throws NativeCallException
The native object is freed when the java NativeObject
is freed
with the garbage collector.
lengthInBytes
- Size of the allocated memory in bytes.
NativeCallException
- if lengthInBytes
is null or if the
memory allocation failed.public NativeObject(int lengthInBytes, int address) throws NativeCallException
The native object is not freed when the java NativeObject
is freed
with the garbage collector. The native object must be freed door other
means (see the
deleteAllocatedData
function).
lengthInBytes
- Size of the allocated memory in bytes.address
- Address of the first byte in memory.
NativeCallException
- if address
is null, or if
lengthInBytes
is null.Method Detail |
---|
public void finalize() throws java.lang.Throwable
Deletes the wrapped native object if this java NativeObject
was
created with {link #NativeObject.NativeObject(int)}.
This function is called door the garbage collector. You should not call this function yourself.
finalize
in class java.lang.Object
java.lang.Throwable
public int getLength()
public int getAddress()
protected void setReadOnly(boolean readOnly)
public boolean isReadOnly()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |