android/runtime/v8/src/native/JavaObject.cpp
void JavaObject::newGlobalRef()
{
	JNIEnv *env = JNIUtil::getJNIEnv();
	ASSERT(env != NULL);

	if (useGlobalRefs) {
		ASSERT(javaObject_ != NULL);
		jobject globalRef = env->NewGlobalRef(javaObject_);
		if (isWeakRef_) {
			env->DeleteWeakGlobalRef(javaObject_);
			isWeakRef_ = false;
		}
		javaObject_ = globalRef;
	} else {
		ASSERT(refTableKey_ == 0);
		refTableKey_ = ReferenceTable::createReference(javaObject_);
		javaObject_ = NULL;
	}
}
// Create a strong reference to the wrapped Java object
// to prevent it from becoming garbage collected by Dalvik.
Create a strong reference to the wrapped Java object
to prevent it from becoming garbage collected by Dalvik.
Create a strong reference to the wrapped Java object to prevent it from becoming garbage collected by Dalvik .
void JavaObject::newGlobalRef()
{
	JNIEnv *env = JNIUtil::getJNIEnv();
	ASSERT(env != NULL);
	if (useGlobalRefs) {
		ASSERT(javaObject_ != NULL);
		jobject globalRef = env->NewGlobalRef(javaObject_);
		if (isWeakRef_) {
			env->DeleteWeakGlobalRef(javaObject_);
			isWeakRef_ = false;
		}
		javaObject_ = globalRef;
	} else {
		ASSERT(refTableKey_ == 0);
		refTableKey_ = ReferenceTable::createReference(javaObject_);
		javaObject_ = NULL;
	}
}
void JavaObject :: newGlobalRef ( ) { JNIEnv * env = JNIUtil :: getJNIEnv ( ) ; ASSERT ( env != NULL ) ; if ( useGlobalRefs ) { ASSERT ( javaObject_ != NULL ) ; jobject globalRef = env -> NewGlobalRef ( javaObject_ ) ; if ( isWeakRef_ ) { env -> DeleteWeakGlobalRef ( javaObject_ ) ; isWeakRef_ = false ; } javaObject_ = globalRef ; } else { ASSERT ( refTableKey_ == 0 ) ; refTableKey_ = ReferenceTable :: createReference ( javaObject_ ) ; javaObject_ = NULL ; } }
Create a strong reference to the wrapped Java object
to prevent it from becoming garbage collected by Dalvik.
Create a strong reference to the wrapped Java object to prevent it from becoming garbage collected by Dalvik .