On Wed, 16 Mar 2022 14:25:44 GMT, Aleksei Efimov <[email protected]> wrote:
>> src/java.base/share/native/libnet/InetAddress.c line 96:
>>
>>> 94: } else {
>>> 95: return JNI_FALSE;
>>> 96: }
>>
>> I don't have knowledge of C or JNI, but the
>> `Java_java_net_InetAddress_isIPv4Available` currently does:
>>
>>
>> return ipv4_available();
>>
>> So maybe a similar construct can be used here instead of if/else blocks? I'm
>> guessing `ipv6_available()` will be returning values that are compatible
>> with `JNI_TRUE/JNI_FALSE`.
>
> I agree that it could be simplified to match
> `Java_java_net_InetAddress_isIPv4Available`. Changed in
> 49fdd576cade2e97639f827f9db6d0f1e31101e2
Thanks for noticing that Jaikiran!
Both `ipv4_available()` and `ipv6_available()` are defined to return `jint` so
the implementation in `Java_java_net_InetAddress_isIPv6Supported` is arguably
the more correct (provided that the method being called returns 0 when the
corresponding IP version is not available).
The signature in the comment should be changed as you suggest though.
Possibly we should consider having both methods use the same construct...
-------------
PR: https://git.openjdk.java.net/jdk/pull/7842