const char* cname = NULL;
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_getAttributeNode  (JNIEnv *env, jobject jthis, jstring jname){  nsIDOMElement* element = (nsIDOMElement*)     env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);  if (!element) {    JavaDOMGlobals::ThrowException(env,      "Element.getAttributeNode: NULL pointer");    return NULL;  }  const char* cname = NULL;  jboolean iscopy = JNI_FALSE;  if (jname) {    cname = env->GetStringUTFChars(jname, &iscopy);    if (!cname) {      JavaDOMGlobals::ThrowException(env,        "Element.getAttributeNode: GetStringUTFChars failed");      return NULL;    }  }  nsIDOMAttr* attr = nsnull;  nsresult rv = element->GetAttributeNode(cname, &attr);  if (iscopy == JNI_TRUE)    env->ReleaseStringUTFChars(jname, cname);  if (NS_FAILED(rv)) {    JavaDOMGlobals::ThrowException(env,      "Element.getAttributeNode: failed", rv);    return NULL;  }  if (!attr)    return NULL;  jobject jattr = env->AllocObject(JavaDOMGlobals::attrClass);  if (!jattr) {    JavaDOMGlobals::ThrowException(env,      "Element.getAttributeNode: failed to allocate object");    return NULL;  }  env->SetLongField(jattr, JavaDOMGlobals::nodePtrFID, (jlong) attr);  if (env->ExceptionOccurred()) {    JavaDOMGlobals::ThrowException(env,      "Element.getAttributeNode: failed to set node ptr");    return NULL;  }  attr->AddRef();  return jattr;}