const char* data = env->GetStringUTFChars(jdata, &iscopy); if (!data) { JavaDOMGlobals::ThrowException(env, "Document.createCDATASection: GetStringUTFChars failed"); return NULL;
if (jdata) { data = env->GetStringUTFChars(jdata, &iscopy); if (!data) { JavaDOMGlobals::ThrowException(env, "Document.createCDATASection: GetStringUTFChars failed"); return NULL; }
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createCDATASection  (JNIEnv *env, jobject jthis, jstring jdata){  nsIDOMDocument* doc = (nsIDOMDocument*)     env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);  if (!doc) {    JavaDOMGlobals::ThrowException(env,      "Document.createCDATASection: NULL pointer");    return NULL;  }  nsIDOMCDATASection* ret = nsnull;  jboolean iscopy = JNI_FALSE;  const char* data = env->GetStringUTFChars(jdata, &iscopy);  if (!data) {    JavaDOMGlobals::ThrowException(env,      "Document.createCDATASection: GetStringUTFChars failed");    return NULL;  }  nsresult rv = doc->CreateCDATASection(data, &ret);  if (iscopy == JNI_TRUE)    env->ReleaseStringUTFChars(jdata, data);  if (NS_FAILED(rv) || !ret) {    JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;    if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&        NS_ERROR_GET_CODE(rv) == NS_ERROR_DOM_NOT_SUPPORTED_ERR) {      exceptionType = JavaDOMGlobals::EXCEPTION_DOM;    }    JavaDOMGlobals::ThrowException(env,      "Document.createCDATASection: failed", rv, exceptionType);    return NULL;  }  jobject jret = env->AllocObject(JavaDOMGlobals::cDataSectionClass);  if (!jret) {    JavaDOMGlobals::ThrowException(env,      "Document.createCDATASection: failed to allocate object");    return NULL;  }  env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) ret);  if (env->ExceptionOccurred()) {    JavaDOMGlobals::ThrowException(env,      "Document.createCDATASection: failed to set node ptr");    return NULL;  }  ret->AddRef();  return jret;}