jobject jnode = env->AllocObject(JavaDOMGlobals::nodeClass); if (!jnode) { JavaDOMGlobals::ThrowException(env, "NamedNodeMap.setNamedItem: failed to allocate object"); return NULL; }  env->SetLongField(jnode, JavaDOMGlobals::nodePtrFID, (jlong) node); if (env->ExceptionOccurred()) { JavaDOMGlobals::ThrowException(env, "NamedNodeMap.setNamedItem: failed to set node ptr"); return NULL; }  node->AddRef(); return jnode;
return JavaDOMGlobals::CreateNodeSubtype(env, node);
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NamedNodeMapImpl_setNamedItem  (JNIEnv *env, jobject jthis, jobject jarg){  nsIDOMNamedNodeMap* map = (nsIDOMNamedNodeMap*)     env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);  if (!map) {    JavaDOMGlobals::ThrowException(env,      "NodeMap.setNamedItem: NULL pointer");    return NULL;  }    nsIDOMNode* arg = (nsIDOMNode*)    env->GetLongField(jarg, JavaDOMGlobals::nodePtrFID);  if (!arg) {    JavaDOMGlobals::ThrowException(env,      "NodeMap.setNamedItem: NULL item pointer");    return NULL;  }  nsIDOMNode* node = nsnull;  nsresult rv = map->SetNamedItem(arg, &node);  if (NS_FAILED(rv) || !node) {    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_INUSE_ATTRIBUTE_ERR)) {      exceptionType = JavaDOMGlobals::EXCEPTION_DOM;    }    JavaDOMGlobals::ThrowException(env,      "NodeMap.setNamedItem: failed", rv, exceptionType);    return NULL;  }  jobject jnode = env->AllocObject(JavaDOMGlobals::nodeClass);  if (!jnode) {    JavaDOMGlobals::ThrowException(env,      "NamedNodeMap.setNamedItem: failed to allocate object");    return NULL;  }  env->SetLongField(jnode, JavaDOMGlobals::nodePtrFID, (jlong) node);  if (env->ExceptionOccurred()) {    JavaDOMGlobals::ThrowException(env,      "NamedNodeMap.setNamedItem: failed to set node ptr");    return NULL;  }  node->AddRef();  return jnode;}