8341789: Fix ExceptionOccurred in java.base

Reviewed-by: bpb, jpai, dfuchs, lancea, rriggs, naoto
This commit is contained in:
Justin Lu 2024-10-10 17:33:22 +00:00
parent 76541b0646
commit 7eb55357ab
10 changed files with 34 additions and 34 deletions

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -114,7 +114,7 @@ Java_java_lang_ClassLoader_defineClass1(JNIEnv *env,
(*env)->GetByteArrayRegion(env, data, offset, length, body);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
goto free_body;
}
@ -259,7 +259,7 @@ Java_java_lang_ClassLoader_defineClass0(JNIEnv *env,
(*env)->GetByteArrayRegion(env, data, offset, length, body);
if ((*env)->ExceptionOccurred(env))
if ((*env)->ExceptionCheck(env))
goto free_body;
if (name != NULL) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 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
@ -70,7 +70,7 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
if (jval == NULL) \
return NULL; \
(*env)->SetObjectArrayElement(env, array, jdk_internal_util_SystemProps_Raw_##prop_index, jval); \
if ((*env)->ExceptionOccurred(env)) \
if ((*env)->ExceptionCheck(env)) \
return NULL; \
(*env)->DeleteLocalRef(env, jval); \
}
@ -86,7 +86,7 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
if (jval == NULL) \
return NULL; \
(*env)->SetObjectArrayElement(env, array, jdk_internal_util_SystemProps_Raw_##prop_index, jval); \
if ((*env)->ExceptionOccurred(env)) \
if ((*env)->ExceptionCheck(env)) \
return NULL; \
(*env)->DeleteLocalRef(env, jval); \
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 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
@ -175,7 +175,7 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes,
(*env)->GetByteArrayRegion(env, bytes, off, len, (jbyte *)buf);
if (!(*env)->ExceptionOccurred(env)) {
if (!(*env)->ExceptionCheck(env)) {
off = 0;
while (len > 0) {
fd = getFD(env, this, fid);

@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@ -117,7 +117,7 @@ JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name,
(*env)->Throw(env, x);
}
}
if (!(*env)->ExceptionOccurred(env)) {
if (!(*env)->ExceptionCheck(env)) {
JNU_ThrowByName(env, name, defaultDetail);
}
}
@ -166,7 +166,7 @@ JNU_ThrowByNameWithMessageAndLastError
}
}
if (!(*env)->ExceptionOccurred(env)) {
if (!(*env)->ExceptionCheck(env)) {
if (messagelen > 0) {
JNU_ThrowByName(env, name, message);
} else {

@ -351,7 +351,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */
#define CHECK_EXCEPTION_NULL_LEAVE(CENL_exception) \
do { \
if ((*env)->ExceptionOccurred(env)) { \
if ((*env)->ExceptionCheck(env)) { \
JLI_ReportExceptionDescription(env); \
LEAVE(); \
} \
@ -363,7 +363,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */
#define CHECK_EXCEPTION_LEAVE(CEL_return_value) \
do { \
if ((*env)->ExceptionOccurred(env)) { \
if ((*env)->ExceptionCheck(env)) { \
JLI_ReportExceptionDescription(env); \
ret = (CEL_return_value); \
LEAVE(); \
@ -1522,7 +1522,7 @@ NewPlatformString(JNIEnv *env, char *s)
if (ary != 0) {
jstring str = 0;
(*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s);
if (!(*env)->ExceptionOccurred(env)) {
if (!(*env)->ExceptionCheck(env)) {
if (makePlatformStringMID == NULL) {
NULL_CHECK0(makePlatformStringMID = (*env)->GetStaticMethodID(env,
cls, "makePlatformString", "(Z[B)Ljava/lang/String;"));

@ -246,14 +246,14 @@ typedef struct {
#define CHECK_EXCEPTION_RETURN_VALUE(CER_value) \
do { \
if ((*env)->ExceptionOccurred(env)) { \
if ((*env)->ExceptionCheck(env)) { \
return CER_value; \
} \
} while (JNI_FALSE)
#define CHECK_EXCEPTION_RETURN() \
do { \
if ((*env)->ExceptionOccurred(env)) { \
if ((*env)->ExceptionCheck(env)) { \
return; \
} \
} while (JNI_FALSE)

@ -135,7 +135,7 @@ void
fileDescriptorClose(JNIEnv *env, jobject this)
{
FD fd = (*env)->GetIntField(env, this, IO_fd_fdID);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
return;
}
@ -150,7 +150,7 @@ fileDescriptorClose(JNIEnv *env, jobject this)
* taking extra precaution over here.
*/
(*env)->SetIntField(env, this, IO_fd_fdID, -1);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
return;
}
/*

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 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
@ -374,7 +374,7 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_boundInetAddress0
if (family == AF_INET) {
sock = openSocket(env, AF_INET);
if (sock < 0 && (*env)->ExceptionOccurred(env)) {
if (sock < 0 && (*env)->ExceptionCheck(env)) {
return JNI_FALSE;
}
@ -383,7 +383,7 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_boundInetAddress0
ifs = enumIPv4Interfaces(env, sock, ifs);
close(sock);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
goto cleanup;
}
}
@ -401,7 +401,7 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_boundInetAddress0
ifs = enumIPv6Interfaces(env, sock, ifs);
close(sock);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
goto cleanup;
}
@ -856,7 +856,7 @@ static netif *enumInterfaces(JNIEnv *env) {
int sock;
sock = openSocket(env, AF_INET);
if (sock < 0 && (*env)->ExceptionOccurred(env)) {
if (sock < 0 && (*env)->ExceptionCheck(env)) {
return NULL;
}
@ -865,7 +865,7 @@ static netif *enumInterfaces(JNIEnv *env) {
ifs = enumIPv4Interfaces(env, sock, ifs);
close(sock);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
freeif(ifs);
return NULL;
}
@ -884,7 +884,7 @@ static netif *enumInterfaces(JNIEnv *env) {
ifs = enumIPv6Interfaces(env, sock, ifs);
close(sock);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
freeif(ifs);
return NULL;
}
@ -1237,7 +1237,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
&addr, broadaddrP, AF_INET, prefix);
// in case of exception, free interface list and buffer and return NULL
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
free(buf);
freeif(ifs);
return NULL;
@ -1281,7 +1281,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
NULL, AF_INET6, (short)prefix);
// if an exception occurred then return the list as is
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
break;
}
}
@ -1478,7 +1478,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
&addr, broadaddrP, AF_INET, prefix);
// in case of exception, free interface list and buffer and return NULL
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
free(buf);
freeif(ifs);
return NULL;
@ -1552,7 +1552,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
NULL, AF_INET6, prefix);
// if an exception occurred then free the list
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
free(buf);
freeif(ifs);
return NULL;
@ -1717,7 +1717,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
ifa->ifa_netmask));
// if an exception occurred then free the list
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
freeifaddrs(origifa);
freeif(ifs);
return NULL;
@ -1757,7 +1757,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
ifa->ifa_netmask));
// if an exception occurred then free the list
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
freeifaddrs(origifa);
freeif(ifs);
return NULL;

@ -106,7 +106,7 @@ Java_sun_net_sdp_SdpSupport_convert0(JNIEnv *env, jclass cls, int fd)
if (res < 0)
JNU_ThrowIOExceptionWithLastError(env, "dup2");
res = close(s);
if (res < 0 && !(*env)->ExceptionOccurred(env))
if (res < 0 && !(*env)->ExceptionCheck(env))
JNU_ThrowIOExceptionWithLastError(env, "close");
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -62,7 +62,7 @@ jbyteArray sockaddrToUnixAddressBytes(JNIEnv *env, struct sockaddr_un *sa, sockl
jbyteArray name = (*env)->NewByteArray(env, namelen);
if (namelen != 0) {
(*env)->SetByteArrayRegion(env, name, 0, namelen, (jbyte*)sa->sun_path);
if ((*env)->ExceptionOccurred(env)) {
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
}