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]

java.net - the never ending story


Hello list,


I've made another patch for jav.nio. This patch adds most the missing 
methods as stubs. I will implement them in future patches. Please 
review and reply.


Michael
-- 
Homepage: http://www.worldforge.org/
GPG-key: http://konqueror.dyndns.org/~mkoch/michael.gpg
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.1481
diff -u -r1.1481 ChangeLog
--- ChangeLog	8 Oct 2002 18:12:42 -0000	1.1481
+++ ChangeLog	9 Oct 2002 18:09:16 -0000
@@ -1,3 +1,41 @@
+2002-10-08  Michael Koch  <konqueror@gmx.de>
+
+	* java/net/HttpURLConnection.java
+	(getPermission): New method.
+	(getErrorStream): New stub method.
+	(getHeaderFieldDate): New stub method.
+	* java/net/Inet4Address.java:
+	(isLinkLocalAddress): Typo fixed.
+	* java/net/InetAddress.java:
+	(readResolve): New stubbed method (for serialization).
+	(isAnyLocalAddress): New stubbed method.
+	(isLoopbackAddress): New stubbed method.
+	(isLinkLocalAddress): New stubbed method.
+	(isSiteLocalAddress): New stubbed method.
+	(isMCGlobal): New stubbed method.
+	(isMCNodeGlobal): New stubbed method.
+	(isMCLinkLocal): New stubbed method.
+	(isMCSiteLocal): New stubbed method.
+	(isMCOrgLocal): New stubbed method.
+	(getCanonicalHostName): New stubbed method.
+	(getByAddress): Create instances of Inet4Address/Inet6Address,
+	instead of InetAddress, documentation added.
+	* java/net/MulticastSocket.java
+	(getInterface): Removed FIXME.
+	(getNetworkInterface): New method.
+	(setNetworkInterface): New method.
+	* java/net/NetworkInterface.java:
+	(toString): Use property "line.separator" instead of "\n".
+	* java/net/URLConnection.java
+	(getContent): New stubbed method.
+	* java/net/URLStreamHandler.java:
+	(equals): New stubbed method.
+	(hostsEqual): New stubbed method.
+	(hashCode): New stubbed method.
+	* java/net/natNetworkInterface.cc:
+	(getRealNetworkInterfaces): Create Inet4Address object
+	instead of InetAddress.
+
 2002-10-08  Ulrich Weigand  <uweigand@de.ibm.com>
 
 	* interpret.cc (_Jv_InterpMethod::run): Use UINT32 instead of
Index: java/net/HttpURLConnection.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/HttpURLConnection.java,v
retrieving revision 1.6
diff -u -r1.6 HttpURLConnection.java
--- java/net/HttpURLConnection.java	25 Sep 2002 09:05:53 -0000	1.6
+++ java/net/HttpURLConnection.java	9 Oct 2002 18:09:16 -0000
@@ -217,11 +217,35 @@
       }
   }
 
-  // TODO12: public Permission getPermission() throws IOException
-  // {
-  // }
+  /**
+   * Returns a permission object representing the permission necessary to make
+   * the connection represented by this object
+   *
+   * @exception IOException If an error occurs
+   */
+  public Permission getPermission() throws IOException
+  {
+    return new SocketPermission (url.getHost (), "connect");
+  }
 
-  // TODO12: public InputStream getErrorStream()
-  // {
-  // }
+  /**
+   * Returns the error stream if the connection failed but the server sent
+   * useful data nonetheless
+   */
+  public InputStream getErrorStream ()
+  {
+    // FIXME: implement this
+    return null;
+  }
+
+  /**
+   * Returns the value of the named field parsed as date
+   */
+  public long getHeaderFieldDate (String key, long value)
+  {
+    // FIXME: implement this correctly
+    // http://www.w3.org/Protocols/HTTP-NG/ng-notes.txt
+    
+    return super.getHeaderFieldDate (key, value);
+  }
 }
Index: java/net/Inet4Address.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/Inet4Address.java,v
retrieving revision 1.1
diff -u -r1.1 Inet4Address.java
--- java/net/Inet4Address.java	5 Oct 2002 07:49:08 -0000	1.1
+++ java/net/Inet4Address.java	9 Oct 2002 18:09:16 -0000
@@ -113,7 +113,7 @@
    */
   public boolean isLinkLocalAddress ()
   {
-    // XXX: This seems to net exist with IPv4 addresses
+    // XXX: This seems to not exist with IPv4 addresses
     return false;
   }
 
Index: java/net/InetAddress.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/InetAddress.java,v
retrieving revision 1.10
diff -u -r1.10 InetAddress.java
--- java/net/InetAddress.java	5 Oct 2002 07:49:08 -0000	1.10
+++ java/net/InetAddress.java	9 Oct 2002 18:09:16 -0000
@@ -9,10 +9,12 @@
 details.  */
 
 package java.net;
+
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.IOException;
 import java.io.Serializable;
+import java.io.ObjectStreamException;
 
 /**
  * @author Per Bothner
@@ -44,6 +46,14 @@
   int family;
   private static final long serialVersionUID = 3286316764910316507L;
 
+  /**
+   * Needed for serialization
+   */
+  private void readResolve () throws ObjectStreamException
+  {
+    // FIXME: implement this
+  }
+	  
   private void readObject(ObjectInputStream ois)
     throws IOException, ClassNotFoundException
   {
@@ -96,6 +106,91 @@
     return false;
   }
 
+  /**
+   * Utility routine to check if the InetAddress in a wildcard address
+   * 
+   * @since 1.4
+   */
+  public boolean isAnyLocalAddress ()
+  {
+    // FIXME: implement this
+    return false;
+  }
+
+  /**
+   * Utility routine to check if the InetAddress is a loopback address
+   * 
+   * @since 1.4
+   */
+  public boolean isLoopbackAddress ()
+  {
+    // FIXME: implement this
+    return addr [0] == 0x7F;
+  }
+
+  /**
+   * @since 1.4
+   */
+  public boolean isLinkLocalAddress ()
+  {
+    // FIXME: implement this
+    return false;
+  }
+
+  /**
+   * @since 1.4
+   */
+  public boolean isSiteLocalAddress ()
+  {
+    // FIXME: implement this
+    return false;
+  }
+
+  /**
+   * @since 1.4
+   */
+  public boolean isMCGlobal ()
+  {
+    // FIXME: implement this
+    return false;
+  }
+
+  /**
+   * @since 1.4
+   */
+  public boolean isMCNodeLocal ()
+  {
+    // FIXME: implement this
+    return false;
+  }
+
+  /**
+   * @since 1.4
+   */
+  public boolean isMCLinkLocal ()
+  {
+    // FIXME: implement this
+    return false;
+  }
+
+  /**
+   * @since 1.4
+   */
+  public boolean isMCSiteLocal ()
+  {
+    // FIXME: implement this
+    return false;
+  }
+
+  /**
+   * @since 1.4
+   */
+  public boolean isMCOrgLocal ()
+  {
+    // FIXME: implement this
+    return false;
+  }
+
   public String getHostName ()
   {
     if (hostName == null)
@@ -103,6 +198,15 @@
     return hostName;
   }
 
+  /**
+   * @since 1.4
+   */
+  public String getCanonicalHostName ()
+  {
+    // FIXME: implement this
+    return "";
+  }
+
   public byte[] getAddress ()
   {
     // An experiment shows that JDK1.2 returns a different byte array each
@@ -199,6 +303,7 @@
   {
     if (obj == null || ! (obj instanceof InetAddress))
       return false;
+    
     // "The Java Class Libraries" 2nd edition says "If a machine has
     // multiple names instances of InetAddress for different name of
     // that same machine are not equal.  This is because they have
@@ -222,13 +327,15 @@
   {
     return getHostName()+'/'+getHostAddress();
   }
-  
+
   /**
    * Returns an InetAddress object given the raw IP address.
    *
    * The argument is in network byte order: the highest order byte of the
    * address is in getAddress()[0].
    *
+   * @param addr The IP address to create the InetAddress object from
+   *
    * @exception UnknownHostException If IP address has illegal length
    *
    * @since 1.4
@@ -241,11 +348,14 @@
 
     return new InetAddress (addr, "");
   }
-  
+
   /**
-   * Create an InetAddress based on the provided host name and IP address.
+   * Creates an InetAddress based on the provided host name and IP address.
    * No name service is checked for the validity of the address.
    *
+   * @param host The hostname of the InetAddress object to create
+   * @param addr The IP address to create the InetAddress object from
+   *
    * @exception UnknownHostException If IP address is of illegal length
    *
    * @since 1.4
@@ -253,8 +363,11 @@
   public static InetAddress getByAddress (String host, byte[] addr)
     throws UnknownHostException
   {
-    if (addr.length == 4 || addr.length == 16)
-      return new InetAddress (addr, host);
+    if (addr.length == 4)
+      return new Inet4Address (addr, host);
+
+    if (addr.length == 16)
+      return new Inet6Address (addr, host);
     
     throw new UnknownHostException ("IP address has illegal length");
   }
Index: java/net/MulticastSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/MulticastSocket.java,v
retrieving revision 1.15
diff -u -r1.15 MulticastSocket.java
--- java/net/MulticastSocket.java	3 Oct 2002 11:23:33 -0000	1.15
+++ java/net/MulticastSocket.java	9 Oct 2002 18:09:16 -0000
@@ -38,6 +38,7 @@
 package java.net;
 
 import java.io.IOException;
+import java.util.Enumeration;
 
 /**
  * Written using on-line Java Platform 1.2 API Specification, as well
@@ -120,7 +121,6 @@
    */
   public InetAddress getInterface() throws SocketException
   {
-    // FIXME: Is it possible that an InetAddress wasn't returned from getOption?
     return (InetAddress) impl.getOption(SocketOptions.IP_MULTICAST_IF);
   }
 
@@ -173,6 +173,58 @@
   }
 
   /**
+   * Sets the local network interface used to send multicast messages
+   *
+   * @param netIF The local network interface used to send multicast messages
+   * 
+   * @exception SocketException If an error occurs
+   * 
+   * @see MulticastSocket:getNetworkInterface
+   * 
+   * @since 1.4
+   */
+  public void setNetworkInterface(NetworkInterface netIf)
+    throws SocketException
+  {
+    if (impl == null)
+      throw new SocketException (
+		      "MulticastSocket: Cant access socket implementation");
+
+    Enumeration e = netIf.getInetAddresses ();
+
+    if (!e.hasMoreElements ())
+      throw new SocketException ("MulticastSocket: Error");
+
+    InetAddress address = (InetAddress) e.nextElement ();
+    impl.setOption (SocketOptions.IP_MULTICAST_IF, address);
+  }
+
+  /**
+   * Gets the local network interface which is used to send multicast messages
+   *
+   * @return The local network interface to send multicast messages
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @see MulticastSocket:setNetworkInterface
+   * 
+   * @since 1.4
+   */
+  public NetworkInterface getNetworkInterface()
+    throws SocketException
+  {
+    if (impl == null)
+      throw new SocketException (
+		      "MulticastSocket: Cant access socket implementation");
+
+    InetAddress address =
+	    (InetAddress) impl.getOption (SocketOptions.IP_MULTICAST_IF);
+    NetworkInterface netIf = NetworkInterface.getByInetAddress (address);
+
+    return netIf;
+  }
+
+  /**
    * Disable/Enable local loopback of multicast packets.  The option is used by
    * the platform's networking code as a hint for setting whether multicast
    * data will be looped back to the local socket. 
@@ -188,6 +240,10 @@
    */
   public void setLoopbackMode(boolean disable) throws SocketException
   {
+    if (impl == null)
+      throw new SocketException (
+		      "MulticastSocket: Cant access socket implementation");
+
     impl.setOption (SocketOptions.IP_MULTICAST_LOOP, new Boolean (disable));
   }
 
Index: java/net/NetworkInterface.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/NetworkInterface.java,v
retrieving revision 1.2
diff -u -r1.2 NetworkInterface.java
--- java/net/NetworkInterface.java	25 Sep 2002 05:05:06 -0000	1.2
+++ java/net/NetworkInterface.java	9 Oct 2002 18:09:16 -0000
@@ -220,15 +220,16 @@
   {
     // FIXME: check if this is correct
     String result;
+    String separator = System.getProperty ("line.separator");
 
     result = "name: " + getDisplayName () + " (" + getName () +
-	     ") addresses:\n";
+	     ") addresses:" + separator;
 
     for (Enumeration e = inetAddresses.elements ();
          e.hasMoreElements (); )
       {
         InetAddress address = (InetAddress) e.nextElement ();
-        result += address.toString () + "\n";
+        result += address.toString () + separator;
       }
 
     return result;
Index: java/net/URLConnection.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URLConnection.java,v
retrieving revision 1.12
diff -u -r1.12 URLConnection.java
--- java/net/URLConnection.java	25 Sep 2002 05:05:06 -0000	1.12
+++ java/net/URLConnection.java	9 Oct 2002 18:09:16 -0000
@@ -251,6 +251,19 @@
   }
 
   /**
+   * Retrieves the content of this URLConnection
+   *
+   * @exception IOException If an error occurs
+   * @exception UnknownServiceException If the protocol does not support the
+   * content type
+   */
+  public Object getContent(Class[] classes) throws IOException
+  {
+    // FIXME: implement this
+    return getContent ();
+  }
+
+  /**
    * Returns a permission object representing the permission necessary to make
    * the connection represented by this object. This method returns null if no
    * permission is required to make the connection.
Index: java/net/URLStreamHandler.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URLStreamHandler.java,v
retrieving revision 1.10
diff -u -r1.10 URLStreamHandler.java
--- java/net/URLStreamHandler.java	3 Oct 2002 11:23:33 -0000	1.10
+++ java/net/URLStreamHandler.java	9 Oct 2002 18:09:16 -0000
@@ -224,6 +224,32 @@
   }
 
   /**
+   * Provides the default equals calculation. May be overidden by handlers for
+   * other protocols that have different requirements for equals(). This method
+   * requires that none of its arguments is null. This is guaranteed by the
+   * fact that it is only called by java.net.URL class.
+   *
+   * @param url1 An URL object
+   * @param url2 An URL object
+   */
+  protected boolean equals (URL url1, URL url2)
+  {
+    // FIXME: implement this
+    return false;
+  }
+
+  /**
+   * Compares the host components of two URLs.
+   *
+   * @exception UnknownHostException If an unknown host is found
+   */
+  protected boolean hostsEqual (URL url1, URL url2)
+  {
+    // FIXME: implement this
+    return false;
+  }
+
+  /**
    * Get the IP address of our host. An empty host field or a DNS failure will
    * result in a null return.
    */
@@ -251,6 +277,16 @@
   protected int getDefaultPort ()
   {
     return -1;
+  }
+
+  /**
+   * Provides the default hash calculation. May be overidden by handlers for
+   * other protocols that have different requirements for hashCode calculation.
+   */
+  protected int hashCode (URL url)
+  {
+    // FIXME: implement this
+    return 0;
   }
 
   /**
Index: java/net/natNetworkInterface.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/natNetworkInterface.cc,v
retrieving revision 1.4
diff -u -r1.4 natNetworkInterface.cc
--- java/net/natNetworkInterface.cc	3 Oct 2002 22:54:04 -0000	1.4
+++ java/net/natNetworkInterface.cc	9 Oct 2002 18:09:16 -0000
@@ -52,7 +52,7 @@
 #include <gcj/cni.h>
 #include <jvm.h>
 #include <java/net/NetworkInterface.h>
-#include <java/net/InetAddress.h>
+#include <java/net/Inet4Address.h>
 #include <java/net/SocketException.h>
 #include <java/util/Vector.h>
 
@@ -123,8 +123,8 @@
       jbyteArray baddr = JvNewByteArray (len);
       memcpy (elements (baddr), &(sa.sin_addr), len);
       jstring if_name = JvNewStringLatin1 (if_record->ifr_name);
-      InetAddress* address =
-        new java::net::InetAddress (baddr, JvNewStringLatin1 (""));
+      Inet4Address* address =
+        new java::net::Inet4Address (baddr, JvNewStringLatin1 (""));
       ht->add (new NetworkInterface (if_name, address));
       if_record++;
     }

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