diff options
author | Michael Koch <konqueror@gmx.de> | 2002-10-10 05:19:22 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2002-10-10 05:19:22 +0000 |
commit | 7393decb70ea1bd5f69faab0648dd64ae94b2082 (patch) | |
tree | f965712000cf470fbf9fff4d979f57fb6d1f2b12 | |
parent | 402a402cabeb85a223952f822eb14af6c3094a4c (diff) | |
download | gcc-7393decb70ea1bd5f69faab0648dd64ae94b2082.zip gcc-7393decb70ea1bd5f69faab0648dd64ae94b2082.tar.gz gcc-7393decb70ea1bd5f69faab0648dd64ae94b2082.tar.bz2 |
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.
From-SVN: r58002
-rw-r--r-- | libjava/ChangeLog | 38 | ||||
-rw-r--r-- | libjava/java/net/HttpURLConnection.java | 36 | ||||
-rw-r--r-- | libjava/java/net/Inet4Address.java | 2 | ||||
-rw-r--r-- | libjava/java/net/InetAddress.java | 123 | ||||
-rw-r--r-- | libjava/java/net/MulticastSocket.java | 58 | ||||
-rw-r--r-- | libjava/java/net/NetworkInterface.java | 5 | ||||
-rw-r--r-- | libjava/java/net/URLConnection.java | 13 | ||||
-rw-r--r-- | libjava/java/net/URLStreamHandler.java | 36 | ||||
-rw-r--r-- | libjava/java/net/natNetworkInterface.cc | 6 |
9 files changed, 299 insertions, 18 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 2a2932c..03683df 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -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 diff --git a/libjava/java/net/HttpURLConnection.java b/libjava/java/net/HttpURLConnection.java index 5072b60..ac48246 100644 --- a/libjava/java/net/HttpURLConnection.java +++ b/libjava/java/net/HttpURLConnection.java @@ -217,11 +217,35 @@ public abstract class HttpURLConnection extends URLConnection } } - // 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"); + } + + /** + * Returns the error stream if the connection failed but the server sent + * useful data nonetheless + */ + public InputStream getErrorStream () + { + // FIXME: implement this + return null; + } - // TODO12: public InputStream getErrorStream() - // { - // } + /** + * 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); + } } diff --git a/libjava/java/net/Inet4Address.java b/libjava/java/net/Inet4Address.java index 429919a..c635c67 100644 --- a/libjava/java/net/Inet4Address.java +++ b/libjava/java/net/Inet4Address.java @@ -113,7 +113,7 @@ public final class Inet4Address extends InetAddress */ public boolean isLinkLocalAddress () { - // XXX: This seems to net exist with IPv4 addresses + // XXX: This seems to not exist with IPv4 addresses return false; } diff --git a/libjava/java/net/InetAddress.java b/libjava/java/net/InetAddress.java index 970627e..c4ea6ef 100644 --- a/libjava/java/net/InetAddress.java +++ b/libjava/java/net/InetAddress.java @@ -9,10 +9,12 @@ Libgcj License. Please consult the file "LIBGCJ_LICENSE" for 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 @@ public class InetAddress implements Serializable 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 @@ public class InetAddress implements Serializable 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 @@ public class InetAddress implements Serializable 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 @@ public class InetAddress implements Serializable { 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 @@ public class InetAddress implements Serializable { 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 @@ public class InetAddress implements Serializable 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 class InetAddress implements Serializable 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"); } diff --git a/libjava/java/net/MulticastSocket.java b/libjava/java/net/MulticastSocket.java index 04d0735..2700ebe 100644 --- a/libjava/java/net/MulticastSocket.java +++ b/libjava/java/net/MulticastSocket.java @@ -38,6 +38,7 @@ exception statement from your version. */ 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 class MulticastSocket extends DatagramSocket */ 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 @@ public class MulticastSocket extends DatagramSocket } /** + * 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 class MulticastSocket extends DatagramSocket */ 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)); } diff --git a/libjava/java/net/NetworkInterface.java b/libjava/java/net/NetworkInterface.java index f0113d0..60a7d76 100644 --- a/libjava/java/net/NetworkInterface.java +++ b/libjava/java/net/NetworkInterface.java @@ -220,15 +220,16 @@ public final class NetworkInterface { // 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; diff --git a/libjava/java/net/URLConnection.java b/libjava/java/net/URLConnection.java index 91c229d..0b39fe8 100644 --- a/libjava/java/net/URLConnection.java +++ b/libjava/java/net/URLConnection.java @@ -251,6 +251,19 @@ public abstract class URLConnection } /** + * 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. diff --git a/libjava/java/net/URLStreamHandler.java b/libjava/java/net/URLStreamHandler.java index 9c6ba25..58add6f 100644 --- a/libjava/java/net/URLStreamHandler.java +++ b/libjava/java/net/URLStreamHandler.java @@ -224,6 +224,32 @@ public abstract class URLStreamHandler } /** + * 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. */ @@ -254,6 +280,16 @@ public abstract class URLStreamHandler } /** + * 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; + } + + /** * Converts an URL of a specific protocol to a string * * @param u The URL to convert diff --git a/libjava/java/net/natNetworkInterface.cc b/libjava/java/net/natNetworkInterface.cc index 9f3f0cd3..f201940 100644 --- a/libjava/java/net/natNetworkInterface.cc +++ b/libjava/java/net/natNetworkInterface.cc @@ -52,7 +52,7 @@ details. */ #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 @@ java::net::NetworkInterface::getRealNetworkInterfaces () 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++; } |