|
JSS 3.1.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.mozilla.jss.util.NativeProxy
NativeProxy, a superclass for Java classes that mirror C data structures. It contains some code to help make sure that native memory is getting freed properly.
Field Summary | |
(package private) static java.util.Random |
indexGenerator
|
private byte[] |
mPointer
Byte array containing native pointer bytes. |
(package private) static java.util.Hashtable |
registry
|
private long |
registryIndex
Native Proxy Registry |
Constructor Summary | |
private |
NativeProxy()
Default constructor. |
|
NativeProxy(byte[] pointer)
Create a NativeProxy from a byte array representing a C pointer. |
Method Summary | |
(package private) static void |
|
static void |
assertRegistryEmpty()
Assert that the Registry is empty. |
boolean |
equals(java.lang.Object obj)
Deep comparison operator. |
protected void |
finalize()
Finalize this NativeProxy by releasing its native resources. |
long |
getRegistryIndex()
|
static java.util.Enumeration |
getRegistryIndices()
|
private static long |
register()
Register a NativeProxy instance. |
protected abstract void |
releaseNativeResources()
Release the native resources used by this proxy. |
private static void |
unregister(long index)
Unregister a NativeProxy instance. |
Methods inherited from class java.lang.Object |
clone, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
Field Detail |
private byte[] mPointer
private long registryIndex
Native Proxy Registry
In debug mode, we keep track of all NativeProxy objects in a static registry. Whenever a NativeProxy is constructed, it registers. Whenever it finalizes, it unregisters. At the end of the game, we should be able to garbage collect and then assert that the registry is empty. This could be done, for example, in the jssjava JVM after main() completes. This registration process verifies that people are calling NativeProxy.finalize() from their subclasses of NativeProxy, so that releaseNativeResources() gets called.
static java.util.Hashtable registry
static java.util.Random indexGenerator
Constructor Detail |
private NativeProxy()
public NativeProxy(byte[] pointer)
pointer
- A byte array, created with JSS_ptrToByteArray, that
contains a pointer pointing to a native data structure. The
NativeProxy instance acts as a proxy for that native data structure.Method Detail |
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
has the same underlying native
pointer. false if the obj
is null or has
a different underlying native pointer.protected abstract void releaseNativeResources()
You don't call this method; NativeProxy.finalize() calls it for you.
You must declare a finalize() method which calls super.finalize().
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
static void()
private static long register()
private static void unregister(long index)
index
- The index of this object in the registry, as returned
from the previous call to register().public static java.util.Enumeration getRegistryIndices()
getRegistryIndex()
public long getRegistryIndex()
getRegistryIndices()
public static void assertRegistryEmpty()
|
JSS 3.1.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |