8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
8033371: jdk/src/solaris/native/java/lang/ProcessEnvironment.c environ doesn't check for JNI pending exceptions 8030116: (process) Check Parfait warnings in src/solaris/native/java/lang/* 8028769: Check src/share/native/java/lang/*.c for cases when JNI calls are used with pending warnings Reviewed-by: chegar
This commit is contained in:
parent
fbe3b00b09
commit
28e1b6ccf2
@ -216,6 +216,7 @@ throwFileNotFoundException(JNIEnv *env, jstring path)
|
||||
#else
|
||||
why = JNU_NewStringPlatform(env, buf);
|
||||
#endif
|
||||
CHECK_NULL(why);
|
||||
}
|
||||
x = JNU_NewObjectByName(env,
|
||||
"java/io/FileNotFoundException",
|
||||
|
@ -132,7 +132,6 @@ Java_java_lang_ClassLoader_defineClass1(JNIEnv *env,
|
||||
if (name != NULL) {
|
||||
utfName = getUTF(env, name, buf, sizeof(buf));
|
||||
if (utfName == NULL) {
|
||||
JNU_ThrowOutOfMemoryError(env, NULL);
|
||||
goto free_body;
|
||||
}
|
||||
VerifyFixClassname(utfName);
|
||||
@ -143,7 +142,6 @@ Java_java_lang_ClassLoader_defineClass1(JNIEnv *env,
|
||||
if (source != NULL) {
|
||||
utfSource = getUTF(env, source, sourceBuf, sizeof(sourceBuf));
|
||||
if (utfSource == NULL) {
|
||||
JNU_ThrowOutOfMemoryError(env, NULL);
|
||||
goto free_utfName;
|
||||
}
|
||||
} else {
|
||||
@ -519,7 +517,6 @@ Java_java_lang_ClassLoader_00024NativeLibrary_findBuiltinLib
|
||||
procHandle = getProcessHandle();
|
||||
cname = JNU_GetStringPlatformChars(env, name, 0);
|
||||
if (cname == NULL) {
|
||||
JNU_ThrowOutOfMemoryError(env, NULL);
|
||||
return NULL;
|
||||
}
|
||||
// Copy name Skipping PREFIX
|
||||
|
@ -56,44 +56,56 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
|
||||
return JVM_IHashCode(env, x);
|
||||
}
|
||||
|
||||
#define PUTPROP(props, key, val) \
|
||||
if (1) { \
|
||||
jstring jkey = (*env)->NewStringUTF(env, key); \
|
||||
jstring jval = (*env)->NewStringUTF(env, val); \
|
||||
jobject r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \
|
||||
if ((*env)->ExceptionOccurred(env)) return NULL; \
|
||||
(*env)->DeleteLocalRef(env, jkey); \
|
||||
(*env)->DeleteLocalRef(env, jval); \
|
||||
(*env)->DeleteLocalRef(env, r); \
|
||||
#define PUTPROP(props, key, val) \
|
||||
if (1) { \
|
||||
jstring jkey, jval; \
|
||||
jobject r; \
|
||||
jkey = (*env)->NewStringUTF(env, key); \
|
||||
if (jkey == NULL) return NULL; \
|
||||
jval = (*env)->NewStringUTF(env, val); \
|
||||
if (jval == NULL) return NULL; \
|
||||
r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \
|
||||
if ((*env)->ExceptionOccurred(env)) return NULL; \
|
||||
(*env)->DeleteLocalRef(env, jkey); \
|
||||
(*env)->DeleteLocalRef(env, jval); \
|
||||
(*env)->DeleteLocalRef(env, r); \
|
||||
} else ((void) 0)
|
||||
|
||||
/* "key" is a char type string with only ASCII character in it.
|
||||
"val" is a nchar (typedefed in java_props.h) type string */
|
||||
|
||||
#define PUTPROP_ForPlatformNString(props, key, val) \
|
||||
if (1) { \
|
||||
jstring jkey = (*env)->NewStringUTF(env, key); \
|
||||
jstring jval = GetStringPlatform(env, val); \
|
||||
jobject r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \
|
||||
if ((*env)->ExceptionOccurred(env)) return NULL; \
|
||||
(*env)->DeleteLocalRef(env, jkey); \
|
||||
(*env)->DeleteLocalRef(env, jval); \
|
||||
(*env)->DeleteLocalRef(env, r); \
|
||||
#define PUTPROP_ForPlatformNString(props, key, val) \
|
||||
if (1) { \
|
||||
jstring jkey, jval; \
|
||||
jobject r; \
|
||||
jkey = (*env)->NewStringUTF(env, key); \
|
||||
if (jkey == NULL) return NULL; \
|
||||
jval = GetStringPlatform(env, val); \
|
||||
if (jval == NULL) return NULL; \
|
||||
r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \
|
||||
if ((*env)->ExceptionOccurred(env)) return NULL; \
|
||||
(*env)->DeleteLocalRef(env, jkey); \
|
||||
(*env)->DeleteLocalRef(env, jval); \
|
||||
(*env)->DeleteLocalRef(env, r); \
|
||||
} else ((void) 0)
|
||||
#define REMOVEPROP(props, key) \
|
||||
if (1) { \
|
||||
jstring jkey = JNU_NewStringPlatform(env, key); \
|
||||
jobject r = (*env)->CallObjectMethod(env, props, removeID, jkey); \
|
||||
if ((*env)->ExceptionOccurred(env)) return NULL; \
|
||||
(*env)->DeleteLocalRef(env, jkey); \
|
||||
(*env)->DeleteLocalRef(env, r); \
|
||||
#define REMOVEPROP(props, key) \
|
||||
if (1) { \
|
||||
jstring jkey; \
|
||||
jobject r; \
|
||||
jkey = JNU_NewStringPlatform(env, key); \
|
||||
if (jkey == NULL) return NULL; \
|
||||
r = (*env)->CallObjectMethod(env, props, removeID, jkey); \
|
||||
if ((*env)->ExceptionOccurred(env)) return NULL; \
|
||||
(*env)->DeleteLocalRef(env, jkey); \
|
||||
(*env)->DeleteLocalRef(env, r); \
|
||||
} else ((void) 0)
|
||||
#define GETPROP(props, key, jret) \
|
||||
if (1) { \
|
||||
jstring jkey = JNU_NewStringPlatform(env, key); \
|
||||
#define GETPROP(props, key, jret) \
|
||||
if (1) { \
|
||||
jstring jkey = JNU_NewStringPlatform(env, key); \
|
||||
if (jkey == NULL) return NULL; \
|
||||
jret = (*env)->CallObjectMethod(env, props, getPropID, jkey); \
|
||||
if ((*env)->ExceptionOccurred(env)) return NULL; \
|
||||
(*env)->DeleteLocalRef(env, jkey); \
|
||||
if ((*env)->ExceptionOccurred(env)) return NULL; \
|
||||
(*env)->DeleteLocalRef(env, jkey); \
|
||||
} else ((void) 0)
|
||||
|
||||
#ifndef VENDOR /* Third party may overwrite this. */
|
||||
@ -169,23 +181,31 @@ JNIEXPORT jobject JNICALL
|
||||
Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
||||
{
|
||||
char buf[128];
|
||||
java_props_t *sprops = GetJavaProperties(env);
|
||||
jmethodID putID = (*env)->GetMethodID(env,
|
||||
(*env)->GetObjectClass(env, props),
|
||||
"put",
|
||||
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
jmethodID removeID = (*env)->GetMethodID(env,
|
||||
(*env)->GetObjectClass(env, props),
|
||||
"remove",
|
||||
"(Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
jmethodID getPropID = (*env)->GetMethodID(env,
|
||||
(*env)->GetObjectClass(env, props),
|
||||
"getProperty",
|
||||
"(Ljava/lang/String;)Ljava/lang/String;");
|
||||
java_props_t *sprops;
|
||||
jmethodID putID, removeID, getPropID;
|
||||
jobject ret = NULL;
|
||||
jstring jVMVal = NULL;
|
||||
|
||||
if (sprops == NULL || putID == NULL ) return NULL;
|
||||
sprops = GetJavaProperties(env);
|
||||
CHECK_NULL_RETURN(sprops, NULL);
|
||||
|
||||
putID = (*env)->GetMethodID(env,
|
||||
(*env)->GetObjectClass(env, props),
|
||||
"put",
|
||||
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
CHECK_NULL_RETURN(putID, NULL);
|
||||
|
||||
removeID = (*env)->GetMethodID(env,
|
||||
(*env)->GetObjectClass(env, props),
|
||||
"remove",
|
||||
"(Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
CHECK_NULL_RETURN(removeID, NULL);
|
||||
|
||||
getPropID = (*env)->GetMethodID(env,
|
||||
(*env)->GetObjectClass(env, props),
|
||||
"getProperty",
|
||||
"(Ljava/lang/String;)Ljava/lang/String;");
|
||||
CHECK_NULL_RETURN(getPropID, NULL);
|
||||
|
||||
PUTPROP(props, "java.specification.version",
|
||||
JDK_MAJOR_VERSION "." JDK_MINOR_VERSION);
|
||||
@ -382,6 +402,7 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
|
||||
GETPROP(props, "sun.locale.formatasdefault", jVMVal);
|
||||
if (jVMVal) {
|
||||
const char * val = (*env)->GetStringUTFChars(env, jVMVal, 0);
|
||||
CHECK_NULL_RETURN(val, NULL);
|
||||
fmtdefault = !strcmp(val, "true");
|
||||
(*env)->ReleaseStringUTFChars(env, jVMVal, val);
|
||||
(*env)->DeleteLocalRef(env, jVMVal);
|
||||
|
@ -53,6 +53,7 @@ Java_java_lang_ProcessEnvironment_environ(JNIEnv *env, jclass ign)
|
||||
jsize i, j;
|
||||
jobjectArray result;
|
||||
jclass byteArrCls = (*env)->FindClass(env, "[B");
|
||||
CHECK_NULL_RETURN(byteArrCls, NULL);
|
||||
|
||||
for (i = 0; environ[i]; i++) {
|
||||
/* Ignore corrupted environment variables */
|
||||
@ -61,7 +62,7 @@ Java_java_lang_ProcessEnvironment_environ(JNIEnv *env, jclass ign)
|
||||
}
|
||||
|
||||
result = (*env)->NewObjectArray(env, 2*count, byteArrCls, 0);
|
||||
if (result == NULL) return NULL;
|
||||
CHECK_NULL_RETURN(result, NULL);
|
||||
|
||||
for (i = 0, j = 0; environ[i]; i++) {
|
||||
const char * varEnd = strchr(environ[i], '=');
|
||||
@ -72,9 +73,9 @@ Java_java_lang_ProcessEnvironment_environ(JNIEnv *env, jclass ign)
|
||||
jsize varLength = varEnd - environ[i];
|
||||
jsize valLength = strlen(valBeg);
|
||||
var = (*env)->NewByteArray(env, varLength);
|
||||
if (var == NULL) return NULL;
|
||||
CHECK_NULL_RETURN(var, NULL);
|
||||
val = (*env)->NewByteArray(env, valLength);
|
||||
if (val == NULL) return NULL;
|
||||
CHECK_NULL_RETURN(val, NULL);
|
||||
(*env)->SetByteArrayRegion(env, var, 0, varLength,
|
||||
(jbyte*) environ[i]);
|
||||
(*env)->SetByteArrayRegion(env, val, 0, valLength,
|
||||
|
@ -206,6 +206,7 @@ JNIEXPORT void JNICALL
|
||||
Java_java_lang_UNIXProcess_init(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
parentPathv = effectivePathv(env);
|
||||
CHECK_NULL(parentPathv);
|
||||
setSIGCHLDHandler(env);
|
||||
}
|
||||
|
||||
|
@ -546,6 +546,9 @@ GetJavaProperties(JNIEnv *env)
|
||||
sprops.display_country = sprops.country;
|
||||
sprops.display_variant = sprops.variant;
|
||||
|
||||
/* ParseLocale failed with OOME */
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
|
||||
#ifdef MACOSX
|
||||
sprops.sun_jnu_encoding = "UTF-8";
|
||||
#else
|
||||
|
@ -32,10 +32,15 @@ static jstring
|
||||
environmentBlock9x(JNIEnv *env)
|
||||
{
|
||||
int i;
|
||||
jmethodID String_init_ID =
|
||||
(*env)->GetMethodID(env, JNU_ClassString(env), "<init>", "([B)V");
|
||||
jmethodID String_init_ID;
|
||||
jbyteArray bytes;
|
||||
jbyte *blockA = (jbyte *) GetEnvironmentStringsA();
|
||||
jbyte *blockA;
|
||||
|
||||
String_init_ID =
|
||||
(*env)->GetMethodID(env, JNU_ClassString(env), "<init>", "([B)V");
|
||||
CHECK_NULL_RETURN(String_init_ID, NULL);
|
||||
|
||||
blockA = (jbyte *) GetEnvironmentStringsA();
|
||||
if (blockA == NULL) {
|
||||
/* Both GetEnvironmentStringsW and GetEnvironmentStringsA
|
||||
* failed. Out of memory is our best guess. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user