android/runtime/v8/src/native/JavaObject.cpp
jobject JavaObject::getJavaObject()
{
	if (useGlobalRefs) {
		ASSERT(javaObject_ != NULL);

		// We must always return a valid Java proxy reference.
		// Otherwise we risk crashing in the calling code.
		// If we are "detached" we will re-attach whenever the Java
		// proxy is requested.
		if (isDetached()) {
			attach(NULL);
		}

		return javaObject_;
	} else {
		if (isWeakRef_) {
			UPDATE_STATS(0, -1);
			jobject javaObject = ReferenceTable::clearWeakReference(refTableKey_);
			if (javaObject == NULL) {
				LOGE(TAG, "Java object reference has been invalidated.");
			}
			isWeakRef_ = false;
			handle_.MakeWeak(this, DetachCallback);
			return javaObject;
		}
		return ReferenceTable::getReference(refTableKey_);
	}
}
// Returns a global reference to the wrapped Java object.
// If the object has become "detached" this will re-attach
// it to ensure the Java object will not get collected.
Returns a global reference to the wrapped Java object.
If the object has become "detached" this will re-attach
it to ensure the Java object will not get collected.
Returns a global reference to the wrapped Java object . If the object has become " detached " this will re - attach it to ensure the Java object will not get collected .
jobject JavaObject::getJavaObject()
{
	if (useGlobalRefs) {
		ASSERT(javaObject_ != NULL);
		if (isDetached()) {
			attach(NULL);
		}
		return javaObject_;
	} else {
		if (isWeakRef_) {
			UPDATE_STATS(0, -1);
			jobject javaObject = ReferenceTable::clearWeakReference(refTableKey_);
			if (javaObject == NULL) {
				LOGE(TAG, "Java object reference has been invalidated.");
			}
			isWeakRef_ = false;
			handle_.MakeWeak(this, DetachCallback);
			return javaObject;
		}
		return ReferenceTable::getReference(refTableKey_);
	}
}
jobject JavaObject :: getJavaObject ( ) { if ( useGlobalRefs ) { ASSERT ( javaObject_ != NULL ) ; if ( isDetached ( ) ) { attach ( NULL ) ; } return javaObject_ ; } else { if ( isWeakRef_ ) { UPDATE_STATS ( 0 , -1 ) ; jobject javaObject = ReferenceTable :: clearWeakReference ( refTableKey_ ) ; if ( javaObject == NULL ) { LOGE ( TAG , " " ) ; } isWeakRef_ = false ; handle_ . MakeWeak ( this , DetachCallback ) ; return javaObject ; } return ReferenceTable :: getReference ( refTableKey_ ) ; } }
Returns a global reference to the wrapped Java object.
Returns a global reference to the wrapped Java object .
// We must always return a valid Java proxy reference. // Otherwise we risk crashing in the calling code. // If we are "detached" we will re-attach whenever the Java // proxy is requested.