nsIDOMNode* newChild = (nsIDOMNode*) env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID); if (!newChild) { JavaDOMGlobals::ThrowException(env, "Node.replaceChild: NULL newChild pointer"); return NULL;
nsIDOMNode* newChild = NULL; if (jnewChild) { newChild = (nsIDOMNode*) env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID); if (!newChild) { JavaDOMGlobals::ThrowException(env, "Node.replaceChild: NULL newChild pointer"); return NULL; }
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_replaceChild  (JNIEnv *env, jobject jthis, jobject jnewChild, jobject joldChild){  nsIDOMNode* node = (nsIDOMNode*)     env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);  if (!node) {    JavaDOMGlobals::ThrowException(env,      "Node.replaceChild: NULL pointer");    return NULL;  }  nsIDOMNode* newChild = (nsIDOMNode*)     env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID);  if (!newChild) {    JavaDOMGlobals::ThrowException(env,      "Node.replaceChild: NULL newChild pointer");    return NULL;  }  nsIDOMNode* oldChild = (nsIDOMNode*)     env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID);  if (!oldChild) {    JavaDOMGlobals::ThrowException(env,      "Node.replaceChild: NULL oldChild pointer");    return NULL;  }  nsIDOMNode* ret = nsnull;  nsresult rv = node->ReplaceChild(newChild, oldChild, &ret);  if (NS_FAILED(rv) || !ret) {    JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;    if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&        (NS_ERROR_GET_CODE(rv) == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ||         NS_ERROR_GET_CODE(rv) == NS_ERROR_DOM_WRONG_DOCUMENT_ERR ||         NS_ERROR_GET_CODE(rv) == NS_ERROR_DOM_HIERARCHY_REQUEST_ERR ||         NS_ERROR_GET_CODE(rv) == NS_ERROR_DOM_NOT_FOUND_ERR)) {      exceptionType = JavaDOMGlobals::EXCEPTION_DOM;    }    JavaDOMGlobals::ThrowException(env,      "Node.replaceChild: failed", rv, exceptionType);    return NULL;  }  return JavaDOMGlobals::CreateNodeSubtype(env, ret);}