Skip to content

Commit 2db3397

Browse files
author
Justin Lu
committedOct 11, 2024
8341797: Fix ExceptionOccurred in jdk.jdi
Reviewed-by: amenkov, cjplummer
1 parent c4965d9 commit 2db3397

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed
 

‎src/jdk.jdi/share/native/libdt_shmem/SharedMemoryConnection.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -115,7 +115,7 @@ packetToByteArray(JNIEnv *env, jdwpPacket *str)
115115

116116
/* total packet length is header + data */
117117
array = (*env)->NewByteArray(env, total_length);
118-
if ((*env)->ExceptionOccurred(env)) {
118+
if ((*env)->ExceptionCheck(env)) {
119119
return NULL;
120120
}
121121

@@ -144,7 +144,7 @@ packetToByteArray(JNIEnv *env, jdwpPacket *str)
144144
if (data_length > 0) {
145145
(*env)->SetByteArrayRegion(env, array, JDWP_HEADER_SIZE,
146146
data_length, str->type.cmd.data);
147-
if ((*env)->ExceptionOccurred(env)) {
147+
if ((*env)->ExceptionCheck(env)) {
148148
return NULL;
149149
}
150150
}
@@ -174,7 +174,7 @@ byteArrayToPacket(JNIEnv *env, jbyteArray b, jdwpPacket *str)
174174
* Get the packet header
175175
*/
176176
(*env)->GetByteArrayRegion(env, b, 0, sizeof(pktHeader), pktHeader);
177-
if ((*env)->ExceptionOccurred(env)) {
177+
if ((*env)->ExceptionCheck(env)) {
178178
/* b shorter than sizeof(pktHeader) */
179179
return;
180180
}
@@ -221,7 +221,7 @@ byteArrayToPacket(JNIEnv *env, jbyteArray b, jdwpPacket *str)
221221
}
222222

223223
(*env)->GetByteArrayRegion(env, b, sizeof(pktHeader), /*sizeof(CmdPacket)+4*/ data_length, data);
224-
if ((*env)->ExceptionOccurred(env)) {
224+
if ((*env)->ExceptionCheck(env)) {
225225
free(data);
226226
return;
227227
}
@@ -326,7 +326,7 @@ JNIEXPORT void JNICALL Java_com_sun_tools_jdi_SharedMemoryConnection_sendPacket0
326326
jint rc;
327327

328328
byteArrayToPacket(env, b, &packet);
329-
if ((*env)->ExceptionOccurred(env)) {
329+
if ((*env)->ExceptionCheck(env)) {
330330
return;
331331
}
332332

‎src/jdk.jdi/share/native/libdt_shmem/SharedMemoryTransport.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -51,7 +51,7 @@ void
5151
throwException(JNIEnv *env, char *exceptionClassName, char *message)
5252
{
5353
jclass excClass = (*env)->FindClass(env, exceptionClassName);
54-
if ((*env)->ExceptionOccurred(env)) {
54+
if ((*env)->ExceptionCheck(env)) {
5555
return;
5656
}
5757
(*env)->ThrowNew(env, excClass, message);
@@ -109,7 +109,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_tools_jdi_SharedMemoryTransportService_atta
109109
const char *addrChars;
110110

111111
addrChars = (*env)->GetStringUTFChars(env, address, NULL);
112-
if ((*env)->ExceptionOccurred(env)) {
112+
if ((*env)->ExceptionCheck(env)) {
113113
return CONNECTION_TO_ID(connection);
114114
} else if (addrChars == NULL) {
115115
throwException(env, "java/lang/InternalError", "GetStringUTFChars failed");
@@ -143,7 +143,7 @@ JNIEXPORT jstring JNICALL Java_com_sun_tools_jdi_SharedMemoryTransportService_na
143143
throwShmemException(env, "shmemBase_name failed", rc);
144144
} else {
145145
nameString = (*env)->NewStringUTF(env, namePtr);
146-
if ((nameString == NULL) && !(*env)->ExceptionOccurred(env)) {
146+
if ((nameString == NULL) && !(*env)->ExceptionCheck(env)) {
147147
throwException(env, "java/lang/InternalError", "Unable to create string");
148148
}
149149
}
@@ -190,7 +190,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_tools_jdi_SharedMemoryTransportService_star
190190

191191
if (address != NULL) {
192192
addrChars = (*env)->GetStringUTFChars(env, address, NULL);
193-
if ((*env)->ExceptionOccurred(env)) {
193+
if ((*env)->ExceptionCheck(env)) {
194194
return TRANSPORT_TO_ID(transport);
195195
} else if (addrChars == NULL) {
196196
throwException(env, "java/lang/InternalError", "GetStringUTFChars failed");

0 commit comments

Comments
 (0)
Please sign in to comment.