size_t length;
jobject string;
int fd;
+ JNIEnv *env;
vp = (struct android_authority_vnode *) vnode;
return -1;
}
+ /* Save the JNI environment within `env', to make wrapping
+ subsequent lines referencing CallNonvirtualIntMethod
+ feasible. */
+ env = android_java_env;
+
/* Allocate a buffer to hold the file name. */
length = strlen (vp->uri);
- string = (*android_java_env)->NewByteArray (android_java_env,
- length);
+ string = (*env)->NewByteArray (env, length);
if (!string)
{
- (*android_java_env)->ExceptionClear (android_java_env);
+ (*env)->ExceptionClear (env);
errno = ENOMEM;
return -1;
}
/* Copy the URI into this byte array. */
- (*android_java_env)->SetByteArrayRegion (android_java_env,
- string, 0, length,
- (jbyte *) vp->uri);
+ (*env)->SetByteArrayRegion (env, string, 0, length,
+ (jbyte *) vp->uri);
/* Try to open the file descriptor. */
- fd
- = (*android_java_env)->CallIntMethod (android_java_env,
- emacs_service,
- service_class.open_content_uri,
- string,
- (jboolean) ((mode & O_WRONLY
- || mode & O_RDWR)
- != 0),
- (jboolean) !(mode & O_WRONLY),
- (jboolean) ((mode & O_TRUNC)
- != 0));
-
- if ((*android_java_env)->ExceptionCheck (android_java_env))
+ fd = (*env)->CallNonvirtualIntMethod (env, emacs_service,
+ service_class.class,
+ service_class.open_content_uri,
+ string,
+ (jboolean) ((mode & O_WRONLY
+ || mode & O_RDWR)
+ != 0),
+ (jboolean) !(mode & O_WRONLY),
+ (jboolean) ((mode & O_TRUNC)
+ != 0));
+ if ((*env)->ExceptionCheck (env))
{
- (*android_java_env)->ExceptionClear (android_java_env);
+ (*env)->ExceptionClear (env);
errno = ENOMEM;
ANDROID_DELETE_LOCAL_REF (string);
return -1;
/* Now, try to delete the document. */
method = service_class.delete_document;
- rc = (*android_java_env)->CallIntMethod (android_java_env,
- emacs_service,
- method, uri, id,
- name);
+ rc = (*android_java_env)->CallNonvirtualIntMethod (android_java_env,
+ emacs_service,
+ service_class.class,
+ method, uri, id,
+ name);
if (android_saf_exception_check (3, id, uri, name))
return -1;