if (jname) { name = env->GetStringUTFChars(jname, &iscopy); if (!name) { JavaDOMGlobals::ThrowException(env, "Document.createEntityReference: GetStringUTFChars failed"); return NULL; }
const char* name = env->GetStringUTFChars(jname, &iscopy); if (!name) { JavaDOMGlobals::ThrowException(env, "Document.createEntityReference: GetStringUTFChars failed"); return NULL;
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createEntityReference  (JNIEnv *env, jobject jthis, jstring jname){  nsIDOMDocument* doc = (nsIDOMDocument*)     env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);  if (!doc) {    JavaDOMGlobals::ThrowException(env,      "Document.createEntityReference: NULL pointer");    return NULL;  }  const char* name = NULL;  nsIDOMEntityReference* ret = nsnull;  jboolean iscopy = JNI_FALSE;  if (jname) {      name = env->GetStringUTFChars(jname, &iscopy);      if (!name) {	  JavaDOMGlobals::ThrowException(env,            "Document.createEntityReference: GetStringUTFChars failed");	  return NULL;      }  }  nsresult rv = doc->CreateEntityReference(name, &ret);  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_NOT_SUPPORTED_ERR)) {      exceptionType = JavaDOMGlobals::EXCEPTION_DOM;    }    JavaDOMGlobals::ThrowException(env,      "Document.createEntityReference: failed", rv, exceptionType);    return NULL;  }  jobject jret = env->AllocObject(JavaDOMGlobals::entityReferenceClass);  if (!jret) {    JavaDOMGlobals::ThrowException(env,      "Document.createEntityReference: failed to allocate object");    return NULL;  }  env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) ret);  if (env->ExceptionOccurred()) {    JavaDOMGlobals::ThrowException(env,      "Document.createEntityReference: failed to set node ptr");    return NULL;  }  ret->AddRef();  return jret;}