On Thu, 16 Feb 2023 18:05:05 GMT, Rich DiCroce <d...@openjdk.org> wrote:

>> src/java.base/windows/native/libnet/NetworkInterface.c line 523:
>> 
>>> 521:  * Signature: (Ljava/lang/String;I)Z
>>> 522:  */
>>> 523: JNIEXPORT jboolean JNICALL 
>>> Java_java_net_NetworkInterface_supportsMulticast0(JNIEnv *env, jclass cls, 
>>> jstring name, jint index) {
>> 
>> I'm not a big fan of using WBEM here. Also, I'm still trying to figure out 
>> when (if ever) this method is supposed to return false
>
> You and me both. As I wrote in the giant comment, I did a lot of 
> experimenting. In the end, what I determined was that if the IGMPLevel (IPv4) 
> or MldLevel (IPv6) is set to 0 (None), then attempting to join a multicast 
> group throws an exception. So that seemed like a reasonable thing that 
> supportsMulticast() could measure. Nothing else I tried, including the 
> existing GetAdaptersAddresses approach, indicated that multicast was disabled 
> in those situations.
> 
> Having said that, I'd be okay with ditching all of this code and just 
> returning true unconditionally. It's unlikely that multicast would be 
> disabled, and a single boolean isn't enough to express the actual setting 
> anyway, since Windows apparently lets you disable receiving multicasts while 
> still allowing you to send them.

Ha! Apparently I have a machine where the implementation of `supportsMulticast` 
implementation makes a difference. On my machine the test 
`jdk/java/net/SocketOption/OptionsTest.java` is failing with:

java.net.SocketException: Invalid argument: no further information
        at java.base/sun.nio.ch.Net.setInterface6(Native Method)
        at 
java.base/sun.nio.ch.DatagramChannelImpl.setOption(DatagramChannelImpl.java:377)
        at 
java.base/sun.nio.ch.DatagramSocketAdaptor.setOption(DatagramSocketAdaptor.java:431)
        at java.base/java.net.DatagramSocket.setOption(DatagramSocket.java:1207)
        at OptionsTest.test(OptionsTest.java:155)
        at OptionsTest.doMulticastSocketTests(OptionsTest.java:235)
        at OptionsTest.main(OptionsTest.java:337)
...

It works with the current master. Will try to figure it out.

BTW. did you try running jdk_net tests?

-------------

PR: https://git.openjdk.org/jdk/pull/12593

Reply via email to