This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: FYI: java.net fixlet


I'm checking this in on the trunk.
(I have a small backlog of potential patches for 3.3; this is on that
list.)

There's some erroneous code in java.net that uses == on arrays.
This fixes those spots, at least the ones I found.  Michael, do you
know if there are others?

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* java/net/Inet6Address.java (isAnyLocalAddress): Don't use "=="
	on arrays.
	(isLoopbackAddress): Likewise.
	* java/net/Inet4Address.java (isAnyLocalAddress): Don't use "=="
	on arrays.

Index: java/net/Inet4Address.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/Inet4Address.java,v
retrieving revision 1.3
diff -u -r1.3 Inet4Address.java
--- java/net/Inet4Address.java 7 Nov 2002 11:20:39 -0000 1.3
+++ java/net/Inet4Address.java 19 Jun 2003 01:07:42 -0000
@@ -1,5 +1,5 @@
 /* Inet4Address.java
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -39,6 +39,7 @@
 
 import java.io.IOException;
 import java.io.ObjectStreamException;
+import java.util.Arrays;
 
 /**
  * @author Michael Koch
@@ -103,7 +104,7 @@
   {
     byte[] anylocal = { 0, 0, 0, 0 };
     
-    return addr == anylocal;
+    return Arrays.equals(addr, anylocal);
   }
 
   /**
Index: java/net/Inet6Address.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/Inet6Address.java,v
retrieving revision 1.1
diff -u -r1.1 Inet6Address.java
--- java/net/Inet6Address.java 7 Nov 2002 09:40:00 -0000 1.1
+++ java/net/Inet6Address.java 19 Jun 2003 01:07:42 -0000
@@ -1,5 +1,5 @@
 /* Inet6Address.java
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,6 +38,7 @@
 package java.net;
 
 import java.io.IOException;
+import java.util.Arrays;
 
 /**
  * @author Michael Koch
@@ -91,7 +92,7 @@
     byte[] anylocal = { 0, 0, 0, 0, 0, 0, 0, 0,
 	                0, 0, 0, 0, 0, 0, 0, 0 };
     
-    return ipaddress == anylocal;
+    return Arrays.equals(ipaddress, anylocal);
   }
 	  
   /**
@@ -104,7 +105,7 @@
     byte[] loopback = { 0, 0, 0, 0, 0, 0, 0, 0,
 	                0, 0, 0, 0, 0, 0, 0, 1 };
     
-    return ipaddress == loopback;
+    return Arrays.equals(ipaddress, loopback);
   }
 
   /**


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]