--- old/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c 2019-05-17 12:07:38.707649111 +0100 +++ new/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c 2019-05-17 12:07:38.443649120 +0100 @@ -173,7 +173,8 @@ */ JNIEXPORT void JNICALL Java_java_net_PlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this, - jint localport, jobject iaObj) { + jint localport, jobject iaObj, + jint scopeId) { /* fdObj is the FileDescriptor field on this */ jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); /* fd is an int field on fdObj */ @@ -200,7 +201,9 @@ JNI_TRUE) != 0) { return; } - setDefaultScopeID(env, &sa.sa); + if (scopeId != -1) { // use the explicit scopeId, if there is one + ((struct sockaddr_in6 *)&sa.sa)->sin6_scope_id = scopeId; + } if (NET_Bind(fd, &sa, len) < 0) { if (errno == EADDRINUSE || errno == EADDRNOTAVAIL ||