8344525: Fix leftover ExceptionOccurred in java.base

Reviewed-by: lbourges, alanb, naoto, iris
This commit is contained in:
Justin Lu 2024-11-22 18:18:22 +00:00
parent 4b1653056d
commit 51763b6700
6 changed files with 16 additions and 16 deletions

View File

@ -650,7 +650,7 @@ JavaMain(void* _args)
* The launcher's exit code (in the absence of calls to * The launcher's exit code (in the absence of calls to
* System.exit) will be non-zero if main threw an exception. * System.exit) will be non-zero if main threw an exception.
*/ */
if (ret && (*env)->ExceptionOccurred(env) == NULL) { if (ret && !(*env)->ExceptionCheck(env)) {
// main method was invoked and no exception was thrown from it, // main method was invoked and no exception was thrown from it,
// return success. // return success.
ret = 0; ret = 0;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -197,14 +197,14 @@ Java_java_util_zip_Deflater_deflateBytesBytes(JNIEnv *env, jobject this, jlong a
jint res; jint res;
if (input == NULL) { if (input == NULL) {
if (inputLen != 0 && (*env)->ExceptionOccurred(env) == NULL) if (inputLen != 0 && !(*env)->ExceptionCheck(env))
JNU_ThrowOutOfMemoryError(env, 0); JNU_ThrowOutOfMemoryError(env, 0);
return 0L; return 0L;
} }
output = (*env)->GetPrimitiveArrayCritical(env, outputArray, 0); output = (*env)->GetPrimitiveArrayCritical(env, outputArray, 0);
if (output == NULL) { if (output == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, inputArray, input, 0); (*env)->ReleasePrimitiveArrayCritical(env, inputArray, input, 0);
if (outputLen != 0 && (*env)->ExceptionOccurred(env) == NULL) if (outputLen != 0 && !(*env)->ExceptionCheck(env))
JNU_ThrowOutOfMemoryError(env, 0); JNU_ThrowOutOfMemoryError(env, 0);
return 0L; return 0L;
} }
@ -231,7 +231,7 @@ Java_java_util_zip_Deflater_deflateBytesBuffer(JNIEnv *env, jobject this, jlong
jlong retVal; jlong retVal;
jint res; jint res;
if (input == NULL) { if (input == NULL) {
if (inputLen != 0 && (*env)->ExceptionOccurred(env) == NULL) if (inputLen != 0 && !(*env)->ExceptionCheck(env))
JNU_ThrowOutOfMemoryError(env, 0); JNU_ThrowOutOfMemoryError(env, 0);
return 0L; return 0L;
} }
@ -257,7 +257,7 @@ Java_java_util_zip_Deflater_deflateBufferBytes(JNIEnv *env, jobject this, jlong
jlong retVal; jlong retVal;
jint res; jint res;
if (output == NULL) { if (output == NULL) {
if (outputLen != 0 && (*env)->ExceptionOccurred(env) == NULL) if (outputLen != 0 && !(*env)->ExceptionCheck(env))
JNU_ThrowOutOfMemoryError(env, 0); JNU_ThrowOutOfMemoryError(env, 0);
return 0L; return 0L;
} }

View File

@ -194,14 +194,14 @@ Java_java_util_zip_Inflater_inflateBytesBytes(JNIEnv *env, jobject this, jlong a
jlong retVal; jlong retVal;
if (input == NULL) { if (input == NULL) {
if (inputLen != 0 && (*env)->ExceptionOccurred(env) == NULL) if (inputLen != 0 && !(*env)->ExceptionCheck(env))
JNU_ThrowOutOfMemoryError(env, 0); JNU_ThrowOutOfMemoryError(env, 0);
return 0L; return 0L;
} }
output = (*env)->GetPrimitiveArrayCritical(env, outputArray, 0); output = (*env)->GetPrimitiveArrayCritical(env, outputArray, 0);
if (output == NULL) { if (output == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, inputArray, input, 0); (*env)->ReleasePrimitiveArrayCritical(env, inputArray, input, 0);
if (outputLen != 0 && (*env)->ExceptionOccurred(env) == NULL) if (outputLen != 0 && !(*env)->ExceptionCheck(env))
JNU_ThrowOutOfMemoryError(env, 0); JNU_ThrowOutOfMemoryError(env, 0);
return 0L; return 0L;
} }
@ -227,7 +227,7 @@ Java_java_util_zip_Inflater_inflateBytesBuffer(JNIEnv *env, jobject this, jlong
jlong retVal; jlong retVal;
if (input == NULL) { if (input == NULL) {
if (inputLen != 0 && (*env)->ExceptionOccurred(env) == NULL) if (inputLen != 0 && !(*env)->ExceptionCheck(env))
JNU_ThrowOutOfMemoryError(env, 0); JNU_ThrowOutOfMemoryError(env, 0);
return 0L; return 0L;
} }
@ -252,7 +252,7 @@ Java_java_util_zip_Inflater_inflateBufferBytes(JNIEnv *env, jobject this, jlong
jlong retVal; jlong retVal;
if (output == NULL) { if (output == NULL) {
if (outputLen != 0 && (*env)->ExceptionOccurred(env) == NULL) if (outputLen != 0 && !(*env)->ExceptionCheck(env))
JNU_ThrowOutOfMemoryError(env, 0); JNU_ThrowOutOfMemoryError(env, 0);
return 0L; return 0L;
} }

View File

@ -537,7 +537,7 @@ fileDescriptorClose(JNIEnv *env, jobject this)
{ {
FD fd = (*env)->GetLongField(env, this, IO_handle_fdID); FD fd = (*env)->GetLongField(env, this, IO_handle_fdID);
HANDLE h = (HANDLE)fd; HANDLE h = (HANDLE)fd;
if ((*env)->ExceptionOccurred(env)) { if ((*env)->ExceptionCheck(env)) {
return; return;
} }
@ -552,7 +552,7 @@ fileDescriptorClose(JNIEnv *env, jobject this)
* taking extra precaution over here. * taking extra precaution over here.
*/ */
(*env)->SetLongField(env, this, IO_handle_fdID, -1); (*env)->SetLongField(env, this, IO_handle_fdID, -1);
if ((*env)->ExceptionOccurred(env)) { if ((*env)->ExceptionCheck(env)) {
return; return;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -143,7 +143,7 @@ NET_ThrowNew(JNIEnv *env, int errorNum, char *msg)
/* /*
* If exception already throw then don't overwrite it. * If exception already throw then don't overwrite it.
*/ */
if ((*env)->ExceptionOccurred(env)) { if ((*env)->ExceptionCheck(env)) {
return; return;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -48,7 +48,7 @@ jbyteArray sockaddrToUnixAddressBytes(JNIEnv *env, struct sockaddr_un *sa, sockl
jbyteArray name = (*env)->NewByteArray(env, namelen); jbyteArray name = (*env)->NewByteArray(env, namelen);
if (name != NULL) { if (name != NULL) {
(*env)->SetByteArrayRegion(env, name, 0, namelen, (jbyte*)sa->sun_path); (*env)->SetByteArrayRegion(env, name, 0, namelen, (jbyte*)sa->sun_path);
if ((*env)->ExceptionOccurred(env)) { if ((*env)->ExceptionCheck(env)) {
return NULL; return NULL;
} }
} }