FYI: Win32 InetAddress fix
Gary Benson
gbenson@redhat.com
Mon Oct 2 10:55:00 GMT 2006
Marco Trudel wrote:
> Mohan Embar wrote:
> > > > The last part of java.net.InetAddress.lookup (a native method)
> > > > is the same in both Posix and Win32 variants except for a
> > > > security check that was removed from the Posix variant in
> > > > August 2004. The attached patch removes this check from the
> > > > Win32, synchronising the two.
> > > >
> > > > I don't have the ability to test this, so could someone try
> > > > it for me? Alternatively, is this a trivial enough change to
> > > > just commit blind?
> > >
> > > Something must have went wrong. java/net/InetAddress.java was
> > > changed according this patch, java/net/natInetAddressWin32.cc
> > > has not. This leads to an error on compilation. Please commit
> > > the rest as well...
> >
> > I agree with Marco. Although I understand that Gary probably can't
> > commit the rest without approval,
>
> There seems to be some misunderstanding. I'm talking about this
> patch: http://gcc.gnu.org/ml/java-patches/2006-q3/txt00034.txt Tom
> gave his ok to commit that, but it seems only parts of it made it
> into the trunk. So I assume it would be ok to commit the rest as
> well... But actually that wouldn't help much. With the rest of that
> patch, GCJ would compile again for win32, but InetAddress throws an
> Exception at runtime:
>
> SocketAddress sock = new SocketAddress(12345); throws a
> NullPointerException in natInetAddressWin32.cc at
> JvSynchronize sync (java::net::InetAddress::loopbackAddress);
>
> I think this has been fixed in the latest patches to this topics.
> But these are not committed and break compilation again.
This commit should fix the build failure and the NullPointerException.
FWIW what happened with all the different patches was that I wrote
http://gcc.gnu.org/ml/java-patches/2006-q3/msg00386.html thinking it
would be a stepping stone to a solution, but inbetween me posting it
to the list and Tom saying to check it in I realised that all that
code would be trashed anyway so I didn't bother committing it.
As far as the other patches go the only outstanding one is
http://gcc.gnu.org/ml/java-patches/2006-q3/msg00486.html (though I
need to remake it because of this commit). That can't be committed
before the branch because the Posix part has a lot of conditional
stuff which might be broken. I'll be committing that just as soon
as we branch.
Cheers,
Gary
-------------- next part --------------
Index: ChangeLog
===================================================================
--- ChangeLog (revision 117367)
+++ ChangeLog (working copy)
@@ -1,3 +1,9 @@
+2006-10-02 Gary Benson <gbenson@redhat.com>
+
+ * java/net/InetAddress.java
+ (checkConnect): Reinstated.
+ (loopbackAddress): Ensure initialized from non-null object.
+
2006-09-30 Keith Seitz <keiths@redhat.com>
* include/java-interp.h (prepared): Change type to pc_t.
Index: java/net/InetAddress.java
===================================================================
--- java/net/InetAddress.java (revision 117367)
+++ java/net/InetAddress.java (working copy)
@@ -101,6 +101,8 @@
try
{
LOCALHOST = getByAddress("localhost", new byte[] {127, 0, 0, 1});
+ // Some soon-to-be-removed native code synchronizes on this.
+ loopbackAddress = LOCALHOST;
}
catch (UnknownHostException e)
{
@@ -793,7 +795,7 @@
static native String getLocalHostname();
// Some soon-to-be-removed native code synchronizes on this.
- static InetAddress loopbackAddress = LOCALHOST;
+ static InetAddress loopbackAddress;
// Some soon-to-be-removed code uses this old and broken method.
InetAddress(byte[] ipaddr, String hostname)
@@ -805,9 +807,13 @@
family = getFamily(ipaddr);
}
- // Some soon-to-be-removed native code uses this old method.
+ // Some soon-to-be-removed native code uses these old methods.
private static InetAddress[] allocArray (int count)
{
return new InetAddress [count];
}
+ private static SecurityException checkConnect (String hostname)
+ {
+ return null;
+ }
}
More information about the Java-patches
mailing list