src/solaris/native/java/io/UnixFileSystem_md.c
Print this page
@@ -281,11 +281,15 @@
DIR *dir = NULL;
struct dirent64 *ptr;
struct dirent64 *result;
int len, maxlen;
jobjectArray rv, old;
+ jclass str_class;
+ str_class = JNU_ClassString(env);
+ CHECK_NULL_RETURN(str_class, NULL);
+
WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
dir = opendir(path);
} END_PLATFORM_STRING(env, path);
if (dir == NULL) return NULL;
@@ -297,22 +301,21 @@
}
/* Allocate an initial String array */
len = 0;
maxlen = 16;
- rv = (*env)->NewObjectArray(env, maxlen, JNU_ClassString(env), NULL);
+ rv = (*env)->NewObjectArray(env, maxlen, str_class, NULL);
if (rv == NULL) goto error;
/* Scan the directory */
while ((readdir64_r(dir, ptr, &result) == 0) && (result != NULL)) {
jstring name;
if (!strcmp(ptr->d_name, ".") || !strcmp(ptr->d_name, ".."))
continue;
if (len == maxlen) {
old = rv;
- rv = (*env)->NewObjectArray(env, maxlen <<= 1,
- JNU_ClassString(env), NULL);
+ rv = (*env)->NewObjectArray(env, maxlen <<= 1, str_class, NULL);
if (rv == NULL) goto error;
if (JNU_CopyObjectArray(env, rv, old, len) < 0) goto error;
(*env)->DeleteLocalRef(env, old);
}
#ifdef MACOSX
@@ -327,11 +330,11 @@
closedir(dir);
free(ptr);
/* Copy the final results into an appropriately-sized array */
old = rv;
- rv = (*env)->NewObjectArray(env, len, JNU_ClassString(env), NULL);
+ rv = (*env)->NewObjectArray(env, len, str_class, NULL);
if (rv == NULL) {
return NULL;
}
if (JNU_CopyObjectArray(env, rv, old, len) < 0) {
return NULL;