Skip to content

Commit

Permalink
8294115: JNI local refs exceeds capacity warning in NetworkInterface:…
Browse files Browse the repository at this point in the history
…:getAll

Reviewed-by: dfuchs
  • Loading branch information
djelinski committed Sep 30, 2022
1 parent b030c7d commit 9dce865
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/java.base/windows/native/libnet/NetworkInterface_winXP.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, 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
Expand Down Expand Up @@ -576,7 +576,9 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
return NULL;
}
(*env)->SetObjectField(env, netifObj, ni_nameID, name);
(*env)->DeleteLocalRef(env, name);
(*env)->SetObjectField(env, netifObj, ni_displayNameID, displayName);
(*env)->DeleteLocalRef(env, displayName);
(*env)->SetIntField(env, netifObj, ni_indexID, ifs->index);
/*
* Get the IP addresses for this interface if necessary
Expand Down Expand Up @@ -646,8 +648,10 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
return NULL;
}
(*env)->SetObjectField(env, ibObj, ni_ibbroadcastID, ia2Obj);
(*env)->DeleteLocalRef(env, ia2Obj);
(*env)->SetShortField(env, ibObj, ni_ibmaskID, addrs->mask);
(*env)->SetObjectArrayElement(env, bindsArr, bind_index++, ibObj);
(*env)->DeleteLocalRef(env, ibObj);
} else /* AF_INET6 */ {
int scope;
jboolean ret;
Expand All @@ -674,13 +678,17 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
(*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj);
(*env)->SetShortField(env, ibObj, ni_ibmaskID, addrs->mask);
(*env)->SetObjectArrayElement(env, bindsArr, bind_index++, ibObj);
(*env)->DeleteLocalRef(env, ibObj);
}
(*env)->SetObjectArrayElement(env, addrArr, addr_index, iaObj);
(*env)->DeleteLocalRef(env, iaObj);
addrs = addrs->next;
addr_index++;
}
(*env)->SetObjectField(env, netifObj, ni_addrsID, addrArr);
(*env)->DeleteLocalRef(env, addrArr);
(*env)->SetObjectField(env, netifObj, ni_bindsID, bindsArr);
(*env)->DeleteLocalRef(env, bindsArr);

free_netaddr(netaddrPToFree);

Expand All @@ -693,6 +701,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
return NULL;
}
(*env)->SetObjectField(env, netifObj, ni_childsID, childArr);
(*env)->DeleteLocalRef(env, childArr);

/* return the NetworkInterface */
return netifObj;
Expand Down Expand Up @@ -871,6 +880,7 @@ JNIEXPORT jobjectArray JNICALL Java_java_net_NetworkInterface_getAll_XP

/* put the NetworkInterface into the array */
(*env)->SetObjectArrayElement(env, netIFArr, arr_index++, netifObj);
(*env)->DeleteLocalRef(env, netifObj);
curr = curr->next;
}

Expand Down

1 comment on commit 9dce865

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.