const char* cname = NULL;
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ElementImpl_getAttribute  (JNIEnv *env, jobject jthis, jstring jname){  nsIDOMElement* element = (nsIDOMElement*)     env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);  if (!element) {    JavaDOMGlobals::ThrowException(env,      "Element.getAttribute: 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.getAttribute: GetStringUTFChars failed");      return NULL;    }  }  nsString attr;  nsresult rv = element->GetAttribute(cname, attr);  if (iscopy == JNI_TRUE)    env->ReleaseStringUTFChars(jname, cname);  if (NS_FAILED(rv)) {    JavaDOMGlobals::ThrowException(env,      "Element.getAttribute: failed", rv);    return NULL;  }  jstring jattr = env->NewString(attr.GetUnicode(), attr.Length());  if (!jattr) {    JavaDOMGlobals::ThrowException(env,      "Element.getAttribute: NewString failed");    return NULL;  }  return jattr;}