summaryrefslogtreecommitdiff
path: root/native/jni/classpath
diff options
context:
space:
mode:
authorIngo Proetel <proetel@aicas.com>2003-08-11 13:44:05 +0000
committerIngo Proetel <proetel@aicas.com>2003-08-11 13:44:05 +0000
commite88c68d464e562af98c3297ad094129c7a7e66f1 (patch)
tree97dde3687521a2ed70049808b9a8e016c1cd5eb8 /native/jni/classpath
parentf765deb0b097bc527a0114f1c3903866f013e028 (diff)
downloadclasspath-e88c68d464e562af98c3297ad094129c7a7e66f1.tar.gz
removed static array for error string. The use of this static array made the code non-reentrant and wasted memory when it was not needed.
Diffstat (limited to 'native/jni/classpath')
-rw-r--r--native/jni/classpath/jcl.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/native/jni/classpath/jcl.c b/native/jni/classpath/jcl.c
index 3a2e27ef6..29f7e1d35 100644
--- a/native/jni/classpath/jcl.c
+++ b/native/jni/classpath/jcl.c
@@ -42,8 +42,6 @@ exception statement from your version. */
#include <stdio.h>
#include <jcl.h>
-static char errstr[4098]; // this way the memory is pre-allocated, so that we do not have to worry if we are out of memory.
-
JNIEXPORT void JNICALL JCL_ThrowException(JNIEnv * env, char * className, char * errMsg) {
jclass excClass;
if((*env)->ExceptionOccurred(env)) {
@@ -56,13 +54,20 @@ JNIEXPORT void JNICALL JCL_ThrowException(JNIEnv * env, char * className, char *
if(errExcClass == NULL) {
errExcClass = (*env)->FindClass(env, "java/lang/InternalError");
if(errExcClass == NULL) {
- sprintf(errstr,"JCL: Utterly failed to throw exeption %s with message %s.",className,errMsg);
- fprintf(stderr, errstr);
+ fprintf(stderr, "JCL: Utterly failed to throw exeption ");
+ fprintf(stderr, className);
+ fprintf(stderr, " with message ");
+ fprintf(stderr, errMsg);
return;
}
}
- sprintf(errstr,"JCL: Failed to throw exception %s with message %s: could not find exception class.", className, errMsg);
- (*env)->ThrowNew(env, errExcClass, errstr);
+ /* Removed this (more comprehensive) error string to avoid the need for a
+ * static variable or allocation of a buffer for this message in this (unlikely)
+ * error case. --Fridi.
+ *
+ * sprintf(errstr,"JCL: Failed to throw exception %s with message %s: could not find exception class.", className, errMsg);
+ */
+ (*env)->ThrowNew(env, errExcClass, className);
}
(*env)->ThrowNew(env, excClass, errMsg);
}