JNIpp 1.0
JNI meets C++
|
The Object class, root of all. More...
Public Member Functions | |
Object () | |
Creates java.lang.Object and wraps it. | |
Object (const jni::LObject &object) | |
Wraps object . | |
bool | IsLive () const |
Tests whether this object is live. | |
void | Retain () const |
Increments reference counter. | |
void | Release () const |
Decrements reference counter. | |
virtual jobject | GetJObject () const |
Returns contained Java object. | |
bool | Equals (PObject other) const |
Indicates whether some other object is "equal to" this one. | |
PClass | GetClass () const |
Returns object's class. | |
jint | GetHashCode () const |
Returns a hash code value for the object. | |
void | Notify () |
Wakes up a single thread that is waiting on this object's monitor. | |
void | NotifyAll () |
Wakes up all threads that are waiting on this object's monitor. | |
void | Wait () |
Causes current thread to wait until another thread invokes the Notify() method or the NotifyAll() method for this object. | |
void | Wait (jlong timeout) |
Causes current thread to wait until either another thread invokes the Notify() method or the NotifyAll() method for this object, or a specified amount of time has elapsed. | |
void | Wait (jlong timeout, jint nanos) |
Causes current thread to wait until either another thread invokes the Notify() method or the NotifyAll() method for this object, or a specified amount of time has elapsed. | |
PString | ToString () const |
Returns a string representation of the object. | |
Static Public Member Functions | |
static java::PClass | GetTypeClass () |
Returns Java class for this class. | |
static jfieldID | GetInstanceFieldID () |
Returns instance field id. | |
static Object * | GetLiveInstance (jobject object, jfieldID instanceFieldID) |
Retrieves object instance pointer from the Java object. | |
static PClass | GetClass (const AbstractObject &object) |
Returns class of the specified object. | |
Static Public Attributes | |
static const bool | IsLiveType |
Flag indicating whether class is live. | |
Protected Member Functions | |
Object (const jni::LObject &object, jfieldID instanceFieldID) | |
Constructs live object. | |
virtual | ~Object () |
Destroys reference to the contained Java object. |
The Object class, root of all.
Wrapper for java.lang.Object
.
Object class uses intrusive reference counting: Retain() adds a reference, Release() releases it. However, you should use ObjectPointer for managing objects lifetime in an exception safe manner.
When subclassing Object you need to decide whether to implement wrapper or live class:
More about creating a wrapper class:
More about creating a live class:
protected native void finalize();
private int nativeInstance;
native
. Association between callbacks and corresponding Java methods is established in JB_DEFINE_LIVE_CLASS().java::Object::Object | ( | ) |
Creates java.lang.Object
and wraps it.
See Object(const jni::LObject&) for details.
java::Object::Object | ( | const jni::LObject & | object | ) |
Wraps object
.
Method performs the following:
See also Object(const jni::LObject&,jfieldID).
java::Object::Object | ( | const jni::LObject & | object, |
jfieldID | instanceFieldID | ||
) | [protected] |
Constructs live object.
Method performs the following:
this
) to the int
field identified by instanceFieldID
.See also Object(const jni::LObject&).
static jfieldID java::Object::GetInstanceFieldID | ( | ) | [static] |
Returns instance field id.
Instance field must be declared as:
private int nativeInstance;
Added by JB_LIVE_CLASS() macro. static java::PClass java::Object::GetTypeClass | ( | ) | [static] |
Returns Java class for this class.
Added by JB_WRAPPER_CLASS() / JB_LIVE_CLASS().
void java::Object::Release | ( | ) | const |
Decrements reference counter.
For live objects decrementing counter from 2 to 1 switches contained Java object from global to weak reference allowing Java's GC to collect it.
When reference count hits zero (or goes below) object is deleted.
void java::Object::Retain | ( | ) | const |
Increments reference counter.
If this object is live incrementing counter from 1 to 2 switches contained Java object from weak to global reference.
const bool java::Object::IsLiveType [static] |
Flag indicating whether class is live.
Added by JB_WRAPPER_CLASS() / JB_LIVE_CLASS().