Code Review Request: 7084032: test/java/net/Inet6Address/B6558853.java fails on Windows XP/2003 if IPv6 enabled (original) (raw)

Chris Hegarty chris.hegarty at oracle.com
Fri Sep 2 23:34:02 PDT 2011


The change looks fine to me.

I'll import it and push it for you.

-Chris.

On 09/ 1/11 04:13 PM, Kurchi Hazra wrote:

Hi, test/java/net/Inet6Address/B6558853.java tests if the address obtained from getHostAddress() on connections using IPv6 link-local addresses contains the zone id. For Inet6Address.getHostAddress() to return the zone id, Inet6Address.scopeidset needs to be set to true in addition to setting the appropriate Inet6Address.scopeid. In case of Windows XP/2003 with IPv6 enabled, the native socket implementation of socketAccept() method in src/windows/native/java/net/TwoStacksPlainSocketImpl.c does not set the scopeidset to true which causes the zone id not to be returned, and B6558853 throws a RuntimeException. The fix is to simply set the scopeidsetID in socketAccept() method to true if the scopeid is greater than 0.

Submitting hg diff: diff --git a/src/windows/native/java/net/TwoStacksPlainSocketImpl.c b/src/windows/native/java/net/TwoStacksPlainSocketImpl.c --- a/src/windows/native/java/net/TwoStacksPlainSocketImpl.c +++ b/src/windows/native/java/net/TwoStacksPlainSocketImpl.c @@ -576,6 +576,7 @@ JavajavanetTwoStacksPlainSocketImpls { /* fields on this */ jint port; + jint scope; jint timeout = (*env)->GetIntField(env, this, psitimeoutID); jobject fdObj = (*env)->GetObjectField(env, this, psifdID); jobject fd1Obj = (*env)->GetObjectField(env, this, psifd1ID); @@ -755,7 +756,11 @@ JavajavanetTwoStacksPlainSocketImpls addr = (*env)->GetObjectField (env, socketAddressObj, ia6ipaddressID); (*env)->SetByteArrayRegion (env, addr, 0, 16, (const char *)&him.him6.sin6addr); (*env)->SetIntField(env, socketAddressObj, iafamilyID, IPv6); - (*env)->SetIntField(env, socketAddressObj, ia6scopeidID, him.him6.sin6scopeid); + scope=him.him6.sin6scopeid; + (*env)->SetIntField(env, socketAddressObj, ia6scopeidID, scope); + if(scope>0) { + (*env)->SetBooleanField(env, socketAddressObj, ia6scopeidsetID, JNITRUE); + } } /* fields common to AFINET and AFINET6 */ Thanks,



More information about the net-dev mailing list