if (!element) {
if (!element || !jname || !jvalue) {
JNIEXPORT void JNICALL Java_org_mozilla_dom_ElementImpl_setAttribute  (JNIEnv *env, jobject jthis, jstring jname, jstring jvalue){  nsIDOMElement* element = (nsIDOMElement*)     env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);  if (!element) {    JavaDOMGlobals::ThrowException(env,      "Element.setAttribute: NULL pointer");    return;  }  const char* name = NULL;  const char* value = NULL;  jboolean iscopy = JNI_FALSE;  if (jname) {    name = env->GetStringUTFChars(jname, &iscopy);    if (!name) {      JavaDOMGlobals::ThrowException(env,        "Element.setAttribute: GetStringUTFChars name failed");      return;    }  }  jboolean iscopy2 = JNI_FALSE;  if (jvalue) {    value = env->GetStringUTFChars(jvalue, &iscopy2);    if (!value) {      JavaDOMGlobals::ThrowException(env,        "Element.setAttribute: GetStringUTFChars name failed");      return;    }  }  nsresult rv = element->SetAttribute(name, value);  if (iscopy2 == JNI_TRUE)    env->ReleaseStringUTFChars(jvalue, value);  if (iscopy == JNI_TRUE)    env->ReleaseStringUTFChars(jname, name);  if (NS_FAILED(rv)) {    JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;    if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&        (rv == NS_ERROR_DOM_INVALID_CHARACTER_ERR ||         rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR)) {      exceptionType = JavaDOMGlobals::EXCEPTION_DOM;    }    JavaDOMGlobals::ThrowException(env,      "Element.setAttribute: failed", rv, exceptionType);    return;  }}