This is the mail archive of the java@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]

FYI: Patch: java.net


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,


I commited the attached patch to trunk to fix some obvious things and 
make others cleaner.


Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+8B8gWSOgCCdjSDsRAv70AJ95TQjuM6HRPbTeD8U0UGI5xNHOgwCfQUtR
9hmE3GzM5xq2Z1Qq+mUpN38=
=QiYW
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.1956
diff -u -b -B -r1.1956 ChangeLog
--- ChangeLog	17 Jun 2003 19:11:55 -0000	1.1956
+++ ChangeLog	18 Jun 2003 08:06:00 -0000
@@ -1,3 +1,14 @@
+2003-06-18  Michael Koch  <konqueror@gmx.de>
+
+	* java/net/InetAddress.java:
+	Reformatted to better match classpath's version.
+	* java/net/URL.java
+	(equals): Simplified.
+	* java/net/URLConnection.java
+	(setDoInput): Revised documentation.
+	(getDefaultUseCaches): Likewise.
+	(setRequestProperty): Added @since tag.
+
 2003-06-17  Michael Koch  <konqueror@gmx.de>
 
 	* java/net/InetSocketAddress.java
Index: java/net/InetAddress.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/InetAddress.java,v
retrieving revision 1.15
diff -u -b -B -r1.15 InetAddress.java
--- java/net/InetAddress.java	2 May 2003 09:27:58 -0000	1.15
+++ java/net/InetAddress.java	18 Jun 2003 08:06:00 -0000
@@ -68,19 +68,21 @@
  */
 public class InetAddress implements Serializable
 {
+  private static final long serialVersionUID = 3286316764910316507L;
+  
   // The Serialized Form specifies that an int 'address' is saved/restored.
   // This class uses a byte array internally so we'll just do the conversion
   // at serialization time and leave the rest of the algorithm as is.
   private int address;
   transient byte[] addr;
   String hostName;
+  
   // The field 'family' seems to be the AF_ value.
   // FIXME: Much of the code in the other java.net classes does not make
   // use of this family field.  A better implementation would be to make
   // use of getaddrinfo() and have other methods just check the family
   // field rather than examining the length of the address each time.
   int family;
-  private static final long serialVersionUID = 3286316764910316507L;
 
   /**
    * Needed for serialization
@@ -96,8 +98,10 @@
     ois.defaultReadObject();
     addr = new byte[4];
     addr[3] = (byte) address;
+    
     for (int i = 2; i >= 0; --i)
       addr[i] = (byte) (address >>= 8);
+    
     // Ignore family from serialized data.  Since the saved address is 32 bits
     // the deserialized object will have an IPv4 address i.e. AF_INET family.
     // FIXME: An alternative is to call the aton method on the deserialized
@@ -112,8 +116,10 @@
     // or a 16 byte IPv6 address.
     int len = addr.length;
     int i = len - 4;
+    
     for (; i < len; i++)
       address = address << 8 | (((int) addr[i]) & 0xFF);
+    
     oos.defaultWriteObject();
   }
 
@@ -123,6 +129,7 @@
   {
     addr = address;
     hostName = hostname;
+    
     if (address != null)
       family = getFamily (address);
   }
@@ -135,10 +142,13 @@
   public boolean isMulticastAddress ()
   {
     int len = addr.length;
+    
     if (len == 4)
       return (addr[0] & 0xF0) == 0xE0;
+    
     if (len == 16)
       return addr[0] == (byte) 0xFF;
+    
     return false;
   }
 
@@ -199,11 +209,13 @@
     // it says 172.16.0.0 - 172.255.255.255 are site local addresses
 
     // 172.16.0.0/12
-    if (addr[0] == 0xAC && (addr[1] & 0xF0) == 0x01)
+    if (addr [0] == 0xAC
+        && (addr [1] & 0xF0) == 0x01)
       return true;
 
     // 192.168.0.0/16
-    if (addr[0] == 0xC0 && addr[1] == 0xA8)
+    if (addr [0] == 0xC0
+        && addr [1] == 0xA8)
       return true;
 
     // XXX: Do we need to check more addresses here ?
@@ -257,7 +269,7 @@
   }
 
   /**
-   * Utility reoutine to check if InetAddress is a site local multicast address
+   * Utility routine to check if InetAddress is a site local multicast address
    *
    * @since 1.4
    */
@@ -341,8 +353,10 @@
   private static SecurityException checkConnect (String hostname)
   {
     SecurityManager s = System.getSecurityManager();
+    
     if (s == null)
       return null;
+    
     try
       {
 	s.checkConnect(hostname, -1);
@@ -415,8 +429,10 @@
     int hash = 0;
     int len = addr.length;
     int i = len > 4 ? len - 4 : 0;
+    
     for ( ; i < len;  i++)
       hash = (hash << 8) | (addr[i] & 0xFF);
+    
     return hash;
   }
 
@@ -425,7 +441,8 @@
    */
   public boolean equals (Object obj)
   {
-    if (obj == null || ! (obj instanceof InetAddress))
+    if (obj == null
+        || ! (obj instanceof InetAddress))
       return false;
     
     // "The Java Class Libraries" 2nd edition says "If a machine has
@@ -436,11 +453,14 @@
     // shows that the latter is correct.
     byte[] addr1 = addr;
     byte[] addr2 = ((InetAddress) obj).addr;
+    
     if (addr1.length != addr2.length)
       return false;
+    
     for (int i = addr1.length;  --i >= 0;  )
       if (addr1[i] != addr2[i])
 	return false;
+    
     return true;
   }
 
@@ -451,10 +471,12 @@
   {
     String result;
     String address = getHostAddress();
+    
     if (hostName != null)
       result = hostName + "/" + address;
     else
       result = address;
+    
     return result;
   }
 
@@ -505,8 +527,10 @@
     throw new UnknownHostException ("IP address has illegal length");
   }
   
-  /** If host is a valid numeric IP address, return the numeric address.
-   * Otherwise, return null. */
+  /**
+   * If host is a valid numeric IP address, return the numeric address.
+   * Otherwise, return null.
+   */
   private static native byte[] aton (String host);
 
   private static native InetAddress[] lookup (String hostname,
@@ -523,9 +547,9 @@
   public static InetAddress getByName (String hostname)
     throws UnknownHostException
   {
-    SecurityManager sm = System.getSecurityManager();
-    if (sm != null)
-      sm.checkConnect (hostname, -1);
+    SecurityManager s = System.getSecurityManager ();
+    if (s != null)
+      s.checkConnect (hostname, -1);
    
     // Default to current host if necessary
     if (hostname == null)
@@ -571,9 +595,9 @@
   public static InetAddress[] getAllByName (String hostname)
     throws UnknownHostException
   {
-    SecurityManager sm = System.getSecurityManager();
-    if (sm != null)
-      sm.checkConnect(hostname, -1);
+    SecurityManager s = System.getSecurityManager ();
+    if (s != null)
+      s.checkConnect (hostname, -1);
 
     // Check if hostname is an IP address
     byte[] address = aton (hostname);
@@ -608,12 +632,14 @@
   public static InetAddress getLocalHost() throws UnknownHostException
   {
     SecurityManager s = System.getSecurityManager();
+    
     // Experimentation shows that JDK1.2 does cache the result.
     // However, if there is a security manager, and the cached result
     // is other than "localhost", we need to check again.
     if (localhost == null
 	|| (s != null && localhost.addr != localhostAddress))
       getLocalHost(s);
+    
     return localhost;
   }
 
@@ -623,7 +649,9 @@
     // Check the localhost cache again, now that we've synchronized.
     if (s == null && localhost != null)
       return;
+    
     String hostname = getLocalHostname();
+    
     if (s != null)
       {
 	// "The Java Class Libraries" suggests that if the security
@@ -643,6 +671,7 @@
 	    hostname = null;
 	  }
       }
+    
     if (hostname != null)
       {
 	try
@@ -654,6 +683,7 @@
 	  {
 	  }
       }
+    
     if (localhost == null)
       localhost = new InetAddress (localhostAddress, "localhost");
   }
Index: java/net/URL.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URL.java,v
retrieving revision 1.20
diff -u -b -B -r1.20 URL.java
--- java/net/URL.java	8 Jun 2003 22:07:48 -0000	1.20
+++ java/net/URL.java	18 Jun 2003 08:06:01 -0000
@@ -418,14 +418,12 @@
    *
    * @return true if the URL is equal, false otherwise
    */
-  public boolean equals(Object obj)
+  public boolean equals (Object obj)
   {
     if (obj == null || ! (obj instanceof URL))
       return false;
 
-    URL uObj = (URL) obj;
-
-    return handler.equals (this, uObj);
+    return handler.equals (this, (URL) obj);
   }
 
   /**
Index: java/net/URLConnection.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URLConnection.java,v
retrieving revision 1.20
diff -u -b -B -r1.20 URLConnection.java
--- java/net/URLConnection.java	27 May 2003 06:17:57 -0000	1.20
+++ java/net/URLConnection.java	18 Jun 2003 08:06:01 -0000
@@ -509,7 +509,8 @@
    * to be done for this connection.  This default to true unless the
    * doOutput flag is set to false, in which case this defaults to false.
    * 
-   * @param doinput The new value of the doInput field
+   * @param input <code>true</code> if input is to be done,
+   * <code>false</code> otherwise
    *
    * @exception IllegalStateException If already connected
    */
@@ -671,7 +672,10 @@
   }
 
   /**
-   * Returns the default value of the useCaches field
+   * Returns the default value used to determine whether or not caching
+   * of documents will be done when possible.
+   *
+   * @return true if caches will be used, false otherwise
    */
   public boolean getDefaultUseCaches()
   {
@@ -701,6 +705,8 @@
    *
    * @see URLConnection#getRequestProperty(String key)
    * @see URLConnection#addRequestProperty(String key, String value)
+   * 
+   * @since 1.4
    */
   public void setRequestProperty(String key, String value)
   {

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