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

View file

@ -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;
}
/*

View file

@ -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;

View file

@ -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");
}
}

View file

@ -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;
}
}