8341797: Fix ExceptionOccurred in jdk.jdi

Reviewed-by: amenkov, cjplummer
This commit is contained in:
Justin Lu 2024-10-11 21:31:58 +00:00
parent c4965d9b13
commit 2db3397187
2 changed files with 11 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -115,7 +115,7 @@ packetToByteArray(JNIEnv *env, jdwpPacket *str)
/* total packet length is header + data */
array = (*env)->NewByteArray(env, total_length);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
@ -144,7 +144,7 @@ packetToByteArray(JNIEnv *env, jdwpPacket *str)
if (data_length > 0) {
(*env)->SetByteArrayRegion(env, array, JDWP_HEADER_SIZE,
data_length, str->type.cmd.data);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
}
@ -174,7 +174,7 @@ byteArrayToPacket(JNIEnv *env, jbyteArray b, jdwpPacket *str)
* Get the packet header
*/
(*env)->GetByteArrayRegion(env, b, 0, sizeof(pktHeader), pktHeader);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
/* b shorter than sizeof(pktHeader) */
return;
}
@ -221,7 +221,7 @@ byteArrayToPacket(JNIEnv *env, jbyteArray b, jdwpPacket *str)
}
(*env)->GetByteArrayRegion(env, b, sizeof(pktHeader), /*sizeof(CmdPacket)+4*/ data_length, data);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
free(data);
return;
}
@ -326,7 +326,7 @@ JNIEXPORT void JNICALL Java_com_sun_tools_jdi_SharedMemoryConnection_sendPacket0
jint rc;
byteArrayToPacket(env, b, &packet);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
return;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -51,7 +51,7 @@ void
throwException(JNIEnv *env, char *exceptionClassName, char *message)
{
jclass excClass = (*env)->FindClass(env, exceptionClassName);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
return;
}
(*env)->ThrowNew(env, excClass, message);
@ -109,7 +109,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_tools_jdi_SharedMemoryTransportService_atta
const char *addrChars;
addrChars = (*env)->GetStringUTFChars(env, address, NULL);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
return CONNECTION_TO_ID(connection);
} else if (addrChars == NULL) {
throwException(env, "java/lang/InternalError", "GetStringUTFChars failed");
@ -143,7 +143,7 @@ JNIEXPORT jstring JNICALL Java_com_sun_tools_jdi_SharedMemoryTransportService_na
throwShmemException(env, "shmemBase_name failed", rc);
} else {
nameString = (*env)->NewStringUTF(env, namePtr);
if ((nameString == NULL) && !(*env)->ExceptionOccurred(env)) {
if ((nameString == NULL) && !(*env)->ExceptionCheck(env)) {
throwException(env, "java/lang/InternalError", "Unable to create string");
}
}
@ -190,7 +190,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_tools_jdi_SharedMemoryTransportService_star
if (address != NULL) {
addrChars = (*env)->GetStringUTFChars(env, address, NULL);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
return TRANSPORT_TO_ID(transport);
} else if (addrChars == NULL) {
throwException(env, "java/lang/InternalError", "GetStringUTFChars failed");